From 259f3864717ebb2d7d2f29ef4bcf63f4785c7cb4 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 14:39:16 -0700 Subject: [PATCH] Added in the mining drill, fixed charging station not working, and fixed tool descriptions. --- .../Graphics/Items/Tools/MiningDrill.png | Bin 0 -> 254 bytes .../Items/Tools/MiningDrillWorking.png | Bin 0 -> 603 bytes .../Objects/Items/Tools/AxeExtended.cs | 2 +- .../Objects/Items/Tools/HoeExtended.cs | 2 +- .../Objects/Items/Tools/MiningDrill.cs | 404 ++++++++++++++++++ .../Objects/Items/Tools/PickaxeExtended.cs | 6 +- .../Items/Tools/WateringCanExtended.cs | 2 +- .../Objects/Machines/ChargingStation.cs | 2 +- .../Framework/Objects/Machines/Machine.cs | 7 +- .../Framework/Objects/ObjectManager.cs | 5 + .../Framework/Utilities/EnergyUtilities.cs | 42 ++ .../Utilities/MultiplayerUtilities.cs | 20 + GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 8 + 14 files changed, 494 insertions(+), 9 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/MiningDrill.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/MiningDrillWorking.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs create mode 100644 GeneralMods/Revitalize/Framework/Utilities/EnergyUtilities.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/MiningDrill.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/MiningDrill.png new file mode 100644 index 0000000000000000000000000000000000000000..5b391f44ca2c3826724c24d3a267cf59ebd948ca GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|c6hothFJ6_ zr#LYG`}gnv#Gia`@+DHHSUmi5m;Juc8LPT^g2&Pwujj1FKX?EL3ceo8Y|FR*Z)5-j zFETY2MkfD|Pva2Yl%`jfwj(Wy87J4&FQlC=Vzp4{*cdO@Y%erO*8B)4-gzo zKcCcbkoU%pLgmNX=hr`+wf>$(@4|w$8x8ZAC-5dFBpk@<$eYJGXKq?22lEt%J3w{H u%*@PQIw0#}b`|oUbL(#nG~imn#K8Q@ljlVHEN7q}7(8A5T-G@yGywqpqhZDX literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/MiningDrillWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/MiningDrillWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..19a22482dc35ac4f38cc64cbd1b6be0b8da3c8f6 GIT binary patch literal 603 zcmV-h0;K(kP)Px%6-h)vRA_@$j$4*Xy*di*_$qsdXP@&L&KsWywM>qd~4w+r* zWI;t*5yZjCv95}PT!(t)yxhfisXsv92OM&_B8Q`tmG-Bu4axay~7Jg_y5nvo(WyyYK67LzV7w+^#`H z;d!3(^$}5AM=v0m$iZ;bf%$R;rt@6t4aGtX?hCUFC+ zz*IF0<3`0v9>D(+te21JWC8EXn~gpc2`&k;p&lnCn(zsnP8Kko3@O(L#5KWEo+@9C zLndjBvxJ}o*_ba^(E0q>+RrCYzvE$XNwBPu^06P(x*Nx-5~wwenjjO8(QoTMPun&= z!rC4Gdkaz6MS@Gc9*i56jW$&xrKV96Wa2h{Wh_HqqlvH0C{Q14GLa(>W)}%IJ@)E& zY*Pw}OM-%+lp*U&By8;fa8Gc(-H)jAMw>hU*eVaeEkQw0%8*asdT^vkq>V5M{+;5O zS3K(D=rWG5Q?X`iMs7DI(DS?qB8o8bBw-RZZ`k`002ovPDHLkV1nUC5WWBa literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs index 527ba22d..42f997f7 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs @@ -239,7 +239,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override string getDescription() { - return this.info.name; + return this.info.description; } public override Item getOne() diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs index 4f89a131..c1137f4f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs @@ -239,7 +239,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override string getDescription() { - return this.info.name; + return this.info.description; } public override Item getOne() diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs new file mode 100644 index 00000000..a473e386 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -0,0 +1,404 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Netcode; +using Revitalize.Framework.Energy; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardewValley.Tools; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Objects.Items.Tools +{ + public class MiningDrill : PickaxeExtended, IEnergyInterface + { + private int boulderTileX; + private int boulderTileY; + private int hitsToBoulder; + private Texture2D energyTexture; + private bool hadEnoughEnergy; + + public EnergyManager EnergyManager + { + get => this.info.EnergyManager; + set + { + this.info.EnergyManager = value; + this.info.requiresUpdate = true; + } + } + + public MiningDrill() + { + + } + + public MiningDrill(BasicItemInformation ItemInfo, int UpgradeLevel, Texture2DExtended WorkingTexture) + { + this.info = ItemInfo; + this.upgradeLevel.Value = UpgradeLevel; + this.guid = Guid.NewGuid(); + this.workingTexture = WorkingTexture; + this.updateInfo(); + } + + + public override void draw(SpriteBatch b) + { + if (this.lastUser == null || this.lastUser.toolPower <= 0 || !this.lastUser.canReleaseTool) + return; + this.updateInfo(); + foreach (Vector2 vector2 in this.tilesAffected(this.lastUser.GetToolLocation(false) / 64f, this.lastUser.toolPower, this.lastUser)) + this.info.animationManager.draw(b, Game1.GlobalToLocal(new Vector2((float)((int)vector2.X * 64), (float)((int)vector2.Y * 64))), Color.White, 4f, SpriteEffects.None, 0.01f); + } + + public override void drawAttachments(SpriteBatch b, int x, int y) + { + this.updateInfo(); + //base.drawAttachments(b, x, y); + //this.info.animationManager.draw(b,) + + + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) + { + this.updateInfo(); + this.info.animationManager.draw(spriteBatch, location, color * transparency, 4f * scaleSize, SpriteEffects.None, layerDepth); + //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); + if (this.energyTexture == null) + { + this.initializeEnergyTexture(); + } + spriteBatch.Draw(this.energyTexture, new Rectangle((int)location.X + 8, (int)location.Y + Game1.tileSize / 2, (int)((Game1.tileSize - 16) * this.EnergyManager.energyPercentRemaining), (int)16), new Rectangle(0, 0, 1, 1), EnergyUtilities.GetEnergyRemainingColor(this.EnergyManager), 0f, Vector2.Zero, SpriteEffects.None, layerDepth); + } + + public override bool beginUsing(GameLocation location, int x, int y, Farmer who) + { + this.updateInfo(); + Revitalize.Framework.Hacks.ColorChanger.SwapPickaxeTextures(this.workingTexture.texture); + this.Update(who.FacingDirection, 0, who); + who.EndUsingTool(); + return true; + } + + public override void endUsing(GameLocation location, Farmer who) + { + if (this.hadEnoughEnergy == false) + { + /* + int num2 = (double)who.Stamina <= 0.0 ? 2 : 1; + switch (who.FacingDirection) + { + case 0: + ((FarmerSprite)who.Sprite).animateOnce(176, 60f * (float)num2, 8); + break; + case 1: + ((FarmerSprite)who.Sprite).animateOnce(168, 60f * (float)num2, 8); + break; + case 2: + ((FarmerSprite)who.Sprite).animateOnce(160, 60f * (float)num2, 8); + break; + case 3: + ((FarmerSprite)who.Sprite).animateOnce(184, 60f * (float)num2, 8); + break; + } + */ + Game1.toolAnimationDone(who); + who.canReleaseTool = false; + who.UsingTool = false; + who.canMove = true; + return; + } + + who.stopJittering(); + who.canReleaseTool = false; + int num = (double)who.Stamina <= 0.0 ? 2 : 1; + if (Game1.isAnyGamePadButtonBeingPressed() || !who.IsLocalPlayer) + who.lastClick = who.GetToolLocation(false); + else + { + who.FarmerSprite.nextOffset = 0; + switch (who.FacingDirection) + { + case 0: + ((FarmerSprite)who.Sprite).animateOnce(176, 60f * (float)num, 8); + break; + case 1: + ((FarmerSprite)who.Sprite).animateOnce(168, 60f * (float)num, 8); + break; + case 2: + ((FarmerSprite)who.Sprite).animateOnce(160, 60f * (float)num, 8); + break; + case 3: + ((FarmerSprite)who.Sprite).animateOnce(184, 60f * (float)num, 8); + break; + } + + } + } + + private void initializeEnergyTexture() + { + this.energyTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); + Color[] color = new Color[1]; + color[0] = new Color(255, 255, 255); + this.energyTexture.SetData(color, 0, 1); + } + + private void baseDoFunction(GameLocation location, int x, int y, int power, Farmer who) + { + this.lastUser = who; + Game1.recentMultiplayerRandom = new Random((int)(short)Game1.random.Next((int)short.MinValue, 32768)); + ToolFactory.getIndexFromTool(this); + if (who.FarmerSprite.currentAnimationIndex <= 0) + return; + MeleeWeapon.timedHitTimer = 500; + + } + + + public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) + { + //base.DoFunction(location, x, y, power, who); + if (this.EnergyManager.hasEnoughEnergy(2 * (this.upgradeLevel.Value + 1)) == true) + { + this.hadEnoughEnergy = true; + } + else + { + this.hadEnoughEnergy = false; + Game1.showRedMessage("Out of energy!"); + return; + } + this.baseDoFunction(location, x, y, power, who); + power = who.toolPower; + //who.Stamina -= (float)(2 * (power + 1)) - (float)who.MiningLevel * 0.1f; + //Drain energy here; + this.EnergyManager.consumeEnergy(2 * (this.upgradeLevel.Value + 1)); + + Utility.clampToTile(new Vector2((float)x, (float)y)); + int num1 = x / 64; + int num2 = y / 64; + Vector2 index = new Vector2((float)num1, (float)num2); + if (location.performToolAction((Tool)this, num1, num2)) + return; + StardewValley.Object @object = (StardewValley.Object)null; + location.Objects.TryGetValue(index, out @object); + if (@object == null) + { + if (who.FacingDirection == 0 || who.FacingDirection == 2) + { + num1 = (x - 8) / 64; + location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); + if (@object == null) + { + num1 = (x + 8) / 64; + location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); + } + } + else + { + num2 = (y + 8) / 64; + location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); + if (@object == null) + { + num2 = (y - 8) / 64; + location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); + } + } + x = num1 * 64; + y = num2 * 64; + if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].performToolAction((Tool)this, 0, index, location)) + location.terrainFeatures.Remove(index); + } + index = new Vector2((float)num1, (float)num2); + if (@object != null) + { + if (@object.Name.Equals("Stone")) + { + location.playSound("hammer"); + if (@object.MinutesUntilReady > 0) + { + int num3 = Math.Max(1, this.UpgradeLevel + 1); + @object.MinutesUntilReady -= num3; + @object.shakeTimer = 200; + if (@object.MinutesUntilReady > 0) + { + Game1.createRadialDebris(Game1.currentLocation, 14, num1, num2, Game1.random.Next(2, 5), false, -1, false, -1); + return; + } + } + if (@object.ParentSheetIndex < 200 && !Game1.objectInformation.ContainsKey(@object.ParentSheetIndex + 1)) + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(@object.ParentSheetIndex + 1, 300f, 1, 2, new Vector2((float)(x - x % 64), (float)(y - y % 64)), true, @object.Flipped) + { + alphaFade = 0.01f + }); + else + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(47, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.Gray, 10, false, 80f, 0, -1, -1f, -1, 0)); + Game1.createRadialDebris(location, 14, num1, num2, Game1.random.Next(2, 5), false, -1, false, -1); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(46, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.White, 10, false, 80f, 0, -1, -1f, -1, 0) + { + motion = new Vector2(0.0f, -0.6f), + acceleration = new Vector2(0.0f, 1f / 500f), + alphaFade = 0.015f + }); + if (!location.Name.StartsWith("UndergroundMine")) + { + if (@object.ParentSheetIndex == 343 || @object.ParentSheetIndex == 450) + { + Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + num1 * 2000 + num2); + if (random.NextDouble() < 0.035 && Game1.stats.DaysPlayed > 1U) + Game1.createObjectDebris(535 + (Game1.stats.DaysPlayed <= 60U || random.NextDouble() >= 0.2 ? (Game1.stats.DaysPlayed <= 120U || random.NextDouble() >= 0.2 ? 0 : 2) : 1), num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID); + if (random.NextDouble() < 0.035 * (who.professions.Contains(21) ? 2.0 : 1.0) && Game1.stats.DaysPlayed > 1U) + Game1.createObjectDebris(382, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID); + if (random.NextDouble() < 0.01 && Game1.stats.DaysPlayed > 1U) + Game1.createObjectDebris(390, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID); + } + location.breakStone(@object.ParentSheetIndex, num1, num2, who, new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + num1 * 4000 + num2)); + } + else + Game1.mine.checkStoneForItems(@object.ParentSheetIndex, num1, num2, who); + if (@object.MinutesUntilReady > 0) + return; + location.Objects.Remove(new Vector2((float)num1, (float)num2)); + location.playSound("stoneCrack"); + ++Game1.stats.RocksCrushed; + } + else if (@object.Name.Contains("Boulder")) + { + location.playSound("hammer"); + if (this.UpgradeLevel < 2) + { + Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Pickaxe.cs.14194"))); + } + else + { + if (num1 == this.boulderTileX && num2 == this.boulderTileY) + { + this.hitsToBoulder += power + 1; + @object.shakeTimer = 190; + } + else + { + this.hitsToBoulder = 0; + this.boulderTileX = num1; + this.boulderTileY = num2; + } + if (this.hitsToBoulder < 4) + return; + location.removeObject(index, false); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2((float)(64.0 * (double)index.X - 32.0), (float)(64.0 * ((double)index.Y - 1.0))), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) + { + delayBeforeAnimationStart = 0 + }); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2((float)(64.0 * (double)index.X + 32.0), (float)(64.0 * ((double)index.Y - 1.0))), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) + { + delayBeforeAnimationStart = 200 + }); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2(64f * index.X, (float)(64.0 * ((double)index.Y - 1.0) - 32.0)), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) + { + delayBeforeAnimationStart = 400 + }); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2(64f * index.X, (float)(64.0 * (double)index.Y - 32.0)), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) + { + delayBeforeAnimationStart = 600 + }); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2(64f * index.X, 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0)); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2((float)(64.0 * (double)index.X + 32.0), 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0) + { + delayBeforeAnimationStart = 250 + }); + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2((float)(64.0 * (double)index.X - 32.0), 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0) + { + delayBeforeAnimationStart = 500 + }); + location.playSound("boulderBreak"); + ++Game1.stats.BouldersCracked; + } + } + else + { + if (!@object.performToolAction((Tool)this, location)) + return; + @object.performRemoveAction(index, location); + if (@object.Type.Equals((object)"Crafting") && @object.Fragility != 2) + { + NetCollection debris1 = Game1.currentLocation.debris; + int objectIndex = @object.bigCraftable.Value ? -@object.ParentSheetIndex : @object.ParentSheetIndex; + Vector2 toolLocation = who.GetToolLocation(false); + Rectangle boundingBox = who.GetBoundingBox(); + double x1 = (double)boundingBox.Center.X; + boundingBox = who.GetBoundingBox(); + double y1 = (double)boundingBox.Center.Y; + Vector2 playerPosition = new Vector2((float)x1, (float)y1); + Debris debris2 = new Debris(objectIndex, toolLocation, playerPosition); + debris1.Add(debris2); + } + Game1.currentLocation.Objects.Remove(index); + } + } + else + { + location.playSound("woodyHit"); + if (location.doesTileHaveProperty(num1, num2, "Diggable", "Back") == null) + return; + MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(12, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.White, 8, false, 80f, 0, -1, -1f, -1, 0) + { + alphaFade = 0.015f + }); + } + } + + + public override void actionWhenStopBeingHeld(Farmer who) + { + Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + base.actionWhenStopBeingHeld(who); + } + + public override Color getCategoryColor() + { + return this.info.categoryColor; + } + + public override string getCategoryName() + { + return this.info.categoryName; + } + + public override string getDescription() + { + StringBuilder b = new StringBuilder(); + b.Append("Energy: "); + b.Append(this.EnergyManager.remainingEnergy); + b.Append("/"); + b.Append(this.EnergyManager.maxEnergy); + b.Append(System.Environment.NewLine); + b.Append(this.info.description); + return b.ToString(); + } + + public override Item getOne() + { + return new MiningDrill(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); + } + + public override object getReplacement() + { + return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel }; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs index 43526d82..ce5e53d6 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs @@ -240,7 +240,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override string getDescription() { - return this.info.name; + return this.info.description; } public override Item getOne() @@ -248,12 +248,12 @@ namespace Revitalize.Framework.Objects.Items.Tools return new PickaxeExtended(this.info.Copy(), this.UpgradeLevel,this.workingTexture.Copy()); } - public object getReplacement() + public virtual object getReplacement() { return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel }; } - public void rebuild(Dictionary additionalSaveData, object replacement) + public virtual void rebuild(Dictionary additionalSaveData, object replacement) { this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs index 08189630..c9f2534f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs @@ -240,7 +240,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override string getDescription() { - return this.info.name; + return this.info.description; } public override Item getOne() diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs index 46d9272e..1a191b2a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs @@ -82,7 +82,7 @@ namespace Revitalize.Framework.Objects.Machines foreach(Item I in this.InventoryManager.items) { if (I is null) continue; - if (I is CustomObject == false) continue; + if (I is IEnergyInterface==false) continue; IEnergyInterface o = (IEnergyInterface)I; if (o.EnergyManager.canReceieveEnergy) { diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index c50e3497..e0f0d739 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Machines //ModCore.log("Machine does consume energy."); return true; } - if(this.EnergyManager.energyInteractionType== Enums.EnergyInteractionType.Storage) + if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) { return true; @@ -289,6 +289,11 @@ namespace Revitalize.Framework.Objects.Machines else { + if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces) + { + this.storeEnergyToNetwork(); + } + return false; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index c36de75e..7725d39c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -296,6 +296,9 @@ namespace Revitalize.Framework.Objects WateringCanExtended steelCan = new WateringCanExtended(new BasicItemInformation("Hardened Watering Can", "Omegasis.Revitalize.Items.Tools.HardenedWateringCan", "A sturdy watering can made from hardened alloy.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "HardenedWateringCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedWateringCan"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedWateringCanWorking"), 100); WateringCanExtended titaniumCan = new WateringCanExtended(new BasicItemInformation("Titanium Watering Can", "Omegasis.Revitalize.Items.Tools.TitaniumWateringCan", "A sturdy watering can made from titanium.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "TitaniumWateringCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumWateringCan"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 3, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumWateringCanWorking"), 125); + MiningDrill miningDrillV1 = new MiningDrill(new BasicItemInformation("Simple Mining Drill", "Omegasis.Revitalize.Items.Tools.MiningDrillV1", "A drill used in mining. Consumes energy instead of stamina.", "Tool", Color.SlateGray, 0, 0, false, 1000, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "MiningDrill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "MiningDrill"), new Animation(0, 0, 16, 16)), Color.White, true, null, null,new Energy.EnergyManager(200, Enums.EnergyInteractionType.Consumes)), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "MiningDrillWorking")); + + this.Tools.Add("BronzePickaxe", bronzePick); this.Tools.Add("HardenedPickaxe", steelPick); this.Tools.Add("TitaniumPickaxe", titaniumPick); @@ -311,6 +314,8 @@ namespace Revitalize.Framework.Objects this.Tools.Add("BronzeWateringCan", bronzeCan); this.Tools.Add("HardenedWateringCan", steelCan); this.Tools.Add("TitaniumWateringCan", titaniumCan); + + this.Tools.Add("MiningDrillV1", miningDrillV1); } /// diff --git a/GeneralMods/Revitalize/Framework/Utilities/EnergyUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/EnergyUtilities.cs new file mode 100644 index 00000000..262e028a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/EnergyUtilities.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Utilities +{ + public class EnergyUtilities + { + + public static Color GetEnergyRemainingColor(Energy.EnergyManager Energy) + { + Color col = new Color(); + //ModCore.log("Energy is: " + this.energy.energyPercentRemaining); + if (Energy.energyPercentRemaining > .75d) + { + col = Color.Green; + } + else if (Energy.energyPercentRemaining > .5d && Energy.energyPercentRemaining <= .75d) + { + col = Color.GreenYellow; + } + else if (Energy.energyPercentRemaining > .25d && Energy.energyPercentRemaining <= .5d) + { + col = Color.Yellow; + } + else if (Energy.energyPercentRemaining > .10d && Energy.energyPercentRemaining <= .25d) + { + col = Color.Orange; + } + else + { + col = Color.Red; + } + return col; + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index 4e6128de..2dbdf2d3 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -21,6 +21,8 @@ namespace Revitalize.Framework.Utilities public static string RequestALLModObjects = "Revitalize.EndOfDayRequestAllObjects"; public static string RequestObjectUpdateSync = "Revitalize.RequestObjectUpdateSync"; + public static Multiplayer GameMultiplayer; + /// /// Handles receiving mod messages. /// @@ -184,5 +186,23 @@ namespace Revitalize.Framework.Utilities ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(), RequestObjectUpdateSync, new string[] { ModCore.Manifest.UniqueID.ToString() }); } + public static StardewValley.Multiplayer GetMultiplayer() + { + if (GameMultiplayer == null) + { + Multiplayer multiplayer = ModCore.ModHelper.Reflection.GetField(typeof(Game1), "multiplayer", true).GetValue(); + if (multiplayer == null) return null; + else + { + GameMultiplayer = multiplayer; + return GameMultiplayer; + } + } + else + { + return GameMultiplayer; + } + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 78ab90eb..8349c541 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -571,7 +571,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("Capacitor",1), ModCore.ObjectManager.GetItem("ChargingStation",1), ModCore.ObjectManager.GetItem("Grinder",1), - new StardewValley.Object((int)Enums.SDVObject.CopperOre,10) + new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), + ModCore.ObjectManager.GetTool("MiningDrillV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 37347172..1d21d711 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -157,6 +157,7 @@ + @@ -176,6 +177,7 @@ + @@ -354,6 +356,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest