diff --git a/GeneralMods/Revitalize/Content/Graphics/HUD/MachineStatusBubble.png b/GeneralMods/Revitalize/Content/Graphics/HUD/MachineStatusBubble.png new file mode 100644 index 00000000..6490c468 Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/HUD/MachineStatusBubble.png differ diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs index 68a6a379..cd68e7af 100644 --- a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs @@ -15,12 +15,16 @@ namespace Revitalize.Framework.Configs public double solarPanelNonSunnyDayEnergyMultiplier; public double solarPanelNightEnergyGenerationMultiplier; + public bool showMachineNotificationBubble_InventoryFull; + public float machineNotificationBubbleAlpha; public GlobalMachineConfig() { this.doMachinesConsumeEnergy = true; this.solarPanelNonSunnyDayEnergyMultiplier = 0.0d; this.solarPanelNightEnergyGenerationMultiplier = .125d; + this.showMachineNotificationBubble_InventoryFull = true; + this.machineNotificationBubbleAlpha = 0.75f; } public static GlobalMachineConfig InitializeConfig() diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index d8bed024..b6ce9009 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -123,6 +123,9 @@ namespace Revitalize.Framework.Objects.Machines public string craftingRecipeBook; + [JsonIgnore] + protected AnimationManager machineStatusBubbleBox; + [JsonIgnore] public bool ProducesItems { @@ -166,6 +169,8 @@ namespace Revitalize.Framework.Objects.Machines this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources=null,int EnergyRequiredPer10Minutes=0,int TimeToProduce=0,bool UpdatesContainer=false, string CraftingBook = "", MultiTiledObject obj=null) : base(PyTKData, info, TileLocation) @@ -177,6 +182,7 @@ namespace Revitalize.Framework.Objects.Machines this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); } public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce=0,bool UpdatesContainer=false, string CraftingBook = "", MultiTiledObject obj = null) : base(PyTKData, info, TileLocation) @@ -189,6 +195,17 @@ namespace Revitalize.Framework.Objects.Machines this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + protected virtual void createStatusBubble() + { + this.machineStatusBubbleBox = new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "HUD", "MachineStatusBubble"), new Animation(0, 0, 20, 24), new Dictionary>() + { + {"Default",new List(){new Animation(0,0,20,24)}}, + {"Empty",new List(){new Animation(20,0,20,24)}}, + {"InventoryFull",new List(){new Animation(40,0,20,24)}} + }, "Default", 0); } public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) @@ -386,6 +403,8 @@ namespace Revitalize.Framework.Objects.Machines addedDepth += 1.0f; } this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f); + this.drawStatusBubble(spriteBatch, x, y, alpha); + try { this.animationManager.tickAnimation(); @@ -424,6 +443,22 @@ namespace Revitalize.Framework.Objects.Machines } + protected virtual void drawStatusBubble(SpriteBatch b,int x, int y,float Alpha) + { + if (this.updatesContainerObjectForProduction == false) return; + if (this.InventoryManager.IsFull && this.ProducesItems && ModCore.Configs.machinesConfig.showMachineNotificationBubble_InventoryFull) + { + y--; + float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.UtcNow.TimeOfDay.TotalMilliseconds / 250.0), 2)); + this.machineStatusBubbleBox.playAnimation("InventoryFull"); + this.machineStatusBubbleBox.draw(b, this.machineStatusBubbleBox.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize+num)), new Rectangle?(this.machineStatusBubbleBox.currentAnimation.sourceRectangle), Color.White*ModCore.Configs.machinesConfig.machineNotificationBubbleAlpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)((y+2) * Game1.tileSize) / 10000f) + .00001f); + } + else + { + + } + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 81a2b7c4..2a393ef0 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -318,6 +318,9 @@ namespace Revitalize TextureManager.AddTextureManager(Manifest, "CraftingMenu"); TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu")); + TextureManager.AddTextureManager(Manifest, "HUD"); + TextureManager.GetTextureManager(Manifest,"HUD").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "HUD")); + TextureManager.AddTextureManager(Manifest, "Objects.Crafting"); TextureManager.GetTextureManager(Manifest, "Objects.Crafting").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Crafting")); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 8840ee7c..87ff03a3 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -205,6 +205,9 @@ + + PreserveNewest + PreserveNewest