From 94d1595efa5b529ab92e698b47b7e172870504c1 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 26 Aug 2019 21:14:37 -0700 Subject: [PATCH 01/98] Updatedd CustomObject to have proper sell price and semi sync over the net. --- .../Framework/Objects/CustomObject.cs | 228 ++++++++++++++---- .../Framework/Objects/Items/Resources/Ore.cs | 4 - GeneralMods/Revitalize/ModCore.cs | 14 +- 3 files changed, 192 insertions(+), 54 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 040a31e2..26c354eb 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -19,6 +19,89 @@ namespace Revitalize.Framework.Objects /// A custom object template. public class CustomObject : PySObject { + + public string text + { + get + { + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result. + else + return ""; //Otherwise return nothing. + } + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + { + this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name. + } + } + } + + + public override string Name + { + + get + { + if (this.info != null) + { + return this.netName.Value.Split('>')[0]; + //return this.info.name; + } + if (this.netName == null) + { + return this.name; + } + else + { + return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value. + } + } + + set + { + if (this.netName == null) + { + return; + } + if (this.netName.Value == null) + { + return; + } + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + { + this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back. + } + else + { + this.netName.Value = value; //Otherwise just set the net name. + } + } + } + + public override string DisplayName + { + get + { + if (this.info != null) + { + return this.info.name; + } + return this.netName.Value.Split('>')[0]; + } + + set + { + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + this.netName.Value = value + ">" + split[1]; + else + this.netName.Value = value; + } + } + + public string id { get @@ -75,10 +158,6 @@ namespace Revitalize.Framework.Objects } } - - - protected Netcode.NetString netItemInfo; - /// Empty constructor. public CustomObject() { @@ -124,8 +203,12 @@ namespace Revitalize.Framework.Objects this.bigCraftable.Value = false; + this.syncObject = new PySync(this); + this.syncObject.init(); //this.initNetFields(); this.InitNetFields(); + this.updateInfo(); + this.Price = info.price; //if (this.info.ignoreBoundingBox) // this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0); } @@ -145,6 +228,16 @@ namespace Revitalize.Framework.Objects : base.getBoundingBox(tileLocation); } + public override int sellToStorePrice() + { + return this.Price; + } + + public override int salePrice() + { + return this.Price * 2; + } + /// Checks for interaction with the object. public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { @@ -170,18 +263,6 @@ namespace Revitalize.Framework.Objects return this.clicked(who); } - public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) - { - CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; - BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - return new CustomObject(data, info, (replacement as Chest).TileLocation); - } - public override Dictionary getAdditionalSaveData() - { - Dictionary serializedInfo = new Dictionary(); - serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - return serializedInfo; - } /// What happens when the player right clicks the object. public virtual bool rightClicked(Farmer who) @@ -332,6 +413,7 @@ namespace Revitalize.Framework.Objects /// What happens when the object is drawn at a tile location. public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { + this.updateInfo(); if (x <= -1) { spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), 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)(this.TileLocation.Y * Game1.tileSize) / 10000f)); @@ -373,6 +455,7 @@ namespace Revitalize.Framework.Objects /// Draw the game object at a non-tile spot. Aka like debris. public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) { + this.updateInfo(); /* if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64)) return; @@ -395,6 +478,7 @@ namespace Revitalize.Framework.Objects //The actual planter box being drawn. if (this.animationManager == null) { + this.syncObject.MarkDirty(); if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); @@ -427,6 +511,7 @@ namespace Revitalize.Framework.Objects /// What happens when the object is drawn in a menu. public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { + this.updateInfo(); if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); if (drawStackNumber && this.Quality > 0) @@ -440,8 +525,11 @@ namespace Revitalize.Framework.Objects /// What happens when the object is drawn when held by a player. public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) { - - if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + this.updateInfo(); + if (this.animationManager == null) + { + Revitalize.ModCore.log("Animation Manager Null"); + } if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); if (f.ActiveObject.bigCraftable.Value) { @@ -473,35 +561,8 @@ namespace Revitalize.Framework.Objects public void InitNetFields() { - if (Game1.IsMultiplayer == false && (Game1.IsClient == false || Game1.IsClient == false)) return; - this.initNetFields(); - this.syncObject = new PySync(this); - this.NetFields.AddField(this.syncObject); - this.netItemInfo = new Netcode.NetString(this.ItemInfo); - this.NetFields.AddField(this.netItemInfo); } - /// - /// Gets all of the data necessary for syncing. - /// - /// - public override Dictionary getSyncData() - { - Dictionary syncData = base.getSyncData(); - syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - return syncData; - } - - /// - /// Syncs all of the info to all players. - /// - /// - public override void sync(Dictionary syncData) - { - //Revitalize.ModCore.log("SYNC OBJECT DATA!"); - base.sync(syncData); - this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]); - } public virtual void replaceAfterLoad() @@ -523,5 +584,82 @@ namespace Revitalize.Framework.Objects //Load in a file that has all object names referenced here or something. return this.info.name; } + + public void updateInfo() + { + if (this.info == null) + { + this.ItemInfo = this.text; + ModCore.log("Updated item info!"); + return; + } + + if (string.IsNullOrEmpty(this.ItemInfo)) + { + this.ItemInfo = this.text; + } + else + { + this.text = this.ItemInfo; + } + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~// + // PyTk Functions // + //~~~~~~~~~~~~~~~~~~~~~~~~~// + #region + + /// + /// Rebuilds the data from saves. + /// + /// + /// + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; + BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + + } + + /// + /// Prepares the data for saves. + /// + /// + public override Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + return serializedInfo; + } + + /// + /// Gets all of the data necessary for syncing. + /// + /// + public override Dictionary getSyncData() + { + Dictionary syncData = new Dictionary(); + //syncData.Add("ID", this.ItemInfo); + //syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + syncData.Add("Greeting:", "Hello from: " + Game1.player.Name); + ModCore.log("Send off SYNC DATA!"); + return syncData; + } + + /// + /// Syncs all of the info to all players. + /// + /// + public override void sync(Dictionary syncData) + { + //Revitalize.ModCore.log("SYNC OBJECT DATA!"); + + //this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]); + //this.ItemInfo = syncData["ID"]; + string greeting = syncData["Greeting"]; + ModCore.log(greeting); + } + #endregion } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs index ed28709a..02646e2b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs @@ -107,10 +107,6 @@ namespace Revitalize.Framework.Objects.Items.Resources return component; } - public override object getReplacement() - { - return base.getReplacement(); - } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 7296a47d..a43c5b0a 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -260,6 +260,7 @@ namespace Revitalize Game1.currentMinigame = new Revitalize.Framework.Minigame.SeasideScrambleMinigame.SeasideScramble(); } */ + /* if (e.Button == SButton.Y) { //Game1.activeClickableMenu = new ItemGrabMenu(Game1.player.Items,false,true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems),); @@ -270,6 +271,7 @@ namespace Revitalize Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, newItems, 36); } + */ } private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e) @@ -382,19 +384,21 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { this.loadContent(); - + + /* if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient) { throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!"); } + */ Serializer.afterLoad(); ShopHacks.AddOreToClintsShop(); // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); - Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); + //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); - Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); + //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); //Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous)); @@ -408,9 +412,9 @@ namespace Revitalize //Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne()); - Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19)); + //Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19)); //Ore tin = ObjectManager.resources.getOre("Tin", 19); - + Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1)); //ModCore.log("Tin sells for: " + tin.sellToStorePrice()); From 9950a6d0c0e50184eb9a2d558a69a5ee5476d51f Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 26 Aug 2019 21:46:36 -0700 Subject: [PATCH 02/98] Better pytk sync. --- .../Framework/Objects/BasicItemInformation.cs | 5 +++++ .../Revitalize/Framework/Objects/CustomObject.cs | 16 ++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 9b46d975..ce3405dc 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -113,6 +113,11 @@ namespace Revitalize.Framework.Objects { return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy()); } + + public bool requiresSyncUpdate() + { + return true; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 26c354eb..dbcfed3e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -20,7 +20,7 @@ namespace Revitalize.Framework.Objects public class CustomObject : PySObject { - public string text + public virtual string text { get { @@ -154,6 +154,7 @@ namespace Revitalize.Framework.Objects } set { + if (string.IsNullOrEmpty(value)) return; this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation)); } } @@ -208,7 +209,7 @@ namespace Revitalize.Framework.Objects //this.initNetFields(); this.InitNetFields(); this.updateInfo(); - this.Price = info.price; + this.Price = this.info.price; //if (this.info.ignoreBoundingBox) // this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0); } @@ -594,14 +595,9 @@ namespace Revitalize.Framework.Objects return; } - if (string.IsNullOrEmpty(this.ItemInfo)) - { - this.ItemInfo = this.text; - } - else - { - this.text = this.ItemInfo; - } + this.ItemInfo = this.text; + this.text = this.ItemInfo; + } //~~~~~~~~~~~~~~~~~~~~~~~~~// From b5ce25d141d1728c7494c039aef9e38a849969e5 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 26 Aug 2019 23:32:30 -0700 Subject: [PATCH 03/98] Added ability for custom objects to sync guids across the net! --- .../Framework/Objects/CustomObject.cs | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index dbcfed3e..f0577427 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -94,6 +94,9 @@ namespace Revitalize.Framework.Objects set { + if (this.netName == null) return; + if (this.netName.Value == null) return; + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) this.netName.Value = value + ">" + split[1]; else @@ -146,16 +149,39 @@ namespace Revitalize.Framework.Objects [JsonIgnore] public Texture2D displayTexture => this.animationManager.getTexture(); - public string ItemInfo + [JsonIgnore] + public virtual string ItemInfo { get { - return Revitalize.ModCore.Serializer.ToJSONString(this.info); + return Revitalize.ModCore.Serializer.ToJSONString(this.info)+"<"+this.guid; } set { if (string.IsNullOrEmpty(value)) return; - this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation)); + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + ModCore.CustomObjects[this.guid] = this; + } + else + { + ModCore.CustomObjects.Add(this.guid,this); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + ModCore.CustomObjects.Remove(oldGuid); + } + } } } @@ -171,8 +197,9 @@ namespace Revitalize.Framework.Objects : base(PyTKData, Vector2.Zero) { this.info = info; - this.initializeBasics(); this.guid = Guid.NewGuid(); + this.initializeBasics(); + this.Stack = Stack; } @@ -182,8 +209,9 @@ namespace Revitalize.Framework.Objects : base(PyTKData, TileLocation) { this.info = info; - this.initializeBasics(); this.guid = Guid.NewGuid(); + this.initializeBasics(); + this.Stack = Stack; } @@ -204,8 +232,6 @@ namespace Revitalize.Framework.Objects this.bigCraftable.Value = false; - this.syncObject = new PySync(this); - this.syncObject.init(); //this.initNetFields(); this.InitNetFields(); this.updateInfo(); @@ -586,7 +612,7 @@ namespace Revitalize.Framework.Objects return this.info.name; } - public void updateInfo() + public virtual void updateInfo() { if (this.info == null) { @@ -598,6 +624,7 @@ namespace Revitalize.Framework.Objects this.ItemInfo = this.text; this.text = this.ItemInfo; + ModCore.log("this guid is: " + this.guid); } //~~~~~~~~~~~~~~~~~~~~~~~~~// From 2f071909267ce9377e4cdf099affaf175da18a20 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 26 Aug 2019 23:33:26 -0700 Subject: [PATCH 04/98] Removed debug message that had a stack trace. --- GeneralMods/Revitalize/Framework/Objects/CustomObject.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index f0577427..eb3800fe 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -623,8 +623,6 @@ namespace Revitalize.Framework.Objects this.ItemInfo = this.text; this.text = this.ItemInfo; - - ModCore.log("this guid is: " + this.guid); } //~~~~~~~~~~~~~~~~~~~~~~~~~// From e0d61f19cc4bae60d2b0d4b6c3218d5d89f67d3b Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 27 Aug 2019 15:10:56 -0700 Subject: [PATCH 05/98] Got container objects to sync across the net which is good. --- .../Framework/Objects/CustomObject.cs | 10 +- .../Objects/Extras/ArcadeCabinetOBJ.cs | 4 +- .../Furniture/ChairMultiTiledObject.cs | 1 + .../Objects/Furniture/LampMultiTiledObject.cs | 4 +- .../Objects/Furniture/StorageFurnitureOBJ.cs | 4 +- .../Furniture/TableMultiTiledObject.cs | 4 +- .../Objects/Furniture/TableTileComponent.cs | 35 +++++- .../Framework/Objects/MultiTiledComponent.cs | 103 +++++++++++++++++- .../Framework/Objects/MultiTiledObject.cs | 74 ++++++++++++- .../Objects/Resources/OreVeins/OreVeinObj.cs | 2 +- .../Utilities/MultiplayerUtilities.cs | 101 +++++++++++++++++ .../Serialization/Converters/ItemCoverter.cs | 3 +- GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + 14 files changed, 329 insertions(+), 20 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index eb3800fe..58857e14 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -121,15 +121,21 @@ namespace Revitalize.Framework.Objects { get { + //ModCore.log("Location Name is: " + this.info.locationName); if (this._location == null) { this._location = Game1.getLocationFromName(this.info.locationName); return this._location; } + else + { + return Game1.getLocationFromName(this.info.locationName); + } return this._location; } set { + this._location = value; if (this._location == null) this.info.locationName = ""; else @@ -168,10 +174,12 @@ namespace Revitalize.Framework.Objects this.guid = Guid.Parse(guidString); if (ModCore.CustomObjects.ContainsKey(this.guid)) { + //ModCore.log("Update item with guid: " + this.guid); ModCore.CustomObjects[this.guid] = this; } else { + //ModCore.log("Add in new guid: " + this.guid); ModCore.CustomObjects.Add(this.guid,this); } @@ -179,7 +187,7 @@ namespace Revitalize.Framework.Objects { if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) { - ModCore.CustomObjects.Remove(oldGuid); + //ModCore.CustomObjects.Remove(oldGuid); } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs index 7b8160a3..53c0d626 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs @@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Extras } } - public override void pickUp() + public override void pickUp(Farmer who) { bool canPickUp = this.removeAndAddToPlayersInventory(); @@ -163,7 +163,7 @@ namespace Revitalize.Framework.Objects.Extras { foreach (KeyValuePair pair in this.objects) { - (pair.Value as ArcadeCabinetTile).removeFromLocation((pair.Value as ArcadeCabinetTile).location, pair.Key); + (pair.Value as ArcadeCabinetTile).removeFromLocation(who.currentLocation, pair.Key); } this.location = null; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs index 694c650f..83fee485 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs @@ -143,6 +143,7 @@ namespace Revitalize.Framework.Objects.Furniture public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) { if (!this.isPlaceable()) diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs index db17d900..9946891d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs @@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Furniture } } - public override void pickUp() + public override void pickUp(Farmer Who) { bool canPickUp = this.removeAndAddToPlayersInventory(); @@ -163,7 +163,7 @@ namespace Revitalize.Framework.Objects.Furniture { foreach (KeyValuePair pair in this.objects) { - (pair.Value as LampTileComponent).removeFromLocation((pair.Value as LampTileComponent).location, pair.Key); + (pair.Value as LampTileComponent).removeFromLocation(Who.currentLocation, pair.Key); } this.location = null; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs index bca689d7..314cc298 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs @@ -153,7 +153,7 @@ namespace Revitalize.Framework.Objects.Furniture } } - public override void pickUp() + public override void pickUp(Farmer who) { bool canPickUp = this.removeAndAddToPlayersInventory(); @@ -161,7 +161,7 @@ namespace Revitalize.Framework.Objects.Furniture { foreach (KeyValuePair pair in this.objects) { - (pair.Value as StorageFurnitureTile).removeFromLocation((pair.Value as StorageFurnitureTile).location, pair.Key); + (pair.Value as StorageFurnitureTile).removeFromLocation(who.currentLocation, pair.Key); } this.location = null; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs index 191806d2..a8b26cf2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs @@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Furniture } } - public override void pickUp() + public override void pickUp(Farmer who) { bool canPickUp = this.removeAndAddToPlayersInventory(); @@ -164,7 +164,7 @@ namespace Revitalize.Framework.Objects.Furniture foreach (KeyValuePair pair in this.objects) { (pair.Value as TableTileComponent).clearHeldObject(); - (pair.Value as TableTileComponent).removeFromLocation((pair.Value as TableTileComponent).location, pair.Key); + (pair.Value as TableTileComponent).removeFromLocation(who.currentLocation, pair.Key); } this.location = null; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 56200fc6..9e5ed04d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -50,6 +50,11 @@ namespace Revitalize.Framework.Objects.Furniture this.Price = Info.price; } + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + } + /// /// Forcefully clears the held object without much fuss. /// @@ -112,8 +117,12 @@ namespace Revitalize.Framework.Objects.Furniture } - + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + this.updateInfo(); + return base.placementAction(location, x, y, who); + } public override bool performObjectDropInAction(Item dropInItem, bool probe, Farmer who) { return false; //this.pickUpItem()==PickUpState.DoNothing; @@ -235,7 +244,10 @@ namespace Revitalize.Framework.Objects.Furniture public override Dictionary getAdditionalSaveData() { Dictionary saveData = base.getAdditionalSaveData(); - Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + if (this.containerObject.childrenGuids.ContainsKey(this.offsetKey)) + { + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + } this.containerObject.getAdditionalSaveData(); return saveData; @@ -251,7 +263,7 @@ namespace Revitalize.Framework.Objects.Furniture y *= -1; } */ - + this.updateInfo(); if (this.info == null) { Revitalize.ModCore.log("info is null"); @@ -302,5 +314,22 @@ namespace Revitalize.Framework.Objects.Furniture } + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + this.updateInfo(); + base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) + { + this.updateInfo(); + base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + this.updateInfo(); + base.drawWhenHeld(spriteBatch, objectPosition, f); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 356d9669..a8628aa2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -5,6 +5,7 @@ using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; +using Revitalize.Framework.Utilities; using StardewValley; using StardewValley.Objects; @@ -12,6 +13,76 @@ namespace Revitalize.Framework.Objects { public class MultiTiledComponent : CustomObject,ISaveElement { + + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container=this.containerObject!=null? this.containerObject.guid.ToString():""; + return info+ "<" +guidStr+"<"+offsetKey+"<"+container; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string offsetVec = data[2]; + string containerObject = data[3]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + } + } + public MultiTiledObject containerObject; public Vector2 offsetKey; @@ -29,6 +100,10 @@ namespace Revitalize.Framework.Objects this.containerObject = obj; } + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + } public override bool isPassable() { return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject; @@ -43,7 +118,7 @@ namespace Revitalize.Framework.Objects public override bool clicked(Farmer who) { //ModCore.log("Clicked a multiTiledComponent!"); - this.containerObject.pickUp(); + this.containerObject.pickUp(who); return true; //return base.clicked(who); } @@ -82,6 +157,7 @@ namespace Revitalize.Framework.Objects /// Places an object down. public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { + this.updateInfo(); this.updateDrawPosition(x, y); this.location = location; @@ -110,6 +186,7 @@ namespace Revitalize.Framework.Objects public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { + this.updateInfo(); if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); if (drawStackNumber && this.Quality > 0) @@ -188,7 +265,12 @@ namespace Revitalize.Framework.Objects saveData.Add("ParentGUID", this.containerObject.guid.ToString()); saveData.Add("GUID", this.guid.ToString()); - Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(),this); + + + if (this.containerObject.childrenGuids.ContainsKey(this.offsetKey)) + { + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + } this.containerObject.getAdditionalSaveData(); return saveData; @@ -210,6 +292,7 @@ namespace Revitalize.Framework.Objects /// What happens when the object is drawn at a tile location. public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { + this.updateInfo(); if (this.info.ignoreBoundingBox == true) { x *= -1; @@ -265,7 +348,23 @@ namespace Revitalize.Framework.Objects } + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + base.drawWhenHeld(spriteBatch, objectPosition, f); + } + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + } + public override void updateInfo() + { + if (this.containerObject != null) + { + this.containerObject.updateInfo(); + } + base.updateInfo(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index da94978d..9d86a4bd 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -13,6 +13,44 @@ namespace Revitalize.Framework.Objects { public class MultiTiledObject : CustomObject { + [JsonIgnore] + public override string ItemInfo + { + get + { + string infoStr = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + return infoStr+ "<" + guidStr; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + ModCore.CustomObjects[this.guid] = this; + } + else + { + ModCore.CustomObjects.Add(this.guid, this); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + } + } + [JsonIgnore] public Dictionary objects; @@ -104,6 +142,7 @@ namespace Revitalize.Framework.Objects public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) { (pair.Value as MultiTiledComponent).draw(spriteBatch, x + ((int)pair.Key.X), y + ((int)pair.Key.Y), alpha); @@ -112,6 +151,7 @@ namespace Revitalize.Framework.Objects public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) { pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile + (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); @@ -122,6 +162,7 @@ namespace Revitalize.Framework.Objects public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); @@ -129,6 +170,7 @@ namespace Revitalize.Framework.Objects public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f); //base.drawWhenHeld(spriteBatch, objectPosition, f); @@ -137,6 +179,7 @@ namespace Revitalize.Framework.Objects public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) { if (!this.isPlaceable()) @@ -172,7 +215,7 @@ namespace Revitalize.Framework.Objects - public virtual void pickUp() + public virtual void pickUp(Farmer who) { bool canPickUp = this.removeAndAddToPlayersInventory(); if (canPickUp) @@ -187,7 +230,7 @@ namespace Revitalize.Framework.Objects ModCore.log("Got a light???"); } } - (pair.Value as MultiTiledComponent).removeFromLocation((pair.Value as MultiTiledComponent).location, pair.Key); + (pair.Value as MultiTiledComponent).removeFromLocation(who.currentLocation, pair.Key); } this.location = null; @@ -209,6 +252,7 @@ namespace Revitalize.Framework.Objects public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { + this.updateInfo(); foreach (KeyValuePair pair in this.objects) { /* @@ -242,7 +286,7 @@ namespace Revitalize.Framework.Objects { bool cleanUp = this.clicked(who); if (cleanUp) - this.pickUp(); + this.pickUp(who); return cleanUp; } @@ -372,5 +416,29 @@ namespace Revitalize.Framework.Objects return 1; } + public override void updateInfo() + { + if (this.info == null) + { + this.ItemInfo = this.text; + ModCore.log("Updated item info for container!"); + return; + } + + this.ItemInfo = this.text; + this.text = this.ItemInfo; + + if (this.objects == null) + { + return; + } + /* + foreach(CustomObject c in this.objects.Values) + { + c.updateInfo(); + } + */ + } + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs index 69cee6a6..b714f4b3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs @@ -167,7 +167,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins } } - public override void pickUp() + public override void pickUp(Farmer who) { return; //Don't pick up ore veins! bool canPickUp = this.removeAndAddToPlayersInventory(); diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs new file mode 100644 index 00000000..de13a589 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Objects; +using StardewValley; + +namespace Revitalize.Framework.Utilities +{ + public static class MultiplayerUtilities + { + public static string RequestGUIDMessage = "Revitalize.RequestGUIDObject"; + public static string RequestGUIDMessage_Tile = "Revitalize.RequestGUIDObject_Tile"; + public static string ReceieveGUIDMessage = "Revitalize.ReceieveGUIDObject"; + public static string ReceieveGUIDMessage_Tile = "Revitalize.ReceieveGUIDObject_Tile"; + public static void GetModMessage(object o, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) + { + ModCore.log("Get a mod message: "+e.Type); + if (e.Type.Equals(RequestGUIDMessage)) + { + ModCore.log("Send GUID Request"); + Guid request = Guid.Parse(e.ReadAs()); + SendGuidObject(request); + } + + if (e.Type.Equals(ReceieveGUIDMessage)) + { + ModCore.log("Receieve GUID Request"); + string objStr = e.ReadAs (); + var v=ModCore.Serializer.DeserializeFromJSONString(objStr); + if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) + { + ModCore.CustomObjects.Add((v as CustomObject).guid, (v as CustomObject)); + } + else + { + ModCore.CustomObjects[(v as CustomObject).guid] = (v as CustomObject); + } + } + + if(e.Type.Equals(RequestGUIDMessage_Tile)) + { + ModCore.log("Send GUID Request FOR TILE"); + Guid request = Guid.Parse(e.ReadAs()); + SendGuidObject_Tile(request); + } + if(e.Type.Equals(ReceieveGUIDMessage_Tile)) + { + ModCore.log("Receieve GUID Request FOR TILE"); + string objStr = e.ReadAs(); + var v = ModCore.Serializer.DeserializeFromJSONString(objStr); + if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) + { + ModCore.CustomObjects.Add((v as CustomObject).guid, (v as CustomObject)); + } + else + { + ModCore.CustomObjects[(v as CustomObject).guid] = (v as CustomObject); + } + } + } + + public static void SendGuidObject(Guid request) + { + if (ModCore.CustomObjects.ContainsKey(request)) + { + ModCore.log("Send guid request!"); + ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString(ModCore.CustomObjects[request]), ReceieveGUIDMessage, new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); + } + else + { + ModCore.log("This mod doesn't have the guid object"); + } + } + + public static void SendGuidObject_Tile(Guid request) + { + if (ModCore.CustomObjects.ContainsKey(request)) + { + ModCore.log("Send guid tile request!"); + ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString( (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject), ReceieveGUIDMessage_Tile , new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); + } + else + { + ModCore.log("This mod doesn't have the guid tile"); + } + } + + public static void RequestGuidObject(Guid request) + { + ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(),RequestGUIDMessage, new string[] { ModCore.Manifest.UniqueID.ToString() }); + } + + public static void RequestGuidObject_Tile(Guid request) + { + ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(), RequestGUIDMessage_Tile, new string[] { ModCore.Manifest.UniqueID.ToString() }); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs index 81547b24..002b720f 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs @@ -24,6 +24,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters { new Framework.Utilities.Serialization.Converters.RectangleConverter(), new Framework.Utilities.Serialization.Converters.Texture2DConverter(), + //new NetFieldConverter() }, Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, @@ -35,7 +36,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { string convertedString = JsonConvert.SerializeObject((Item)value, this.settings); - DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver; + DefaultContractResolver resolver = serializer.ContractResolver as ContractResolvers.NetFieldContract; writer.WriteStartObject(); writer.WritePropertyName("Type"); serializer.Serialize(writer, value.GetType().FullName.ToString()); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index a43c5b0a..33e1968d 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -231,6 +231,7 @@ namespace Revitalize ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines; //ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged; //ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay; + ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; CustomObjects = new Dictionary(); //Adds in recipes to the mod. @@ -398,7 +399,7 @@ namespace Revitalize // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); - //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); + Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); //Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous)); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index a380750a..e053ea9e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -146,6 +146,7 @@ + From 19732ad2bf1684c2077febda826babd94ac43ee2 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 27 Aug 2019 16:47:22 -0700 Subject: [PATCH 06/98] Got objects to sync across locations even when not present! --- .../Framework/Illuminate/LightManager.cs | 8 + .../Framework/Objects/BasicItemInformation.cs | 336 ++++++++++++++++-- .../Framework/Objects/CustomObject.cs | 30 ++ .../Framework/Objects/MultiTiledComponent.cs | 20 +- .../Framework/Objects/MultiTiledObject.cs | 15 +- .../Framework/Utilities/InventoryManager.cs | 11 + .../Utilities/MultiplayerUtilities.cs | 19 +- .../Animations/AnimationManager.cs | 12 +- 8 files changed, 408 insertions(+), 43 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs index 6b1f3ef6..7968a389 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; using StardewValley; namespace Revitalize.Framework.Illuminate @@ -29,6 +30,9 @@ namespace Revitalize.Framework.Illuminate /// public const int lightBigNumber= 1000000; + [JsonIgnore] + public bool requiresUpdate; + /// /// Constructor. /// @@ -55,6 +59,7 @@ namespace Revitalize.Framework.Illuminate this.lights.Add(IdKey, light); if (this.fakeLights.ContainsKey(IdKey)) return true; this.fakeLights.Add(IdKey, new FakeLightSource(light.Identifier, light.position.Value, light.color.Value.Invert(), light.radius.Value)); + this.requiresUpdate = true; return true; } @@ -80,6 +85,7 @@ namespace Revitalize.Framework.Illuminate this.lights.Add(IdKey, light); if (this.fakeLights.ContainsKey(IdKey)) return true; this.fakeLights.Add(IdKey, new FakeLightSource(light.Identifier, light.position.Value, light.color.Value.Invert(), light.radius.Value)); + this.requiresUpdate = true; return true; } @@ -121,6 +127,7 @@ namespace Revitalize.Framework.Illuminate Game1.currentLightSources.Add(light); location.sharedLights.Add((int)IdKey.X*lightBigNumber+(int)IdKey.Y,light); this.repositionLight(light, IdKey, gameObject); + this.requiresUpdate = true; return true; } @@ -161,6 +168,7 @@ namespace Revitalize.Framework.Illuminate { Vector2 initialPosition = gameObject.TileLocation * Game1.tileSize; light.position.Value = initialPosition + offset; + this.requiresUpdate = true; } /// diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index ce3405dc..c5e8c3c9 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -7,40 +7,305 @@ using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities; using StardewValley; using StardustCore.UIUtilities; +using Newtonsoft.Json; namespace Revitalize.Framework.Objects { public class BasicItemInformation { - public string name; - public string id; - public string description; - public string categoryName; - public Color categoryColor; - public int price; - public int edibility; - public int fragility; - public bool canBeSetIndoors; - public bool canBeSetOutdoors; - public bool isLamp; - public string locationName; + private string _name; + public string name + { + get + { + return this._name; + } + set + { + this._name = value; + this.requiresUpdate = true; + } + } + + private string _id; + public string id + { + get + { + return this._id; + } + set + { + this._id = value; + this.requiresUpdate = true; + } + } - public AnimationManager animationManager; - public Vector2 drawPosition; + private string _description; + public string description + { + get + { + return this._description; + } + set + { + this._description = value; + this.requiresUpdate = true; + } + } - public Color drawColor; + private string _categoryName; + public string categoryName + { + get + { + return this._categoryName; + } + set + { + this._categoryName = value; + this.requiresUpdate = true; + } + } - public bool ignoreBoundingBox; + private Color _categoryColor; + public Color categoryColor + { + get + { + return this._categoryColor; + } + set + { + this._categoryColor = value; + this.requiresUpdate = true; + } + } - public InventoryManager inventory; + private int _price; + public int price + { + get + { + return this._price; + } + set + { + this._price = value; + this.requiresUpdate = true; + } + } - public LightManager lightManager; + private int _edibility; + public int edibility + { + get + { + return this._edibility; + } + set + { + this._edibility = value; + this.requiresUpdate = true; + } + } - public Enums.Direction facingDirection; - public int shakeTimer; + private int _fragility; + public int fragility + { + get + { + return this._fragility; + } + set + { + this._fragility = value; + this.requiresUpdate = true; + } + } + + + private bool _canBeSetIndoors; + public bool canBeSetIndoors + { + get + { + return this._canBeSetIndoors; + } + set + { + this._canBeSetIndoors = value; + this.requiresUpdate = true; + } + } + + + + private bool _canBeSetOutdoors; + public bool canBeSetOutdoors + { + get + { + return this._canBeSetOutdoors; + } + set + { + this._canBeSetOutdoors = value; + this.requiresUpdate = true; + } + } + + private bool _isLamp; + public bool isLamp + { + get + { + return this._isLamp; + } + set + { + this._isLamp = value; + this.requiresUpdate = true; + } + } + + private string _locationName; + public string locationName + { + get + { + return this._locationName; + + } + set + { + this._locationName = value; + this.requiresUpdate = true; + } + } + + private AnimationManager _animationManager; + public AnimationManager animationManager + { + get + { + return this._animationManager; + } + set + { + this._animationManager = value; + this.requiresUpdate = true; + } + } + + private Vector2 _drawPosition; + public Vector2 drawPosition + { + get + { + return this._drawPosition; + } + set + { + this._drawPosition = value; + this.requiresUpdate = true; + } + } + + + private Color _drawColor; + public Color drawColor + { + get + { + return this._drawColor; + } + set + { + this._drawColor = value; + this.requiresUpdate = true; + } + } + + + private bool _ignoreBoundingBox; + public bool ignoreBoundingBox + { + get + { + return this._ignoreBoundingBox; + } + set + { + this._ignoreBoundingBox = value; + this.requiresUpdate = true; + } + } + + private InventoryManager _inventory; + public InventoryManager inventory + { + get + { + return this._inventory; + } + set + { + this._inventory = value; + this.requiresUpdate = true; + } + } + + + private LightManager _lightManager; + public LightManager lightManager + { + get + { + return this._lightManager; + } + set + { + this._lightManager = value; + this.requiresUpdate = true; + } + } + + private Enums.Direction _facingDirection; + public Enums.Direction facingDirection + { + get + { + return this._facingDirection; + } + set + { + this._facingDirection = value; + this.requiresUpdate = true; + } + } + + + private int _shakeTimer; + public int shakeTimer + { + get + { + return this._shakeTimer; + } + set + { + this._shakeTimer = value; + this.requiresUpdate = true; + } + } + + [JsonIgnore] + public bool requiresUpdate; public BasicItemInformation() { this.name = ""; @@ -61,7 +326,6 @@ namespace Revitalize.Framework.Objects this.facingDirection = Enums.Direction.Down; this.id = ""; this.shakeTimer = 0; - } public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) @@ -116,7 +380,35 @@ namespace Revitalize.Framework.Objects public bool requiresSyncUpdate() { - return true; + return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate(); + } + + public void forceUpdate() + { + this.requiresUpdate = true; + } + private bool animationManagerRequiresUpdate() + { + if (this._animationManager == null) return false; + else return this._animationManager.requiresUpdate; + } + private bool inventoryManagerRequiresUpdate() + { + if (this._inventory == null) return false; + else return this._inventory.requiresUpdate; + } + private bool lightManagerRequiresUpdate() + { + if (this._lightManager == null) return false; + else return this._lightManager.requiresUpdate; + } + + public void cleanAfterUpdate() + { + this.requiresUpdate = false; + this._inventory.requiresUpdate = false; + this._animationManager.requiresUpdate = false; + this._lightManager.requiresUpdate = false; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 58857e14..5d4bf9e9 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -629,8 +629,38 @@ namespace Revitalize.Framework.Objects return; } + if (this.requiresUpdate()) + { + this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + } + } + + public virtual void forceUpdate() + { + if (this.info == null) + { + this.ItemInfo = this.text; + ModCore.log("Updated item info!"); + return; + } this.ItemInfo = this.text; this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + this.info.forceUpdate(); + } + + public virtual bool requiresUpdate() + { + if (this.info.requiresSyncUpdate()) + { + return true; + } + else + { + return false; + } } //~~~~~~~~~~~~~~~~~~~~~~~~~// diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index a8628aa2..7f285116 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -271,6 +271,8 @@ namespace Revitalize.Framework.Objects { Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); } + + this.containerObject.getAdditionalSaveData(); return saveData; @@ -360,11 +362,23 @@ namespace Revitalize.Framework.Objects public override void updateInfo() { - if (this.containerObject != null) + if (this.info == null || this.containerObject==null) { - this.containerObject.updateInfo(); + this.ItemInfo = this.text; + ModCore.log("Updated item info!"); + return; } - base.updateInfo(); + + if (this.requiresUpdate()) + { + this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + } + } + public override bool requiresUpdate() + { + return base.requiresUpdate(); } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 9d86a4bd..0ca4e9ab 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -425,19 +425,12 @@ namespace Revitalize.Framework.Objects return; } - this.ItemInfo = this.text; - this.text = this.ItemInfo; - - if (this.objects == null) + if (this.requiresUpdate()) { - return; + this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); } - /* - foreach(CustomObject c in this.objects.Values) - { - c.updateInfo(); - } - */ } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index ecf938ac..c16409e2 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; using StardewValley; namespace Revitalize.Framework.Utilities @@ -25,6 +26,8 @@ namespace Revitalize.Framework.Utilities /// Checks to see if this core object actually has a valid inventory. public bool HasInventory => this.capacity > 0; + [JsonIgnore] + public bool requiresUpdate; public InventoryManager() { this.capacity = 0; @@ -77,9 +80,11 @@ namespace Revitalize.Framework.Utilities if (self != null && self.canStackWith(item)) { self.addToStack(item.Stack); + this.requiresUpdate = true; return true; } } + this.requiresUpdate = true; this.items.Add(item); return true; } @@ -108,6 +113,7 @@ namespace Revitalize.Framework.Utilities if (item.Stack == 1) return item; + this.requiresUpdate = true; item.Stack = item.Stack - 1; return item.getOne(); } @@ -115,6 +121,7 @@ namespace Revitalize.Framework.Utilities /// Empty the inventory. public void clear() { + this.requiresUpdate = true; this.items.Clear(); } @@ -128,13 +135,17 @@ namespace Revitalize.Framework.Utilities public void resizeCapacity(int Amount) { if (this.capacity + Amount < this.MaxCapacity) + { this.capacity += Amount; + this.requiresUpdate = true; + } } /// Sets the upper limity of the capacity size for the inventory. public void setMaxLimit(int amount) { this.MaxCapacity = amount; + this.requiresUpdate = true; } /// diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index de13a589..4c244035 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -28,14 +28,16 @@ namespace Revitalize.Framework.Utilities { ModCore.log("Receieve GUID Request"); string objStr = e.ReadAs (); - var v=ModCore.Serializer.DeserializeFromJSONString(objStr); + CustomObject v=(CustomObject)ModCore.Serializer.DeserializeFromJSONString(objStr); if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) { - ModCore.CustomObjects.Add((v as CustomObject).guid, (v as CustomObject)); + ModCore.CustomObjects.Add((v as CustomObject).guid, v); + //v.forceUpdate(); } else { - ModCore.CustomObjects[(v as CustomObject).guid] = (v as CustomObject); + ModCore.CustomObjects[(v as CustomObject).guid] = v; + //v.forceUpdate(); } } @@ -49,14 +51,16 @@ namespace Revitalize.Framework.Utilities { ModCore.log("Receieve GUID Request FOR TILE"); string objStr = e.ReadAs(); - var v = ModCore.Serializer.DeserializeFromJSONString(objStr); + CustomObject v =(CustomObject)ModCore.Serializer.DeserializeFromJSONString(objStr); if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) { - ModCore.CustomObjects.Add((v as CustomObject).guid, (v as CustomObject)); + ModCore.CustomObjects.Add((v as CustomObject).guid, v); + //v.forceUpdate(); } else { - ModCore.CustomObjects[(v as CustomObject).guid] = (v as CustomObject); + ModCore.CustomObjects[(v as CustomObject).guid] = v; + //v.forceUpdate(); } } } @@ -66,6 +70,7 @@ namespace Revitalize.Framework.Utilities if (ModCore.CustomObjects.ContainsKey(request)) { ModCore.log("Send guid request!"); + //ModCore.CustomObjects[request].forceUpdate(); ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString(ModCore.CustomObjects[request]), ReceieveGUIDMessage, new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else @@ -79,6 +84,8 @@ namespace Revitalize.Framework.Utilities if (ModCore.CustomObjects.ContainsKey(request)) { ModCore.log("Send guid tile request!"); + //(ModCore.CustomObjects[request] as MultiTiledComponent).forceUpdate(); + //(ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.forceUpdate(); ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString( (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject), ReceieveGUIDMessage_Tile , new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index b0222568..4e53cfec 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; using StardewValley; using StardustCore.UIUtilities; @@ -22,6 +23,8 @@ namespace StardustCore.Animations public string animationDataString; + [JsonIgnore] + public bool requiresUpdate; public bool IsNull => this.defaultDrawFrame == null && this.objectTexture == null; /// @@ -99,6 +102,7 @@ namespace StardustCore.Animations if (this.currentAnimation.frameCountUntilNextAnimation == 0) this.getNextAnimation(); this.currentAnimation.tickAnimationFrame(); + this.requiresUpdate = true; } catch (Exception err) { @@ -108,7 +112,7 @@ namespace StardustCore.Animations } /// Get the next animation frame in the list of animations. - public void getNextAnimation() + private void getNextAnimation() { this.currentAnimationListIndex++; if (this.currentAnimationListIndex == this.currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. @@ -118,6 +122,7 @@ namespace StardustCore.Animations } else { + this.requiresUpdate = true; this.playDefaultAnimation(); return; } @@ -125,6 +130,7 @@ namespace StardustCore.Animations //Get the next animation from the list and reset it's counter to the starting frame value. this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; this.currentAnimation.startAnimation(); + this.requiresUpdate = true; } /// Gets the animation from the dictionary of all animations available. @@ -139,6 +145,7 @@ namespace StardustCore.Animations this.currentAnimationList = dummyList; this.currentAnimation = this.currentAnimationList[StartingFrame]; this.currentAnimationName = AnimationName; + this.requiresUpdate = true; return true; } else @@ -179,6 +186,7 @@ namespace StardustCore.Animations this.currentAnimationName = AnimationName; this.currentAnimation.startAnimation(); this.loopAnimation = true; + this.requiresUpdate = true; return true; } else @@ -219,6 +227,7 @@ namespace StardustCore.Animations this.currentAnimationName = AnimationName; this.currentAnimation.startAnimation(); this.loopAnimation = false; + this.requiresUpdate = true; return true; } else @@ -245,6 +254,7 @@ namespace StardustCore.Animations this.currentAnimation = this.defaultDrawFrame; this.currentAnimationName = ""; this.currentAnimationListIndex = 0; + this.requiresUpdate = true; } /// Sets the animation manager to an on state, meaning that this animation will update on the draw frame. From b53379736d7047ceae729c371a0e95d9f3dc44c4 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 27 Aug 2019 19:27:34 -0700 Subject: [PATCH 07/98] Added syncing for custom objects before saving. --- .../Framework/Objects/CustomObject.cs | 12 +- .../Utilities/MultiplayerUtilities.cs | 26 +++- .../Serialization/Converters/ItemCoverter.cs | 6 +- .../Converters/NetFieldConverter.cs | 144 ++++++++++++++++-- .../Utilities/Serialization/Serialization.cs | 30 +++- GeneralMods/Revitalize/ModCore.cs | 17 +++ 6 files changed, 215 insertions(+), 20 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 5d4bf9e9..65531817 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -109,6 +109,13 @@ namespace Revitalize.Framework.Objects { get { + + if (this.info == null) + { + ModCore.log("Info was null when getting data."); + this.updateInfo(); + } + return this.info.id; } } @@ -675,8 +682,8 @@ namespace Revitalize.Framework.Objects /// public override void rebuild(Dictionary additionalSaveData, object replacement) { - CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; - BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + //CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; + //BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); } @@ -689,6 +696,7 @@ namespace Revitalize.Framework.Objects Dictionary serializedInfo = new Dictionary(); serializedInfo.Add("id", this.ItemInfo); serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return serializedInfo; } diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index 4c244035..4b4ac848 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Xna.Framework; using Revitalize.Framework.Objects; using StardewValley; @@ -14,6 +15,7 @@ namespace Revitalize.Framework.Utilities public static string RequestGUIDMessage_Tile = "Revitalize.RequestGUIDObject_Tile"; public static string ReceieveGUIDMessage = "Revitalize.ReceieveGUIDObject"; public static string ReceieveGUIDMessage_Tile = "Revitalize.ReceieveGUIDObject_Tile"; + public static string RequestALLModObjects = "Revitalize.EndOfDayRequestAllObjects"; public static void GetModMessage(object o, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) { ModCore.log("Get a mod message: "+e.Type); @@ -32,12 +34,12 @@ namespace Revitalize.Framework.Utilities if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) { ModCore.CustomObjects.Add((v as CustomObject).guid, v); - //v.forceUpdate(); + v.updateInfo(); } else { ModCore.CustomObjects[(v as CustomObject).guid] = v; - //v.forceUpdate(); + v.updateInfo(); } } @@ -55,12 +57,22 @@ namespace Revitalize.Framework.Utilities if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) { ModCore.CustomObjects.Add((v as CustomObject).guid, v); - //v.forceUpdate(); + v.updateInfo(); } else { ModCore.CustomObjects[(v as CustomObject).guid] = v; - //v.forceUpdate(); + v.updateInfo(); + } + } + + if (e.Type.Equals(RequestALLModObjects)) + { + List < KeyValuePair > list = ModCore.CustomObjects.ToList(); + foreach(var v in list) + { + (v.Value).updateInfo(); + SendGuidObject(v.Key); } } } @@ -86,6 +98,7 @@ namespace Revitalize.Framework.Utilities ModCore.log("Send guid tile request!"); //(ModCore.CustomObjects[request] as MultiTiledComponent).forceUpdate(); //(ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.forceUpdate(); + (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.updateInfo(); ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString( (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject), ReceieveGUIDMessage_Tile , new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else @@ -104,5 +117,10 @@ namespace Revitalize.Framework.Utilities ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(), RequestGUIDMessage_Tile, new string[] { ModCore.Manifest.UniqueID.ToString() }); } + public static void RequestALLGuidObjects() + { + ModCore.ModHelper.Multiplayer.SendMessage(RequestALLModObjects, RequestALLModObjects,new string[] { ModCore.Manifest.UniqueID.ToString() }); + } + } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs index 002b720f..ca952b82 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs @@ -24,19 +24,20 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters { new Framework.Utilities.Serialization.Converters.RectangleConverter(), new Framework.Utilities.Serialization.Converters.Texture2DConverter(), + Serializer.NetFieldConverter //new NetFieldConverter() }, Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Include }; + this.settings.ContractResolver = new ContractResolvers.NetFieldContract(); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { string convertedString = JsonConvert.SerializeObject((Item)value, this.settings); - DefaultContractResolver resolver = serializer.ContractResolver as ContractResolvers.NetFieldContract; writer.WriteStartObject(); writer.WritePropertyName("Type"); serializer.Serialize(writer, value.GetType().FullName.ToString()); @@ -63,8 +64,9 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters return null; } - JObject jo = JObject.Load(reader); + JObject jo = null; + jo = JObject.Load(reader); string t = jo["Type"].Value(); //See if the type has already been cached and if so return it for deserialization. diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs index 06552ce7..c5d2181a 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs @@ -1,37 +1,159 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; +using Netcode; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Revitalize.Framework.Utilities.Serialization.Converters { public class NetFieldConverter:JsonConverter { + public static Dictionary AllTypes = new Dictionary(); + + JsonSerializerSettings settings; + public NetFieldConverter() + { + this.settings = new JsonSerializerSettings() + { + Converters = new List() + { + new Framework.Utilities.Serialization.Converters.RectangleConverter(), + new Framework.Utilities.Serialization.Converters.Texture2DConverter(), + this + //new NetFieldConverter() + }, + Formatting = Formatting.Indented, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + NullValueHandling = NullValueHandling.Include + }; + this.settings.ContractResolver = new ContractResolvers.NetFieldContract(); + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - writer.WriteValue("NetFields"); + string convertedString = JsonConvert.SerializeObject(value, this.settings); + writer.WriteStartObject(); + writer.WritePropertyName("Type"); + serializer.Serialize(writer, value.GetType().FullName.ToString()); + writer.WritePropertyName("Item"); + serializer.Serialize(writer, convertedString); + + writer.WriteEndObject(); } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + /// + /// Reads the JSON representation of the object. + /// + /// The to read from. + /// Type of the object. + /// The existing value of object being read. + /// The calling serializer. + /// The object value. + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - - string str = (string)reader.Value; - //string str=jsonObject.ToObject(serializer); + if (reader.TokenType == JsonToken.Null) + { + return null; + } + + JObject jo = null; + if (reader == null) return null; + if (reader.Value == null) return null; + + jo = JObject.Load(reader); + string t = jo["Type"].Value(); + + //See if the type has already been cached and if so return it for deserialization. + if (AllTypes.ContainsKey(t)) + { + + return JsonConvert.DeserializeObject(jo["Item"].ToString(), AllTypes[t], this.settings); + } + + Assembly asm = typeof(StardewValley.Object).Assembly; + Type type = null; + + type = asm.GetType(t); + + if (type == null) + { + asm = typeof(Revitalize.ModCore).Assembly; + type = asm.GetType(t); + } + + if (type == null) + { + foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + asm = assembly; + type = asm.GetType(t); + if (t != null) break; + } + } + + if (type == null) + { + throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can;t deserialize this thing!: " + t); + } + + //Cache the newly found type. + AllTypes.Add(t, type); + + return JsonConvert.DeserializeObject(jo["Item"].ToString(), type, this.settings); + /* + if (t== typeof(StardewValley.Tools.Axe).FullName.ToString()) + { + Revitalize.ModCore.log("DESERIALIZE AXE!!!"); + //return jo["Item"].Value(); + return JsonConvert.DeserializeObject(jo["Item"].ToString(),this.settings); + } + else if (t == typeof(Revitalize.Framework.Objects.MultiTiledObject).FullName.ToString()) + { + + Revitalize.ModCore.log("DESERIALIZE Multi Tile Object!!!"); + return JsonConvert.DeserializeObject(jo["Item"].ToString(), this.settings); + // return jo["Item"].Value(); + } + else if (t == typeof(Revitalize.Framework.Objects.MultiTiledComponent).FullName.ToString()) + { + Revitalize.ModCore.log("DESERIALIZE Multi Tile Component!!!"); + return JsonConvert.DeserializeObject(jo["Item"].ToString(), this.settings); + // return jo["Item"].Value(); + } + else + { + + throw new NotImplementedException("CANT DESERIALIZE: " + t.ToString()); + } + */ + - return new Netcode.NetFields(); - return null; } + public override bool CanWrite => true; + public override bool CanRead => true; + public override bool CanConvert(Type objectType) { - return objectType == typeof(Netcode.NetFields); + return this.IsSameOrSubclass(typeof(INetSerializable), objectType); } - public override bool CanRead => true; - public override bool CanWrite => true; + /// + /// https://stackoverflow.com/questions/2742276/how-do-i-check-if-a-type-is-a-subtype-or-the-type-of-an-object + /// + /// + /// + /// + public bool IsSameOrSubclass(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant.IsSubclassOf(potentialBase) + || potentialDescendant == potentialBase; + } } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index 7e8b2567..70a0d788 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Utilities.Serialization.ContractResolvers; +using Revitalize.Framework.Utilities.Serialization.Converters; using StardewValley; using StardewValley.Objects; @@ -38,6 +39,8 @@ namespace Revitalize.Framework.Utilities /// private JsonSerializerSettings settings; + + public static NetFieldConverter NetFieldConverter; /// /// Constructor. /// @@ -49,10 +52,12 @@ namespace Revitalize.Framework.Utilities this.serializer.NullValueHandling = NullValueHandling.Include; this.serializer.ContractResolver = new NetFieldContract(); + NetFieldConverter = new NetFieldConverter(); this.addConverter(new Framework.Utilities.Serialization.Converters.RectangleConverter()); this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter()); this.addConverter(new Framework.Utilities.Serialization.Converters.ItemCoverter()); + this.addConverter(NetFieldConverter); //this.addConverter(new Framework.Utilities.Serialization.Converters.CustomObjectDataConverter()); //this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter()); //this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter()); @@ -258,7 +263,30 @@ namespace Revitalize.Framework.Utilities { //ModCore.log("Found a custom object in a chest!"); string jsonString = JsonName; - string guidName = jsonString.Split(new string[] { "GUID=" }, StringSplitOptions.None)[1]; + ModCore.log(JsonName); + string dataSplit= jsonString.Split(new string[] { "<" }, StringSplitOptions.None)[1]; + string backUpGUID = dataSplit.Split('|')[0]; + string[] guidArr = jsonString.Split(new string[] { "|" }, StringSplitOptions.None); + + foreach(string s in guidArr) + { + ModCore.log(s); + } + + string guidName = guidArr[guidArr.Length - 1]; + guidName = guidName.Substring(5); + + try + { + Guid g = Guid.Parse(guidName); + } + catch (Exception err) + { + Guid d = Guid.Parse(backUpGUID); + guidName = backUpGUID; + } + ModCore.log("THE GUID IS:"+ guidName); + //ModCore.log(jsonString); string type = jsonString.Split('|')[2]; Item I = (Item)ModCore.Serializer.DeserializeGUID(guidName, Type.GetType(type)); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 33e1968d..868d2156 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -232,12 +232,29 @@ namespace Revitalize //ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged; //ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay; ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; + ModHelper.Events.GameLoop.DayEnding += this.GameLoop_DayEnding; + ModHelper.Events.GameLoop.Saving += this.GameLoop_Saving; CustomObjects = new Dictionary(); //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); } + private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e) + { + /* + foreach(var v in CustomObjects) + { + v.Value.updateInfo(); + } + */ + } + + private void GameLoop_DayEnding(object sender, StardewModdingAPI.Events.DayEndingEventArgs e) + { + MultiplayerUtilities.RequestALLGuidObjects(); + } + /// /// Loads in textures to be used by the mod. /// From a752503964b2ba503ef827888e05061a81e0af7b Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 27 Aug 2019 19:42:05 -0700 Subject: [PATCH 08/98] Got custom furniture to sync before and after saves! --- .../Framework/Objects/CustomObject.cs | 2 +- .../Objects/Furniture/ChairTileComponent.cs | 4 +++- .../Objects/Furniture/LampTileComponent.cs | 2 ++ .../Objects/Furniture/TableTileComponent.cs | 2 ++ .../Furniture/ChairInformation.cs | 2 +- .../Furniture/FurnitureInformation.cs | 16 ---------------- .../Framework/Objects/MultiTiledComponent.cs | 2 +- .../Utilities/MultiplayerUtilities.cs | 18 +++++++++--------- .../Utilities/Serialization/Serialization.cs | 6 +++--- GeneralMods/Revitalize/Revitalize.csproj | 1 - 10 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 65531817..2487ac83 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -112,7 +112,7 @@ namespace Revitalize.Framework.Objects if (this.info == null) { - ModCore.log("Info was null when getting data."); + //ModCore.log("Info was null when getting data."); this.updateInfo(); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index 6634cc31..d3be7f08 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; using StardewValley; @@ -22,11 +23,12 @@ namespace Revitalize.Framework.Objects.Furniture /// /// Checks if the player can sit "on" this component. /// + [JsonIgnore] public bool CanSitHere { get { - return (this.furnitureInfo as InformationFiles.Furniture.ChairInformation).canSitHere; + return this.furnitureInfo.canSitHere; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs index 77c9c7a6..cb483679 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities.Serialization; @@ -15,6 +16,7 @@ namespace Revitalize.Framework.Objects.Furniture { public class LampTileComponent:FurnitureTileComponent { + [JsonIgnore] public bool canTurnOn { get diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 9e5ed04d..98303134 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; using Revitalize.Framework.Utilities.Serialization; @@ -18,6 +19,7 @@ namespace Revitalize.Framework.Objects.Furniture public TableInformation furnitureInfo; + [JsonIgnore] public bool CanPlaceItemsHere { get diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs index f1e4fe33..3719751f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Revitalize.Framework.Objects.InformationFiles.Furniture { - public class ChairInformation:FurnitureInformation + public class ChairInformation { public bool canSitHere; diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs deleted file mode 100644 index 2df3b252..00000000 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Revitalize.Framework.Objects.InformationFiles.Furniture -{ - public class FurnitureInformation - { - public FurnitureInformation() - { - - } - } -} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 7f285116..b3a0d24d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -365,7 +365,7 @@ namespace Revitalize.Framework.Objects if (this.info == null || this.containerObject==null) { this.ItemInfo = this.text; - ModCore.log("Updated item info!"); + //ModCore.log("Updated item info!"); return; } diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index 4b4ac848..5e2e1c2d 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -18,17 +18,17 @@ namespace Revitalize.Framework.Utilities public static string RequestALLModObjects = "Revitalize.EndOfDayRequestAllObjects"; public static void GetModMessage(object o, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) { - ModCore.log("Get a mod message: "+e.Type); + //ModCore.log("Get a mod message: "+e.Type); if (e.Type.Equals(RequestGUIDMessage)) { - ModCore.log("Send GUID Request"); + //ModCore.log("Send GUID Request"); Guid request = Guid.Parse(e.ReadAs()); SendGuidObject(request); } if (e.Type.Equals(ReceieveGUIDMessage)) { - ModCore.log("Receieve GUID Request"); + //ModCore.log("Receieve GUID Request"); string objStr = e.ReadAs (); CustomObject v=(CustomObject)ModCore.Serializer.DeserializeFromJSONString(objStr); if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) @@ -45,13 +45,13 @@ namespace Revitalize.Framework.Utilities if(e.Type.Equals(RequestGUIDMessage_Tile)) { - ModCore.log("Send GUID Request FOR TILE"); + //odCore.log("Send GUID Request FOR TILE"); Guid request = Guid.Parse(e.ReadAs()); SendGuidObject_Tile(request); } if(e.Type.Equals(ReceieveGUIDMessage_Tile)) { - ModCore.log("Receieve GUID Request FOR TILE"); + //ModCore.log("Receieve GUID Request FOR TILE"); string objStr = e.ReadAs(); CustomObject v =(CustomObject)ModCore.Serializer.DeserializeFromJSONString(objStr); if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) @@ -81,13 +81,13 @@ namespace Revitalize.Framework.Utilities { if (ModCore.CustomObjects.ContainsKey(request)) { - ModCore.log("Send guid request!"); + //ModCore.log("Send guid request!"); //ModCore.CustomObjects[request].forceUpdate(); ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString(ModCore.CustomObjects[request]), ReceieveGUIDMessage, new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else { - ModCore.log("This mod doesn't have the guid object"); + //ModCore.log("This mod doesn't have the guid object"); } } @@ -95,7 +95,7 @@ namespace Revitalize.Framework.Utilities { if (ModCore.CustomObjects.ContainsKey(request)) { - ModCore.log("Send guid tile request!"); + //ModCore.log("Send guid tile request!"); //(ModCore.CustomObjects[request] as MultiTiledComponent).forceUpdate(); //(ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.forceUpdate(); (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.updateInfo(); @@ -103,7 +103,7 @@ namespace Revitalize.Framework.Utilities } else { - ModCore.log("This mod doesn't have the guid tile"); + //ModCore.log("This mod doesn't have the guid tile"); } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index 70a0d788..72ea284b 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -263,14 +263,14 @@ namespace Revitalize.Framework.Utilities { //ModCore.log("Found a custom object in a chest!"); string jsonString = JsonName; - ModCore.log(JsonName); + //ModCore.log(JsonName); string dataSplit= jsonString.Split(new string[] { "<" }, StringSplitOptions.None)[1]; string backUpGUID = dataSplit.Split('|')[0]; string[] guidArr = jsonString.Split(new string[] { "|" }, StringSplitOptions.None); foreach(string s in guidArr) { - ModCore.log(s); + //ModCore.log(s); } string guidName = guidArr[guidArr.Length - 1]; @@ -285,7 +285,7 @@ namespace Revitalize.Framework.Utilities Guid d = Guid.Parse(backUpGUID); guidName = backUpGUID; } - ModCore.log("THE GUID IS:"+ guidName); + //ModCore.log("THE GUID IS:"+ guidName); //ModCore.log(jsonString); string type = jsonString.Split('|')[2]; diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e053ea9e..e454010f 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -127,7 +127,6 @@ - From acca21e511028cfcbb875b958c40ac0c462e856a Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 28 Aug 2019 00:31:14 -0700 Subject: [PATCH 09/98] Got multi tiled objects to sync its components so that it displays properly in the world and syncs 100 times better. --- .../Framework/Objects/CustomObject.cs | 14 +- .../Framework/Objects/MultiTiledComponent.cs | 24 +-- .../Framework/Objects/MultiTiledObject.cs | 142 +++++++++++++++++- .../Utilities/MultiplayerUtilities.cs | 20 ++- .../Utilities/Serialization/Serialization.cs | 9 +- GeneralMods/Revitalize/ModCore.cs | 4 +- 6 files changed, 180 insertions(+), 33 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 2487ac83..a78639b0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -155,8 +155,16 @@ namespace Revitalize.Framework.Objects public Guid guid; + [JsonIgnore] /// The animation manager. - public AnimationManager animationManager => this.info.animationManager; + public AnimationManager animationManager + { + get + { + this.updateInfo(); + return this.info.animationManager; + } + } /// The display texture for this object. [JsonIgnore] @@ -167,7 +175,7 @@ namespace Revitalize.Framework.Objects { get { - return Revitalize.ModCore.Serializer.ToJSONString(this.info)+"<"+this.guid; + return Revitalize.ModCore.Serializer.ToJSONString(this.info)+"<"+this.guid+"<"+ModCore.Serializer.ToJSONString(this.data); } set { @@ -175,8 +183,10 @@ namespace Revitalize.Framework.Objects string[] data = value.Split('<'); string infoString = data[0]; string guidString = data[1]; + string pytkData = data[2]; this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = ModCore.Serializer.DeserializeFromJSONString(pytkData); Guid oldGuid = this.guid; this.guid = Guid.Parse(guidString); if (ModCore.CustomObjects.ContainsKey(this.guid)) diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index b3a0d24d..ece39866 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -20,9 +20,10 @@ namespace Revitalize.Framework.Objects { string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; string container=this.containerObject!=null? this.containerObject.guid.ToString():""; - return info+ "<" +guidStr+"<"+offsetKey+"<"+container; + return info+ "<" +guidStr+"<"+pyTkData+"<"+offsetKey+"<"+container; } set { @@ -30,10 +31,11 @@ namespace Revitalize.Framework.Objects string[] data = value.Split('<'); string infoString = data[0]; string guidString = data[1]; - string offsetVec = data[2]; - string containerObject = data[3]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); - + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); if (string.IsNullOrEmpty(offsetVec)) return; if (string.IsNullOrEmpty(containerObject)) return; this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); @@ -350,16 +352,6 @@ namespace Revitalize.Framework.Objects } - public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) - { - base.drawWhenHeld(spriteBatch, objectPosition, f); - } - - public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) - { - base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); - } - public override void updateInfo() { if (this.info == null || this.containerObject==null) @@ -376,9 +368,5 @@ namespace Revitalize.Framework.Objects this.info.cleanAfterUpdate(); } } - public override bool requiresUpdate() - { - return base.requiresUpdate(); - } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 0ca4e9ab..3a4fe5a2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; +using Revitalize.Framework.Utilities; using StardewValley; using StardewValley.Objects; @@ -20,7 +21,28 @@ namespace Revitalize.Framework.Objects { string infoStr = Revitalize.ModCore.Serializer.ToJSONString(this.info); string guidStr = this.guid.ToString(); - return infoStr+ "<" + guidStr; + string pytkData = ModCore.Serializer.ToJSONString(this.data); + string dictStr = ModCore.Serializer.ToJSONString(this.childrenGuids); + if (this.objects != null) + { + foreach (KeyValuePair pair in this.objects) + { + if (pair.Value == null) continue; + if ((pair.Value as CustomObject) == null) continue; + if((pair.Value as CustomObject).guid==null) continue; + if(ModCore.CustomObjects.ContainsKey( (pair.Value as CustomObject).guid)) + { + ModCore.CustomObjects[(pair.Value as CustomObject).guid] = (CustomObject)pair.Value; + } + else + { + ModCore.CustomObjects.Add((pair.Value as CustomObject).guid, (pair.Value as CustomObject)); + } + } + } + + //ModCore.log("Serializing dict:" + dictStr); + return infoStr + "<" + guidStr + "<" + pytkData+"<"+dictStr; } set { @@ -28,10 +50,16 @@ namespace Revitalize.Framework.Objects string[] data = value.Split('<'); string infoString = data[0]; string guidString = data[1]; + string pytkData = data[2]; + string dictStr = data[3]; + //ModCore.log("Getting dictStr:" + dictStr); this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pytkData); Guid oldGuid = this.guid; this.guid = Guid.Parse(guidString); + + //this.childrenGuids = ModCore.Serializer.DeserializeFromJSONString>(dictStr); if (ModCore.CustomObjects.ContainsKey(this.guid)) { ModCore.CustomObjects[this.guid] = this; @@ -48,6 +76,27 @@ namespace Revitalize.Framework.Objects //ModCore.CustomObjects.Remove(oldGuid); } } + + Dictionary dict = ModCore.Serializer.DeserializeFromJSONString>(dictStr); + if (dict == null) return; + if (dict.Count == 0) return; + else + { + //ModCore.log("Children dicts are updated!"); + this.childrenGuids = dict; + foreach(KeyValuePair pair in dict) + { + if (ModCore.CustomObjects.ContainsKey(pair.Value)) + { + this.removeComponent(pair.Key); + this.addComponent(pair.Key, (MultiTiledComponent)ModCore.CustomObjects[pair.Value]); + } + else + { + MultiplayerUtilities.RequestGuidObject(pair.Value); + } + } + } } } @@ -80,8 +129,8 @@ namespace Revitalize.Framework.Objects } - public MultiTiledObject(CustomObjectData PyTKData,BasicItemInformation info) - : base(PyTKData,info) + public MultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info) + : base(PyTKData, info) { this.objects = new Dictionary(); this.childrenGuids = new Dictionary(); @@ -89,7 +138,7 @@ namespace Revitalize.Framework.Objects } public MultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation) - : base(PyTKData,info, TileLocation) + : base(PyTKData, info, TileLocation) { this.objects = new Dictionary(); this.childrenGuids = new Dictionary(); @@ -97,7 +146,7 @@ namespace Revitalize.Framework.Objects } public MultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) - : base(PyTKData,info, TileLocation) + : base(PyTKData, info, TileLocation) { this.objects = new Dictionary(); this.childrenGuids = new Dictionary(); @@ -119,7 +168,7 @@ namespace Revitalize.Framework.Objects } this.objects.Add(key, obj); - if (this.childrenGuids.ContainsKey(key)==false) + if (this.childrenGuids.ContainsKey(key) == false) { this.childrenGuids.Add(key, obj.guid); } @@ -129,9 +178,9 @@ namespace Revitalize.Framework.Objects if (key.Y > this.height) this.height = (int)key.Y; (obj as MultiTiledComponent).containerObject = this; (obj as MultiTiledComponent).offsetKey = key; + this.info.forceUpdate(); return true; } - public bool removeComponent(Vector2 key) { if (!this.objects.ContainsKey(key)) @@ -313,7 +362,7 @@ namespace Revitalize.Framework.Objects { objs.Add(pair.Key, (MultiTiledComponent)pair.Value); } - return new MultiTiledObject(this.data,this.info.Copy(), this.TileLocation, objs); + return new MultiTiledObject(this.data, this.info.Copy(), this.TileLocation, objs); } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) @@ -418,12 +467,35 @@ namespace Revitalize.Framework.Objects public override void updateInfo() { + //this.recreateComponents(); if (this.info == null) { this.ItemInfo = this.text; ModCore.log("Updated item info for container!"); return; } + if (this.objects != null) + { + if (this.childrenGuids != null) + { + if (this.objects.Count == 0 || this.objects.Count != this.childrenGuids.Count) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info for container!"); + return; + } + } + else + { + if (this.objects.Count == 0) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info for container!"); + return; + } + + } + } if (this.requiresUpdate()) { @@ -433,5 +505,59 @@ namespace Revitalize.Framework.Objects } } + public virtual void recreateComponents() + { + + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + if ((ModCore.CustomObjects[this.guid] as MultiTiledObject).objects.Count > 0) + { + this.objects = (ModCore.CustomObjects[this.guid] as MultiTiledObject).objects; + } + else + { + + } + if((ModCore.CustomObjects[this.guid] as MultiTiledObject).childrenGuids.Count > 0) + { + this.childrenGuids = (ModCore.CustomObjects[this.guid] as MultiTiledObject).childrenGuids; + } + } + else + { + MultiplayerUtilities.RequestGuidObject(this.guid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + if (this.objects == null || this.childrenGuids == null) + { + ModCore.log("Either objects or children guids are null"); + return; + } + + + ModCore.log("Recreate children components"); + if (this.objects.Count < this.childrenGuids.Count) + { + foreach (KeyValuePair pair in this.childrenGuids) + { + if (ModCore.CustomObjects.ContainsKey(pair.Value)) + { + this.removeComponent(pair.Key); + this.addComponent(pair.Key,(MultiTiledComponent)ModCore.CustomObjects[pair.Value]); + } + else + { + MultiplayerUtilities.RequestGuidObject(pair.Value); + MultiplayerUtilities.RequestGuidObject_Tile(pair.Value); + } + } + } + else + { + ModCore.log("Count is exactly the same!"); + ModCore.log("Count is: " + this.objects.Count+" : and " + this.childrenGuids.Count); + } + } + } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index 5e2e1c2d..12dcbf9d 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -34,11 +34,13 @@ namespace Revitalize.Framework.Utilities if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) { ModCore.CustomObjects.Add((v as CustomObject).guid, v); + v.info.forceUpdate(); v.updateInfo(); } else { ModCore.CustomObjects[(v as CustomObject).guid] = v; + v.info.forceUpdate(); v.updateInfo(); } } @@ -57,11 +59,13 @@ namespace Revitalize.Framework.Utilities if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) { ModCore.CustomObjects.Add((v as CustomObject).guid, v); + v.info.forceUpdate(); v.updateInfo(); } else { ModCore.CustomObjects[(v as CustomObject).guid] = v; + v.info.forceUpdate(); v.updateInfo(); } } @@ -81,13 +85,16 @@ namespace Revitalize.Framework.Utilities { if (ModCore.CustomObjects.ContainsKey(request)) { - //ModCore.log("Send guid request!"); + //ModCore.log("Send guid request: "+request.ToString()); //ModCore.CustomObjects[request].forceUpdate(); + ModCore.CustomObjects[request].info.forceUpdate(); + ModCore.CustomObjects[request].updateInfo(); + ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString(ModCore.CustomObjects[request]), ReceieveGUIDMessage, new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else { - //ModCore.log("This mod doesn't have the guid object"); + ModCore.log("This mod doesn't have the guid object"); } } @@ -98,7 +105,14 @@ namespace Revitalize.Framework.Utilities //ModCore.log("Send guid tile request!"); //(ModCore.CustomObjects[request] as MultiTiledComponent).forceUpdate(); //(ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.forceUpdate(); - (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.updateInfo(); + try + { + (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.updateInfo(); + } + catch(Exception err) + { + + } ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString( (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject), ReceieveGUIDMessage_Tile , new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index 72ea284b..faa54ebf 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -144,13 +144,20 @@ namespace Revitalize.Framework.Utilities public void restoreModObjects() { //Replace all items in the world. + List objsToRestore = new List(); foreach (var v in ModCore.ObjectGroups) { foreach (var obj in v.Value.objects.Values) { - (obj as CustomObject).replaceAfterLoad(); + //(obj as CustomObject).replaceAfterLoad(); + objsToRestore.Add(obj as CustomObject); } } + foreach(CustomObject o in objsToRestore) + { + (o as CustomObject).replaceAfterLoad(); + } + //Replace all held items or items in inventories. foreach (GameLocation loc in LocationUtilities.GetAllLocations()) { diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 868d2156..5c5b9593 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -208,6 +208,7 @@ namespace Revitalize this.initailizeComponents(); Serializer = new Serializer(); playerInfo = new PlayerInfo(); + CustomObjects = new Dictionary(); //Loads in textures to be used by the mod. this.loadInTextures(); @@ -234,7 +235,7 @@ namespace Revitalize ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; ModHelper.Events.GameLoop.DayEnding += this.GameLoop_DayEnding; ModHelper.Events.GameLoop.Saving += this.GameLoop_Saving; - CustomObjects = new Dictionary(); + //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); @@ -433,6 +434,7 @@ namespace Revitalize //Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19)); //Ore tin = ObjectManager.resources.getOre("Tin", 19); Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1)); + Game1.player.addItemToInventory(new StardewValley.Object(388, 100)); //ModCore.log("Tin sells for: " + tin.sellToStorePrice()); From 288912d0468ac1960ff8232e0aafa7060252bb38 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 28 Aug 2019 12:29:51 -0700 Subject: [PATCH 10/98] Updated all furniture and objects to sync additional data. Got items to sync better with less issues, and ore seems to not cause as many problems as I thought. --- .../Framework/Objects/CustomObject.cs | 26 ++-- .../Objects/Extras/ArcadeCabinetTile.cs | 81 +++++++++++ .../Objects/Furniture/ChairTileComponent.cs | 81 +++++++++++ .../Objects/Furniture/LampTileComponent.cs | 1 + .../Objects/Furniture/TableTileComponent.cs | 80 +++++++++++ .../InformationFiles/ObjectGUIDInfo.cs | 23 ---- .../Framework/Objects/MultiTiledComponent.cs | 3 +- .../Framework/Objects/MultiTiledObject.cs | 3 +- .../Framework/Objects/ResourceManager.cs | 24 ++++ .../Objects/Resources/OreVeins/OreVeinObj.cs | 2 + .../Objects/Resources/OreVeins/OreVeinTile.cs | 129 +++++++++++++++++- .../Utilities/MultiplayerUtilities.cs | 48 +++++++ GeneralMods/Revitalize/Revitalize.csproj | 1 - 13 files changed, 457 insertions(+), 45 deletions(-) delete mode 100644 GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index a78639b0..b33561f6 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -8,6 +8,7 @@ using PyTK.CustomElementHandler; using StardustCore.Animations; using StardewValley; using StardewValley.Objects; +using Revitalize.Framework.Utilities; namespace Revitalize.Framework.Objects { @@ -109,13 +110,13 @@ namespace Revitalize.Framework.Objects { get { - + if (this.info == null) { //ModCore.log("Info was null when getting data."); this.updateInfo(); } - + return this.info.id; } } @@ -175,7 +176,7 @@ namespace Revitalize.Framework.Objects { get { - return Revitalize.ModCore.Serializer.ToJSONString(this.info)+"<"+this.guid+"<"+ModCore.Serializer.ToJSONString(this.data); + return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + ModCore.Serializer.ToJSONString(this.data); } set { @@ -197,7 +198,7 @@ namespace Revitalize.Framework.Objects else { //ModCore.log("Add in new guid: " + this.guid); - ModCore.CustomObjects.Add(this.guid,this); + ModCore.CustomObjects.Add(this.guid, this); } if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) @@ -224,7 +225,7 @@ namespace Revitalize.Framework.Objects this.info = info; this.guid = Guid.NewGuid(); this.initializeBasics(); - + this.Stack = Stack; } @@ -236,7 +237,7 @@ namespace Revitalize.Framework.Objects this.info = info; this.guid = Guid.NewGuid(); this.initializeBasics(); - + this.Stack = Stack; } @@ -648,24 +649,15 @@ namespace Revitalize.Framework.Objects if (this.requiresUpdate()) { - this.ItemInfo = this.text; this.text = this.ItemInfo; this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); } } - public virtual void forceUpdate() + public virtual void getUpdate() { - if (this.info == null) - { - this.ItemInfo = this.text; - ModCore.log("Updated item info!"); - return; - } this.ItemInfo = this.text; - this.text = this.ItemInfo; - this.info.cleanAfterUpdate(); - this.info.forceUpdate(); } public virtual bool requiresUpdate() diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs index df47002b..737c032b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs @@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Input; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.InformationFiles.Furniture; +using Revitalize.Framework.Utilities; using Revitalize.Framework.Utilities.Serialization; using StardewValley; using StardewValley.Minigames; @@ -19,6 +20,86 @@ namespace Revitalize.Framework.Objects.Extras { public ArcadeCabinetInformation arcadeInfo; + + + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + string furnitureInfo = ModCore.Serializer.ToJSONString(this.arcadeInfo); + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + furnitureInfo; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + string furnitureInfo = data[5]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + if (string.IsNullOrEmpty(furnitureInfo) == false) + { + this.arcadeInfo = ModCore.Serializer.DeserializeFromJSONString(furnitureInfo); + } + + } + } public ArcadeCabinetTile() : base() { diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index d3be7f08..a436d18d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; +using Revitalize.Framework.Utilities; using StardewValley; using StardewValley.Objects; @@ -20,6 +21,86 @@ namespace Revitalize.Framework.Objects.Furniture { public ChairInformation furnitureInfo; + + + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + string furnitureInfo = ModCore.Serializer.ToJSONString(this.furnitureInfo); + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + furnitureInfo; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + string furnitureInfo = data[5]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + if (string.IsNullOrEmpty(furnitureInfo) == false) + { + this.furnitureInfo = ModCore.Serializer.DeserializeFromJSONString(furnitureInfo); + } + + } + } /// /// Checks if the player can sit "on" this component. /// diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs index cb483679..cba8113a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs @@ -25,6 +25,7 @@ namespace Revitalize.Framework.Objects.Furniture } } + [JsonIgnore] public LightManager lightManager { get diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 98303134..697d3f2b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Input; using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; +using Revitalize.Framework.Utilities; using Revitalize.Framework.Utilities.Serialization; using StardewValley; @@ -19,6 +20,85 @@ namespace Revitalize.Framework.Objects.Furniture public TableInformation furnitureInfo; + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + string furnitureInfo = ModCore.Serializer.ToJSONString(this.furnitureInfo); + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + furnitureInfo; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + string furnitureInfo = data[5]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + if (string.IsNullOrEmpty(furnitureInfo) == false) + { + this.furnitureInfo = ModCore.Serializer.DeserializeFromJSONString(furnitureInfo); + } + + } + } + [JsonIgnore] public bool CanPlaceItemsHere { diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs deleted file mode 100644 index d3b14494..00000000 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Revitalize.Framework.Objects.InformationFiles -{ - public class ObjectGUIDInfo - { - public enum ObjectType - { - Solid, - Display - } - - public ObjectGUIDInfo() - { - - } - - } -} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index ece39866..dfd52595 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -363,9 +363,10 @@ namespace Revitalize.Framework.Objects if (this.requiresUpdate()) { - this.ItemInfo = this.text; + //this.ItemInfo = this.text; this.text = this.ItemInfo; this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 3a4fe5a2..e4fd96d8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -499,9 +499,10 @@ namespace Revitalize.Framework.Objects if (this.requiresUpdate()) { - this.ItemInfo = this.text; + //this.ItemInfo = this.text; this.text = this.ItemInfo; this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); } } diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 700d8822..6d76ef25 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -289,6 +289,30 @@ namespace Revitalize.Framework.Objects } } + public OreResourceInformation getOreResourceInfo(string id) + { + if (this.oreVeins.ContainsKey(id)) + { + return (OreResourceInformation)this.oreVeins[id].resourceInfo; + } + else + { + return null; + } + } + + public List getExtraDropInformationFromOres(string id) + { + if (this.oreVeins.ContainsKey(id)) + { + return (this.oreVeins[id].objects[Vector2.Zero] as OreVeinTile).extraDrops; + } + else + { + return null; + } + } + /// /// Checks to see if a resource can be spawned here. /// diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs index b714f4b3..26dd84b4 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles; using StardewValley; @@ -13,6 +14,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins { public class OreVeinObj:MultiTiledObject { + [JsonIgnore] public ResourceInformaton resourceInfo { get diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs index d0c9c97e..b4f37016 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; using Revitalize.Framework.Utilities.Serialization; using StardewValley; @@ -20,7 +21,113 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins /// public OreResourceInformation resourceInfo; public List extraDrops; - public int healthValue; + + private int _healthValue; + public int healthValue + { + get + { + return this._healthValue; + } + set + { + this._healthValue = value; + if (this.info != null) + { + this.info.forceUpdate(); + } + } + } + + + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + string health = this.healthValue.ToString(); + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<"+health; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + string health = data[5]; + this.healthValue = Convert.ToInt32(health); + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + + //Instead of serializing this info it's static pretty much always so just pull the info from the resource manager. + OreResourceInformation oreResource = ModCore.ObjectManager.resources.getOreResourceInfo(this.info.id); + List extraDrops = ModCore.ObjectManager.resources.getExtraDropInformationFromOres(this.info.id); + if (this.resourceInfo == null) + { + this.resourceInfo = oreResource; + } + if (this.extraDrops == null) + { + this.extraDrops = extraDrops; + } +; + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + } + } public OreVeinTile() : base() @@ -120,7 +227,13 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins if (this.location != null) { this.location.playSound("hammer"); - //ModCore.log("Ore has this much health left: "+this.healthValue); + ModCore.log("Ore has this much health left and location is not null: "+this.healthValue); + this.info.shakeTimer = 200; + } + else + { + Game1.player.currentLocation.playSound("hammer"); + ModCore.log("Ore has this much health left and location is null!: "+this.healthValue); this.info.shakeTimer = 200; } return false; @@ -201,6 +314,18 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins Game1.createRadialDebris(this.location, 14, (int)this.TileLocation.X, (int)this.TileLocation.Y, Game1.random.Next(4, 10), false, -1, false, -1); this.location.removeObject(this.TileLocation, false); this.containerObject.removeComponent(this.offsetKey); + ModCore.CustomObjects.Remove(this.containerObject.guid); + ModCore.CustomObjects.Remove(this.guid); + } + else + { + Game1.player.currentLocation.playSound("stoneCrack"); + Game1.createRadialDebris(Game1.player.currentLocation, 14, (int)this.TileLocation.X, (int)this.TileLocation.Y, Game1.random.Next(4, 10), false, -1, false, -1); + Game1.player.currentLocation.removeObject(this.TileLocation, false); + this.containerObject.removeComponent(this.offsetKey); + //Remove both tile and container from sync. + ModCore.CustomObjects.Remove(this.containerObject.guid); + ModCore.CustomObjects.Remove(this.guid); } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index 12dcbf9d..4e6128de 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -9,6 +9,9 @@ using StardewValley; namespace Revitalize.Framework.Utilities { + /// + /// Deals with syncing objects in multiplayer. + /// public static class MultiplayerUtilities { public static string RequestGUIDMessage = "Revitalize.RequestGUIDObject"; @@ -16,6 +19,13 @@ namespace Revitalize.Framework.Utilities public static string ReceieveGUIDMessage = "Revitalize.ReceieveGUIDObject"; public static string ReceieveGUIDMessage_Tile = "Revitalize.ReceieveGUIDObject_Tile"; public static string RequestALLModObjects = "Revitalize.EndOfDayRequestAllObjects"; + public static string RequestObjectUpdateSync = "Revitalize.RequestObjectUpdateSync"; + + /// + /// Handles receiving mod messages. + /// + /// + /// public static void GetModMessage(object o, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) { //ModCore.log("Get a mod message: "+e.Type); @@ -79,8 +89,22 @@ namespace Revitalize.Framework.Utilities SendGuidObject(v.Key); } } + + if (e.Type.Equals(RequestObjectUpdateSync)) + { + string guidString = e.ReadAs(); + Guid guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(guid)) + { + ModCore.CustomObjects[guid].getUpdate(); + } + } } + /// + /// Sends a custom object to be synced. + /// + /// public static void SendGuidObject(Guid request) { if (ModCore.CustomObjects.ContainsKey(request)) @@ -98,6 +122,10 @@ namespace Revitalize.Framework.Utilities } } + /// + /// Sends the container object from the tile component object's guid. + /// + /// public static void SendGuidObject_Tile(Guid request) { if (ModCore.CustomObjects.ContainsKey(request)) @@ -121,20 +149,40 @@ namespace Revitalize.Framework.Utilities } } + /// + /// Requests the object from the given guid. + /// + /// public static void RequestGuidObject(Guid request) { ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(),RequestGUIDMessage, new string[] { ModCore.Manifest.UniqueID.ToString() }); } + /// + /// Requests a container object from tile component object's guid. + /// + /// public static void RequestGuidObject_Tile(Guid request) { ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(), RequestGUIDMessage_Tile, new string[] { ModCore.Manifest.UniqueID.ToString() }); } + /// + /// Send a request to all other revitalize mods to get all of the synced guid objects that isn't held by this mod. + /// public static void RequestALLGuidObjects() { ModCore.ModHelper.Multiplayer.SendMessage(RequestALLModObjects, RequestALLModObjects,new string[] { ModCore.Manifest.UniqueID.ToString() }); } + /// + /// Sends a request to all other revitalize mods to update the given guid object. + /// + /// + public static void RequestUpdateSync(Guid request) + { + ModCore.ModHelper.Multiplayer.SendMessage(request.ToString(), RequestObjectUpdateSync, new string[] { ModCore.Manifest.UniqueID.ToString() }); + } + } } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e454010f..13eb9130 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -128,7 +128,6 @@ - From dae750bf7cae85f99200e96b30a696ed78cf7c8b Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 28 Aug 2019 14:08:20 -0700 Subject: [PATCH 11/98] Added in notes for mini-greenhouse idea. --- GeneralMods/Revitalize/ModCore.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 5c5b9593..e036856b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -62,7 +62,16 @@ namespace Revitalize -crank (costs stamina) Storage: -Batery Pack - - + -Mini-greenhouse + -takes fertilizer which can do things like help crops grow or increase prodcuction yield/quality. + -takes crop/extended crop seeds + -takes sprinklers + -has grid (1x1, 2x2, 3x3, 4x4, 5x5) system for growing crops/placing sprinkers + -sprinkers auto water crops + -can auto harvest + -hover over crop to see it's info + -can be upgraded to grow crops from specific seasons with season stones (spring,summer, fall winter) (configurable if they are required) + -Add in season stone recipe // -Furnace // -Seed Maker From 9a1fbd8ab3ecd3fdb5d10251e1417c72dcd54400 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 28 Aug 2019 14:33:56 -0700 Subject: [PATCH 12/98] Added in idea for dye machine. --- GeneralMods/Revitalize/ModCore.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index e036856b..f93c87df 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -103,6 +103,15 @@ namespace Revitalize -juice??? -lava? + -Dyes! + -Dye custom objects certain colors! + -Rainbow Dye -(set a custom object to any color) + -red, green, blue, yellow, pink, etc + -Make dye from flowers/coal/algee (black), etc + Dye Machine + -takes custom object and dye + -dyes the object + -can use water to wash off dye. Menus: // -Crafting Menu From 44d63f0a13cd33f30a82d2ecb79879b3957582d5 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 28 Aug 2019 21:13:51 -0700 Subject: [PATCH 13/98] Added in idea for dyed wool. --- GeneralMods/Revitalize/ModCore.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index f93c87df..3cf4a869 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -112,6 +112,8 @@ namespace Revitalize -takes custom object and dye -dyes the object -can use water to wash off dye. + -maybe dye stardew valley items??? + -Dyed Wool (Artisan good) Menus: // -Crafting Menu From 7143d4548c7206834993ab3a7ca9d3ad5d8f7996 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 29 Aug 2019 19:51:13 -0700 Subject: [PATCH 14/98] Added in prismatic ore vein, nugget, and furnace recipe. Also added in gemstone to nugget or shard depending on config. --- .../Items/Resources/Ore/PrismaticNugget.png | Bin 0 -> 237 bytes .../Objects/Resources/Ore/Prismatic.png | Bin 0 -> 605 bytes .../Framework/Configs/ConfigManager.cs | 24 + .../Configs/VanillaMachineRecipeConfig.cs | 36 + .../Framework/Crafting/VanillaRecipeBook.cs | 64 +- .../Revitalize/Framework/Enums/Enums.cs | 1144 +++++++++++++++++ .../Environment/DarkerNightConfig.cs | 9 + .../Framework/Objects/ResourceManager.cs | 55 +- GeneralMods/Revitalize/ModCore.cs | 53 +- GeneralMods/Revitalize/Revitalize.csproj | 8 + 10 files changed, 1362 insertions(+), 31 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/PrismaticNugget.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Resources/Ore/Prismatic.png create mode 100644 GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs create mode 100644 GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/PrismaticNugget.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/PrismaticNugget.png new file mode 100644 index 0000000000000000000000000000000000000000..985430599feccdc84ac549adc0eb4923bc715731 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|mV3H5hFJ6_ zCrGfeIGm{GPzx_UTg#Eg@$-Dbt{#`a%TE7G|NsBL{Szq`;~9E~UkQoLVPjd7`l06k z%tlA1L$Qmubv8aU>FnEKIsNVb|KgJW|L;HXBR}(m!z}KwAI5*eA3se@u-MY|@cP$s zo}}lVTkg(peE45k<6C;dkNXYIvch`I`wUo&PPn~G`LW8p@gcXf!r{a=2cfwK4jg!J lM&QT&nTiwclo*6CFr;j7&Px%7fD1xR5*=&k>5*GVH}4aUFAaK?3m65t&7mvRS=^EgMyIZRX?Pmod~-Mg-vlJ zdDB0TH${4}5TaFRgarl#HlzzLN^{0`5iQig8Md}lx^p2|wB9b}PCGOG+`aGneI7pV z`@${>D2Uz8cTGS+h;O|jpdcjKy`!kQazm2cBA_5f#}65Mm#+*X$?pG(sw?59rsm=z zdy!x$%zUa3fHq&RAqq1n!VC(tpk+Yl4X2T8cIH!k1Vdpmg)sm$ZH2U&K+{&Zy?&M+ z#aGdwWkC3+?tsn1haVOI0|rQ|37kiclU5V-C_e5_L>ZFb{u4;wXPLYZ!XHrp(DOOc zY690j2W`#mCds9O%A3wsLtZ7xZsBV6qUUpbDL6QJuu!~nb33i)Pf(lu%3?Ch%+fRf zp7$eUI>%^iJj&DYo5cotJ_lgH<*9^+0LQcIXxfVT7bKgV&#ssO&MZxneEE?V3y)1g zXTRT&09bx*W>UWk)(*{^qkTBY+~O2_m-k?`){+$Ux? zGgZ|9f6mn~arfG``lXbvsONJ;k985eH^~#(U3|o?neGGK-UxtW-nmU6+3a}42vNNY zfNXXNeLYqMVA-09|B9zm`&E0##>N_Tb@e8}nVJWT-l!+JxWGHrYQW_UO6dlWWOt;p r#Z^~~TMgiNWo9Y`CQ(@)?J&n*D1^=0!US&H00000NkvXXu0mjffF&1{ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs new file mode 100644 index 00000000..14023629 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Configs +{ + /// + /// Handles holding all of the config information. + /// + public class ConfigManager + { + /// + /// The config file for vanilla machine recipes. + /// + public VanillaMachineRecipeConfig vanillaMachineConfig; + + public ConfigManager() + { + this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs b/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs new file mode 100644 index 00000000..6f5eefbf --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Environment; + +namespace Revitalize.Framework.Configs +{ + public class VanillaMachineRecipeConfig + { + /// + /// Should the more expensive recipe be used for smelting. If true the 7 gems smelt a sigle nugget. If false they smelt a prismatic shard after 7 days. + /// + public bool ExpensiveGemstoneToPrismaticFurnaceRecipe; + + public VanillaMachineRecipeConfig() + { + this.ExpensiveGemstoneToPrismaticFurnaceRecipe = false; + } + + public static VanillaMachineRecipeConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "VanillaMachineRecipeConfig.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "VanillaMachineRecipeConfig.json")); + else + { + VanillaMachineRecipeConfig Config = new VanillaMachineRecipeConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "VanillaMachineRecipeConfig.json"), Config); + return Config; + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs index a509f121..ca5b1bdc 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs @@ -35,7 +35,7 @@ namespace Revitalize.Framework.Crafting VanillaRecipe furnace_tinOre = new VanillaRecipe(new Dictionary() { {ModCore.ObjectManager.resources.getOre("Tin"),5 }, - {new StardewValley.Object(382,1),1} + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} }, new KeyValuePair(ModCore.ObjectManager.GetItem("TinIngot"), 1), TimeUtilities.GetMinutesFromTime(0,0,50), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Tin Ore", furnace_tinOre); @@ -43,7 +43,7 @@ namespace Revitalize.Framework.Crafting VanillaRecipe furnace_bauxiteOre = new VanillaRecipe(new Dictionary() { {ModCore.ObjectManager.resources.getOre("Bauxite"),5 }, - {new StardewValley.Object(382,1),1} + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} }, new KeyValuePair(ModCore.ObjectManager.GetItem("AluminumIngot"), 1), TimeUtilities.GetMinutesFromTime(0,1,30), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Bauxite Ore", furnace_bauxiteOre); @@ -51,7 +51,7 @@ namespace Revitalize.Framework.Crafting VanillaRecipe furnace_leadOre = new VanillaRecipe(new Dictionary() { {ModCore.ObjectManager.resources.getOre("Lead"),5 }, - {new StardewValley.Object(382,1),1} + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} }, new KeyValuePair(ModCore.ObjectManager.GetItem("LeadIngot"), 1), TimeUtilities.GetMinutesFromTime(0,2,0), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Lead Ore", furnace_leadOre); @@ -59,7 +59,7 @@ namespace Revitalize.Framework.Crafting VanillaRecipe furnace_silverOre = new VanillaRecipe(new Dictionary() { {ModCore.ObjectManager.resources.getOre("Silver"),5 }, - {new StardewValley.Object(382,1),1} + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} }, new KeyValuePair(ModCore.ObjectManager.GetItem("SilverIngot"), 1), TimeUtilities.GetMinutesFromTime(0,3,0), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Silver Ore", furnace_silverOre); @@ -67,10 +67,64 @@ namespace Revitalize.Framework.Crafting VanillaRecipe furnace_titaniumOre = new VanillaRecipe(new Dictionary() { {ModCore.ObjectManager.resources.getOre("Titanium"),5 }, - {new StardewValley.Object(382,1),1} + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} }, new KeyValuePair(ModCore.ObjectManager.GetItem("TitaniumIngot"), 1), TimeUtilities.GetMinutesFromTime(0,4,0), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Titanium Ore", furnace_titaniumOre); + + VanillaRecipe furnace_prismaticNugget = new VanillaRecipe(new Dictionary() + { + {ModCore.ObjectManager.resources.getOre("PrismaticNugget"),7 }, + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,1), 1), TimeUtilities.GetMinutesFromTime(0, 7, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Prismatic Nugget", furnace_prismaticNugget); + + if (ModCore.Configs.vanillaMachineConfig.ExpensiveGemstoneToPrismaticFurnaceRecipe) + { + VanillaRecipe furnace_gemsToPrismaticNugget = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Emerald,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Aquamarine,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Ruby,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Amethyst,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Topaz,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Jade,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Diamond,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} + }, new KeyValuePair(ModCore.ObjectManager.resources.getOre("PrismaticNugget"), 1), TimeUtilities.GetMinutesFromTime(7, 0, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Emerald", furnace_gemsToPrismaticNugget); + this.recipesByObjectName["Furnace"].Add("Aquamarine", furnace_gemsToPrismaticNugget); + this.recipesByObjectName["Furnace"].Add("Ruby", furnace_gemsToPrismaticNugget); + this.recipesByObjectName["Furnace"].Add("Amethyst", furnace_gemsToPrismaticNugget); + this.recipesByObjectName["Furnace"].Add("Topaz", furnace_gemsToPrismaticNugget); + this.recipesByObjectName["Furnace"].Add("Jade", furnace_gemsToPrismaticNugget); + this.recipesByObjectName["Furnace"].Add("Diamond", furnace_gemsToPrismaticNugget); + } + else + { + VanillaRecipe furnace_gemsToPrismaticShard = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Emerald,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Aquamarine,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Ruby,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Amethyst,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Topaz,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Jade,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Diamond,1),1}, + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1} + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,1), 1), TimeUtilities.GetMinutesFromTime(7, 0, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Emerald", furnace_gemsToPrismaticShard); + this.recipesByObjectName["Furnace"].Add("Aquamarine", furnace_gemsToPrismaticShard); + this.recipesByObjectName["Furnace"].Add("Ruby", furnace_gemsToPrismaticShard); + this.recipesByObjectName["Furnace"].Add("Amethyst", furnace_gemsToPrismaticShard); + this.recipesByObjectName["Furnace"].Add("Topaz", furnace_gemsToPrismaticShard); + this.recipesByObjectName["Furnace"].Add("Jade", furnace_gemsToPrismaticShard); + this.recipesByObjectName["Furnace"].Add("Diamond", furnace_gemsToPrismaticShard); + } + } /// diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index 3d3d7e09..825f1574 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -6,8 +6,14 @@ using System.Threading.Tasks; namespace Revitalize.Framework { + /// + /// Enums. + /// public class Enums { + /// + /// References Stardew Valley facing direction for easier coding. + /// public enum Direction { Up, @@ -16,5 +22,1143 @@ namespace Revitalize.Framework Left } + /// + /// References Stardew Valley Object id's for easier coding. + /// + public enum SDVObject + { + Weeds = 0, + + //Stone = 2, + + //Stone = 4, + + WildHorseradish = 16, + + Daffodil = 18, + + Leek = 20, + + Dandelion = 22, + + Parsnip = 24, + + Lumber = 30, + + Emerald = 60, + + Aquamarine = 62, + + Ruby = 64, + + Amethyst = 66, + + Topaz = 68, + + Jade = 70, + + Diamond = 72, + + PrismaticShard = 74, + + //Stone = 75, + + //Stone = 76, + + //Stone = 77, + + CaveCarrot = 78, + + SecretNote = 79, + + Quartz = 80, + + FireQuartz = 82, + + FrozenTear = 84, + + EarthCrystal = 86, + + Coconut = 88, + + CactusFruit = 90, + + Sap = 92, + + Torch = 93, + + SpiritTorch = 94, + + DwarfScrollI = 96, + + DwarfScrollII = 97, + + DwarfScrollIII = 98, + + DwarfScrollIV = 99, + + ChippedAmphora = 100, + + Arrowhead = 101, + + LostBook = 102, + + AncientDoll = 103, + + ElvishJewelry = 104, + + ChewingStick = 105, + + OrnamentalFan = 106, + + DinosaurEgg = 107, + + RareDisc = 108, + + AncientSword = 109, + + RustySpoon = 110, + + RustySpur = 111, + + RustyCog = 112, + + ChickenStatue = 113, + + AncientSeed = 114, + + PrehistoricTool = 115, + + DriedStarfish = 116, + + Anchor = 117, + + GlassShards = 118, + + BoneFlute = 119, + + PrehistoricHandaxe = 120, + + DwarvishHelm = 121, + + DwarfGadget = 122, + + AncientDrum = 123, + + GoldenMask = 124, + + GoldenRelic = 125, + + StrangeDoll1 = 126, + + StrangeDoll2 = 127, + + Pufferfish = 128, + + Anchovy = 129, + + Tuna = 130, + + Sardine = 131, + + Bream = 132, + + LargemouthBass = 136, + + SmallmouthBass = 137, + + RainbowTrout = 138, + + Salmon = 139, + + Walleye = 140, + + Perch = 141, + + Carp = 142, + + Catfish = 143, + + Pike = 144, + + Sunfish = 145, + + RedMullet = 146, + + Herring = 147, + + Eel = 148, + + Octopus = 149, + + RedSnapper = 150, + + Squid = 151, + + Seaweed = 152, + + GreenAlgae = 153, + + SeaCucumber = 154, + + SuperCucumber = 155, + + Ghostfish = 156, + + WhiteAlgae = 157, + + Stonefish = 158, + + Crimsonfish = 159, + + Angler = 160, + + IcePip = 161, + + LavaEel = 162, + + Legend = 163, + + Sandfish = 164, + + ScorpionCarp = 165, + + TreasureChest = 166, + + JojaCola = 167, + + Trash = 168, + + Driftwood = 169, + + BrokenGlasses = 170, + + BrokenCD = 171, + + SoggyNewspaper = 172, + + Egg = 176, + + LargeEgg = 174, + + Hay = 178, + + BrownEgg = 180, + + LargeBrownEgg = 182, + + Milk = 184, + + LargeMilk = 186, + + GreenBean = 188, + + Cauliflower = 190, + + Potato = 192, + + FriedEgg = 194, + + Omelet = 195, + + Salad = 196, + + CheeseCauliflower = 197, + + BakedFish = 198, + + ParsnipSoup = 199, + + VegetableMedley = 200, + + CompleteBreakfast = 201, + + FriedCalamari = 202, + + StrangeBun = 203, + + LuckyLunch = 204, + + FriedMushroom = 205, + + Pizza = 206, + + BeanHotpot = 207, + + GlazedYams = 208, + + CarpSurprise = 209, + + Hashbrowns = 210, + + Pancakes = 211, + + SalmonDinner = 212, + + FishTaco = 213, + + CrispyBass = 214, + + PepperPoppers = 215, + + Bread = 216, + + TomKhaSoup = 218, + + TroutSoup = 219, + + ChocolateCake = 220, + + PinkCake = 221, + + RhubarbPie = 222, + + Cookie = 223, + + Spaghetti = 224, + + FriedEel = 225, + + SpicyEel = 226, + + Sashimi = 227, + + MakiRoll = 228, + + Tortilla = 229, + + RedPlate = 230, + + EggplantParmesan = 231, + + RicePudding = 232, + + IceCream = 233, + + BlueberryTart = 234, + + AutumnsBounty = 235, + + PumpkinSoup = 236, + + SuperMeal = 237, + + CranberrySauce = 238, + + Stuffing = 239, + + FarmersLunch = 240, + + SurvivalBurger = 241, + + DishOTheSea = 242, + + MinersTreat = 243, + + RootsPlatter = 244, + + Sugar = 245, + + WheatFlour = 246, + + Oil = 247, + + Garlic = 248, + + Kale = 250, + + Rhubarb = 252, + + Melon = 254, + + Tomato = 256, + + Morel = 257, + + Blueberry = 258, + + FiddleheadFern = 259, + + HotPepper = 260, + + Wheat = 262, + + Radish = 264, + + RedCabbage = 266, + + Starfruit = 268, + + Corn = 270, + + Eggplant = 272, + + Artichoke = 274, + + Pumpkin = 276, + + BokChoy = 278, + + Yam = 280, + + Chanterelle = 281, + + Cranberries = 282, + + Holly = 283, + + Beet = 284, + + CherryBomb = 286, + + Bomb = 287, + + MegaBomb = 288, + + //Stone = 290, + + Twig = 294, + + //Twig = 295, + + Salmonberry = 296, + + GrassStarter = 297, + + HardwoodFence = 298, + + AmaranthSeeds = 299, + + Amaranth = 300, + + GrapeStarter = 301, + + HopsStarter = 302, + + PaleAle = 303, + + Hops = 304, + + VoidEgg = 305, + + Mayonnaise = 306, + + DuckMayonnaise = 307, + + VoidMayonnaise = 308, + + Acorn = 309, + + MapleSeed = 310, + + PineCone = 311, + + //Weeds = 313, + + //Weeds = 314, + + //Weeds = 315, + + //Weeds = 316, + + //Weeds = 317, + + //Weeds = 318, + + //Weeds = 319, + + //Weeds = 320, + + //Weeds = 321, + + WoodFence = 322, + + StoneFence = 323, + + IronFence = 324, + + Gate = 325, + + DwarvishTranslationGuide = 326, + + WoodFloor = 328, + + StoneFloor = 329, + + Clay = 330, + + WeatheredFloor = 331, + + CrystalFloor = 333, + + CopperBar = 334, + + IronBar = 335, + + GoldBar = 336, + + IridiumBar = 337, + + RefinedQuartz = 338, + + Honey = 340, + + TeaSet = 341, + + Pickles = 342, + + //Stone = 343, + + Jelly = 344, + + Beer = 346, + + RareSeed = 347, + + Wine = 348, + + EnergyTonic = 349, + + Juice = 350, + + MuscleRemedy = 351, + + BasicFertilizer = 368, + + QualityFertilizer = 369, + + BasicRetainingSoil = 370, + + QualityRetainingSoil = 371, + + Clam = 372, + + GoldenPumpkin = 373, + + CopperOre = 378, + + IronOre = 380, + + Coal = 382, + + GoldOre = 384, + + IridiumOre = 386, + + Wood = 388, + + Stone = 390, + + NautilusShell = 392, + + Coral = 393, + + RainbowShell = 394, + + Coffee = 395, + + SpiceBerry = 396, + + SeaUrchin = 397, + + Grape = 398, + + SpringOnion = 399, + + Strawberry = 400, + + StrawFloor = 401, + + SweetPea = 402, + + FieldSnack = 403, + + CommonMushroom = 404, + + WoodPath = 405, + + WildPlum = 406, + + GravelPath = 407, + + Hazelnut = 408, + + CrystalPath = 409, + + Blackberry = 410, + + CobblestonePath = 411, + + WinterRoot = 412, + + BlueSlimeEgg = 413, + + CrystalFruit = 414, + + SteppingStonePath = 415, + + SnowYam = 416, + + SweetGemBerry = 417, + + Crocus = 418, + + Vinegar = 419, + + RedMushroom = 420, + + Sunflower = 421, + + PurpleMushroom = 422, + + Rice = 423, + + Cheese = 424, + + GoatCheese = 426, + + Cloth = 428, + + Truffle = 430, + + TruffleOil = 432, + + CoffeeBean = 433, + + Stardrop = 434, + + GoatMilk = 436, + + RedSlimeEgg = 437, + + LargeGoatMilk = 438, + + PurpleSlimeEgg = 439, + + Wool = 440, + + ExplosiveAmmo = 441, + + DuckEgg = 442, + + DuckFeather = 444, + + RabbitsFoot = 446, + + StoneBase = 449, + + //Stone = 450, + + //Weeds = 452, + + AncientFruit = 454, + + AlgaeSoup = 456, + + PaleBroth = 457, + + Bouquet = 458, + + Mead = 459, + + MermaidsPendant = 460, + + DecorativePot = 461, + + DrumBlock = 463, + + FluteBlock = 464, + + SpeedGrow = 465, + + DeluxeSpeedGrow = 466, + + ParsnipSeeds = 472, + + BeanStarter = 473, + + CauliflowerSeeds = 474, + + PotatoSeeds = 475, + + GarlicSeeds = 476, + + KaleSeeds = 477, + + RhubarbSeeds = 478, + + MelonSeeds = 479, + + TomatoSeeds = 480, + + BlueberrySeeds = 481, + + PepperSeeds = 482, + + WheatSeeds = 483, + + RadishSeeds = 484, + + RedCabbageSeeds = 485, + + StarfruitSeeds = 486, + + CornSeeds = 487, + + EggplantSeeds = 488, + + ArtichokeSeeds = 489, + + PumpkinSeeds = 490, + + BokChoySeeds = 491, + + YamSeeds = 492, + + CranberrySeeds = 493, + + BeetSeeds = 494, + + SpringSeeds = 495, + + SummerSeeds = 496, + + FallSeeds = 497, + + WinterSeeds = 498, + + AncientSeeds = 499, + + TulipBulb = 427, + + JazzSeeds = 429, + + PoppySeeds = 453, + + SpangleSeeds = 455, + + SunflowerSeeds = 431, + + FairySeeds = 425, + + SmallGlowRing = 516, + + GlowRing = 517, + + SmallMagnetRing = 518, + + MagnetRing = 519, + + SlimeCharmerRing = 520, + + WarriorRing = 521, + + VampireRing = 522, + + SavageRing = 523, + + RingofYoba = 524, + + SturdyRing = 525, + + BurglarsRing = 526, + + IridiumBand = 527, + + JukeboxRing = 528, + + AmethystRing = 529, + + TopazRing = 530, + + AquamarineRing = 531, + + JadeRing = 532, + + EmeraldRing = 533, + + RubyRing = 534, + + Geode = 535, + + FrozenGeode = 536, + + MagmaGeode = 537, + + Alamite = 538, + + Bixite = 539, + + Baryte = 540, + + Aerinite = 541, + + Calcite = 542, + + Dolomite = 543, + + Esperite = 544, + + Fluorapatite = 545, + + Geminite = 546, + + Helvite = 547, + + Jamborite = 548, + + Jagoite = 549, + + Kyanite = 550, + + Lunarite = 551, + + Malachite = 552, + + Neptunite = 553, + + LemonStone = 554, + + Nekoite = 555, + + Orpiment = 556, + + PetrifiedSlime = 557, + + ThunderEgg = 558, + + Pyrite = 559, + + OceanStone = 560, + + GhostCrystal = 561, + + Tigerseye = 562, + + Jasper = 563, + + Opal = 564, + + FireOpal = 565, + + Celestine = 566, + + Marble = 567, + + Sandstone = 568, + + Granite = 569, + + Basalt = 570, + + Limestone = 571, + + Soapstone = 572, + + Hematite = 573, + + Mudstone = 574, + + Obsidian = 575, + + Slate = 576, + + FairyStone = 577, + + StarShards = 578, + + PrehistoricScapula = 579, + + PrehistoricTibia = 580, + + PrehistoricSkull = 581, + + SkeletalHand = 582, + + PrehistoricRib = 583, + + PrehistoricVertebra = 584, + + SkeletalTail = 585, + + NautilusFossil = 586, + + AmphibianFossil = 587, + + PalmFossil = 588, + + Trilobite = 589, + + ArtifactSpot = 590, + + Tulip = 591, + + SummerSpangle = 593, + + FairyRose = 595, + + BlueJazz = 597, + + Sprinkler = 599, + + Poppy = 376, + + PlumPudding = 604, + + ArtichokeDip = 605, + + StirFry = 606, + + RoastedHazelnuts = 607, + + PumpkinPie = 608, + + RadishSalad = 609, + + FruitSalad = 610, + + BlackberryCobbler = 611, + + CranberryCandy = 612, + + Apple = 613, + + Bruschetta = 618, + + QualitySprinkler = 621, + + IridiumSprinkler = 645, + + Coleslaw = 648, + + FiddleheadRisotto = 649, + + PoppyseedMuffin = 651, + + CherrySapling = 628, + + ApricotSapling = 629, + + OrangeSapling = 630, + + PeachSapling = 631, + + PomegranateSapling = 632, + + AppleSapling = 633, + + Apricot = 634, + + Orange = 635, + + Peach = 636, + + Pomegranate = 637, + + Cherry = 638, + + //Stone = 668, + + //Stone = 670, + + //Weeds = 674, + + //Weeds = 675, + + //Weeds = 676, + + //Weeds = 677, + + //Weeds = 678, + + //Weeds = 679, + + GreenSlimeEgg = 680, + + RainTotem = 681, + + MutantCarp = 682, + + BugMeat = 684, + + Bait = 685, + + Spinner = 686, + + DressedSpinner = 687, + + WarpTotemFarm = 688, + + WarpTotemMountains = 689, + + WarpTotemBeach = 690, + + BarbedHook = 691, + + LeadBobber = 692, + + TreasureHunter = 693, + + TrapBobber = 694, + + CorkBobber = 695, + + Sturgeon = 698, + + TigerTrout = 699, + + Bullhead = 700, + + Tilapia = 701, + + Chub = 702, + + Magnet = 703, + + Dorado = 704, + + Albacore = 705, + + Shad = 706, + + Lingcod = 707, + + Halibut = 708, + + Hardwood = 709, + + CrabPot = 710, + + Lobster = 715, + + Crayfish = 716, + + Crab = 717, + + Cockle = 718, + + Mussel = 719, + + Shrimp = 720, + + Snail = 721, + + Periwinkle = 722, + + Oyster = 723, + + MapleSyrup = 724, + + OakResin = 725, + + PineTar = 726, + + Chowder = 727, + + LobsterBisque = 730, + + FishStew = 728, + + Escargot = 729, + + MapleBar = 731, + + CrabCakes = 732, + + Woodskip = 734, + + StrawberrySeeds = 745, + + JackOLantern = 746, + + RottenPlant = 747, + + //RottenPlant = 748, + + OmniGeode = 749, + + //Weeds = 750, + + //Stone = 751, + + //Stone = 760, + + //Stone = 762, + + //Stone = 764, + + //Stone = 765, + + Slime = 766, + + BatWing = 767, + + SolarEssence = 768, + + VoidEssence = 769, + + MixedSeeds = 770, + + Fiber = 771, + + OilofGarlic = 772, + + LifeElixir = 773, + + WildBait = 774, + + Glacierfish = 775, + + //Weeds = 784, + + //Weeds = 785, + + //Weeds = 786, + + BatteryPack = 787, + + LostAxe = 788, + + LuckyPurpleShorts = 789, + + BerryBasket = 790, + + //Weeds = 792, + + //Weeds = 793, + + //Weeds = 794, + + VoidSalmon = 795, + + Slimejack = 796, + + Pearl = 797, + + MidnightSquid = 798, + + SpookFish = 799, + + Blobfish = 800, + + WeddingRing = 801, + + CactusSeeds = 802, + + IridiumMilk = 803, + } + + public enum SDVBigCraftable + { + LightningRod=9, + Keg=12, + Furnace=13, + PreservesJar=15, + JojaSodaMachine=117, + StatueOfEndlessFortune=127, + WormBin=154, + StatueOfPerfection=160, + SolidGoldLewis=164 + } } } diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs index 71819fff..6aa78f50 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs @@ -1,8 +1,17 @@ namespace Revitalize.Framework.Environment { + /// + /// Deals with configurations for darker night. + /// public class DarkerNightConfig { + /// + /// Is darker night enabled? + /// public bool Enabled; + /// + /// The intensity for how dark it gets at night. + /// public float DarknessIntensity; public DarkerNightConfig() { diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 6d76ef25..d372edd3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -130,7 +130,7 @@ namespace Revitalize.Framework.Objects /// Serializes an example ore to eb /// private void serializeOreVeins() { - OreVeinObj tinOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Tin", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Tin"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Tin Ore Vein", "Omegasis.Revitalize.Resources.Ore.Tin", "A ore vein that is full of tin.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Tin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Tin"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + OreVeinObj tinOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Tin", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Tin"), typeof(OreVeinObj), Color.White), new BasicItemInformation("Tin Ore Vein", "Omegasis.Revitalize.Resources.Ore.Tin", "A ore vein that is full of tin.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Tin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Tin"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); OreVeinTile tinOre_0_0= new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Tin", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Tin"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Tin Ore Vein", "Omegasis.Revitalize.Resources.Ore.Tin", "A ore vein that is full of tin.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Tin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Tin"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(this.getOre("Tin"), true, true, true, false, new List() { @@ -150,7 +150,7 @@ namespace Revitalize.Framework.Objects ModCore.Serializer.SerializeContentFile("TinOre", tinOre_file, Path.Combine(this.oreResourceDataPath, "TinOre")); - OreVeinObj bauxiteOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Bauxite", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Bauxite Ore Vein", "Omegasis.Revitalize.Resources.Ore.Bauxite", "A ore vein that is full of bauxite ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + OreVeinObj bauxiteOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Bauxite", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), typeof(OreVeinObj), Color.White), new BasicItemInformation("Bauxite Ore Vein", "Omegasis.Revitalize.Resources.Ore.Bauxite", "A ore vein that is full of bauxite ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); OreVeinTile bauxiteOre_0_0 = new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Bauxite", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Bauxite Ore Vein", "Omegasis.Revitalize.Resources.Ore.Bauxite", "A ore vein that is full of bauxite ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Bauxite"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(this.getOre("Bauxite"), true, true, true, false, new List() { @@ -161,7 +161,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .70d, 0.16d, 0.20d, 1d, 1d, 0, 0, 0, 0), new List(), 4); + }, null, null, .70d, 0.16d, 0.20d, 1d, 1d, 0, 0, 0, 0), new List(), 5); OreFactoryInfo bauxiteOre_0_0_file = new OreFactoryInfo(bauxiteOre_0_0); OreFactoryInfo bauxiteOre_file = new OreFactoryInfo(bauxiteOre); @@ -170,7 +170,7 @@ namespace Revitalize.Framework.Objects ModCore.Serializer.SerializeContentFile("BauxiteOre", bauxiteOre_file, Path.Combine(this.oreResourceDataPath, "BauxiteOre")); - OreVeinObj silverOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Silver", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Silver"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Silver Ore Vein", "Omegasis.Revitalize.Resources.Ore.Silver", "A ore vein that is full of silver ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Silver"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Silver"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + OreVeinObj silverOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Silver", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Silver"), typeof(OreVeinObj), Color.White), new BasicItemInformation("Silver Ore Vein", "Omegasis.Revitalize.Resources.Ore.Silver", "A ore vein that is full of silver ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Silver"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Silver"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); OreVeinTile silverOre_0_0 = new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Silver", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Silver"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Silver Ore Vein", "Omegasis.Revitalize.Resources.Ore.Silver", "A ore vein that is full of silver ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Silver"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Silver"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(this.getOre("Silver"), true, true, true, false, new List() { @@ -181,7 +181,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .50d, 0.10d, 0.14d, 1d, 1d, 0, 0, 0, 0), new List(), 4); + }, null, null, .50d, 0.10d, 0.14d, 1d, 1d, 0, 0, 0, 0), new List(), 6); OreFactoryInfo silverOre_0_0_file = new OreFactoryInfo(silverOre_0_0); OreFactoryInfo silverOre_file = new OreFactoryInfo(silverOre); @@ -189,7 +189,7 @@ namespace Revitalize.Framework.Objects ModCore.Serializer.SerializeContentFile("SilverOre_0_0", silverOre_0_0_file, Path.Combine(this.oreResourceDataPath, "SilverOre")); ModCore.Serializer.SerializeContentFile("SilverOre", silverOre_file, Path.Combine(this.oreResourceDataPath, "SilverOre")); - OreVeinObj leadOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Lead", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Lead"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Lead Ore Vein", "Omegasis.Revitalize.Resources.Ore.Lead", "A ore vein that is full of lead ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Lead"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Lead"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + OreVeinObj leadOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Lead", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Lead"), typeof(OreVeinObj), Color.White), new BasicItemInformation("Lead Ore Vein", "Omegasis.Revitalize.Resources.Ore.Lead", "A ore vein that is full of lead ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Lead"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Lead"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); OreVeinTile leadOre_0_0 = new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Lead", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Lead"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Lead Ore Vein", "Omegasis.Revitalize.Resources.Ore.Lead", "A ore vein that is full of lead ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Lead"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Lead"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(this.getOre("Lead"), true, true, true, false, new List() { @@ -201,7 +201,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .60d, 0.13d, 0.17d, 1d, 1d, 0, 0, 0, 0), new List(), 4); + }, null, null, .60d, 0.13d, 0.17d, 1d, 1d, 0, 0, 0, 0), new List(), 7); OreFactoryInfo leadOre_0_0_file = new OreFactoryInfo(leadOre_0_0); OreFactoryInfo leadOre_file = new OreFactoryInfo(leadOre); @@ -210,7 +210,7 @@ namespace Revitalize.Framework.Objects ModCore.Serializer.SerializeContentFile("LeadOre", leadOre_file, Path.Combine(this.oreResourceDataPath, "LeadOre")); - OreVeinObj titaniumOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Titanium", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Titanium Ore Vein", "Omegasis.Revitalize.Resources.Ore.Titanium", "A ore vein that is full of lead ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + OreVeinObj titaniumOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Titanium", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), typeof(OreVeinObj), Color.White), new BasicItemInformation("Titanium Ore Vein", "Omegasis.Revitalize.Resources.Ore.Titanium", "A ore vein that is full of lead ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); OreVeinTile titaniumOre_0_0 = new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Titanium", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Titanium Ore Vein", "Omegasis.Revitalize.Resources.Ore.Titanium", "A ore vein that is full of lead ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Titanium"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(this.getOre("Titanium"), true, true, true, false, new List() { @@ -222,15 +222,35 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .40d, 0.05d, 0.10d, 1d, 1d, 0, 0, 0, 0), new List(), 4); + }, null, null, .40d, 0.05d, 0.10d, 1d, 1d, 0, 0, 0, 0), new List(), 8); OreFactoryInfo titaniumOre_0_0_file = new OreFactoryInfo(titaniumOre_0_0); OreFactoryInfo titaniumOre_file = new OreFactoryInfo(titaniumOre); ModCore.Serializer.SerializeContentFile("TitaniumOre_0_0", titaniumOre_0_0_file, Path.Combine(this.oreResourceDataPath, "TitaniumOre")); ModCore.Serializer.SerializeContentFile("TitaniumOre", titaniumOre_file, Path.Combine(this.oreResourceDataPath, "TitaniumOre")); - - } + + + OreVeinObj prismaticOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Prismatic", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Prismatic"), typeof(OreVeinObj), Color.White), new BasicItemInformation("Prismatic Ore Vein", "Omegasis.Revitalize.Resources.Ore.Prismatic", "A ore vein that contains rare prismatic nuggets!", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Prismatic"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Prismatic"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + OreVeinTile prismaticOre_0_0 = new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Prismatic", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Prismatic"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Prismatic Ore Vein", "Omegasis.Revitalize.Resources.Ore.Prismatic", "A ore vein that is full of prismatic ore.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Prismatic"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Prismatic"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), + new InformationFiles.OreResourceInformation(this.getOre("PrismaticNugget"), true, true, true, false, new List() + { + new IntRange(110,120) + }, new List(), null, (i => i % 10 == 0), 7, 7, 1, 1, new IntRange(1, 1), new IntRange(1, 1), new IntRange(1, 5), new List() + { + new IntRange(1,9999) + }, new List() + { + }, null, null, .03d, 1d, 0.01d, 0.10, 1d, 1, 1, 1,1), new List(), 10); + + OreFactoryInfo prismaticOre_0_0_file = new OreFactoryInfo(prismaticOre_0_0); + OreFactoryInfo prismaticOre_file = new OreFactoryInfo(prismaticOre); + + ModCore.Serializer.SerializeContentFile("PrismaticOre_0_0", prismaticOre_0_0_file, Path.Combine(this.oreResourceDataPath, "PrismaticOre")); + ModCore.Serializer.SerializeContentFile("PrismaticOre", prismaticOre_file, Path.Combine(this.oreResourceDataPath, "PrismaticOre")); + + + } /// /// Loads in all of the ore items into the game. @@ -253,6 +273,9 @@ namespace Revitalize.Framework.Objects Ore titaniumOre = new Ore(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TitaniumOre", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumOre"), typeof(Ore), Color.White, true), new BasicItemInformation("Titanium Ore", "Omegasis.Revitalize.Items.Resources.Ore.TitaniumOre", "Titanium ore that can be smelted into titanium ingots for further use.", "Ore", Color.Silver, -300, 0, false, 35, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumOre"), new AnimationManager(), Color.White, true, null, null), 1); this.ores.Add("Titanium", titaniumOre); + Ore prismaticOre = new Ore(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.PrismaticNugget", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "PrismaticNugget"), typeof(Ore), Color.White, true), new BasicItemInformation("Prismatic Nugget", "Omegasis.Revitalize.Items.Resources.Ore.PrismaticNugget", "Rare prismatic ore that can be smelted into a prismatic shard when seven are gathered.", "Ore", Color.Silver, -300, 0, false, 200, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "PrismaticNugget"), new AnimationManager(), Color.White, true, null, null), 1); + this.ores.Add("PrismaticNugget", prismaticOre); + CustomObject tinIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TinIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Tin Ingot", "Omegasis.Revitalize.Items.Resources.Ore.TinIngot", "A tin ingot that can be used for crafting purposes.", "Metal", Color.Silver, -300, 0, false,75, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinIngot"), new AnimationManager(), Color.White, true, null, null), 1); ModCore.ObjectManager.AddItem("TinIngot", tinIngot); @@ -511,7 +534,7 @@ namespace Revitalize.Framework.Objects { if (LocationUtilities.Farm_IsFarmHiltopFarm() == false) { - ModCore.log("Farm is not hiltop farm!"); + //ModCore.log("Farm is not hiltop farm!"); return; } GameLocation farm = Game1.getFarm(); @@ -523,7 +546,7 @@ namespace Revitalize.Framework.Objects if ((pair.Value.resourceInfo as OreResourceInformation).spawnsOnFarm) { spawnableOreVeins.Add(pair.Value); - ModCore.log("Found an ore that spawns on the farm!"); + //ModCore.log("Found an ore that spawns on the farm!"); } } foreach (OreVeinObj ore in spawnableOreVeins) @@ -534,7 +557,7 @@ namespace Revitalize.Framework.Objects List openTiles = this.getFarmQuarryOpenTiles(ore); if (openTiles.Count == 0) { - ModCore.log("No open farm tiles!"); + //ModCore.log("No open farm tiles!"); } amount = Math.Min(amount, openTiles.Count); //Only spawn for as many open tiles or the amount of nodes to spawn. for (int i = 0; i < amount; i++) @@ -546,11 +569,11 @@ namespace Revitalize.Framework.Objects i--; //If the tile didn't spawn due to some odd reason ensure that the amount is spawned. openTiles.Remove(openTiles[position]); //amount = Math.Min(amount, openTiles.Count); //Only spawn for as many open tiles or the amount of nodes to spawn. - ModCore.log("Did not spawn ore in the farm quarry!"); + //ModCore.log("Did not spawn ore in the farm quarry!"); } else { - ModCore.log("Spawned ore in the farm quarry!"); + //ModCore.log("Spawned ore in the farm quarry!"); openTiles.Remove(openTiles[position]); //Remove that tile from the list of open tiles. } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 3cf4a869..2626ea0c 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -23,6 +23,7 @@ using Revitalize.Framework.Objects.Extras; using Revitalize.Framework.Minigame.SeasideScrambleMinigame; using Revitalize.Framework.Objects.Items.Resources; using Revitalize.Framework.Hacks; +using Revitalize.Framework.Configs; namespace Revitalize { @@ -107,7 +108,9 @@ namespace Revitalize -Dye custom objects certain colors! -Rainbow Dye -(set a custom object to any color) -red, green, blue, yellow, pink, etc - -Make dye from flowers/coal/algee (black), etc + -Make dye from flowers/coal/algee/minerals/gems (black), etc + -soapstone (washes off dye) + -Lunarite (white) Dye Machine -takes custom object and dye -dyes the object @@ -131,7 +134,7 @@ namespace Revitalize // -Spell books // -Potions! // -Magic Meter - // -Connected chests much like Project EE2 from MC + // -Connected chests (3 digit color code) much like Project EE2 from MC // // // -Food @@ -218,11 +221,13 @@ namespace Revitalize public static Dictionary CustomObjects; + public static ConfigManager Configs; public override void Entry(IModHelper helper) { ModHelper = helper; ModMonitor = this.Monitor; Manifest = this.ModManifest; + Configs = new ConfigManager(); this.createDirectories(); this.initailizeComponents(); @@ -255,10 +260,19 @@ namespace Revitalize ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; ModHelper.Events.GameLoop.DayEnding += this.GameLoop_DayEnding; ModHelper.Events.GameLoop.Saving += this.GameLoop_Saving; - + //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); + + /* + foreach(var v in Game1.objectInformation) + { + string name = v.Value.Split('/')[0]; + ModCore.log(name + "="+v.Key+","+Environment.NewLine,false); + } + */ + } private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e) @@ -273,7 +287,7 @@ namespace Revitalize private void GameLoop_DayEnding(object sender, StardewModdingAPI.Events.DayEndingEventArgs e) { - MultiplayerUtilities.RequestALLGuidObjects(); + //MultiplayerUtilities.RequestALLGuidObjects(); } /// @@ -437,7 +451,7 @@ namespace Revitalize // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); - Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); + //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); //Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous)); @@ -453,9 +467,21 @@ namespace Revitalize //Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19)); //Ore tin = ObjectManager.resources.getOre("Tin", 19); - Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1)); - Game1.player.addItemToInventory(new StardewValley.Object(388, 100)); - + //Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1)); + //Game1.player.addItemToInventory(new StardewValley.Object(388, 100)); + Game1.player.addItemsByMenuIfNecessary(new List() + { + new StardewValley.Object(Vector2.Zero, (int)Enums.SDVBigCraftable.Furnace), + new StardewValley.Object((int)Enums.SDVObject.Coal,10), + new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,5), + new StardewValley.Object((int)Enums.SDVObject.Emerald,1), + new StardewValley.Object((int)Enums.SDVObject.Aquamarine,1), + new StardewValley.Object((int)Enums.SDVObject.Ruby,1), + new StardewValley.Object((int)Enums.SDVObject.Amethyst,1), + new StardewValley.Object((int)Enums.SDVObject.Topaz,1), + new StardewValley.Object((int)Enums.SDVObject.Jade,1), + new StardewValley.Object((int)Enums.SDVObject.Diamond,1), + }); //ModCore.log("Tin sells for: " + tin.sellToStorePrice()); //ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7)); @@ -480,9 +506,16 @@ namespace Revitalize ///Logs information to the console. /// /// - public static void log(object message) + public static void log(object message, bool StackTrace = true) { - ModMonitor.Log(message.ToString() + " " + getFileDebugInfo()); + if (StackTrace) + { + ModMonitor.Log(message.ToString() + " " + getFileDebugInfo()); + } + else + { + ModMonitor.Log(message.ToString()); + } } public static string getFileDebugInfo() diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 13eb9130..41f7e9a5 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -52,6 +52,8 @@ + + @@ -197,6 +199,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -257,6 +262,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From b42dfffde40bbe0d2606f98fb9bb18e36c3951f0 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 29 Aug 2019 19:54:58 -0700 Subject: [PATCH 15/98] Updated prismatic ore spawn chance to be actual non-testing values. --- GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index d372edd3..8525383e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -236,12 +236,12 @@ namespace Revitalize.Framework.Objects new InformationFiles.OreResourceInformation(this.getOre("PrismaticNugget"), true, true, true, false, new List() { new IntRange(110,120) - }, new List(), null, (i => i % 10 == 0), 7, 7, 1, 1, new IntRange(1, 1), new IntRange(1, 1), new IntRange(1, 5), new List() + }, new List(), null, (i => i % 10 == 0), 1, 3, 1, 1, new IntRange(1, 1), new IntRange(1, 1), new IntRange(1, 5), new List() { new IntRange(1,9999) }, new List() { - }, null, null, .03d, 1d, 0.01d, 0.10, 1d, 1, 1, 1,1), new List(), 10); + }, null, null, .05d, 0.01d, 0.01d, 0.10, 1d, 1, 1, 1,1), new List(), 10); OreFactoryInfo prismaticOre_0_0_file = new OreFactoryInfo(prismaticOre_0_0); OreFactoryInfo prismaticOre_file = new OreFactoryInfo(prismaticOre); From e849e051616bde890457b64137a75b1e8d920418 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 29 Aug 2019 21:11:34 -0700 Subject: [PATCH 16/98] Added in alloys, alloy recipes in furnace, and vocalization enabling options. --- .../Configs/Shops_BlacksmithConfig.cs | 18 ++++++++++ .../Framework/Crafting/VanillaRecipeBook.cs | 35 +++++++++++++++++++ .../Framework/Objects/ResourceManager.cs | 14 +++++++- GeneralMods/Revitalize/ModCore.cs | 1 + .../Vocalization/Vocalization/ModConfig.cs | 3 ++ .../Vocalization/Vocalization/Vocalization.cs | 22 ++++++++++-- 6 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs diff --git a/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs b/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs new file mode 100644 index 00000000..f80b6217 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Configs +{ + public class Shops_BlacksmithConfig + { + + public Shops_BlacksmithConfig() + { + + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs index ca5b1bdc..97fde867 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs @@ -125,6 +125,41 @@ namespace Revitalize.Framework.Crafting this.recipesByObjectName["Furnace"].Add("Diamond", furnace_gemsToPrismaticShard); } + VanillaRecipe furnace_steelIngot = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.IronBar,1),1 }, + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),5} + }, new KeyValuePair(ModCore.ObjectManager.GetItem("SteelIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 12, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Iron Bar", furnace_steelIngot); + + VanillaRecipe furnace_brassIngot = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1 }, + {ModCore.ObjectManager.GetItem("AluminumIngot"),1}, + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1} + }, new KeyValuePair(ModCore.ObjectManager.GetItem("BrassIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 6, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Aluminum Ingot", furnace_brassIngot); + + VanillaRecipe furnace_bronzeIngot = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1 }, + {ModCore.ObjectManager.GetItem("TinIngot"),1}, + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1} + }, new KeyValuePair(ModCore.ObjectManager.GetItem("BronzeIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 8, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Tin Ingot", furnace_bronzeIngot); + + VanillaRecipe furnace_electrumIngot = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.GoldBar,1),1 }, + {ModCore.ObjectManager.GetItem("SilverIngot"),1}, + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1} + }, new KeyValuePair(ModCore.ObjectManager.GetItem("ElectrumIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 12, 0), new StatCost(), false); + + this.recipesByObjectName["Furnace"].Add("Silver Ingot", furnace_electrumIngot); + } /// diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 8525383e..ec5dae79 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -288,8 +288,20 @@ namespace Revitalize.Framework.Objects CustomObject silverIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.SilverIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SilverIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Silver Ingot", "Omegasis.Revitalize.Items.Resources.Ore.SilverIngot", "A silver ingot that can be used for crafting purposes.", "Ore", Color.Silver, -300, 0, false, 220, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SilverIngot"), new AnimationManager(), Color.White, true, null, null), 1); ModCore.ObjectManager.AddItem("SilverIngot", silverIngot); - CustomObject titaniumIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TitaniumIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Titanium Ingot", "Omegasis.Revitalize.Items.Resources.Ore.TitaniumIngot", "A titanium ingot that can be used for crafting purposes.", "Ore", Color.Silver, -300, 325, false, 35, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumIngot"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject titaniumIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TitaniumIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Titanium Ingot", "Omegasis.Revitalize.Items.Resources.Ore.TitaniumIngot", "A titanium ingot that can be used for crafting purposes.", "Ore", Color.Silver, -300, 0, false, 325, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumIngot"), new AnimationManager(), Color.White, true, null, null), 1); ModCore.ObjectManager.AddItem("TitaniumIngot", titaniumIngot); + + CustomObject brassIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.BrassIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BrassIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Brass Ingot", "Omegasis.Revitalize.Items.Resources.Ore.BrassIngot", "A brass alloy ingot made from copper and aluminum. It can be used for crafting purposes.", "Ore", Color.Silver, -300, 0, false, 195, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BrassIngot"), new AnimationManager(), Color.White, true, null, null), 1); + ModCore.ObjectManager.AddItem("BrassIngot", brassIngot); + + CustomObject bronzeIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.BronzeIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BronzeIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Bronze Ingot", "Omegasis.Revitalize.Items.Resources.Ore.BronzeIngot", "A bronze alloy ingot made from copper and tin. It can be used for crafting purposes.", "Ore", Color.Silver, -300, 0, false, 150, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BronzeIngot"), new AnimationManager(), Color.White, true, null, null), 1); + ModCore.ObjectManager.AddItem("BronzeIngot", bronzeIngot); + + CustomObject electrumIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.ElectrumIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "ElectrumIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Electrum Ingot", "Omegasis.Revitalize.Items.Resources.Ore.ElectrumIngot", "A electrum alloy ingot made from gold and silver. It can be used for crafting purposes for things that use electricity.", "Ore", Color.Silver, -300, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "ElectrumIngot"), new AnimationManager(), Color.White, true, null, null), 1); + ModCore.ObjectManager.AddItem("ElectrumIngot", electrumIngot); + + CustomObject steelIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.SteelIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SteelIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Steel Ingot", "Omegasis.Revitalize.Items.Resources.Ore.SteelIngot", "A steel ingot that was made by processing iron again with more coal. It can be used for crafting purposes especially for making new machines.", "Ore", Color.Silver, -300, 0, false, 180, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SteelIngot"), new AnimationManager(), Color.White, true, null, null), 1); + ModCore.ObjectManager.AddItem("SteelIngot", steelIngot); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 2626ea0c..f7fc08ea 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -481,6 +481,7 @@ namespace Revitalize new StardewValley.Object((int)Enums.SDVObject.Topaz,1), new StardewValley.Object((int)Enums.SDVObject.Jade,1), new StardewValley.Object((int)Enums.SDVObject.Diamond,1), + new StardewValley.Object((int)Enums.SDVObject.IronBar,1), }); //ModCore.log("Tin sells for: " + tin.sellToStorePrice()); diff --git a/GeneralMods/Vocalization/Vocalization/ModConfig.cs b/GeneralMods/Vocalization/Vocalization/ModConfig.cs index 0def7da6..b3c42fd0 100644 --- a/GeneralMods/Vocalization/Vocalization/ModConfig.cs +++ b/GeneralMods/Vocalization/Vocalization/ModConfig.cs @@ -26,6 +26,9 @@ namespace Vocalization /// The current mode for the mod. public string currentMode = "Full"; + public bool ShopDialogueEnabled=true; + public bool TVDialogueEnabled = true; + public bool LetterDialogueEnabled = true; /// Validates public void verifyValidMode() diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index d98da72f..c418512f 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -20,6 +20,18 @@ using Vocalization.Framework.Menus; namespace Vocalization { /* + *Mode: + * Simple: Hello, Goodbye, etc + * Full: All dialogue + * None: Dialogue disabled + * Cinematic: Simple unless in a cutscene + * CutscenesOnly: (if game event is up play dialogue) + * + * (Code in) Have option to enable/disable shop dialogue + * (Code in) have option to enable/disable tv dialogue + * (Code in) have option to enable/disable letter dialogue + * + * * Things to sanitize/load in * * NPC Dialogue(sanitized, not loaded); @@ -250,7 +262,7 @@ namespace Vocalization private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e) { - if(e.Button.ToString()== config.menuHotkey) + if (e.Button.ToString() == config.menuHotkey) { Game1.activeClickableMenu = new VocalizationMenu(100, 64, 600, 300, true); } @@ -317,7 +329,7 @@ namespace Vocalization new KeyValuePair(speech, ExtraTextureDrawOrder.after) }; - Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper,this.ModManifest ,Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null)), false, components); + Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null)), false, components); //Change this to take the vocalization menu instead var modTabs = new List> @@ -515,6 +527,7 @@ namespace Vocalization }; foreach (string v in tries) { + if (v.Equals("TV") && config.TVDialogueEnabled == false) continue; //Add in support for TV Shows bool f = DialogueCues.TryGetValue(v, out CharacterVoiceCue voice); currentDialogue = sanitizeDialogueInGame(currentDialogue); //If contains the stuff in the else statement, change things up. @@ -538,6 +551,7 @@ namespace Vocalization //Support for Letters if (Game1.activeClickableMenu is LetterViewerMenu letterMenu) { + if (config.LetterDialogueEnabled == false) return; //Use reflection to get original text back. //mail dialogue text will probably need to be sanitized as well.... List mailText = (List)ModHelper.Reflection.GetField>(letterMenu, "mailMessage"); @@ -553,6 +567,7 @@ namespace Vocalization currentDialogue = sanitizeDialogueInGame(currentDialogue); //If contains the stuff in the else statement, change things up. if (voice.dialogueCues.ContainsKey(currentDialogue)) { + //Not variable messages. Aka messages that don't contain words the user can change such as farm name, farmer name etc. voice.speak(currentDialogue); } @@ -566,6 +581,7 @@ namespace Vocalization //Support for shops if (Game1.activeClickableMenu is ShopMenu shopMenu) { + if (config.ShopDialogueEnabled == false) return; string shopDialogue = shopMenu.potraitPersonDialogue; //Check this string to the dict of voice cues shopDialogue = shopDialogue.Replace(Environment.NewLine, ""); @@ -2417,7 +2433,7 @@ namespace Vocalization cleanDialogues = sanitizeDialogueFromDictionaries(dia, cue); foreach (string str in cleanDialogues) { - ModMonitor.Log("POST SANITIZARION: "+str); + ModMonitor.Log("POST SANITIZARION: " + str); if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); From 6aa741b68992691e6d5b14409cede09f5f25ff81 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 29 Aug 2019 22:32:41 -0700 Subject: [PATCH 17/98] Updated vocalization to detect heart events. --- GeneralMods/Revitalize/Revitalize.csproj | 1 + .../Framework/VoiceAudioOptions.cs | 6 +- .../Vocalization/Vocalization/ModConfig.cs | 2 + .../Vocalization/Vocalization/Vocalization.cs | 174 ++++++++++-------- 4 files changed, 103 insertions(+), 80 deletions(-) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 41f7e9a5..471373d9 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -53,6 +53,7 @@ + diff --git a/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs b/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs index 8c6074f2..0bf8ff13 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs @@ -15,20 +15,24 @@ namespace Vocalization.Framework /// The audio clip that plays when the current voice mode is "SimpleAndHeartEvents". public string simpleAndHeartEvents; + public bool isHeartEvent; + public VoiceAudioOptions() { this.simple = ""; this.full = ""; this.heartEvents = ""; this.simpleAndHeartEvents = ""; + this.isHeartEvent = false; } - public VoiceAudioOptions(string simple, string full, string heartEvent, string simpleAndHeartEvent) + public VoiceAudioOptions(string simple, string full, string heartEvent, string simpleAndHeartEvent,bool IsHeartEvent) { this.simple = simple; this.full = full; this.heartEvents = heartEvent; this.simpleAndHeartEvents = simpleAndHeartEvent; + this.isHeartEvent = IsHeartEvent; } public string getAudioClip() diff --git a/GeneralMods/Vocalization/Vocalization/ModConfig.cs b/GeneralMods/Vocalization/Vocalization/ModConfig.cs index b3c42fd0..6146543f 100644 --- a/GeneralMods/Vocalization/Vocalization/ModConfig.cs +++ b/GeneralMods/Vocalization/Vocalization/ModConfig.cs @@ -30,6 +30,8 @@ namespace Vocalization public bool TVDialogueEnabled = true; public bool LetterDialogueEnabled = true; + public bool Developer_ScrapeOnlyEnglishDialogue=true; + /// Validates public void verifyValidMode() { diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index c418512f..ce8d2ec0 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -641,6 +641,10 @@ namespace Vocalization { foreach (LanguageName language in config.translationInfo.LanguageNames) { + if(Vocalization.config.Developer_ScrapeOnlyEnglishDialogue && language!= LanguageName.English) + { + continue; + } string relativeLanguagePath = Path.Combine(RelativeVoicePath, language.ToString()); // check if mod supports language @@ -742,7 +746,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -775,7 +779,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -805,7 +809,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -853,7 +857,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -876,7 +880,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -915,7 +919,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(ahh, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(ahh, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -942,7 +946,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(ahh, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(ahh, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -999,7 +1003,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -1023,7 +1027,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -1046,7 +1050,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -1066,7 +1070,7 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -1111,8 +1115,8 @@ namespace Vocalization { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, replacementStrings.kid1Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, replacementStrings.kid2Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, replacementStrings.kid1Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, replacementStrings.kid2Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1126,7 +1130,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, replacementStrings.kid1Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, replacementStrings.kid1Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else @@ -1152,7 +1156,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(clean_str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(clean_str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else @@ -1179,7 +1183,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, pair2.Key, i.ToString()), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, pair2.Key, i.ToString()), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1204,7 +1208,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, lvl + tool), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), language, lvl + tool), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else @@ -1230,7 +1234,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(actual, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(actual, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else @@ -1244,7 +1248,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(dia, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(dia, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else @@ -1262,7 +1266,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1303,7 +1307,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1345,7 +1349,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else @@ -1373,7 +1377,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -1412,7 +1416,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1452,7 +1456,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -1500,7 +1504,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1537,7 +1541,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key.ToString()))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key.ToString()), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else @@ -1580,7 +1584,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1636,7 +1640,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1720,7 +1724,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1758,7 +1762,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1781,7 +1785,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1794,7 +1798,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1808,7 +1812,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1824,7 +1828,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1838,7 +1842,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1851,7 +1855,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1865,7 +1869,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1881,7 +1885,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1895,7 +1899,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1909,7 +1913,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1923,7 +1927,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1937,7 +1941,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -1985,7 +1989,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key), out VoiceAudioOptions value); - cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2019,7 +2023,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key), out VoiceAudioOptions value); - cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2051,7 +2055,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key), out VoiceAudioOptions value); - cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2092,7 +2096,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, config.translationInfo.getXNBForTranslation("Temp", language), pair.Key), out VoiceAudioOptions value); - cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2144,7 +2148,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -2189,7 +2193,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -2224,7 +2228,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -2246,7 +2250,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2284,7 +2288,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2329,7 +2333,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,IsDialogueHeartEvent(pair.Key))); } else { @@ -2375,7 +2379,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -2437,7 +2441,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2517,7 +2521,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents,false)); } else { @@ -2539,7 +2543,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2553,7 +2557,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2566,7 +2570,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2581,7 +2585,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2595,7 +2599,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2611,7 +2615,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2628,7 +2632,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2642,7 +2646,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2656,7 +2660,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2673,7 +2677,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2689,7 +2693,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2706,7 +2710,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2723,7 +2727,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2740,7 +2744,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2756,7 +2760,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2772,7 +2776,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2788,7 +2792,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2806,7 +2810,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2819,7 +2823,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName1, key1))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName1, key1), out VoiceAudioOptions value); - cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2844,7 +2848,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str2, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str2, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2879,7 +2883,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, key))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, key), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2919,7 +2923,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, fileName, pair.Key.ToString()))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, fileName, pair.Key.ToString()), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -2939,7 +2943,7 @@ namespace Vocalization if (AudioCues.getWavFileReferences(language).ContainsKey(AudioCues.generateKey(language, cue.name, "StringsFromCSFiles", pair.Key.ToString()))) { AudioCues.getWavFileReferences(language).TryGetValue(AudioCues.generateKey(language, cue.name, "StringsFromCSFiles", pair.Key.ToString()), out VoiceAudioOptions value); - cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents, false)); } else { @@ -3511,5 +3515,17 @@ namespace Vocalization return splicedText; } + + public static bool IsDialogueHeartEvent(string text) + { + string[] splits = text.Split('/'); + + if (splits.Length > 1) + { + char firstChar = splits[1][0]; + if (firstChar.Equals('f')) return true; + } + return false; + } } } From 2dab29c6ba6150d0aea7b9f144b2c1e8e786d286 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 31 Aug 2019 11:47:15 -0700 Subject: [PATCH 18/98] Added in configurable sell prices for Clint for custom ores. Fixed machines not tracking custom objects when reloading a save. --- .../Framework/Configs/ConfigManager.cs | 3 ++ .../Configs/Shops_BlacksmithConfig.cs | 47 +++++++++++++++++++ .../Configs/VanillaMachineRecipeConfig.cs | 7 +++ .../Framework/Hacks/ObjectInteractionHacks.cs | 47 +++++++++++++++++-- .../Revitalize/Framework/Hacks/ShopHacks.cs | 10 ++-- GeneralMods/Revitalize/ModCore.cs | 1 + 6 files changed, 107 insertions(+), 8 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs index 14023629..b64af045 100644 --- a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs +++ b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs @@ -16,9 +16,12 @@ namespace Revitalize.Framework.Configs /// public VanillaMachineRecipeConfig vanillaMachineConfig; + public Shops_BlacksmithConfig shops_blacksmithConfig; + public ConfigManager() { this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); + this.shops_blacksmithConfig = Shops_BlacksmithConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs b/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs index f80b6217..3ab241b3 100644 --- a/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/Shops_BlacksmithConfig.cs @@ -1,17 +1,64 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Revitalize.Framework.Configs { + /// + /// Deals with the sell prices for ores in the blacksmith shop. + /// public class Shops_BlacksmithConfig { + /// + /// The sell price for tin ore from the blacksmith. + /// + public int tinOreSellPrice; + /// + /// The sell price for bauxite ore from the blacksmith. + /// + public int bauxiteOreSellPrice; + /// + /// The sell price for lead ore from the blacksmith. + /// + public int leadOreSellPrice; + /// + /// The sell price for silver ore from the blacksmith. + /// + public int silverOreSellPrice; + /// + /// The sell price for titanium ore from the blacksmith. + /// + public int titaniumOreSellPrice; + /// + /// Constructor. + /// public Shops_BlacksmithConfig() { + this.tinOreSellPrice = 100; + this.bauxiteOreSellPrice = 150; + this.leadOreSellPrice = 200; + this.silverOreSellPrice = 250; + this.titaniumOreSellPrice = 300; + } + /// + /// Initializes the config for the blacksmith shop prices. + /// + /// + public static Shops_BlacksmithConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs","Shops","BlacksmithShopPricesConfig.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs","Shops", "BlacksmithShopPricesConfig.json")); + else + { + Shops_BlacksmithConfig Config = new Shops_BlacksmithConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs","Shops", "BlacksmithShopPricesConfig.json"), Config); + return Config; + } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs b/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs index 6f5eefbf..788f45f4 100644 --- a/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/VanillaMachineRecipeConfig.cs @@ -15,11 +15,18 @@ namespace Revitalize.Framework.Configs /// public bool ExpensiveGemstoneToPrismaticFurnaceRecipe; + /// + /// Constructor. + /// public VanillaMachineRecipeConfig() { this.ExpensiveGemstoneToPrismaticFurnaceRecipe = false; } + /// + /// Initializes the config for vanilla machine recipes. + /// + /// public static VanillaMachineRecipeConfig InitializeConfig() { if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "VanillaMachineRecipeConfig.json"))) diff --git a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs index 5914f950..440eac20 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Revitalize.Framework.Crafting; using Revitalize.Framework.Objects; +using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Utilities; using StardewValley; using SObject = StardewValley.Object; @@ -76,6 +77,43 @@ namespace Revitalize.Framework.Hacks } } + /// + /// Restores all tracked machines after loading for proper rendering. + /// + public static void AfterLoad_RestoreTrackedMachines() + { + foreach(GameLocation loc in LocationUtilities.GetAllLocations()) + { + foreach(StardewValley.Object obj in loc.Objects.Values) + { + if( (obj.heldObject.Value is CustomObject)) + { + //Don't want to render for tables since tables have special held object logic. + if (IsSameOrSubclass(typeof(TableTileComponent), obj.GetType()) == true) continue; + else + { + if (TrackedMachines.ContainsKey(loc)) + { + TrackedMachines[loc].Add(obj); + } + else + { + TrackedMachines.Add(loc, new List() + { + obj + }); + } + } + } + } + } + } + + /// + /// Renders custom objects as held objects for stardew valley machines. + /// + /// + /// public static void Render_RenderCustomObjectsHeldInMachines(object sender, StardewModdingAPI.Events.RenderedWorldEventArgs e) { if (TrackedMachines.ContainsKey(Game1.player.currentLocation)) @@ -105,10 +143,13 @@ namespace Revitalize.Framework.Hacks TrackedMachines[Game1.player.currentLocation].Remove(obj); } } - else - { + } - } + + public static bool IsSameOrSubclass(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant.IsSubclassOf(potentialBase) + || potentialDescendant == potentialBase; } } diff --git a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs index 3c632cbc..1e178c61 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs @@ -18,11 +18,11 @@ namespace Revitalize.Framework.Hacks /// public static void AddOreToClintsShop() { - PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),100), "Clint"); - PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), 150), "Clint"); - PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), 200), "Clint"); - PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), 250), "Clint"); - PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), 300), "Clint"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),ModCore.Configs.shops_blacksmithConfig.tinOreSellPrice), "Clint"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), ModCore.Configs.shops_blacksmithConfig.bauxiteOreSellPrice), "Clint"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), ModCore.Configs.shops_blacksmithConfig.leadOreSellPrice), "Clint"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), ModCore.Configs.shops_blacksmithConfig.silverOreSellPrice), "Clint"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), ModCore.Configs.shops_blacksmithConfig.titaniumOreSellPrice), "Clint"); } } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index f7fc08ea..2a2f7ece 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -446,6 +446,7 @@ namespace Revitalize */ Serializer.afterLoad(); ShopHacks.AddOreToClintsShop(); + ObjectInteractionHacks.AfterLoad_RestoreTrackedMachines(); // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); From 5be5222b19762996d35bf1bcde74800d6b7cbe52 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 31 Aug 2019 12:08:52 -0700 Subject: [PATCH 19/98] Fixed chairs rotating too fast and allowed them to use shift-left click instead for sitting. --- .../Framework/Configs/ConfigManager.cs | 2 + .../Framework/Configs/FurnitureConfig.cs | 45 +++++++++++++++++++ .../Framework/Objects/CustomObject.cs | 4 +- .../Objects/Furniture/ChairTileComponent.cs | 25 ++++++++--- .../Furniture/FurnitureTileComponent.cs | 3 ++ .../Objects/Furniture/TableTileComponent.cs | 1 + GeneralMods/Revitalize/ModCore.cs | 2 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + 8 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs diff --git a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs index b64af045..1f464231 100644 --- a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs +++ b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs @@ -17,11 +17,13 @@ namespace Revitalize.Framework.Configs public VanillaMachineRecipeConfig vanillaMachineConfig; public Shops_BlacksmithConfig shops_blacksmithConfig; + public FurnitureConfig furnitureConfig; public ConfigManager() { this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); this.shops_blacksmithConfig = Shops_BlacksmithConfig.InitializeConfig(); + this.furnitureConfig = FurnitureConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs b/GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs new file mode 100644 index 00000000..f5263cd6 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Configs +{ + /// + /// Deals with config settings for furniture. + /// + public class FurnitureConfig + { + /// + /// How many draw frames should happen between rotating a furniture piece. + /// + public int furnitureFrameRotationDelay; + + /// + /// Constructor. + /// + public FurnitureConfig() + { + this.furnitureFrameRotationDelay = 20; + } + + /// + /// Initializes the config for furniture. + /// + /// + public static FurnitureConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "FurnitureConfig.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "FurnitureConfig.json")); + else + { + FurnitureConfig Config = new FurnitureConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "FurnitureConfig.json"), Config); + return Config; + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index b33561f6..387e4f8e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -299,13 +299,13 @@ namespace Revitalize.Framework.Objects MouseState mState = Mouse.GetState(); KeyboardState keyboardState = Game1.GetKeyboardState(); - if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift))) + if (mState.RightButton == ButtonState.Pressed && keyboardState.IsKeyDown(Keys.LeftShift)==false && keyboardState.IsKeyDown(Keys.RightShift)==false) { //ModCore.log("Right clicked!"); return this.rightClicked(who); } - if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift)==true || keyboardState.IsKeyDown(Keys.RightShift)==true)) return this.shiftRightClicked(who); return base.checkForAction(who, justCheckingForActivity); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index a436d18d..c58afba3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -21,8 +21,7 @@ namespace Revitalize.Framework.Objects.Furniture { public ChairInformation furnitureInfo; - - + [JsonIgnore] public override string ItemInfo { get @@ -139,10 +138,17 @@ namespace Revitalize.Framework.Objects.Furniture /// public override bool rightClicked(Farmer who) { - this.containerObject.rotate(); //Ensure that all of the chair pieces rotate at the same time. - - this.checkForSpecialUpSittingAnimation(); - return true; + if (this.framesUntilNextRotation <= 0) + { + this.containerObject.rotate(); //Ensure that all of the chair pieces rotate at the same time. + this.checkForSpecialUpSittingAnimation(); + this.framesUntilNextRotation = ModCore.Configs.furnitureConfig.furnitureFrameRotationDelay; + return true; + } + else + { + return true; + } //return base.rightClicked(who); } @@ -263,6 +269,10 @@ namespace Revitalize.Framework.Objects.Furniture spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + if (this.framesUntilNextRotation > 0) + this.framesUntilNextRotation--; + if (this.framesUntilNextRotation < 0) this.framesUntilNextRotation = 0; + } else @@ -281,6 +291,9 @@ namespace Revitalize.Framework.Objects.Furniture 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); + if (this.framesUntilNextRotation > 0) + this.framesUntilNextRotation--; + if (this.framesUntilNextRotation < 0) this.framesUntilNextRotation = 0; try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs index 3fd18a89..27665240 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Objects.InformationFiles.Furniture; @@ -13,6 +14,8 @@ namespace Revitalize.Framework.Objects.Furniture public class FurnitureTileComponent:MultiTiledComponent { + [JsonIgnore] + public int framesUntilNextRotation = 0; public FurnitureTileComponent():base() { diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 697d3f2b..142f1461 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -20,6 +20,7 @@ namespace Revitalize.Framework.Objects.Furniture public TableInformation furnitureInfo; + [JsonIgnore] public override string ItemInfo { get diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 2a2f7ece..86d946ef 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -450,7 +450,7 @@ namespace Revitalize // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); - //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); + Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 471373d9..f610310d 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -53,6 +53,7 @@ + From a3c0e4f8a0207f02f2210874e5fff480fa2b60bc Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 31 Aug 2019 12:19:05 -0700 Subject: [PATCH 20/98] Stopped spamming inventory. Checked and items do sync over the net. --- GeneralMods/Revitalize/ModCore.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 86d946ef..13dee0c8 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -470,6 +470,7 @@ namespace Revitalize //Ore tin = ObjectManager.resources.getOre("Tin", 19); //Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1)); //Game1.player.addItemToInventory(new StardewValley.Object(388, 100)); + /* Game1.player.addItemsByMenuIfNecessary(new List() { new StardewValley.Object(Vector2.Zero, (int)Enums.SDVBigCraftable.Furnace), @@ -484,6 +485,7 @@ namespace Revitalize new StardewValley.Object((int)Enums.SDVObject.Diamond,1), new StardewValley.Object((int)Enums.SDVObject.IronBar,1), }); + */ //ModCore.log("Tin sells for: " + tin.sellToStorePrice()); //ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7)); From 0d760f5cfe2c0df790d2b6815e2167c3117b6336 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 31 Aug 2019 18:23:47 -0700 Subject: [PATCH 21/98] Got farmhand inventory to be reconstructed even when farmhand is offline. --- .../Framework/Objects/ObjectManager.cs | 101 +++++++++++++- .../Objects/Resources/OreVeins/OreVeinTile.cs | 2 + .../Utilities/Serialization/Serialization.cs | 34 +++++ GeneralMods/Revitalize/ModCore.cs | 127 ++++++++++-------- 4 files changed, 208 insertions(+), 56 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index f3e8afcd..b4672647 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -87,6 +87,8 @@ namespace Revitalize.Framework.Objects this.resources = new ResourceManager(); this.ItemsByName = new Dictionary(); + + ChairMultiTiledObject s = new ChairMultiTiledObject(); } /// @@ -268,7 +270,104 @@ namespace Revitalize.Framework.Objects { } - + + /// + /// Scans all mod items to try to find a match. + /// + /// + /// + /// + public Item getItemByIDAndType(string ID,Type T) + { + + foreach(var v in this.chairs) + { + if(v.Value.GetType()==T && v.Value.info.id == ID) + { + Item I= v.Value.getOne(); + return I; + } + } + + foreach(var v in this.furnitureStorage) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + + foreach(var v in this.generic) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + + foreach(var v in this.ItemsByName) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + foreach(var v in this.lamps) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + foreach(var v in this.miscellaneous) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + foreach(var v in this.rugs) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + foreach(var v in this.tables) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + + foreach(var v in this.resources.ores) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + + } + foreach(var v in this.resources.oreVeins) + { + if (v.Value.GetType() == T && v.Value.info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } + + return null; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs index b4f37016..d3d716e8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Utilities; @@ -40,6 +41,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins } + [JsonIgnore] public override string ItemInfo { get diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index faa54ebf..b4341ed1 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using PyTK.CustomElementHandler; using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Utilities.Serialization.ContractResolvers; @@ -305,6 +306,39 @@ namespace Revitalize.Framework.Utilities return I; } + public Item DeserializeFromFarmhandInventory(string JsonName) + { + //ModCore.log("Found a custom object in a chest!"); + string jsonString = JsonName; + //ModCore.log(JsonName); + string dataSplit = jsonString.Split(new string[] { "<" }, StringSplitOptions.None)[2]; + string backUpGUID = dataSplit.Split('|')[0]; + string[] guidArr = jsonString.Split(new string[] { "|" }, StringSplitOptions.None); + + string infoStr = jsonString.Split(new string[] { "<" }, StringSplitOptions.None)[0]; + string guidStr= jsonString.Split(new string[] { "<" }, StringSplitOptions.None)[1]; + + CustomObjectData pyTkData = ModCore.Serializer.DeserializeFromJSONString(dataSplit); + Type t = Type.GetType(pyTkData.type); + string id = pyTkData.id; + //Need Item info + + string guidName = backUpGUID; + string infoSplit = infoStr.Split('|')[3]; + infoSplit = infoSplit.Substring(3); + BasicItemInformation info = ModCore.Serializer.DeserializeFromJSONString(infoSplit); + + CustomObject clone = (CustomObject)ModCore.ObjectManager.getItemByIDAndType(id, t); + if (clone != null) + { + clone.info = info; + ModCore.log("Guid is????:"+guidStr); + clone.guid = Guid.Parse(guidStr); + return clone; + } + return null; + } + public void returnToTitle() { //this.gatherAllFilesForCleanup(); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 13dee0c8..34045f16 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -24,17 +24,18 @@ using Revitalize.Framework.Minigame.SeasideScrambleMinigame; using Revitalize.Framework.Objects.Items.Resources; using Revitalize.Framework.Hacks; using Revitalize.Framework.Configs; +using StardewValley.Locations; +using System.Linq; namespace Revitalize { //Bugs: // -Chair tops cut off objects - // -load content MUST be enabled for the table to be placed?????? WTF + // -load content MUST be enabled for the table to be placed?????? // TODO: /* Add in crafting menu. * Add in crafting table. - * Find way to hack vanilla furnace for more recipes. * * // -Make this mod able to load content packs for easier future modding @@ -85,15 +86,17 @@ namespace Revitalize // -Auto Preserves // -Auto Keg // -Auto Cask - // -Calcinator (oil+stone) + // -Calcinator (oil+stone: produces titanum?) // -Materials - // -Tin/Bronze/Alluminum/Silver?Platinum/Etc + // -Tin/Bronze/Alluminum/Silver?Platinum/Etc (all but platinum: may add in at a later date) -titanium -Alloys! - -Brass - -Electrum + -Brass (done) + -Electrum (done) + -Steel (done) + -Bronze (done) -Mythrill - -Steel + -Star Metal -Star Steel -Cobalt @@ -189,7 +192,7 @@ namespace Revitalize Accessories (recover hp/stamina,max hp,more friendship ,run faster, take less damage, etc) - -NEckalces + -Neckalces -Broaches -Earings -Pendants @@ -261,33 +264,79 @@ namespace Revitalize ModHelper.Events.GameLoop.DayEnding += this.GameLoop_DayEnding; ModHelper.Events.GameLoop.Saving += this.GameLoop_Saving; - //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); - /* - foreach(var v in Game1.objectInformation) - { - string name = v.Value.Split('/')[0]; - ModCore.log(name + "="+v.Key+","+Environment.NewLine,false); - } - */ + ModHelper.Events.Display.MenuChanged += this.Display_MenuChanged; } + private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e) + { + if (e.NewMenu != null) + { + ModCore.log(e.NewMenu.GetType()); + + if (e.NewMenu.GetType() == typeof(StardewValley.Menus.ItemGrabMenu)) + { + if (Game1.player.currentLocation is Cabin) + { + ModCore.log("Let's get processing!"); + List> addition = new List>(); + for (int i = 0; i < (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory.Count; i++) + { + Item I = (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[i]; + if (I is Chest && I.Name != "Chest") + { + ModCore.log("Found a custom object!"); + Item cObj= ModCore.Serializer.DeserializeFromFarmhandInventory(I.Name); + if (cObj == null) + { + ModCore.log("NULL OBJ"); + } + else + { + ModCore.log("Not null!"); + } + if (cObj == null) continue; + addition.Add(new KeyValuePair(i,cObj)); + } + } + + /* + for(int I=0; I< (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory.Count; I++) + { + if((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[I] == null) + { + if (addition.Count > 0) { + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[I] = addition[0].Value; + addition.RemoveAt(0); + } + } + } + */ + + foreach(KeyValuePair pair in addition) + { + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[pair.Key] = pair.Value; + } + + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu = new InventoryMenu((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.xPositionOnScreen, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.yPositionOnScreen, true, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.highlightMethod, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.capacity, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.rows, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.horizontalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.verticalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.drawSlots); + (Game1.activeClickableMenu as ItemGrabMenu).populateClickableComponentList(); + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.populateClickableComponentList(); + } + } + } + } + private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e) { - /* - foreach(var v in CustomObjects) - { - v.Value.updateInfo(); - } - */ + + } private void GameLoop_DayEnding(object sender, StardewModdingAPI.Events.DayEndingEventArgs e) { - //MultiplayerUtilities.RequestALLGuidObjects(); } /// @@ -437,13 +486,6 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { this.loadContent(); - - /* - if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient) - { - throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!"); - } - */ Serializer.afterLoad(); ShopHacks.AddOreToClintsShop(); ObjectInteractionHacks.AfterLoad_RestoreTrackedMachines(); @@ -463,32 +505,7 @@ namespace Revitalize axe =(StardewValley.Tools.Axe)Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"),typeof(StardewValley.Tools.Axe)); //Game1.player.addItemToInventory(axe); */ - //Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne()); - - //Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19)); - //Ore tin = ObjectManager.resources.getOre("Tin", 19); - //Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1)); - //Game1.player.addItemToInventory(new StardewValley.Object(388, 100)); - /* - Game1.player.addItemsByMenuIfNecessary(new List() - { - new StardewValley.Object(Vector2.Zero, (int)Enums.SDVBigCraftable.Furnace), - new StardewValley.Object((int)Enums.SDVObject.Coal,10), - new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,5), - new StardewValley.Object((int)Enums.SDVObject.Emerald,1), - new StardewValley.Object((int)Enums.SDVObject.Aquamarine,1), - new StardewValley.Object((int)Enums.SDVObject.Ruby,1), - new StardewValley.Object((int)Enums.SDVObject.Amethyst,1), - new StardewValley.Object((int)Enums.SDVObject.Topaz,1), - new StardewValley.Object((int)Enums.SDVObject.Jade,1), - new StardewValley.Object((int)Enums.SDVObject.Diamond,1), - new StardewValley.Object((int)Enums.SDVObject.IronBar,1), - }); - */ - //ModCore.log("Tin sells for: " + tin.sellToStorePrice()); - - //ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7)); } /* From 70edc9acf0fa0a7dfec78d99d57f093cd067e2e8 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 31 Aug 2019 18:27:08 -0700 Subject: [PATCH 22/98] Moved farmhand inventory recreation to MenuHacks.cs --- .../Revitalize/Framework/Hacks/MenuHacks.cs | 45 +++++++++++++- GeneralMods/Revitalize/ModCore.cs | 60 +------------------ 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs index dc00e61c..d31b4676 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; using Revitalize.Framework.Objects; using StardewValley; using StardewValley.BellsAndWhistles; +using StardewValley.Locations; using StardewValley.Menus; +using StardewValley.Objects; namespace Revitalize.Framework.Hacks { @@ -140,8 +142,49 @@ namespace Revitalize.Framework.Hacks { EndOfDay_HasProcessedModdedItems = false; } - + /// + /// Recreates the farmhand's inventory even when they are offline. + /// + /// + /// + public static void RecreateFarmhandInventory(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e) + { + if (e.NewMenu != null) + { + ModCore.log(e.NewMenu.GetType()); + + if (e.NewMenu.GetType() == typeof(StardewValley.Menus.ItemGrabMenu)) + { + if (Game1.player.currentLocation is Cabin) + { + //ModCore.log("Let's get processing!"); + List> addition = new List>(); + for (int i = 0; i < (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory.Count; i++) + { + Item I = (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[i]; + if (I is Chest && I.Name != "Chest") + { + //ModCore.log("Found a custom object!"); + Item cObj = ModCore.Serializer.DeserializeFromFarmhandInventory(I.Name); + if (cObj == null) continue; + addition.Add(new KeyValuePair(i, cObj)); + } + } + + foreach (KeyValuePair pair in addition) + { + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[pair.Key] = pair.Value; + } + + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu = new InventoryMenu((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.xPositionOnScreen, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.yPositionOnScreen, true, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.highlightMethod, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.capacity, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.rows, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.horizontalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.verticalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.drawSlots); + (Game1.activeClickableMenu as ItemGrabMenu).populateClickableComponentList(); + (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.populateClickableComponentList(); + } + } + } + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 34045f16..f5666cb0 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -267,68 +267,10 @@ namespace Revitalize //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); - ModHelper.Events.Display.MenuChanged += this.Display_MenuChanged; + ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory; } - private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e) - { - if (e.NewMenu != null) - { - ModCore.log(e.NewMenu.GetType()); - - if (e.NewMenu.GetType() == typeof(StardewValley.Menus.ItemGrabMenu)) - { - if (Game1.player.currentLocation is Cabin) - { - ModCore.log("Let's get processing!"); - List> addition = new List>(); - for (int i = 0; i < (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory.Count; i++) - { - Item I = (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[i]; - if (I is Chest && I.Name != "Chest") - { - ModCore.log("Found a custom object!"); - Item cObj= ModCore.Serializer.DeserializeFromFarmhandInventory(I.Name); - if (cObj == null) - { - ModCore.log("NULL OBJ"); - } - else - { - ModCore.log("Not null!"); - } - if (cObj == null) continue; - addition.Add(new KeyValuePair(i,cObj)); - } - } - - /* - for(int I=0; I< (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory.Count; I++) - { - if((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[I] == null) - { - if (addition.Count > 0) { - (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[I] = addition[0].Value; - addition.RemoveAt(0); - } - } - } - */ - - foreach(KeyValuePair pair in addition) - { - (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[pair.Key] = pair.Value; - } - - (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu = new InventoryMenu((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.xPositionOnScreen, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.yPositionOnScreen, true, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.highlightMethod, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.capacity, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.rows, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.horizontalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.verticalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.drawSlots); - (Game1.activeClickableMenu as ItemGrabMenu).populateClickableComponentList(); - (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.populateClickableComponentList(); - } - } - } - } - private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e) { From bd03736e65ed20a91bcabe878abb2f40cf3284cb Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 2 Sep 2019 19:02:58 -0700 Subject: [PATCH 23/98] Started work on crafting menu. Still need to display all required items, a description, and a craft button. --- .../Content/Graphics/Menus/Misc/MenuTab.png | Bin 0 -> 255 bytes .../Graphics/Menus/Misc/MenuTabHorizontal.png | Bin 0 -> 248 bytes .../Crafting/MachineCraftingRecipe.cs | 12 + .../Revitalize/Framework/Crafting/Recipe.cs | 4 +- .../Framework/Crafting/VanillaRecipe.cs | 2 +- .../Menus/CraftingInformationPage.cs | 96 +++++++ .../Framework/Menus/CraftingMenuV1.cs | 257 ++++++++++++++++++ ...{InventoryMenu.cs => InventoryMenuPage.cs} | 3 + .../Framework/Menus/InventoryTransferMenu.cs | 3 + .../MenuComponents/CraftingRecipeButton.cs | 67 +++++ .../Framework/Objects/Machines/Machine.cs | 12 + .../Framework/Utilities/ObjectUtilities.cs | 16 ++ GeneralMods/Revitalize/ModCore.cs | 20 ++ GeneralMods/Revitalize/Revitalize.csproj | 14 +- .../StardustCore/Animations/AnimatedSprite.cs | 17 ++ .../ComponentsV2/Buttons/AnimatedButton.cs | 2 +- .../ComponentsV2/Buttons/ItemDisplayButton.cs | 36 ++- .../Vocalization/Vocalization/Vocalization.cs | 2 +- 18 files changed, 556 insertions(+), 7 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTab.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTabHorizontal.png create mode 100644 GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs create mode 100644 GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs create mode 100644 GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs rename GeneralMods/Revitalize/Framework/Menus/{InventoryMenu.cs => InventoryMenuPage.cs} (98%) create mode 100644 GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTab.png b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTab.png new file mode 100644 index 0000000000000000000000000000000000000000..9d68580b6a4baba0422dacc336909b85f07578f7 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|c6z!vhIn+o zow`t{$w9=Gzpr;;)B;AS!NZvmu!5(O_Y|MSqC*Rg?ybCUSsq^* z^`e>~qRRcQbQ5pV%eia;-`RHSHmu*Y{Y&3&UzRe)hWZ%(GsYfT;RoKT1C=r(P@$5?pRX)hjrg^7?FaM$M%~LZ?`qWbQ?^_hv_)^9$ z%YIL+&J8WE1uQ^RuQ-AI`A0VM)ZJ26X|asL^NoxG4y+6YdV;~z)z4*}Q$iB}k85Ad literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTabHorizontal.png b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTabHorizontal.png new file mode 100644 index 0000000000000000000000000000000000000000..6c67d130cdbe2b17a9a663005abea793d08c7ccd GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|HhH=@hIn)) z_guS{lmG-19{xM?;feP9dNwU)G0Au5c|gE_-=}~4!TZi00D=W;y=4!tk4sBPSkxD| zgOOV&;?R`*#XJ7IO4W*FNM0bFH)n#UD0hau%L$o?4GO#CqFj4&4$r?=*_y>@wBSfW zio<6GsjUfDnil39yllN*V&1(UVf;1|3RSZ89ZJ6T-G@yGywqltzk?6 literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs b/GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs new file mode 100644 index 00000000..a584ecbe --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Crafting +{ + public class MachineCraftingRecipe + { + } +} diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index d5c87ef6..6a04e150 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -174,7 +174,7 @@ namespace Revitalize.Framework.Crafting /// The inventory to put outputs into. /// Should this item be dropped to the ground when crafted? /// Checks to see if the invventory is the player's - private void craft(ref IList from, ref IList to, bool dropToGround = false, bool isPlayerInventory = false) + public void craft(ref IList from, ref IList to, bool dropToGround = false, bool isPlayerInventory = false) { InventoryManager manager = new InventoryManager(to); if (manager.ItemCount + this.outputs.Count >= manager.capacity) @@ -207,7 +207,7 @@ namespace Revitalize.Framework.Crafting return this.PlayerContainsAllIngredients() && this.statCost.canSafelyAffordCost(); } - public bool CanCraft(List items) + public bool CanCraft(IList items) { return this.InventoryContainsAllIngredient(items); } diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs index 85b893db..033a017a 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs @@ -9,7 +9,7 @@ using StardewValley; namespace Revitalize.Framework.Crafting { /// - /// A vanilla recipe to be used with staandard stardew valley machines such as the furnace. + /// A vanilla recipe to be used with standard stardew valley machines such as the furnace. /// public class VanillaRecipe { diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs new file mode 100644 index 00000000..25f94d80 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -0,0 +1,96 @@ +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 Revitalize.Framework.Menus.MenuComponents; +using Revitalize.Framework.Objects; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Menus +{ + public class CraftingInformationPage:IClickableMenuExtended + { + + public CraftingRecipeButton infoButton; + public Color backgroundColor; + + public Vector2 itemDisplayLocation; + + public IList inventory; + + public Item actualItem + { + get + { + return this.infoButton.displayItem.item; + } + } + + public CraftingInformationPage():base() + { + + } + + public CraftingInformationPage(int x, int y, int width, int height,Color BackgroundColor,CraftingRecipeButton ItemToDisplay,ref IList Inventory) : base(x, y, width, height, false) + { + this.backgroundColor = BackgroundColor; + this.infoButton = ItemToDisplay; + this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128)); + this.inventory = Inventory; + } + + public override void draw(SpriteBatch b) + { + this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + this.infoButton.draw(b,this.itemDisplayLocation); + + b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName, this.itemDisplayLocation + this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); + + this.drawMouse(b); + } + + public bool doesMenuContainPoint(int x, int y) + { + Rectangle r = new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height); + return r.Contains(x, y); + } + + public bool canCraftRecipe() + { + return this.infoButton.recipe.CanCraft(this.inventory); + } + + public Color getNameColor() + { + if (this.canCraftRecipe()) return Color.Black; + else return Color.Red; + } + + private Vector2 getHeightOffsetFromItem() + { + if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.actualItem.GetType())){ + return new Vector2(0, 64f); + } + if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), this.actualItem.GetType())) + { + return new Vector2(0, 64f*(this.actualItem as MultiTiledObject).Height); + } + + return new Vector2(0, 64f); + } + + private Vector2 getItemNameOffset() + { + Vector2 length = Game1.dialogueFont.MeasureString(this.actualItem.DisplayName); + length.X = length.X / 4; + length.Y = 0; + return length; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs new file mode 100644 index 00000000..6ee24e09 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -0,0 +1,257 @@ +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 Revitalize.Framework.Menus.MenuComponents; +using StardewValley; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus +{ + public class CraftingMenuV1 : IClickableMenuExtended + { + + /// + /// All the different pages for crafting. + /// + public Dictionary CraftingTabs; + + public Dictionary> craftingItemsToDisplay; + public IList fromInventory; + public IList toInventory; + + public int currentPageIndex; + public string currentTab; + public int currentScrollIndex; + + public Color backgroundColor; + + public int xOffset = 72; + + public string hoverText; + + /// + /// How many crafting recipes to display at a time. + /// + public int amountOfRecipesToShow = 4; + + public bool playerInventory; + + public CraftingInformationPage craftingInfo; + + public CraftingMenuV1() : base() + { + + } + + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, IList Inventory) : base(X, Y, Width, Height, false) + { + this.backgroundColor = BackgroundColor; + this.CraftingTabs = new Dictionary(); + this.craftingItemsToDisplay = new Dictionary>(); + this.currentPageIndex = 0; + this.fromInventory = Inventory; + this.toInventory = Inventory; + this.playerInventory = true; + } + + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList Inventory) : base(X, Y, Width, Height, false) + { + this.backgroundColor = BackgroundColor; + this.CraftingTabs = new Dictionary(); + this.craftingItemsToDisplay = new Dictionary>(); + this.currentPageIndex = 0; + this.fromInventory = Inventory; + this.toInventory = Inventory; + } + + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList FromInventory, ref IList ToInventory) : base(X, Y, Width, Height, false) + { + this.backgroundColor = BackgroundColor; + this.CraftingTabs = new Dictionary(); + this.craftingItemsToDisplay = new Dictionary>(); + this.currentPageIndex = 0; + this.fromInventory = FromInventory; + this.toInventory = ToInventory; + } + + public void addInCraftingPageTab(string name, AnimatedButton Button) + { + int count = this.CraftingTabs.Count; + + if (this.CraftingTabs.ContainsKey(name)) + { + return; + } + else + { + Vector2 newPos = new Vector2(100 + (48) * (count + 1), 100 + (24 * 4) * (count + 1)); + Button.Position = newPos; + this.CraftingTabs.Add(name, Button); + this.craftingItemsToDisplay.Add(name, new List()); + } + + } + + public void addInCraftingRecipe(CraftingRecipeButton Button, string WhichTab) + { + if (this.craftingItemsToDisplay.ContainsKey(WhichTab)) + { + int count = this.craftingItemsToDisplay.Count; + Vector2 newPos = new Vector2(100 + (64) * (count + 1), 100 + (16 * 4) * (count + 1)); + Button.displayItem.Position = newPos; + this.craftingItemsToDisplay[WhichTab].Add(Button); + } + else + { + throw new Exception("Tab: " + WhichTab + " doesn't exist!"); + } + } + + public override void receiveScrollWheelAction(int direction) + { + + } + + public override void performHoverAction(int x, int y) + { + + bool hovered = false; + foreach (KeyValuePair pair in this.CraftingTabs) + { + if (pair.Value.containsPoint(x, y)) + { + this.hoverText = pair.Key; + hovered = true; + } + } + + //get range of buttons to show + + if (string.IsNullOrEmpty(this.currentTab) == false) + { + List buttonsToDraw = this.getRecipeButtonsToDisplay(); + foreach (CraftingRecipeButton button in buttonsToDraw) + { + if (button.containsPoint(x, y)) + { + this.hoverText = button.recipe.outputName; + hovered = true; + } + } + } + + + if (hovered == false) + { + this.hoverText = ""; + } + + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + foreach (KeyValuePair pair in this.CraftingTabs) + { + if (pair.Value.containsPoint(x, y)) + { + this.currentTab = pair.Key; + return; + } + } + + //get range of buttons to show + + if (string.IsNullOrEmpty(this.currentTab) == false) + { + List buttonsToDraw = this.getRecipeButtonsToDisplay(); + foreach (CraftingRecipeButton button in buttonsToDraw) + { + if (button.containsPoint(x, y)) + { + //button.craftItem(this.fromInventory, this.toInventory); + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, 400, this.backgroundColor, button,ref this.fromInventory); + Game1.soundBank.PlayCue("coin"); + if (this.playerInventory) + { + Game1.player.Items = this.toInventory; + return; + } + + } + } + } + + if (this.craftingInfo != null) + { + if (this.craftingInfo.doesMenuContainPoint(x, y)) return; + } + this.craftingInfo = null; + } + + + public override void draw(SpriteBatch b) + { + this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + + foreach (KeyValuePair pair in this.CraftingTabs) + { + pair.Value.draw(b); + } + + if (string.IsNullOrEmpty(this.currentTab)) + { + if (string.IsNullOrEmpty(this.hoverText) == false) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + this.drawMouse(b); + return; + } + + List buttonsToDraw = this.getRecipeButtonsToDisplay(); + + foreach (CraftingRecipeButton button in buttonsToDraw) + { + if (button.recipe.CanCraft(this.fromInventory)) + { + button.draw(b); + } + else + { + button.draw(b, .25f); + } + + b.DrawString(Game1.smallFont, button.displayItem.item.DisplayName, button.displayItem.Position + new Vector2(64, 0), Color.Brown); + } + + if (this.craftingInfo != null) + { + this.craftingInfo.draw(b); + } + + if (string.IsNullOrEmpty(this.hoverText) == false) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + + this.drawMouse(b); + } + + public override void update(GameTime time) + { + base.update(time); + } + + public List getRecipeButtonsToDisplay() + { + List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentScrollIndex, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow)); + return buttonsToDraw; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs similarity index 98% rename from GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs rename to GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs index 405fef98..0214a6d8 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs @@ -15,6 +15,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// Deals with displaying the internal contents of an inventory. Used mainly as a component for another menu that extends this functionality. + /// public class InventoryMenuPage { diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs index 8367489f..a3edbeda 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -13,6 +13,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// Used with transfering items between two inventories. + /// public class InventoryTransferMenu : IClickableMenuExtended { public InventoryMenu playerInventory; diff --git a/GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs b/GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs new file mode 100644 index 00000000..c7e8b161 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs @@ -0,0 +1,67 @@ +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 Revitalize.Framework.Crafting; +using StardewValley; +using StardustCore.Animations; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus.MenuComponents +{ + public class CraftingRecipeButton + { + public Recipe recipe; + public ItemDisplayButton displayItem; + + + public CraftingRecipeButton(Recipe RecipeToCraft, StardustCore.Animations.AnimatedSprite Background,Vector2 Position,Rectangle BoundingBox,float Scale, bool DrawStackNumber, Color DrawColor) + { + this.recipe = RecipeToCraft; + this.displayItem = new ItemDisplayButton(this.recipe.DisplayItem, Background, Position, BoundingBox, Scale, DrawStackNumber, DrawColor); + } + + + /// + /// Draws the component to the screen. + /// + /// + public void draw(SpriteBatch B) + { + this.displayItem.draw(B, 0.25f, 1f, false); + } + + public void draw(SpriteBatch B,Vector2 Position) + { + this.displayItem.draw(B,Position,0.25f, 1f, false); + } + + /// + /// Draw the display item with the given alpha + /// + /// + /// + public void draw(SpriteBatch B,float Alpha=1f) + { + this.displayItem.draw(B, 0.25f, Alpha, false); + } + + public bool containsPoint(int x, int y) + { + return this.displayItem.Contains(x, y); + } + + public void craftItem() + { + this.recipe.craft(); + } + + public void craftItem(IList fromInventory, IList toInventory) + { + this.recipe.craft(ref fromInventory, ref toInventory, false, false); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs new file mode 100644 index 00000000..02c5cf55 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects.Machines +{ + public class Machine + { + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs index 82b2e99d..5ef2f1d7 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs @@ -28,5 +28,21 @@ namespace Revitalize.Framework.Utilities else return false; } + public static bool IsSameOrSubclass(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant.IsSubclassOf(potentialBase) + || potentialDescendant == potentialBase; + } + + public static bool IsSameType(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant == potentialBase; + } + + public static bool IsSubclass(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant.IsSubclassOf(potentialBase); + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index f5666cb0..137c38f0 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -26,6 +26,8 @@ using Revitalize.Framework.Hacks; using Revitalize.Framework.Configs; using StardewValley.Locations; using System.Linq; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; +using Revitalize.Framework.Menus; namespace Revitalize { @@ -294,6 +296,8 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest, "Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Resources", "Ore")); TextureManager.AddTextureManager(Manifest, "Items.Resources.Ore"); TextureManager.GetTextureManager(Manifest, "Items.Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Ore")); + TextureManager.AddTextureManager(Manifest, "Menus"); + TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc")); } private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) @@ -316,6 +320,22 @@ namespace Revitalize Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, newItems, 36); } */ + + if (e.Button == SButton.U) + { + + CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 600, Color.White, Game1.player.Items); + menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 } + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Coal, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + menu.currentTab = "Default"; + + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; + } } private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index f610310d..ca418ef2 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -56,6 +56,7 @@ + @@ -76,8 +77,11 @@ - + + + + @@ -134,6 +138,7 @@ + @@ -243,6 +248,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -383,6 +394,7 @@ + diff --git a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs index b8406802..33920309 100644 --- a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs +++ b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs @@ -72,6 +72,23 @@ namespace StardustCore.Animations this.draw(b, 1f, 0f,Alpha); } + /// + /// Draws the sprite to the screen. + /// + /// + /// + /// + /// + public virtual void draw(SpriteBatch b,Vector2 Position,float Scale ,float Alpha = 1f) + { + this.draw(b, Position, Scale,0f,Alpha); + } + + public virtual void draw(SpriteBatch b,float Scale ,float Alpha = 1f) + { + this.draw(b, Scale, 0f, Alpha); + } + /// /// Draws the sprite to the screen. /// diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs index 70fe129a..a86159c7 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs @@ -95,7 +95,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// public void draw(SpriteBatch b,float Alpha=1f) { - this.sprite.draw(b,Alpha); + this.sprite.draw(b,this.scale,Alpha); } /// diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs index 87d38efd..32fd685c 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs @@ -111,6 +111,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons this.draw(b, 1f, Alpha, false); } + /// /// The full draw function for drawing this component to the screen. /// @@ -120,10 +121,43 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) { - this.background.draw(b, this.scale, Depth,Alpha); + if(this.background!=null)this.background.draw(b, this.scale, Depth,Alpha); if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow); } + /// + /// Draws the component at the given position. + /// + /// + /// + /// + /// + /// + public void draw(SpriteBatch b,Vector2 Position ,float Depth, float Alpha, bool DrawShadow) + { + if (this.background != null) this.background.draw(b,Position,this.scale, Depth, Alpha); + if (this.item != null) this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + } + + public void draw(SpriteBatch b,float ItemScale ,float Depth, float Alpha, bool DrawShadow) + { + this.background.draw(b, this.scale, Depth, Alpha); + if (this.item != null) this.item.drawInMenu(b, this.position, ItemScale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + } + + /// + /// Draws just the item to the screen. + /// + /// + /// The scale for the item. + /// The spritebatch depth to draw the item. + /// The alpha for the item. + /// Should the shadow be drawn for the item? + public void drawJustItem(SpriteBatch b,float Scale,float Depth, float Alpha, bool DrawShadow) + { + if (this.item != null) this.item.drawInMenu(b, this.position, Scale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + } + public bool receiveLeftClick(int x, int y) { return this.boundingBox.Contains(new Point(x, y)); diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index ce8d2ec0..581e85b2 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -264,7 +264,7 @@ namespace Vocalization { if (e.Button.ToString() == config.menuHotkey) { - Game1.activeClickableMenu = new VocalizationMenu(100, 64, 600, 300, true); + if(Game1.activeClickableMenu==null) Game1.activeClickableMenu = new VocalizationMenu(100, 64, 600, 300, true); } } From 5f48f540790050910499387990c0e89438425511 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 2 Sep 2019 20:13:57 -0700 Subject: [PATCH 24/98] Added in description and required items. Needs a craft button now to complete the craft information page. Menu still needs scroll. --- .../Menus/CraftingInformationPage.cs | 52 +++++++++++++++++++ .../Framework/Menus/CraftingMenuV1.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 5 +- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 25f94d80..518ab9e4 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -10,9 +10,14 @@ using Revitalize.Framework.Objects; using Revitalize.Framework.Utilities; using StardewValley; using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// Need to display description, required items, and a craft button. Also need to make the menu longer. + /// Also need to make the crafting menu scroll better. + /// public class CraftingInformationPage:IClickableMenuExtended { @@ -23,6 +28,8 @@ namespace Revitalize.Framework.Menus public IList inventory; + private Dictionary requiredItems; + public Item actualItem { get @@ -42,6 +49,13 @@ namespace Revitalize.Framework.Menus this.infoButton = ItemToDisplay; this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128)); this.inventory = Inventory; + + this.requiredItems = new Dictionary(); + for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) + { + ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).Key, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); + this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).Value); + } } public override void draw(SpriteBatch b) @@ -51,6 +65,14 @@ namespace Revitalize.Framework.Menus b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName, this.itemDisplayLocation + this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); + b.DrawString(Game1.smallFont, Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width),new Vector2(this.xPositionOnScreen+64,this.getItemDescriptionOffset().Y), Color.Black); + + foreach(KeyValuePair button in this.requiredItems) + { + button.Key.draw(b); + b.DrawString(Game1.smallFont, button.Key.item.DisplayName+ " x "+button.Value.ToString(), button.Key.Position + new Vector2(64, 16), this.getNameColor(button.Key.item, button.Value)); + } + this.drawMouse(b); } @@ -71,6 +93,20 @@ namespace Revitalize.Framework.Menus else return Color.Red; } + public Color getNameColor(Item I, int amount) + { + KeyValuePair Pair = new KeyValuePair(I, amount); + if (this.infoButton.recipe.InventoryContainsIngredient(this.inventory, Pair)) + { + return Color.Black; + } + else + { + return Color.Red; + } + + } + private Vector2 getHeightOffsetFromItem() { if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.actualItem.GetType())){ @@ -92,5 +128,21 @@ namespace Revitalize.Framework.Menus return length; } + private Vector2 getItemDescriptionOffset() + { + return this.getHeightOffsetFromItem()+new Vector2(0,64)+new Vector2(0,this.itemDisplayLocation.Y); + } + + /// + /// Gets the height position for where to draw a required ingredient. + /// + /// + private Vector2 getIngredientHeightOffset() + { + string parsedDescription = Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width); + Vector2 offset=Game1.smallFont.MeasureString(parsedDescription); + return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count)); + } + } } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 6ee24e09..0ce44829 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -174,7 +174,7 @@ namespace Revitalize.Framework.Menus if (button.containsPoint(x, y)) { //button.craftItem(this.fromInventory, this.toInventory); - this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, 400, this.backgroundColor, button,ref this.fromInventory); + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button,ref this.fromInventory); Game1.soundBank.PlayCue("coin"); if (this.playerInventory) { @@ -197,7 +197,7 @@ namespace Revitalize.Framework.Menus public override void draw(SpriteBatch b) { this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); - + //this.drawDialogueBoxBackground(); foreach (KeyValuePair pair in this.CraftingTabs) { pair.Value.draw(b); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 137c38f0..6934253b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -324,13 +324,14 @@ namespace Revitalize if (e.Button == SButton.U) { - CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 600, Color.White, Game1.player.Items); + CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 0, 400, 800, Color.White, Game1.player.Items); menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here - {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 } + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + {new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,1),3 }, }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Coal, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); menu.currentTab = "Default"; From 85592f1b533318b16405c4efad825d5dcda4d859 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 2 Sep 2019 20:48:29 -0700 Subject: [PATCH 25/98] The crafting menu works but needs some polish. --- .../Menus/CraftingMenu/CraftButton.png | Bin 0 -> 621 bytes .../Menus/CraftingInformationPage.cs | 34 +++++++++++++++++- .../Framework/Menus/CraftingMenuV1.cs | 1 + GeneralMods/Revitalize/ModCore.cs | 7 ++-- GeneralMods/Revitalize/Revitalize.csproj | 4 ++- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/CraftButton.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/CraftButton.png b/GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/CraftButton.png new file mode 100644 index 0000000000000000000000000000000000000000..07d192ec194a2afd28667b47a3cec919490ca121 GIT binary patch literal 621 zcmV-z0+RiSP)Px%CrLy>R7i={mOp3{aTLctC#m36ClMX5$&iqt1OtW)t^o-dLY6LZ5enj*!LdWS zI21(a5|=DTh7bZ>ixdN`hhWJK?VUI@hg_x9si0yVF2Cb<|IArZC0_{K@ArG}{l4#g z-{qdd6l=NcB@2Y^*iZmc;F52s$K>+=msC=W4*{~5-Lau4LGtb)Xve=8U99>XAKv;v zBYoqak_|%Usaa`P0eQ2~T<7qU!|05{dr1I<`r*s>pLB-jUQmES_8ygT25V588~Gq!JbeV&8{?NX<40LpN+1t$n~%NmfiGy|KOP?F(Fof>-`a(b`1-A4&178+ND-!A(j) zE&||dmAG@+KT!fv4iJ`FYZtwQf~b@;-g8h9*+**^Lkh{~)}ZEVX@STDMAhUAH@0_u z6_Ozm`kNLB7Gc&p4xxA8?#&dHa)!>(l`oF;EJ6Z1dq;`H5T;Bai0Gytj zQ7?mP<^Urqb zvf^8d^Wc8)T-Zd}&x#Rc6C5QJSj=Hgv(j|OhT^5ZsN?i+f{_-zVuB4t00000NkvXX Hu0mjfswN*w literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 518ab9e4..154cdc2f 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -15,7 +15,7 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { /// - /// Need to display description, required items, and a craft button. Also need to make the menu longer. + /// Need to display a craft button. /// Also need to make the crafting menu scroll better. /// public class CraftingInformationPage:IClickableMenuExtended @@ -30,6 +30,8 @@ namespace Revitalize.Framework.Menus private Dictionary requiredItems; + public AnimatedButton craftingButton; + public Item actualItem { get @@ -56,6 +58,19 @@ namespace Revitalize.Framework.Menus ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).Key, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).Value); } + this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f); + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + if (this.craftingButton.containsPoint(x, y)) + { + if (this.canCraftRecipe()) + { + Game1.soundBank.PlayCue("coin"); + this.infoButton.craftItem(); + } + } } public override void draw(SpriteBatch b) @@ -73,6 +88,8 @@ namespace Revitalize.Framework.Menus b.DrawString(Game1.smallFont, button.Key.item.DisplayName+ " x "+button.Value.ToString(), button.Key.Position + new Vector2(64, 16), this.getNameColor(button.Key.item, button.Value)); } + this.craftingButton.draw(b, this.getCraftableColor().A); + this.drawMouse(b); } @@ -87,6 +104,16 @@ namespace Revitalize.Framework.Menus return this.infoButton.recipe.CanCraft(this.inventory); } + /// + /// Gets the color for the crafting button. + /// + /// + private Color getCraftableColor() + { + if (this.canCraftRecipe()) return Color.White; + else return new Color(1f, 1f, 1f, 0.25f); + } + public Color getNameColor() { if (this.canCraftRecipe()) return Color.Black; @@ -144,5 +171,10 @@ namespace Revitalize.Framework.Menus return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count)); } + private float getCraftingButtonHeight() + { + return this.yPositionOnScreen + this.height - 64*2; + } + } } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 0ce44829..c217d23a 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -188,6 +188,7 @@ namespace Revitalize.Framework.Menus if (this.craftingInfo != null) { + this.craftingInfo.receiveLeftClick(x, y); if (this.craftingInfo.doesMenuContainPoint(x, y)) return; } this.craftingInfo = null; diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 6934253b..025dc24f 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -298,6 +298,8 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest, "Items.Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Ore")); TextureManager.AddTextureManager(Manifest, "Menus"); TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc")); + TextureManager.AddTextureManager(Manifest, "CraftingMenu"); + TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu")); } private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) @@ -331,8 +333,7 @@ namespace Revitalize { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - {new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,1),3 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Coal, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); menu.currentTab = "Default"; if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; @@ -468,7 +469,7 @@ namespace Revitalize axe =(StardewValley.Tools.Axe)Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"),typeof(StardewValley.Tools.Axe)); //Game1.player.addItemToInventory(axe); */ - + Game1.player.addItemToInventory(new StardewValley.Object((int)Enums.SDVObject.Coal, 1)); } /* diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index ca418ef2..167dd137 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -230,6 +230,9 @@ PreserveNewest + + PreserveNewest + Always @@ -394,7 +397,6 @@ - From dd4b4a0ee3c3ece312f26f309862d1ac9673bf87 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 3 Sep 2019 13:49:21 -0700 Subject: [PATCH 26/98] Added left and right buttons to the crafting menu. Also centered item name text. --- .../Menus/CraftingInformationPage.cs | 14 ++- .../Framework/Menus/CraftingMenuV1.cs | 95 +++++++++++++++++-- GeneralMods/Revitalize/ModCore.cs | 4 +- 3 files changed, 103 insertions(+), 10 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 154cdc2f..1d482ba2 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -32,6 +32,8 @@ namespace Revitalize.Framework.Menus public AnimatedButton craftingButton; + public bool isPlayerInventory; + public Item actualItem { get @@ -45,12 +47,13 @@ namespace Revitalize.Framework.Menus } - public CraftingInformationPage(int x, int y, int width, int height,Color BackgroundColor,CraftingRecipeButton ItemToDisplay,ref IList Inventory) : base(x, y, width, height, false) + public CraftingInformationPage(int x, int y, int width, int height,Color BackgroundColor,CraftingRecipeButton ItemToDisplay,ref IList Inventory,bool IsPlayerInventory) : base(x, y, width, height, false) { this.backgroundColor = BackgroundColor; this.infoButton = ItemToDisplay; this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128)); this.inventory = Inventory; + this.isPlayerInventory = IsPlayerInventory; this.requiredItems = new Dictionary(); for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) @@ -69,6 +72,11 @@ namespace Revitalize.Framework.Menus { Game1.soundBank.PlayCue("coin"); this.infoButton.craftItem(); + + if (this.isPlayerInventory) + { + this.inventory = Game1.player.Items; + } } } } @@ -78,7 +86,7 @@ namespace Revitalize.Framework.Menus this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); this.infoButton.draw(b,this.itemDisplayLocation); - b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName, this.itemDisplayLocation + this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); + b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName,new Vector2(this.xPositionOnScreen+ (this.width/2),this.itemDisplayLocation.Y)+ this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); b.DrawString(Game1.smallFont, Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width),new Vector2(this.xPositionOnScreen+64,this.getItemDescriptionOffset().Y), Color.Black); @@ -150,7 +158,7 @@ namespace Revitalize.Framework.Menus private Vector2 getItemNameOffset() { Vector2 length = Game1.dialogueFont.MeasureString(this.actualItem.DisplayName); - length.X = length.X / 4; + length.X = length.X / 2; length.Y = 0; return length; } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index c217d23a..9c36f563 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -26,7 +26,6 @@ namespace Revitalize.Framework.Menus public int currentPageIndex; public string currentTab; - public int currentScrollIndex; public Color backgroundColor; @@ -37,17 +36,39 @@ namespace Revitalize.Framework.Menus /// /// How many crafting recipes to display at a time. /// - public int amountOfRecipesToShow = 4; + public int amountOfRecipesToShow = 6; public bool playerInventory; public CraftingInformationPage craftingInfo; + public AnimatedButton leftButton; + public AnimatedButton rightButton; + + + private int maxPages + { + get + { + if (string.IsNullOrEmpty(this.currentTab)) return 0; + return (this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow) + 1; + } + } + public CraftingMenuV1() : base() { } + /// + /// Constructor to be used when the inventory is the player's + /// + /// + /// + /// + /// + /// + /// public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, IList Inventory) : base(X, Y, Width, Height, false) { this.backgroundColor = BackgroundColor; @@ -57,8 +78,18 @@ namespace Revitalize.Framework.Menus this.fromInventory = Inventory; this.toInventory = Inventory; this.playerInventory = true; + this.initializeButtons(); } + /// + /// Constructor to be used when inventory destination is the same and not the player. + /// + /// + /// + /// + /// + /// + /// public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList Inventory) : base(X, Y, Width, Height, false) { this.backgroundColor = BackgroundColor; @@ -67,8 +98,19 @@ namespace Revitalize.Framework.Menus this.currentPageIndex = 0; this.fromInventory = Inventory; this.toInventory = Inventory; + this.initializeButtons(); } + /// + /// Inventory constructor to be used when the input and output inventories are different. + /// + /// + /// + /// + /// + /// + /// + /// public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList FromInventory, ref IList ToInventory) : base(X, Y, Width, Height, false) { this.backgroundColor = BackgroundColor; @@ -77,6 +119,23 @@ namespace Revitalize.Framework.Menus this.currentPageIndex = 0; this.fromInventory = FromInventory; this.toInventory = ToInventory; + this.initializeButtons(); + } + + public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) + { + base.gameWindowSizeChanged(oldBounds, newBounds); + if (this.craftingInfo != null) + { + this.craftingInfo.gameWindowSizeChanged(oldBounds, newBounds); + + } + } + + private void initializeButtons() + { + this.leftButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Left Button", new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White),new Rectangle(0,0,32,32),2f); + this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen+this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); } public void addInCraftingPageTab(string name, AnimatedButton Button) @@ -89,7 +148,7 @@ namespace Revitalize.Framework.Menus } else { - Vector2 newPos = new Vector2(100 + (48) * (count + 1), 100 + (24 * 4) * (count + 1)); + Vector2 newPos = new Vector2(100 + (48) * (count + 1), this.yPositionOnScreen + (24 * 4) * (count + 1)); Button.Position = newPos; this.CraftingTabs.Add(name, Button); this.craftingItemsToDisplay.Add(name, new List()); @@ -102,7 +161,7 @@ namespace Revitalize.Framework.Menus if (this.craftingItemsToDisplay.ContainsKey(WhichTab)) { int count = this.craftingItemsToDisplay.Count; - Vector2 newPos = new Vector2(100 + (64) * (count + 1), 100 + (16 * 4) * (count + 1)); + Vector2 newPos = new Vector2(this.xPositionOnScreen + (64) * (count + 1), this.yPositionOnScreen + (16 * 4) * (count + 1)); Button.displayItem.Position = newPos; this.craftingItemsToDisplay[WhichTab].Add(Button); } @@ -155,11 +214,28 @@ namespace Revitalize.Framework.Menus public override void receiveLeftClick(int x, int y, bool playSound = true) { + if (this.leftButton.containsPoint(x, y)) + { + if (this.currentPageIndex <= 0) this.currentPageIndex = 0; + else + { + this.currentPageIndex--; + } + } + if (this.rightButton.containsPoint(x, y)) + { + if (this.currentPageIndex+1 < this.maxPages) + { + this.currentPageIndex++; + } + } + foreach (KeyValuePair pair in this.CraftingTabs) { if (pair.Value.containsPoint(x, y)) { this.currentTab = pair.Key; + this.currentPageIndex = 0; return; } } @@ -174,7 +250,7 @@ namespace Revitalize.Framework.Menus if (button.containsPoint(x, y)) { //button.craftItem(this.fromInventory, this.toInventory); - this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button,ref this.fromInventory); + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button,ref this.fromInventory,this.playerInventory); Game1.soundBank.PlayCue("coin"); if (this.playerInventory) { @@ -198,6 +274,13 @@ namespace Revitalize.Framework.Menus public override void draw(SpriteBatch b) { this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + + this.leftButton.draw(b); + //Draw page numbers here. + //b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/) + b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + this.maxPages).ToString(), new Vector2(this.xPositionOnScreen+128, this.yPositionOnScreen), Color.White); + this.rightButton.draw(b); + //this.drawDialogueBoxBackground(); foreach (KeyValuePair pair in this.CraftingTabs) { @@ -250,7 +333,7 @@ namespace Revitalize.Framework.Menus public List getRecipeButtonsToDisplay() { - List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentScrollIndex, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow)); + List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex* this.amountOfRecipesToShow, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow)); return buttonsToDraw; } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 025dc24f..6d04ebbd 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -199,6 +199,8 @@ namespace Revitalize -Earings -Pendants + + make chat notification when people are sleeping */ public class ModCore : Mod @@ -326,7 +328,7 @@ namespace Revitalize if (e.Button == SButton.U) { - CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 0, 400, 800, Color.White, Game1.player.Items); + CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items); menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() From cbf2efc690f41fa7c2378c41b3609a67ebae35dd Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 3 Sep 2019 14:22:00 -0700 Subject: [PATCH 27/98] Fixed paging issue for crafting menu not going to the right page. --- .../Framework/Menus/CraftingMenuV1.cs | 40 ++++++++-------- GeneralMods/Revitalize/ModCore.cs | 47 +++++++++++++++++++ 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 9c36f563..e312a96b 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -36,7 +36,7 @@ namespace Revitalize.Framework.Menus /// /// How many crafting recipes to display at a time. /// - public int amountOfRecipesToShow = 6; + public int amountOfRecipesToShow = 9; public bool playerInventory; @@ -51,7 +51,7 @@ namespace Revitalize.Framework.Menus get { if (string.IsNullOrEmpty(this.currentTab)) return 0; - return (this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow) + 1; + return (int)(Math.Ceiling((double)(this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow))); } } @@ -134,8 +134,8 @@ namespace Revitalize.Framework.Menus private void initializeButtons() { - this.leftButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Left Button", new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White),new Rectangle(0,0,32,32),2f); - this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen+this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); + this.leftButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Left Button", new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); + this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen + this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); } public void addInCraftingPageTab(string name, AnimatedButton Button) @@ -160,8 +160,8 @@ namespace Revitalize.Framework.Menus { if (this.craftingItemsToDisplay.ContainsKey(WhichTab)) { - int count = this.craftingItemsToDisplay.Count; - Vector2 newPos = new Vector2(this.xPositionOnScreen + (64) * (count + 1), this.yPositionOnScreen + (16 * 4) * (count + 1)); + int count = this.craftingItemsToDisplay[WhichTab].Count % this.amountOfRecipesToShow; + Vector2 newPos = new Vector2(this.xPositionOnScreen + (128), (this.yPositionOnScreen + 64) + (64 * (count + 1))); Button.displayItem.Position = newPos; this.craftingItemsToDisplay[WhichTab].Add(Button); } @@ -171,14 +171,8 @@ namespace Revitalize.Framework.Menus } } - public override void receiveScrollWheelAction(int direction) - { - - } - public override void performHoverAction(int x, int y) { - bool hovered = false; foreach (KeyValuePair pair in this.CraftingTabs) { @@ -203,13 +197,10 @@ namespace Revitalize.Framework.Menus } } } - - if (hovered == false) { this.hoverText = ""; } - } public override void receiveLeftClick(int x, int y, bool playSound = true) @@ -220,13 +211,15 @@ namespace Revitalize.Framework.Menus else { this.currentPageIndex--; + Game1.playSound("shwip"); } } if (this.rightButton.containsPoint(x, y)) { - if (this.currentPageIndex+1 < this.maxPages) + if (this.currentPageIndex < this.maxPages) { this.currentPageIndex++; + Game1.playSound("shwip"); } } @@ -250,7 +243,13 @@ namespace Revitalize.Framework.Menus if (button.containsPoint(x, y)) { //button.craftItem(this.fromInventory, this.toInventory); - this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button,ref this.fromInventory,this.playerInventory); + + if (this.playerInventory) + { + this.fromInventory = Game1.player.Items; + } + + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width + this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button, ref this.fromInventory, this.playerInventory); Game1.soundBank.PlayCue("coin"); if (this.playerInventory) { @@ -278,7 +277,7 @@ namespace Revitalize.Framework.Menus this.leftButton.draw(b); //Draw page numbers here. //b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/) - b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + this.maxPages).ToString(), new Vector2(this.xPositionOnScreen+128, this.yPositionOnScreen), Color.White); + b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages+1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen), Color.White); this.rightButton.draw(b); //this.drawDialogueBoxBackground(); @@ -333,7 +332,10 @@ namespace Revitalize.Framework.Menus public List getRecipeButtonsToDisplay() { - List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex* this.amountOfRecipesToShow, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow)); + + int amount = this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow; + int min = this.currentPageIndex == amount ? this.craftingItemsToDisplay[this.currentTab].Count % this.amountOfRecipesToShow : this.amountOfRecipesToShow; + List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex * this.amountOfRecipesToShow, min); return buttonsToDraw; } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 6d04ebbd..5c0b67b4 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -336,6 +336,53 @@ namespace Revitalize //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + + menu.currentTab = "Default"; if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; From 010e705b6a2a9dddafb4456ae60993942fdc4aeb Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 3 Sep 2019 15:12:34 -0700 Subject: [PATCH 28/98] Got crafting recipes page to sort itself. --- .../Framework/Menus/CraftingMenuV1.cs | 20 ++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 27 ++++++++++--------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index e312a96b..5b466029 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -17,6 +17,9 @@ namespace Revitalize.Framework.Menus /// /// All the different pages for crafting. + /// + /// Sort recipes by recipe name. + /// Add in search box /// public Dictionary CraftingTabs; @@ -138,6 +141,23 @@ namespace Revitalize.Framework.Menus this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen + this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); } + public void sortRecipes() + { + foreach(KeyValuePair> pair in this.craftingItemsToDisplay) + { + List copy = pair.Value.ToList(); + pair.Value.Clear(); + + copy=copy.OrderBy(x => x.displayItem.item.DisplayName).ToList(); + foreach(CraftingRecipeButton b in copy) + { + this.addInCraftingRecipe(b, pair.Key); + } + } + + + } + public void addInCraftingPageTab(string name, AnimatedButton Button) { int count = this.CraftingTabs.Count; diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 5c0b67b4..3587ebd7 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -335,7 +335,12 @@ namespace Revitalize { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Wool, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here @@ -345,45 +350,41 @@ namespace Revitalize { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.OakResin, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.ChocolateCake, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.QualitySprinkler, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.JackOLantern, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.WildPlum, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Egg, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); - menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() - { - //Inputs here - {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.BakedFish, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.currentTab = "Default"; + menu.sortRecipes(); if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; } From 733461ecde268a338aebaf5264262cbdddc99a30 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 3 Sep 2019 15:48:38 -0700 Subject: [PATCH 29/98] Added in a search box which hides elements that don't match the search pattern for recipes. --- .../Framework/Menus/CraftingMenuV1.cs | 194 ++++++++++++++++-- 1 file changed, 174 insertions(+), 20 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 5b466029..996e3b1c 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -5,35 +5,61 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; using Revitalize.Framework.Menus.MenuComponents; using StardewValley; +using StardewValley.Menus; using StardustCore.UIUtilities; using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// A simple menu for displaying craftable objects. + /// public class CraftingMenuV1 : IClickableMenuExtended { /// /// All the different pages for crafting. - /// - /// Sort recipes by recipe name. - /// Add in search box /// public Dictionary CraftingTabs; + /// + /// All of the actual buttons to display for crafting. + /// public Dictionary> craftingItemsToDisplay; + /// + /// The inventory to tke items from. + /// public IList fromInventory; + /// + /// The inventory to put items into. + /// public IList toInventory; + /// + /// The current page index for the current tab. + /// public int currentPageIndex; + /// + /// The name of the current tab. + /// public string currentTab; + /// + /// The background color for the menu. + /// public Color backgroundColor; + /// + /// The x offset for the menu so that tabs can be interacted with properly. + /// public int xOffset = 72; + /// + /// Teh hover text to display. + /// public string hoverText; /// @@ -41,20 +67,47 @@ namespace Revitalize.Framework.Menus /// public int amountOfRecipesToShow = 9; + /// + /// Is this menu the player's? + /// public bool playerInventory; + /// + /// The crafting info menu that displays when a recipe is clicked. + /// public CraftingInformationPage craftingInfo; + /// + /// The previous page button. + /// public AnimatedButton leftButton; + /// + /// The next page button. + /// public AnimatedButton rightButton; + /// + /// The search box used for looking for specific items. + /// + public StardewValley.Menus.TextBox searchBox; - + /// + /// The maximum amount of pages to display. + /// private int maxPages { get { if (string.IsNullOrEmpty(this.currentTab)) return 0; - return (int)(Math.Ceiling((double)(this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow))); + List searchSelection; + if (string.IsNullOrEmpty(this.searchBox.Text) == false) + { + searchSelection = this.craftingItemsToDisplay[this.currentTab].FindAll(i => i.displayItem.item.DisplayName.ToLowerInvariant().Contains(this.searchBox.Text.ToLowerInvariant())); + } + else + { + searchSelection = this.craftingItemsToDisplay[this.currentTab]; + } + return (int)(Math.Ceiling((double)(searchSelection.Count / this.amountOfRecipesToShow))); } } @@ -125,6 +178,11 @@ namespace Revitalize.Framework.Menus this.initializeButtons(); } + /// + /// Fix the display of menu elements when the menu is resized. + /// + /// + /// public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) { base.gameWindowSizeChanged(oldBounds, newBounds); @@ -135,29 +193,61 @@ namespace Revitalize.Framework.Menus } } + /// + /// Initialize the buttons for the menu. + /// private void initializeButtons() { this.leftButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Left Button", new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen + this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); - } + this.searchBox = new TextBox((Texture2D)null, (Texture2D)null, Game1.dialogueFont, Game1.textColor); + this.searchBox.X = this.xPositionOnScreen + this.width + 96; + this.searchBox.Y = this.yPositionOnScreen; + this.searchBox.Width = 256; + this.searchBox.Height = 192; + Game1.keyboardDispatcher.Subscriber = (IKeyboardSubscriber)this.searchBox; + this.searchBox.Selected = false; + } + /// + /// What happens when the menu receives a key press. + /// + /// + public override void receiveKeyPress(Keys key) + { + if (this.searchBox.Selected && key != Keys.Escape) + { + return; + } + else + { + base.receiveKeyPress(key); + } + } + /// + /// Sorts all of the recipes for the menu. + /// public void sortRecipes() { - foreach(KeyValuePair> pair in this.craftingItemsToDisplay) + foreach (KeyValuePair> pair in this.craftingItemsToDisplay) { List copy = pair.Value.ToList(); pair.Value.Clear(); - copy=copy.OrderBy(x => x.displayItem.item.DisplayName).ToList(); - foreach(CraftingRecipeButton b in copy) + copy = copy.OrderBy(x => x.displayItem.item.DisplayName).ToList(); + foreach (CraftingRecipeButton b in copy) { this.addInCraftingRecipe(b, pair.Key); } } - - - } + + } + /// + /// Adds in a new tab for the crafting recipe menu. + /// + /// + /// public void addInCraftingPageTab(string name, AnimatedButton Button) { int count = this.CraftingTabs.Count; @@ -176,6 +266,11 @@ namespace Revitalize.Framework.Menus } + /// + /// Adds in a crafting recipe to the crafting menu. + /// + /// + /// public void addInCraftingRecipe(CraftingRecipeButton Button, string WhichTab) { if (this.craftingItemsToDisplay.ContainsKey(WhichTab)) @@ -191,6 +286,11 @@ namespace Revitalize.Framework.Menus } } + /// + /// What happens when you hover over a menu element. + /// + /// + /// public override void performHoverAction(int x, int y) { bool hovered = false; @@ -223,6 +323,12 @@ namespace Revitalize.Framework.Menus } } + /// + /// What happens when the meu receives a left click. + /// + /// + /// + /// public override void receiveLeftClick(int x, int y, bool playSound = true) { if (this.leftButton.containsPoint(x, y)) @@ -243,6 +349,17 @@ namespace Revitalize.Framework.Menus } } + Rectangle r = new Rectangle(this.searchBox.X, this.searchBox.Y, this.searchBox.Width, this.searchBox.Height / 2); + if (r.Contains(x, y)) + { + this.searchBox.Update(); + this.searchBox.SelectMe(); + } + else + { + this.searchBox.Selected = false; + } + foreach (KeyValuePair pair in this.CraftingTabs) { if (pair.Value.containsPoint(x, y)) @@ -290,16 +407,24 @@ namespace Revitalize.Framework.Menus } + /// + /// Draws the menu to the screen. + /// + /// public override void draw(SpriteBatch b) { this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + if (this.currentPageIndex > this.maxPages) this.currentPageIndex = 0; + this.leftButton.draw(b); //Draw page numbers here. //b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/) - b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages+1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen), Color.White); + b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages + 1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen), Color.White); this.rightButton.draw(b); + this.searchBox.Draw(b, true); + //this.drawDialogueBoxBackground(); foreach (KeyValuePair pair in this.CraftingTabs) { @@ -345,18 +470,47 @@ namespace Revitalize.Framework.Menus this.drawMouse(b); } - public override void update(GameTime time) + /// + /// Gets all of the crafting buttons to display. + /// + /// + private List getRecipeButtonsToDisplay() { - base.update(time); + List searchSelection; + if (string.IsNullOrEmpty(this.searchBox.Text) == false) + { + searchSelection = this.craftingItemsToDisplay[this.currentTab].FindAll(i => i.displayItem.item.DisplayName.ToLowerInvariant().Contains(this.searchBox.Text.ToLowerInvariant())); + } + else + { + searchSelection = this.craftingItemsToDisplay[this.currentTab]; + } + searchSelection = this.searchSort(searchSelection); + + int amount = searchSelection.Count / this.amountOfRecipesToShow; + int min = this.currentPageIndex == amount ? searchSelection.Count % this.amountOfRecipesToShow : this.amountOfRecipesToShow; + List buttonsToDraw = searchSelection.GetRange(this.currentPageIndex * this.amountOfRecipesToShow, min); + return buttonsToDraw; } - public List getRecipeButtonsToDisplay() + /// + /// Repositions crafting buttons based on the current sort context. + /// + /// + /// + private List searchSort(List Unsorted) { + List copy = Unsorted.ToList(); + //copy = copy.OrderBy(x => x.displayItem.item.DisplayName).ToList(); //Sort the recipes again. Probably unnecessary. - int amount = this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow; - int min = this.currentPageIndex == amount ? this.craftingItemsToDisplay[this.currentTab].Count % this.amountOfRecipesToShow : this.amountOfRecipesToShow; - List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex * this.amountOfRecipesToShow, min); - return buttonsToDraw; + //Do sorting; + + for (int i = 0; i < Unsorted.Count; i++) + { + int count = i % this.amountOfRecipesToShow; + copy[i].displayItem.Position = new Vector2(this.xPositionOnScreen + (128), (this.yPositionOnScreen + 64) + (64 * (count + 1))); + } + return copy; } } From cf3029306bcaff2ade90d8cf35ce8fa68f197626 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 4 Sep 2019 14:20:05 -0700 Subject: [PATCH 30/98] Added in crafting books for workbenches and other crafting tables, added in unlockable crafting recipes, and made the menu show up when innteracting with new crafting tables. --- .../Graphics/Objects/Crafting/Anvil.png | Bin 0 -> 917 bytes .../Graphics/Objects/Crafting/Workbench.png | Bin 0 -> 558 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 240 ++++++++++++++++ .../Crafting/CraftingRecipeComponent.cs | 26 ++ .../Revitalize/Framework/Crafting/Recipe.cs | 42 +-- .../Crafting/UnlockableCraftingRecipe.cs | 33 +++ .../Menus/CraftingInformationPage.cs | 8 +- .../CraftingTables/CraftingTableTile.cs | 266 ++++++++++++++++++ .../Framework/Objects/MultiTiledObject.cs | 10 +- .../Framework/Utilities/PlayerUtilities.cs | 21 ++ GeneralMods/Revitalize/ModCore.cs | 46 ++- GeneralMods/Revitalize/Revitalize.csproj | 11 + 12 files changed, 659 insertions(+), 44 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Crafting/Anvil.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Crafting/Workbench.png create mode 100644 GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs create mode 100644 GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeComponent.cs create mode 100644 GeneralMods/Revitalize/Framework/Crafting/UnlockableCraftingRecipe.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs create mode 100644 GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Crafting/Anvil.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Crafting/Anvil.png new file mode 100644 index 0000000000000000000000000000000000000000..627032c11d4a7ca2394f8354f492cb4012d36e7b GIT binary patch literal 917 zcmV;G18V$Px&Pf0{UR9J=Wl|gS4R}_W6gcK!2nWWBG4)Uat6QENG83#}@X)zrY)XD{RStLq- zKvRizx3KOK3D~nJ3#76^?2t>Tuu&x}%aIaLomjC&Exopxai9_s8WzqQ#$#t}6E>A{ zHrC8s-*fJ{_r3@F*vCHh0K+gG!!Vq^&C4W@;J^A0OR9F z8gksZb0d&r*N>*T=$t=)ifB{=ApQFT&d$y9;>EuJ96tOp4PNT0uAA+{O%cbHw8bG))C?f1&QC zUr4Vco}XWKRCO3#pFr0qnnVor_49n=Swr=sEA=WrGe$T)X7TcV27r7%*HmdDF~x-o zUt*ez4QqQq5+6IJp(uw?ltb9|D}=B}CTFPCYycExnE$q4QvIh&sa#>8ub(&CD5ad> zgx*6~>*wH>MJXpZcvPcW{fkIstU*MrW|K_LU|Ans+1MytbsczTQ!q5`6U;BZVxX^| za5zjT6k;%CaO5wbyMdn^cGj@|vOb;C z`eJeOg9#AALWr#FT)zBWM=cC= z0GfwU!aHnUVqKqLb+zP*xONT4akhW({`cwA^i9BlfEkeL{niU%Q7mpY#e3sqD`WwF z0UjYY0v(Vo@K#$aZnjKVEN))+KC9{o{;S=O>1lI0P=IaMuPx$=t)FDR9J=WmOo1)K^Vq=(G?+tARJf(0xND2EG#6=iB~B29TH0oeum?&5Q~Uk z!4NGy!Pd@0K}DNjDJfQ52&^CmBpd-D5{q>vn?I9HE|XZ?J03k%U`$5>=yf{SvQ zr`IU}@})uuz!2hdW_eJ3o*%~p*9e^q$$Gw22pJ;qZSjqJcXGf4>fBZ;0EE{z&S@`o34c1!Jwjj^aZ^lLf_EgoKkL`!T1p?0zUMC|-Dtf`05b7pO8l?y zoG;`{g(Dq;U3k-4JNyl}G5<5aM*si-07*qoM6N<$g2l1($N&HU literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs new file mode 100644 index 00000000..16caf6d4 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -0,0 +1,240 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Revitalize.Framework.Menus; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardustCore.Animations; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Crafting +{ + public class CraftingRecipeBook + { + /// + /// Organizes crafting recipes by group. So a workbench would have a workbench crafting book, and anvil has different recipes, etc. + /// + public static Dictionary CraftingRecipesByGroup; + + + /// + /// All of the crafting recipes contained by this crafting list. + /// + public Dictionary craftingRecipes; + + + /// + /// All of the crafting tabs to be used for the menu. + /// + public Dictionary craftingMenuTabs; + + /// + /// Which group of crafting recipes this book belongs to. + /// + public string craftingGroup; + + public string defaultTab; + + public CraftingRecipeBook() + { + + } + + public CraftingRecipeBook(string CraftingGroup) + { + this.craftingGroup = CraftingGroup; + this.craftingRecipes = new Dictionary(); + this.craftingMenuTabs = new Dictionary(); + } + + /// + /// Adds in a new crafting recipe. + /// + /// + /// + public void addCraftingRecipe(string Name, UnlockableCraftingRecipe Recipe) + { + if (this.craftingRecipes.ContainsKey(Name) == false) + { + this.craftingRecipes.Add(Name, Recipe); + } + else + { + throw new Exception("This crafting book already contains a recipe with the same id!"); + } + } + + /// + /// Adds in a crafting recipe. + /// + /// + /// + /// Is this recipe already unlocked? + public void addCraftingRecipe(string Name, Recipe Recipe, bool Unlocked) + { + UnlockableCraftingRecipe recipe = new UnlockableCraftingRecipe(this.craftingGroup, Recipe, Unlocked); + this.addCraftingRecipe(Name, recipe); + } + + public void addInCraftingTab(string TabName, AnimatedButton TabSprite, bool IsDefaultTab) + { + if (this.craftingMenuTabs.ContainsKey(TabName)) + { + throw new Exception("A tab with the same name already exists!"); + } + else + { + this.craftingMenuTabs.Add(TabName, TabSprite); + } + if (IsDefaultTab) + { + this.defaultTab = TabName; + } + } + + /// + /// Gets the crafting recipe by it's name. + /// + /// + /// + public UnlockableCraftingRecipe getCraftingRecipe(string Name) + { + if (this.craftingRecipes.ContainsKey(Name)) + { + return this.craftingRecipes[Name]; + } + else return null; + } + + /// + /// Checks to see if a crafting recipe has been unlocked. + /// + /// + /// + public bool hasUnlockedCraftingRecipe(string Name) + { + UnlockableCraftingRecipe recipe = this.getCraftingRecipe(Name); + if (recipe == null) return false; + else return recipe.hasUnlocked; + } + + /// + /// Unlocks the crating recipe so that it can be shown in the menu. + /// + /// + public void unlockRecipe(string Name) + { + UnlockableCraftingRecipe recipe = this.getCraftingRecipe(Name); + if (recipe == null) return; + else recipe.unlock(); + } + + /// + /// Opens up a crafting menu from this crafting book. + /// + public void openCraftingMenu() + { + CraftingMenuV1 menu = new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items); + //menu.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + + foreach (KeyValuePair pair in this.craftingMenuTabs) + { + menu.addInCraftingPageTab(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in this.craftingRecipes) + { + if (pair.Value.hasUnlocked) + { + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab); + ModCore.log("Add in a crafting recipe to the menu!"); + } + else + { + ModCore.log("Recipe is locked!"); + } + } + menu.currentTab = this.defaultTab; + menu.sortRecipes(); + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; + } + + #region + //~~~~~~~~~~~~~~~~~~~~// + // Static Functions // + //~~~~~~~~~~~~~~~~~~~~// + + + public static void BeforeSave_SaveRecipeBooks(object o, StardewModdingAPI.Events.SavingEventArgs e) + { + if (!Directory.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"))) Directory.CreateDirectory(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData")); + string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData")); + string playerData = Path.Combine(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"), PlayerUtilities.GetUniqueCharacterString()); + string objectPath = Path.Combine(playerData, "RecipeInformation"); + Directory.CreateDirectory(objectPath); + string[] objectFiles = Directory.GetFiles(objectPath); + + foreach (KeyValuePair book in CraftingRecipeBook.CraftingRecipesByGroup) + { + string recipePath = Path.Combine(objectPath, book.Key + ".json"); + ModCore.Serializer.Serialize(recipePath, book.Value); + } + } + + public static void AfterLoad_LoadRecipeBooks(object o, StardewModdingAPI.Events.SaveLoadedEventArgs e) + { + if (!Directory.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"))) Directory.CreateDirectory(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData")); + string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData")); + string playerData = Path.Combine(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"), PlayerUtilities.GetUniqueCharacterString()); + string objectPath = Path.Combine(playerData, "RecipeInformation"); + Directory.CreateDirectory(objectPath); + string[] objectFiles = Directory.GetFiles(objectPath); + foreach (string file in objectFiles) + { + CraftingRecipeBook book = ModCore.Serializer.Deserialize(file); + string fileName = Path.GetFileNameWithoutExtension(file); + CraftingRecipeBook.CraftingRecipesByGroup.Add(fileName, book); + } + + InitializeRecipeBooks(); + } + + private static void InitializeRecipeBooks() + { + + CraftingRecipeBook WorkbenchRecipes = new CraftingRecipeBook("Workbench"); + WorkbenchRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f),true); + WorkbenchRecipes.addCraftingRecipe("Nothing", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + //Inputs here + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,1),1), + }, new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), true)); + + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) + { + foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) + { + if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) + { + + } + else + { + CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. + } + } + } + else + { + CraftingRecipesByGroup.Add("Workbench", WorkbenchRecipes); + } + } + + #endregion + } +} diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeComponent.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeComponent.cs new file mode 100644 index 00000000..6414034e --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeComponent.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using StardewValley; + +namespace Revitalize.Framework.Crafting +{ + public class CraftingRecipeComponent + { + public Item item; + public int requiredAmount; + + public CraftingRecipeComponent() + { + + } + + public CraftingRecipeComponent(Item I, int RequiredAmount) + { + this.item = I; + this.requiredAmount = RequiredAmount; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index 6a04e150..00999d22 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -13,11 +13,11 @@ namespace Revitalize.Framework.Crafting /// /// The ingredients necessary to craft this recipe. /// - public Dictionary ingredients; + public List ingredients; /// /// The items produced by this recipe. /// - public Dictionary outputs; + public List outputs; /// /// The item that is displayed for the crafting recipe. @@ -26,7 +26,7 @@ namespace Revitalize.Framework.Crafting public Item DisplayItem { - get => this.displayItem ?? this.outputs.ElementAt(0).Key; + get => this.displayItem ?? this.outputs.ElementAt(0).item; set => this.displayItem = value; } @@ -49,20 +49,20 @@ namespace Revitalize.Framework.Crafting /// Constructor for single item output. /// All the ingredients required to make the output. /// The item given as output with how many - public Recipe(Dictionary inputs, KeyValuePair output, StatCost StatCost = null) + public Recipe(List inputs, CraftingRecipeComponent output, StatCost StatCost = null) { this.ingredients = inputs; - this.DisplayItem = output.Key; - this.outputDescription = output.Key.getDescription(); - this.outputName = output.Key.DisplayName; - this.outputs = new Dictionary + this.DisplayItem = output.item; + this.outputDescription = output.item.getDescription(); + this.outputName = output.item.DisplayName; + this.outputs = new List() { - [output.Key] = output.Value + output }; this.statCost = StatCost ?? new StatCost(); } - public Recipe(Dictionary inputs, Dictionary outputs, string OutputName, string OutputDescription, Item DisplayItem = null, StatCost StatCost = null) + public Recipe(List inputs, List outputs, string OutputName, string OutputDescription, Item DisplayItem = null, StatCost StatCost = null) { this.ingredients = inputs; this.outputs = outputs; @@ -79,7 +79,7 @@ namespace Revitalize.Framework.Crafting } /// Checks if a player contains a recipe ingredient. - public bool PlayerContainsIngredient(KeyValuePair pair) + public bool PlayerContainsIngredient(CraftingRecipeComponent pair) { return this.InventoryContainsIngredient(Game1.player.Items.ToList(), pair); } @@ -87,17 +87,17 @@ namespace Revitalize.Framework.Crafting /// Checks if an inventory contains all items. public bool InventoryContainsAllIngredient(IList items) { - foreach (KeyValuePair pair in this.ingredients) + foreach (CraftingRecipeComponent pair in this.ingredients) if (!this.InventoryContainsIngredient(items, pair)) return false; return true; } /// Checks if an inventory contains an ingredient. - public bool InventoryContainsIngredient(IList items, KeyValuePair pair) + public bool InventoryContainsIngredient(IList items, CraftingRecipeComponent pair) { foreach (Item i in items) { - if (i != null && this.ItemEqualsOther(i, pair.Key) && pair.Value <= i.Stack) + if (i != null && this.ItemEqualsOther(i, pair.item) && pair.requiredAmount <= i.Stack) return true; } return false; @@ -123,17 +123,17 @@ namespace Revitalize.Framework.Crafting InventoryManager manager = new InventoryManager(from); List removalList = new List(); - foreach (KeyValuePair pair in this.ingredients) + foreach (CraftingRecipeComponent pair in this.ingredients) { foreach (Item item in manager.items) { if (item == null) continue; - if (this.ItemEqualsOther(item, pair.Key)) + if (this.ItemEqualsOther(item, pair.item)) { - if (item.Stack == pair.Value) + if (item.Stack == pair.requiredAmount) removalList.Add(item); //remove the item else - item.Stack -= pair.Value; //or reduce the stack size. + item.Stack -= pair.requiredAmount; //or reduce the stack size. } } } @@ -155,10 +155,10 @@ namespace Revitalize.Framework.Crafting var manager = isPlayerInventory ? new InventoryManager(new List()) : new InventoryManager(to); - foreach (KeyValuePair pair in this.outputs) + foreach (CraftingRecipeComponent pair in this.outputs) { - Item item = pair.Key.getOne(); - item.addToStack(pair.Value - 1); + Item item = pair.item.getOne(); + item.addToStack(pair.requiredAmount - 1); bool added = manager.addItem(item); if (!added && dropToGround) Game1.createItemDebris(item, Game1.player.getStandingPosition(), Game1.player.getDirection()); diff --git a/GeneralMods/Revitalize/Framework/Crafting/UnlockableCraftingRecipe.cs b/GeneralMods/Revitalize/Framework/Crafting/UnlockableCraftingRecipe.cs new file mode 100644 index 00000000..18683b27 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Crafting/UnlockableCraftingRecipe.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Crafting +{ + public class UnlockableCraftingRecipe + { + public Recipe recipe; + public bool hasUnlocked; + public string whichTab; + + public UnlockableCraftingRecipe() + { + + } + + public UnlockableCraftingRecipe(string WhichTab, Recipe recipe, bool HasUnlocked=false) + { + this.recipe = recipe; + this.hasUnlocked = HasUnlocked; + this.whichTab = WhichTab; + } + + public void unlock() + { + this.hasUnlocked = true; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 1d482ba2..3d4608d3 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Revitalize.Framework.Crafting; using Revitalize.Framework.Menus.MenuComponents; using Revitalize.Framework.Objects; using Revitalize.Framework.Utilities; @@ -58,8 +59,8 @@ namespace Revitalize.Framework.Menus this.requiredItems = new Dictionary(); for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) { - ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).Key, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); - this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).Value); + ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); + this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount); } this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f); } @@ -130,7 +131,8 @@ namespace Revitalize.Framework.Menus public Color getNameColor(Item I, int amount) { - KeyValuePair Pair = new KeyValuePair(I, amount); + CraftingRecipeComponent Pair = new CraftingRecipeComponent(I, amount); + if (this.infoButton.recipe.InventoryContainsIngredient(this.inventory, Pair)) { return Color.Black; diff --git a/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs b/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs new file mode 100644 index 00000000..7b7a239d --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs @@ -0,0 +1,266 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Objects.CraftingTables +{ + public class CraftingTableTile: MultiTiledComponent + { + + public string craftingBookName; + + [JsonIgnore] + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + string furnitureInfo = this.craftingBookName; + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + furnitureInfo; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + string craftingBookName = data[5]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + if (string.IsNullOrEmpty(craftingBookName) == false) + { + this.craftingBookName = craftingBookName; + } + + } + } + + + + public CraftingTableTile() : base() + { + + } + + public CraftingTableTile(CustomObjectData PyTKData, BasicItemInformation Info, string CraftingTableRecipeBookName) : base(PyTKData, Info) + { + this.craftingBookName = CraftingTableRecipeBookName; + this.Price = Info.price; + } + + public CraftingTableTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation, string CraftingTableRecipeBookName) : base(PyTKData, Info, TileLocation) + { + this.craftingBookName = CraftingTableRecipeBookName; + this.Price = Info.price; + } + + + + /// + /// When the chair is right clicked ensure that all pieces associated with it are also rotated. + /// + /// + /// + public override bool rightClicked(Farmer who) + { + if (Framework.Crafting.CraftingRecipeBook.CraftingRecipesByGroup.ContainsKey(this.craftingBookName)) + { + Framework.Crafting.CraftingRecipeBook.CraftingRecipesByGroup[this.craftingBookName].openCraftingMenu(); + return true; + } + else + { + return true; + } + } + + + public override Item getOne() + { + CraftingTableTile component = new CraftingTableTile(this.data, this.info.Copy(),this.craftingBookName); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + CraftingTableTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + + /// + ///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden. + /// + public void checkForSpecialUpSittingAnimation() + { + if (this.info.facingDirection == Enums.Direction.Up && Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject) + { + string animationKey = "Sitting_" + (int)Enums.Direction.Up; + if (this.animationManager.animations.ContainsKey(animationKey)) + { + this.animationManager.setAnimation(animationKey); + } + } + } + + + /// What happens when the object is drawn at a tile location. + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + if (objectPosition.X < 0) objectPosition.X *= -1; + if (objectPosition.Y < 0) objectPosition.Y *= -1; + base.drawWhenHeld(spriteBatch, objectPosition, f); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index e4fd96d8..23234803 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -471,7 +471,7 @@ namespace Revitalize.Framework.Objects if (this.info == null) { this.ItemInfo = this.text; - ModCore.log("Updated item info for container!"); + //ModCore.log("Updated item info for container!"); return; } if (this.objects != null) @@ -531,12 +531,12 @@ namespace Revitalize.Framework.Objects } if (this.objects == null || this.childrenGuids == null) { - ModCore.log("Either objects or children guids are null"); + //ModCore.log("Either objects or children guids are null"); return; } - ModCore.log("Recreate children components"); + //ModCore.log("Recreate children components"); if (this.objects.Count < this.childrenGuids.Count) { foreach (KeyValuePair pair in this.childrenGuids) @@ -555,8 +555,8 @@ namespace Revitalize.Framework.Objects } else { - ModCore.log("Count is exactly the same!"); - ModCore.log("Count is: " + this.objects.Count+" : and " + this.childrenGuids.Count); + //ModCore.log("Count is exactly the same!"); + //ModCore.log("Count is: " + this.objects.Count+" : and " + this.childrenGuids.Count); } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs new file mode 100644 index 00000000..e71f1977 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using StardewValley; + +namespace Revitalize.Framework.Utilities +{ + public class PlayerUtilities + { + /// + /// Gets the unique id for the character. + /// + /// + public static string GetUniqueCharacterString() + { + return Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID; + } + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 3587ebd7..456f1a64 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -28,6 +28,7 @@ using StardewValley.Locations; using System.Linq; using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; using Revitalize.Framework.Menus; +using Revitalize.Framework.Objects.CraftingTables; namespace Revitalize { @@ -253,38 +254,32 @@ namespace Revitalize //Adds in event handling for the mod. ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; + ModHelper.Events.GameLoop.SaveLoaded += CraftingRecipeBook.AfterLoad_LoadRecipeBooks; + ModHelper.Events.GameLoop.Saving += CraftingRecipeBook.BeforeSave_SaveRecipeBooks; + ModHelper.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged; ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked; ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle; - ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed; + ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged; ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn; + ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed; ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction; + ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion; ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines; //ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged; //ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay; ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; - ModHelper.Events.GameLoop.DayEnding += this.GameLoop_DayEnding; - ModHelper.Events.GameLoop.Saving += this.GameLoop_Saving; //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); + CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary(); ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory; } - private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e) - { - - - } - - private void GameLoop_DayEnding(object sender, StardewModdingAPI.Events.DayEndingEventArgs e) - { - } - /// /// Loads in textures to be used by the mod. /// @@ -302,6 +297,9 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc")); TextureManager.AddTextureManager(Manifest, "CraftingMenu"); TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu")); + + TextureManager.AddTextureManager(Manifest, "Objects.Crafting"); + TextureManager.GetTextureManager(Manifest, "Objects.Crafting").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Crafting")); } private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) @@ -327,7 +325,7 @@ namespace Revitalize if (e.Button == SButton.U) { - + /* CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items); menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); @@ -387,6 +385,7 @@ namespace Revitalize menu.sortRecipes(); if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; + */ } } @@ -414,10 +413,12 @@ namespace Revitalize bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); + /* Recipe pie = new Recipe(new Dictionary() { [bigObject] = 1 }, new KeyValuePair(new Furniture(3, Vector2.Zero), 1), new StatCost(100, 50, 0, 0)); + */ ObjectManager.miscellaneous.Add("Omegasis.BigTiledTest", bigObject); @@ -464,6 +465,19 @@ namespace Revitalize ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet); //ModCore.log("Added in SSC!"); + + + MultiTiledObject WorkbenchObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(), Color.White, false, null, null)); + CraftingTableTile workbenchTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Workbench"); + WorkbenchObj.addComponent(new Vector2(0,0),workbenchTile_0_0); + WorkbenchObj.addComponent(new Vector2(1, 0), workbenchTile_1_0); + WorkbenchObj.addComponent(new Vector2(0, 1), workbenchTile_0_1); + WorkbenchObj.addComponent(new Vector2(1, 1), workbenchTile_1_1); + + ObjectManager.AddItem("Workbench", WorkbenchObj); } private void createDirectories() @@ -506,7 +520,9 @@ namespace Revitalize // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); - Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); + //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); + + Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 167dd137..b57506d7 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -56,10 +56,13 @@ + + + @@ -117,6 +120,7 @@ + @@ -155,6 +159,7 @@ + @@ -257,6 +262,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest From 4bfdef4383fa5619a5f0357389c016acf6129082 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 4 Sep 2019 14:34:34 -0700 Subject: [PATCH 31/98] Added in the anvil recipe for the workbench. --- .../Framework/Crafting/CraftingRecipeBook.cs | 36 +++++++++++++++++-- GeneralMods/Revitalize/ModCore.cs | 20 ++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index 16caf6d4..825f483e 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -209,11 +209,11 @@ namespace Revitalize.Framework.Crafting CraftingRecipeBook WorkbenchRecipes = new CraftingRecipeBook("Workbench"); WorkbenchRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f),true); - WorkbenchRecipes.addCraftingRecipe("Nothing", new UnlockableCraftingRecipe("Default", new Recipe(new List() + WorkbenchRecipes.addCraftingRecipe("Anvil", new UnlockableCraftingRecipe("Default", new Recipe(new List() { //Inputs here - new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,1),1), - }, new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), true)); + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)), true)); if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { @@ -233,6 +233,36 @@ namespace Revitalize.Framework.Crafting { CraftingRecipesByGroup.Add("Workbench", WorkbenchRecipes); } + + + CraftingRecipeBook AnvilRecipes = new CraftingRecipeBook("Anvil"); + AnvilRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); + /* + WorkbenchRecipes.addCraftingRecipe("Nothing", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + //Inputs here + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,1),1), + }, new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), true)); + */ + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) + { + foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) + { + if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) + { + + } + else + { + CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. + } + } + } + else + { + CraftingRecipesByGroup.Add("Anvil", AnvilRecipes); + } + } #endregion diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 456f1a64..fd7c662a 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -468,16 +468,27 @@ namespace Revitalize MultiTiledObject WorkbenchObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(), Color.White, false, null, null)); - CraftingTableTile workbenchTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Workbench"); - CraftingTableTile workbenchTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Workbench"); - CraftingTableTile workbenchTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Workbench"); - CraftingTableTile workbenchTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Workbench"); WorkbenchObj.addComponent(new Vector2(0,0),workbenchTile_0_0); WorkbenchObj.addComponent(new Vector2(1, 0), workbenchTile_1_0); WorkbenchObj.addComponent(new Vector2(0, 1), workbenchTile_0_1); WorkbenchObj.addComponent(new Vector2(1, 1), workbenchTile_1_1); + MultiTiledObject AnvilObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(), Color.White, false, null, null)); + CraftingTableTile anvilTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Anvil"); + CraftingTableTile anvilTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Anvil"); + CraftingTableTile anvilTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Anvil"); + CraftingTableTile anvilTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Anvil"); + AnvilObj.addComponent(new Vector2(0, 0), anvilTile_0_0); + AnvilObj.addComponent(new Vector2(1, 0), anvilTile_1_0); + AnvilObj.addComponent(new Vector2(0, 1), anvilTile_0_1); + AnvilObj.addComponent(new Vector2(1, 1), anvilTile_1_1); + ObjectManager.AddItem("Workbench", WorkbenchObj); + ObjectManager.AddItem("Anvil", AnvilObj); } private void createDirectories() @@ -536,6 +547,7 @@ namespace Revitalize //Game1.player.addItemToInventory(axe); */ Game1.player.addItemToInventory(new StardewValley.Object((int)Enums.SDVObject.Coal, 1)); + Game1.player.addItemByMenuIfNecessary(ModCore.ObjectManager.GetItem("SteelIngot", 20)); } /* From a4d8a4c1a84c28b0d2e7b5f9ce3808cf441e60ce Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Fri, 6 Sep 2019 14:15:54 -0700 Subject: [PATCH 32/98] Figured out the logic of how to have custom pickaxes! Now to make the other tools/upgrades/recipes... --- .../Items/Tools/DefaultPickaxeWorking.png | Bin 0 -> 908 bytes .../Content/Graphics/Items/Tools/Pickaxe.png | Bin 0 -> 369 bytes .../Items/Tools/TestingPickaxeWorking.png | Bin 0 -> 1027 bytes .../Framework/Hacks/ColorChanger.cs | 126 +++++++ .../Framework/Hacks/ObjectInteractionHacks.cs | 22 ++ .../Framework/Objects/CustomObject.cs | 28 -- .../Framework/Objects/Interfaces/IItemInfo.cs | 18 + .../Objects/Items/Tools/PickaxeExtended.cs | 307 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 24 +- .../Objects/Resources/OreVeins/OreVeinTile.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 19 ++ GeneralMods/Revitalize/Revitalize.csproj | 13 + 12 files changed, 530 insertions(+), 31 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultPickaxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/Pickaxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TestingPickaxeWorking.png create mode 100644 GeneralMods/Revitalize/Framework/Hacks/ColorChanger.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Interfaces/IItemInfo.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultPickaxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultPickaxeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..5969b4f6aca7262c555464c348cc4dac1174acfe GIT binary patch literal 908 zcmV;719SX|P)Px&MoC0LRA_F;?28h(d)XrNk6o+=?31p>NBUB@hbPvgy!4?9$1h zQyr=fMHCmeLQ%5BsdPz)4t+>A`=DuQZ2|@&;?hzm=a9ZM*5)qnF0l^pH$C$1?tk~c z@4mZxfq;O3fPjF2fPjF2fd7iAq%EeBwz%wmTqgN!PH+5ENn1FMBOJ%kGBKac32pHn z& zs;@$7peY9j2UwOxWv?nNm(S)zDwA#v)|#_$-E`}H63)GIK@nAzy(%fXGrrHC1e@rKQJbI9Nb~um3RQnW5UQ0(JQxDt zUZZmaUr{xbh=qL#w|8KA@*2-GL# z(|`u5@%QyE9F0be+c25HyJN%9x{c`3lU-Pc_;{q1fBLx#s_@Q|IwWFYPx$D@jB_R5*>LkTFQZKoo|*6fI6!+!_=lW-yb8LqW(`1f3k53mt1AlZzd7aT2Vf z;HVCn9HiqxHYtM84zW0ty18_cI-EmHh`pRq{I`4W{_nl_!#`!r7TS%v1n5T*0D%aV zKUvM?6^~9kj9&)44u=3TsRtr7JS%>SaXefB9A91;{V0+EuH)c0TU2a2g)L8?=#3`& z6SCU#w$kaY<4~(@b9QlFc$Om1LV6am-Ka}(b1k#r(r?TgOC}HpTe0nL{T~5|xi^}m zp?zgh49GJBbi4QX%~qOEEINu)6rp?c-ECS*H>}(b|Q8yNCI|`ci!YfZu#O?VAKb P00000NkvXXu0mjfw+@|y literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TestingPickaxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TestingPickaxeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..77740d6dd70adc39c281c25bd07c1693fa0dde5b GIT binary patch literal 1027 zcmV+e1pNDnP)Px&y-7qtRA_(y9Vq?%^NtHBu45mf!;-O%`iqMl+5yXr1 zP!KEhqzEE{2LCFd2yy3ulVGdgX zGbKN@@Bp>&fGj@%(fF9sd=+$5Q_>Y=RiM+~FLdC<-6S8@#oTh&p(hFH`aZ`DNpT0!Fl=V*(MDc7Ky&tR>vZ<0p7{dxYdX%#}AVR|cpO(TemR z83znUItlr!0N`FgfQPq7%#q(VMkt_Ff|;vVq!!R9jF zh55Q_Gwf*pLQk-XdrxOvt=od(Trq?WR7Il>zFGLna!%UUwgAARg|^>*Kbpv|!Qp7~ z{M~1umASGtc89{p_XJvg7~_ilVMQq5j`lC+VqEk8(M9bYEGj{Z|IvcGd0=c>yV(Ra z-){KezKRa^ZKFFB;?&g#wlTH>F17^Nu%(OcP>Abu4}gN}1pvIvf0vpEMi*9r*|o`B zz9cn&HkV~Kmj&8vV}u9k*<6;_FJ4HIYulqtOxKv0u1Pl`fL*;|sd*8tNJlkAM>SPH zj>&KzI($?ZBP`)vyRc|4N`@|3m*hm5qI;tt9`KtUX zHxX!T1BE4APap}^yQm6(@=2bFyGh5ptO$*~!v3lQRiVnCe3A!7%%ASD>JC)>9Hzp* z*b+e7vXxBX8;dOgsT_@P3mvE;9=N-S{0;ttecJ%IBH4t#=5Lsz&9*VN0yb9)%%rZH z + /// Taken from SDV to be able to swap tool colors + /// + public static class ColorChanger + { + + private static Texture2D mostRecentPicxaxeSwap; + + public static void SwapPickaxeTextures(Texture2D TargetTexture) + { + /* + if (mostRecentPicxaxeSwap != null) + { + if (TargetTexture == mostRecentPicxaxeSwap) return; + } + */ + int height = Game1.toolSpriteSheet.Height; + int width = Game1.toolSpriteSheet.Width; + + Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height]; + Game1.toolSpriteSheet.GetData(beforeData); + Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace + TargetTexture.GetData(afterData); //Get data from swap texture. + + ///Convert tool data to grid + Color[,] beforeGrid = new Color[height, width]; + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + // Assumes row major ordering of the array. + beforeGrid[row, column] = beforeData[row * width + column]; + } + } + //Convert target data to grid + int targetHeight = TargetTexture.Height; + int targetWidth = TargetTexture.Width; + Color[,] afterGrid = new Color[targetHeight, targetWidth]; + for (int row = 0; row < targetHeight; row++) + { + for (int column = 0; column < targetWidth; column++) + { + // Assumes row major ordering of the array. + afterGrid[row, column] = afterData[row * targetWidth + column]; + } + } + + + //Copy over data from the target texture into the before grid. + Rectangle stoneRegion = new Rectangle(0,80,80,32); + Rectangle copperRegion = new Rectangle(); + Rectangle ironRegion = new Rectangle(224, 80, 80, 32); //Create the region we want to replace. + Rectangle goldRegion = new Rectangle(); + Rectangle irridumRegon = new Rectangle(); + + List rects = new List(); + //rects.Add(ironRegion); + rects.Add(stoneRegion); + foreach (Rectangle region in rects) + { + + for (int x = region.X; x < region.X + region.Width; x++) + { + for (int y = region.Y; y < region.Y + region.Height; y++) + { + //ModCore.log("value is: " + new Vector2(x, y)); + beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order. + } + } + + + //Convert the tool grid back into a 1d color array + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + try + { + beforeData[row * width + column] = beforeGrid[row, column]; + } + catch (Exception err) + { + ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + ModCore.log("That's position: " + (row * width + column).ToString()); + } + //ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + //ModCore.log("That's position: " + (row * width + column).ToString()); + //beforeData[row * targetWidth + column] = beforeGrid[row,column]; + } + } + } + + + //beforeGrid.CopyTo(beforeData, 0); + //Reapply the texture. + Game1.toolSpriteSheet.SetData(beforeData); + + Stream stream = File.Create(Path.Combine(ModCore.ModHelper.DirectoryPath,"ToolTest.png")); + Game1.toolSpriteSheet.SaveAsPng(stream, width, height); + stream.Dispose(); + } + + public static void ResetPickaxeTexture() + { + SwapPickaxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultPickaxeWorking")); + } + + public static void ResetToolColorSwaps() + { + ResetPickaxeTexture(); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs index 440eac20..f526d86d 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs @@ -8,7 +8,9 @@ using Revitalize.Framework.Crafting; using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Utilities; +using StardewModdingAPI; using StardewValley; +using StardewValley.Tools; using SObject = StardewValley.Object; namespace Revitalize.Framework.Hacks { @@ -152,5 +154,25 @@ namespace Revitalize.Framework.Hacks || potentialDescendant == potentialBase; } + + + /// + /// Resets tool colors when left click is used for normal tools. + /// + /// + /// + public static void ResetNormalToolsColorOnLeftClick(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) + { + if (e.Button == SButton.MouseLeft) + { + if (Game1.player.CurrentTool != null) + { + if (ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(Pickaxe)) || ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(Axe)) || ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(Hoe)) || ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(WateringCan))) + { + ColorChanger.ResetToolColorSwaps(); + } + } + } + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 387e4f8e..9ffadbf1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -701,34 +701,6 @@ namespace Revitalize.Framework.Objects Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return serializedInfo; } - - /// - /// Gets all of the data necessary for syncing. - /// - /// - public override Dictionary getSyncData() - { - Dictionary syncData = new Dictionary(); - //syncData.Add("ID", this.ItemInfo); - //syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - syncData.Add("Greeting:", "Hello from: " + Game1.player.Name); - ModCore.log("Send off SYNC DATA!"); - return syncData; - } - - /// - /// Syncs all of the info to all players. - /// - /// - public override void sync(Dictionary syncData) - { - //Revitalize.ModCore.log("SYNC OBJECT DATA!"); - - //this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]); - //this.ItemInfo = syncData["ID"]; - string greeting = syncData["Greeting"]; - ModCore.log(greeting); - } #endregion } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Interfaces/IItemInfo.cs b/GeneralMods/Revitalize/Framework/Objects/Interfaces/IItemInfo.cs new file mode 100644 index 00000000..96255c7d --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Interfaces/IItemInfo.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects.Interfaces +{ + public interface IItemInfo + { + BasicItemInformation Info + { + get; + set; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs new file mode 100644 index 00000000..27e5da44 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs @@ -0,0 +1,307 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Hacks; +using Revitalize.Framework.Objects.Interfaces; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardewValley.Tools; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Objects.Items.Tools +{ + public class PickaxeExtended:StardewValley.Tools.Pickaxe, ISaveElement,IItemInfo + { + public BasicItemInformation info; + public Texture2DExtended workingTexture; + + /// + /// Used only for accessibility for casting. + /// + [JsonIgnore] + public BasicItemInformation Info + { + get + { + return this.info; + } + set + { + this.info = value; + } + } + + public Guid guid; + + public override string Name + { + + get + { + if (this.info != null) + { + return this.netName.Value.Split('>')[0]; + //return this.info.name; + } + if (this.netName == null) + { + return this.Name; + } + else + { + return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value. + } + } + + set + { + if (this.netName == null) + { + return; + } + if (this.netName.Value == null) + { + return; + } + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + { + this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back. + } + else + { + this.netName.Value = value; //Otherwise just set the net name. + } + } + } + + public override string DisplayName + { + get + { + if (this.info != null) + { + return this.info.name; + } + return this.netName.Value.Split('>')[0]; + } + + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + this.netName.Value = value + ">" + split[1]; + else + this.netName.Value = value; + } + } + + public virtual string text + { + get + { + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result. + else + return ""; //Otherwise return nothing. + } + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + { + this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name. + } + } + } + + [JsonIgnore] + public virtual string ItemInfo + { + get + { + return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid+"<"+ Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture); + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string WorkingTexture = data[2]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString(WorkingTexture); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomItems[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomItems.Add(this.guid, this); + } + + } + } + + public PickaxeExtended() + { + + } + + public PickaxeExtended(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); + } + + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public override bool beginUsing(GameLocation location, int x, int y, Farmer who) + { + this.updateInfo(); + Revitalize.Framework.Hacks.ColorChanger.SwapPickaxeTextures(this.workingTexture.texture); + return base.beginUsing(location, x, y, who); + } + public override void endUsing(GameLocation location, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + base.endUsing(location, who); + } + + public override bool onRelease(GameLocation location, int x, int y, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + return base.onRelease(location, x, y, who); + } + + 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() + { + return this.info.name; + } + + public override Item getOne() + { + return new PickaxeExtended(this.info.Copy(), this.UpgradeLevel,this.workingTexture.Copy()); + } + + public object getReplacement() + { + return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel }; + } + + public void rebuild(Dictionary additionalSaveData, object replacement) + { + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + } + + + /// + /// Updates the info on the item. + /// + public virtual void updateInfo() + { + if (this.info == null || this.workingTexture==null) + { + this.ItemInfo = this.text; + ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + /// + /// Gets an update for this item. + /// + public virtual void getUpdate() + { + this.ItemInfo = this.text; + } + + /// + /// Checks to see if this item requires a sync update. + /// + /// + public virtual bool requiresUpdate() + { + if (this.info.requiresSyncUpdate()) + { + return true; + } + else + { + return false; + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index b4672647..d2efea64 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Revitalize.Framework.Objects.Furniture; +using Revitalize.Framework.Objects.Interfaces; using StardewModdingAPI; using StardewValley; @@ -53,6 +54,8 @@ namespace Revitalize.Framework.Objects public Dictionary ItemsByName; + public Dictionary Tools; + /// /// Constructor. /// @@ -88,7 +91,7 @@ namespace Revitalize.Framework.Objects this.resources = new ResourceManager(); this.ItemsByName = new Dictionary(); - ChairMultiTiledObject s = new ChairMultiTiledObject(); + this.Tools = new Dictionary(); } /// @@ -252,6 +255,17 @@ namespace Revitalize.Framework.Objects } } + /// + /// Gets a tool from the list of managed tools. + /// + /// + /// + public Item GetTool(string Name) + { + if (this.Tools.ContainsKey("Name")) return this.Tools[Name].getOne(); + else return null; + } + /// /// Adds a new object manager to the master pool of managers. /// @@ -365,6 +379,14 @@ namespace Revitalize.Framework.Objects return I; } } + foreach(var v in this.Tools) + { + if (v.Value.GetType() == T && (v.Value as IItemInfo).Info.id == ID) + { + Item I = v.Value.getOne(); + return I; + } + } return null; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs index d3d716e8..da2bcc55 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs @@ -229,13 +229,13 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins if (this.location != null) { this.location.playSound("hammer"); - ModCore.log("Ore has this much health left and location is not null: "+this.healthValue); + //ModCore.log("Ore has this much health left and location is not null: "+this.healthValue); this.info.shakeTimer = 200; } else { Game1.player.currentLocation.playSound("hammer"); - ModCore.log("Ore has this much health left and location is null!: "+this.healthValue); + //ModCore.log("Ore has this much health left and location is null!: "+this.healthValue); this.info.shakeTimer = 200; } return false; diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index fd7c662a..755674ea 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -29,6 +29,8 @@ using System.Linq; using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; using Revitalize.Framework.Menus; using Revitalize.Framework.Objects.CraftingTables; +using Revitalize.Framework.Objects.Items.Tools; +using StardewValley.Tools; namespace Revitalize { @@ -228,6 +230,7 @@ namespace Revitalize public static VanillaRecipeBook VanillaRecipeBook; public static Dictionary CustomObjects; + public static Dictionary CustomItems; public static ConfigManager Configs; public override void Entry(IModHelper helper) @@ -242,6 +245,7 @@ namespace Revitalize Serializer = new Serializer(); playerInfo = new PlayerInfo(); CustomObjects = new Dictionary(); + CustomItems = new Dictionary(); //Loads in textures to be used by the mod. this.loadInTextures(); @@ -271,6 +275,7 @@ namespace Revitalize //ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged; //ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay; ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; + ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.ResetNormalToolsColorOnLeftClick; //Adds in recipes to the mod. VanillaRecipeBook = new VanillaRecipeBook(); @@ -280,6 +285,8 @@ namespace Revitalize } + + /// /// Loads in textures to be used by the mod. /// @@ -293,6 +300,9 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest, "Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Resources", "Ore")); TextureManager.AddTextureManager(Manifest, "Items.Resources.Ore"); TextureManager.GetTextureManager(Manifest, "Items.Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Ore")); + TextureManager.AddTextureManager(Manifest, "Tools"); + TextureManager.GetTextureManager(Manifest, "Tools").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Tools")); + TextureManager.AddTextureManager(Manifest, "Menus"); TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc")); TextureManager.AddTextureManager(Manifest, "CraftingMenu"); @@ -300,6 +310,8 @@ namespace Revitalize TextureManager.AddTextureManager(Manifest, "Objects.Crafting"); TextureManager.GetTextureManager(Manifest, "Objects.Crafting").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Crafting")); + + } private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) @@ -548,6 +560,13 @@ namespace Revitalize */ Game1.player.addItemToInventory(new StardewValley.Object((int)Enums.SDVObject.Coal, 1)); Game1.player.addItemByMenuIfNecessary(ModCore.ObjectManager.GetItem("SteelIngot", 20)); + PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); + Game1.player.addItemsByMenuIfNecessary(new List() + { + pick, + new StardewValley.Object((int)Enums.SDVObject.Wood,100) + + }); } /* diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b57506d7..83f9d189 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -74,6 +75,7 @@ + @@ -141,7 +143,9 @@ + + @@ -235,6 +239,15 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest From 36e7b5e6ef0199a258842c32442848dfe8c99d47 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Fri, 6 Sep 2019 15:18:12 -0700 Subject: [PATCH 33/98] Added in axes, watering cans, and hoes and default color swaps. Now to make content. --- .../Items/Tools/DefaultAxeWorking.png | Bin 0 -> 993 bytes .../Items/Tools/DefaultHoeWorking.png | Bin 0 -> 1141 bytes .../Items/Tools/DefaultWateringCanWorking.png | Bin 0 -> 1222 bytes .../Framework/Hacks/ColorChanger.cs | 352 +++++++++++++++++- .../Objects/Items/Tools/AxeExtended.cs | 305 +++++++++++++++ .../Objects/Items/Tools/HoeExtended.cs | 305 +++++++++++++++ .../Objects/Items/Tools/PickaxeExtended.cs | 1 - .../Items/Tools/WateringCanExtended.cs | 306 +++++++++++++++ 8 files changed, 1263 insertions(+), 6 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultAxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultHoeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultWateringCanWorking.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultAxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultAxeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..5ea2c373e13bf2164a9075b97a8d38025e2bb514 GIT binary patch literal 993 zcmV<710MW|P)Px&n@L1LRA_Fnrq_fD1*%6*IO zp5A-^`~Ua<|NGxTN=iyfN=iyfN=iyf%KwSYT3u|`>f&9m<9+6Xs192@+oVPeC)9wO zwYs>wQN=Kf>s-%!MVtuyFzgSvH(;w!@SooWmW}|h2WS8#(-HtiPUq*B4Q-yXOQt1O z%_7-s7C?l_o9KZh(-PHM#ec8XD*ocHgOX_pOGkWJyves4A7SZ;l4%Jer}OnUUn$L# zWZhC0K%r1z)hvdlvB(?<$X!sz(h<^&;!-j#@#Ohqme=bX|9OkOgBvWb*Lm{%F?Tnr zzCv*^a{631KQx4A#nKU^rm#v*`U>n0Qa9x*fw+nz_7_?fg$T_4J zt(wIvNkL(AOf{ffbidzEBs8BHv9h$l;i=lV*RS^YsrLdSr{nepNJFSbf{LeJMj9-e z&2r>)Li>dp@W|=VeEJZ8<@I{vh5YvWzsh5z(SpC=DdW0s0a zul8VrsU8s|Zof%rLz{f@CIH9%CNSBXr-pDoGXhW!!OdD-csc9>p{2lO+K#OSbLipe z8J_o8!u{a|LGQYZ^gg#YKpWbg;6*Eu7k=@%XP)C`c%O-21*Fq;SN9oztt@8FTsndv$unZ<*W z+=L`?^q*S@%Un3?JV_1UeY`lo@I7%Jgc{HjdN%U{l7{bf8DP5nX#M{K%wm;4HsWjV P00000NkvXXu0mjf7PRVK literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultHoeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/DefaultHoeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..1922817b8f090464179fba35ac565ae3ff161c8c GIT binary patch literal 1141 zcmV-*1d98KP)Px(FG)l}RA_JrD!lEny$iKoDd7R>ZRLFv= zs%m~Zoeou1l`^3}C0{xX#ezT=*H%!iR&Dmp7tf%#yYwb^y;u01LnD0|4Ft zSa@XbM+gDOakzIki<!Ec?q)r`iit-E0U^Y+Z@zd2gor3f z5*0-e9LG7u$K~ZE2qBOpiCRT;2?!YC>Fus7i9aYz`pxY^$bwEyWct5)G>V9ZXNTvt zmeNdlg|1aRC%UdN0x(WMCcx2o6FLOw?QY=0 zoZP?t9{F4vN9WPUu=HTvfTQzXWG^O!K+`lc{MogpX`y3ZE5{(B2u;&augUoK-5&q| zb?kfaYdi=cuE?|rXw7Xx7WDq@_x%M7UNYRelfu+Q2F-3S_E_uuVa%83=yYk;CYZ8a zF&cl`F>U?)>g$DU{O+qC@T4>b060|-0jzj#f@cU@$>-9*aab<{X9E5YKpnu>rQk$7 ztoecKgGbq}m=PdvS8O8s@$#UW(%W4+Tb=;`oSa?ZyN8BEjYb3V!J*5MLIng6$%BFt zFvBkq2NBhS^>!E2xb~o<^B#ZQ$HIJLBLygqDQVZ0ke~ovADKk z_KCy4Z=%=AtOU|D&8#B_Lnb+3SF)C3#Flq^O-FG;I3K%DZ zm_R(wW9DZGzyG=l;QF;JYB^ygjt4rc2y0v1VxAGU{-Jqbzbv5qn&DxhC_)rfSHF5q zj`dy|X9I77unqiTn3L)4E;LQEc^SKA_PE9PhcGpf!Q;u%fyd`_>Cg=f6fmDlPx(fJsC_RA_Be7RVw*JArEyTR27{UAwpOaKZRVo!oL#o>Nl#q?xUSE|6 zy_`&%Nu2Y@qUShH;`b2&*IQQj({H~<8kEarbh}-;ohYSSD@~MMGhBa?IQy%e^|Of~ z@#;+uv>gD$6@PPkLoXu}Wm0jvplZ19bzmCFS)&A`l>Pa~Us5~X+}_A!NDu^Qtuz4u z*PkRxuNhh^O$0&kpz)mZusB_aJs&q_x7P=6y~XP4>J;ZZoGs0O`e-y70Dy~&i%hly zz-(y-H-lTauB)Dv=jY&h@wQ69Zm*B}-L?PmL#$zSVNtakhwpU&0E|JK{l78z=NeK< z^*#yHsD-9!f-x3ZfbNJmKf1vAUPq;!J^|H*Mfe{-pwVb#5|MKrT9yT1Xnzm{W1~2d z!ct1?AMXJerY=D#Oq=2~h9N#oAK&ZX5>Bj*UZav=jN#quk#gXA@29A4>0|05CPZ{1mu&}|+Z(uSJ1W~~ zXF)dT#8zP%SkHe-t1M6y(n+M=)-ocCslMEYBL(ONfQwJGl9etLSSue4MGUmwhh;HCq7B+ zAMauRkKa{YO+)WjPkD+Ux(4niVst|28Gy+5)W2RvIOpN$K99H=+^Q%$+S$d?&Msz4 zGm-vulz_ScLI}973)3{=x~^J0oU`*x8&cD#h5N^Q5JKR)Z@-5S0{h2%iT}vZn6#JE z>+fg;>7pe?^QefIZAXbm&x_LqSe6CLvSOQMT|`392C_jXmcpN}zrb}}6sHT3-?Vf| z<7j7BrJ8egp1P3S385S*&KH!3dL%ux5JmgDpC}TYCa>P)I5{{4olqXa_d3e=BpYJ0 zNCVN9;AU{EI+*1AniOqWzSoamIuC7svf9L3Z&fW!I-cqN>lCL8i8dq}^jPPgisu}k k(l+gEn>PMa+K{91FAy@ym?$$?VE_OC07*qoM6N<$f|9sJ(EtDd literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Hacks/ColorChanger.cs b/GeneralMods/Revitalize/Framework/Hacks/ColorChanger.cs index 508ae8a2..fe195c35 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/ColorChanger.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/ColorChanger.cs @@ -17,8 +17,15 @@ namespace Revitalize.Framework.Hacks public static class ColorChanger { - private static Texture2D mostRecentPicxaxeSwap; + private static bool AxeNeedsReset; + private static bool PickaxeNeedsReset; + private static bool WateringCanNeedsReset; + private static bool HoeNeedsReset; + /// + /// Swaps the colors for the pickaxe working animation. + /// + /// public static void SwapPickaxeTextures(Texture2D TargetTexture) { /* @@ -108,19 +115,354 @@ namespace Revitalize.Framework.Hacks //Reapply the texture. Game1.toolSpriteSheet.SetData(beforeData); - Stream stream = File.Create(Path.Combine(ModCore.ModHelper.DirectoryPath,"ToolTest.png")); - Game1.toolSpriteSheet.SaveAsPng(stream, width, height); - stream.Dispose(); + //Stream stream = File.Create(Path.Combine(ModCore.ModHelper.DirectoryPath,"ToolTest.png")); + //Game1.toolSpriteSheet.SaveAsPng(stream, width, height); + //stream.Dispose(); + PickaxeNeedsReset = true; } + /// + /// Swaps the colors for the hoe animation. + /// + /// + public static void SwapHoeTextures(Texture2D TargetTexture) + { + /* + if (mostRecentPicxaxeSwap != null) + { + if (TargetTexture == mostRecentPicxaxeSwap) return; + } + */ + int height = Game1.toolSpriteSheet.Height; + int width = Game1.toolSpriteSheet.Width; + + Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height]; + Game1.toolSpriteSheet.GetData(beforeData); + Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace + TargetTexture.GetData(afterData); //Get data from swap texture. + + ///Convert tool data to grid + Color[,] beforeGrid = new Color[height, width]; + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + // Assumes row major ordering of the array. + beforeGrid[row, column] = beforeData[row * width + column]; + } + } + //Convert target data to grid + int targetHeight = TargetTexture.Height; + int targetWidth = TargetTexture.Width; + Color[,] afterGrid = new Color[targetHeight, targetWidth]; + for (int row = 0; row < targetHeight; row++) + { + for (int column = 0; column < targetWidth; column++) + { + // Assumes row major ordering of the array. + afterGrid[row, column] = afterData[row * targetWidth + column]; + } + } + + + //Copy over data from the target texture into the before grid. + Rectangle stoneRegion = new Rectangle(0, 16, 80, 32); + Rectangle copperRegion = new Rectangle(); + Rectangle ironRegion = new Rectangle(224, 16, 80, 32); //Create the region we want to replace. + Rectangle goldRegion = new Rectangle(); + Rectangle irridumRegon = new Rectangle(); + + List rects = new List(); + //rects.Add(ironRegion); + rects.Add(stoneRegion); + foreach (Rectangle region in rects) + { + + for (int x = region.X; x < region.X + region.Width; x++) + { + for (int y = region.Y; y < region.Y + region.Height; y++) + { + //ModCore.log("value is: " + new Vector2(x, y)); + beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order. + } + } + + + //Convert the tool grid back into a 1d color array + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + try + { + beforeData[row * width + column] = beforeGrid[row, column]; + } + catch (Exception err) + { + ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + ModCore.log("That's position: " + (row * width + column).ToString()); + } + //ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + //ModCore.log("That's position: " + (row * width + column).ToString()); + //beforeData[row * targetWidth + column] = beforeGrid[row,column]; + } + } + } + + + //beforeGrid.CopyTo(beforeData, 0); + //Reapply the texture. + Game1.toolSpriteSheet.SetData(beforeData); + HoeNeedsReset = true; + } + + /// + /// Swaps the colors for the axe working animation. + /// + /// + public static void SwapAxeTextures(Texture2D TargetTexture) + { + /* + if (mostRecentPicxaxeSwap != null) + { + if (TargetTexture == mostRecentPicxaxeSwap) return; + } + */ + int height = Game1.toolSpriteSheet.Height; + int width = Game1.toolSpriteSheet.Width; + + Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height]; + Game1.toolSpriteSheet.GetData(beforeData); + Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace + TargetTexture.GetData(afterData); //Get data from swap texture. + + ///Convert tool data to grid + Color[,] beforeGrid = new Color[height, width]; + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + // Assumes row major ordering of the array. + beforeGrid[row, column] = beforeData[row * width + column]; + } + } + //Convert target data to grid + int targetHeight = TargetTexture.Height; + int targetWidth = TargetTexture.Width; + Color[,] afterGrid = new Color[targetHeight, targetWidth]; + for (int row = 0; row < targetHeight; row++) + { + for (int column = 0; column < targetWidth; column++) + { + // Assumes row major ordering of the array. + afterGrid[row, column] = afterData[row * targetWidth + column]; + } + } + + + //Copy over data from the target texture into the before grid. + Rectangle stoneRegion = new Rectangle(0, 144, 80, 32); + Rectangle copperRegion = new Rectangle(); + Rectangle ironRegion = new Rectangle(224, 144, 80, 32); //Create the region we want to replace. + Rectangle goldRegion = new Rectangle(); + Rectangle irridumRegon = new Rectangle(); + + List rects = new List(); + //rects.Add(ironRegion); + rects.Add(stoneRegion); + foreach (Rectangle region in rects) + { + + for (int x = region.X; x < region.X + region.Width; x++) + { + for (int y = region.Y; y < region.Y + region.Height; y++) + { + //ModCore.log("value is: " + new Vector2(x, y)); + beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order. + } + } + + + //Convert the tool grid back into a 1d color array + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + try + { + beforeData[row * width + column] = beforeGrid[row, column]; + } + catch (Exception err) + { + ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + ModCore.log("That's position: " + (row * width + column).ToString()); + } + //ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + //ModCore.log("That's position: " + (row * width + column).ToString()); + //beforeData[row * targetWidth + column] = beforeGrid[row,column]; + } + } + } + + + //beforeGrid.CopyTo(beforeData, 0); + //Reapply the texture. + Game1.toolSpriteSheet.SetData(beforeData); + AxeNeedsReset = true; + } + + /// + /// Swaps the colors for the watering can working animation. + /// + /// + public static void SwapWateringCanTextures(Texture2D TargetTexture) + { + /* + if (mostRecentPicxaxeSwap != null) + { + if (TargetTexture == mostRecentPicxaxeSwap) return; + } + */ + int height = Game1.toolSpriteSheet.Height; + int width = Game1.toolSpriteSheet.Width; + + Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height]; + Game1.toolSpriteSheet.GetData(beforeData); + Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace + TargetTexture.GetData(afterData); //Get data from swap texture. + + ///Convert tool data to grid + Color[,] beforeGrid = new Color[height, width]; + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + // Assumes row major ordering of the array. + beforeGrid[row, column] = beforeData[row * width + column]; + } + } + //Convert target data to grid + int targetHeight = TargetTexture.Height; + int targetWidth = TargetTexture.Width; + Color[,] afterGrid = new Color[targetHeight, targetWidth]; + for (int row = 0; row < targetHeight; row++) + { + for (int column = 0; column < targetWidth; column++) + { + // Assumes row major ordering of the array. + afterGrid[row, column] = afterData[row * targetWidth + column]; + } + } + + + //Copy over data from the target texture into the before grid. + Rectangle stoneRegion = new Rectangle(0, 208, 80, 32); + Rectangle copperRegion = new Rectangle(); + Rectangle ironRegion = new Rectangle(224, 208, 80, 32); //Create the region we want to replace. + Rectangle goldRegion = new Rectangle(); + Rectangle irridumRegon = new Rectangle(); + + List rects = new List(); + //rects.Add(ironRegion); + rects.Add(stoneRegion); + foreach (Rectangle region in rects) + { + + for (int x = region.X; x < region.X + region.Width; x++) + { + for (int y = region.Y; y < region.Y + region.Height; y++) + { + //ModCore.log("value is: " + new Vector2(x, y)); + beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order. + } + } + + + //Convert the tool grid back into a 1d color array + for (int row = 0; row < height; row++) + { + for (int column = 0; column < width; column++) + { + try + { + beforeData[row * width + column] = beforeGrid[row, column]; + } + catch (Exception err) + { + ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + ModCore.log("That's position: " + (row * width + column).ToString()); + } + //ModCore.log("Setting pixel color at: " + new Vector2(column, row)); + //ModCore.log("That's position: " + (row * width + column).ToString()); + //beforeData[row * targetWidth + column] = beforeGrid[row,column]; + } + } + } + + + //beforeGrid.CopyTo(beforeData, 0); + //Reapply the texture. + Game1.toolSpriteSheet.SetData(beforeData); + WateringCanNeedsReset = true; + } + + /// + /// Resets the colors for the pickaxe. + /// public static void ResetPickaxeTexture() { SwapPickaxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultPickaxeWorking")); } + /// + /// Resets the colors for the hoe. + /// + public static void ResetHoeTexture() + { + SwapHoeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultHoeWorking")); + } + + /// + /// Resets the colors for the axe. + /// + public static void ResetAxeTexture() + { + SwapAxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultAxeWorking")); + } + + /// + /// Resets the colors for the watering can. + /// + public static void ResetWateringCanTexture() + { + SwapAxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultWateringCanWorking")); + } + + /// + /// Resets all of the custom color swaps for tools. + /// public static void ResetToolColorSwaps() { - ResetPickaxeTexture(); + if (PickaxeNeedsReset) + { + ResetPickaxeTexture(); + PickaxeNeedsReset = false; + } + if (HoeNeedsReset) + { + ResetHoeTexture(); + HoeNeedsReset = false; + } + if (AxeNeedsReset) + { + ResetAxeTexture(); + AxeNeedsReset = false; + } + if (WateringCanNeedsReset) + { + ResetWateringCanTexture(); + WateringCanNeedsReset = false; + } } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs new file mode 100644 index 00000000..527ba22d --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs @@ -0,0 +1,305 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.Interfaces; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardewValley.Tools; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Objects.Items.Tools +{ + public class AxeExtended: StardewValley.Tools.Axe, ISaveElement, IItemInfo + { + public BasicItemInformation info; + public Texture2DExtended workingTexture; + + /// + /// Used only for accessibility for casting. + /// + [JsonIgnore] + public BasicItemInformation Info + { + get + { + return this.info; + } + set + { + this.info = value; + } + } + + public Guid guid; + + public override string Name + { + + get + { + if (this.info != null) + { + return this.netName.Value.Split('>')[0]; + //return this.info.name; + } + if (this.netName == null) + { + return this.Name; + } + else + { + return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value. + } + } + + set + { + if (this.netName == null) + { + return; + } + if (this.netName.Value == null) + { + return; + } + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + { + this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back. + } + else + { + this.netName.Value = value; //Otherwise just set the net name. + } + } + } + + public override string DisplayName + { + get + { + if (this.info != null) + { + return this.info.name; + } + return this.netName.Value.Split('>')[0]; + } + + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + this.netName.Value = value + ">" + split[1]; + else + this.netName.Value = value; + } + } + + public virtual string text + { + get + { + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result. + else + return ""; //Otherwise return nothing. + } + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + { + this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name. + } + } + } + + [JsonIgnore] + public virtual string ItemInfo + { + get + { + return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture); + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string WorkingTexture = data[2]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString(WorkingTexture); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomItems[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomItems.Add(this.guid, this); + } + + } + } + + public AxeExtended() + { + + } + + public AxeExtended(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); + } + + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public override bool beginUsing(GameLocation location, int x, int y, Farmer who) + { + this.updateInfo(); + Revitalize.Framework.Hacks.ColorChanger.SwapAxeTextures(this.workingTexture.texture); + return base.beginUsing(location, x, y, who); + } + public override void endUsing(GameLocation location, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + base.endUsing(location, who); + } + + public override bool onRelease(GameLocation location, int x, int y, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + return base.onRelease(location, x, y, who); + } + + public override void actionWhenStopBeingHeld(Farmer who) + { + Revitalize.Framework.Hacks.ColorChanger.ResetAxeTexture(); + base.actionWhenStopBeingHeld(who); + } + + public override Color getCategoryColor() + { + return this.info.categoryColor; + } + + public override string getCategoryName() + { + return this.info.categoryName; + } + + public override string getDescription() + { + return this.info.name; + } + + public override Item getOne() + { + return new AxeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); + } + + public object getReplacement() + { + return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel }; + } + + public void rebuild(Dictionary additionalSaveData, object replacement) + { + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel; + } + + + /// + /// Updates the info on the item. + /// + public virtual void updateInfo() + { + if (this.info == null || this.workingTexture == null) + { + this.ItemInfo = this.text; + return; + } + + if (this.requiresUpdate()) + { + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + /// + /// Gets an update for this item. + /// + public virtual void getUpdate() + { + this.ItemInfo = this.text; + } + + /// + /// Checks to see if this item requires a sync update. + /// + /// + public virtual bool requiresUpdate() + { + if (this.info.requiresSyncUpdate()) + { + return true; + } + else + { + return false; + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs new file mode 100644 index 00000000..4f89a131 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs @@ -0,0 +1,305 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.Interfaces; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardewValley.Tools; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Objects.Items.Tools +{ + public class HoeExtended: StardewValley.Tools.Hoe, ISaveElement, IItemInfo + { + public BasicItemInformation info; + public Texture2DExtended workingTexture; + + /// + /// Used only for accessibility for casting. + /// + [JsonIgnore] + public BasicItemInformation Info + { + get + { + return this.info; + } + set + { + this.info = value; + } + } + + public Guid guid; + + public override string Name + { + + get + { + if (this.info != null) + { + return this.netName.Value.Split('>')[0]; + //return this.info.name; + } + if (this.netName == null) + { + return this.Name; + } + else + { + return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value. + } + } + + set + { + if (this.netName == null) + { + return; + } + if (this.netName.Value == null) + { + return; + } + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + { + this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back. + } + else + { + this.netName.Value = value; //Otherwise just set the net name. + } + } + } + + public override string DisplayName + { + get + { + if (this.info != null) + { + return this.info.name; + } + return this.netName.Value.Split('>')[0]; + } + + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + this.netName.Value = value + ">" + split[1]; + else + this.netName.Value = value; + } + } + + public virtual string text + { + get + { + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result. + else + return ""; //Otherwise return nothing. + } + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + { + this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name. + } + } + } + + [JsonIgnore] + public virtual string ItemInfo + { + get + { + return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture); + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string WorkingTexture = data[2]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString(WorkingTexture); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomItems[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomItems.Add(this.guid, this); + } + + } + } + + public HoeExtended() + { + + } + + public HoeExtended(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); + } + + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public override bool beginUsing(GameLocation location, int x, int y, Farmer who) + { + this.updateInfo(); + Revitalize.Framework.Hacks.ColorChanger.SwapHoeTextures(this.workingTexture.texture); + return base.beginUsing(location, x, y, who); + } + public override void endUsing(GameLocation location, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + base.endUsing(location, who); + } + + public override bool onRelease(GameLocation location, int x, int y, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + return base.onRelease(location, x, y, who); + } + + public override void actionWhenStopBeingHeld(Farmer who) + { + Revitalize.Framework.Hacks.ColorChanger.ResetHoeTexture(); + base.actionWhenStopBeingHeld(who); + } + + public override Color getCategoryColor() + { + return this.info.categoryColor; + } + + public override string getCategoryName() + { + return this.info.categoryName; + } + + public override string getDescription() + { + return this.info.name; + } + + public override Item getOne() + { + return new HoeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); + } + + public object getReplacement() + { + return new StardewValley.Tools.Hoe { UpgradeLevel = this.UpgradeLevel }; + } + + public void rebuild(Dictionary additionalSaveData, object replacement) + { + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.upgradeLevel.Value = (replacement as Hoe).UpgradeLevel; + } + + + /// + /// Updates the info on the item. + /// + public virtual void updateInfo() + { + if (this.info == null || this.workingTexture == null) + { + this.ItemInfo = this.text; + return; + } + + if (this.requiresUpdate()) + { + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + /// + /// Gets an update for this item. + /// + public virtual void getUpdate() + { + this.ItemInfo = this.text; + } + + /// + /// Checks to see if this item requires a sync update. + /// + /// + public virtual bool requiresUpdate() + { + if (this.info.requiresSyncUpdate()) + { + return true; + } + else + { + return false; + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs index 27e5da44..43526d82 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs @@ -268,7 +268,6 @@ namespace Revitalize.Framework.Objects.Items.Tools if (this.info == null || this.workingTexture==null) { this.ItemInfo = this.text; - ModCore.log("Updated item info!"); return; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs new file mode 100644 index 00000000..08189630 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs @@ -0,0 +1,306 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.Interfaces; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardewValley.Tools; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Objects.Items.Tools +{ + public class WateringCanExtended:StardewValley.Tools.WateringCan, ISaveElement, IItemInfo + { + public BasicItemInformation info; + public Texture2DExtended workingTexture; + + /// + /// Used only for accessibility for casting. + /// + [JsonIgnore] + public BasicItemInformation Info + { + get + { + return this.info; + } + set + { + this.info = value; + } + } + + public Guid guid; + + public override string Name + { + + get + { + if (this.info != null) + { + return this.netName.Value.Split('>')[0]; + //return this.info.name; + } + if (this.netName == null) + { + return this.Name; + } + else + { + return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value. + } + } + + set + { + if (this.netName == null) + { + return; + } + if (this.netName.Value == null) + { + return; + } + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + { + this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back. + } + else + { + this.netName.Value = value; //Otherwise just set the net name. + } + } + } + + public override string DisplayName + { + get + { + if (this.info != null) + { + return this.info.name; + } + return this.netName.Value.Split('>')[0]; + } + + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + this.netName.Value = value + ">" + split[1]; + else + this.netName.Value = value; + } + } + + public virtual string text + { + get + { + if (this.netName.Value.Split('>') is string[] split && split.Length > 1) + return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result. + else + return ""; //Otherwise return nothing. + } + set + { + if (this.netName == null) return; + if (this.netName.Value == null) return; + { + this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name. + } + } + } + + [JsonIgnore] + public virtual string ItemInfo + { + get + { + return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture); + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string WorkingTexture = data[2]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString(WorkingTexture); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomItems[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomItems.Add(this.guid, this); + } + + } + } + + public WateringCanExtended() + { + + } + + public WateringCanExtended(BasicItemInformation ItemInfo, int UpgradeLevel, Texture2DExtended WorkingTexture,int WaterCapacity) + { + this.info = ItemInfo; + this.upgradeLevel.Value = UpgradeLevel; + this.guid = Guid.NewGuid(); + this.workingTexture = WorkingTexture; + this.waterCanMax = WaterCapacity; + 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); + } + + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public override bool beginUsing(GameLocation location, int x, int y, Farmer who) + { + this.updateInfo(); + Revitalize.Framework.Hacks.ColorChanger.SwapWateringCanTextures(this.workingTexture.texture); + return base.beginUsing(location, x, y, who); + } + public override void endUsing(GameLocation location, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + base.endUsing(location, who); + } + + public override bool onRelease(GameLocation location, int x, int y, Farmer who) + { + //Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture(); + return base.onRelease(location, x, y, who); + } + + public override void actionWhenStopBeingHeld(Farmer who) + { + Revitalize.Framework.Hacks.ColorChanger.ResetWateringCanTexture(); + base.actionWhenStopBeingHeld(who); + } + + public override Color getCategoryColor() + { + return this.info.categoryColor; + } + + public override string getCategoryName() + { + return this.info.categoryName; + } + + public override string getDescription() + { + return this.info.name; + } + + public override Item getOne() + { + return new WateringCanExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy(),this.waterCanMax); + } + + public object getReplacement() + { + return new StardewValley.Tools.WateringCan { UpgradeLevel = this.UpgradeLevel, waterCanMax=this.waterCanMax }; + } + + public void rebuild(Dictionary additionalSaveData, object replacement) + { + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.upgradeLevel.Value = (replacement as WateringCan).UpgradeLevel; + } + + + /// + /// Updates the info on the item. + /// + public virtual void updateInfo() + { + if (this.info == null || this.workingTexture == null) + { + this.ItemInfo = this.text; + return; + } + + if (this.requiresUpdate()) + { + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + /// + /// Gets an update for this item. + /// + public virtual void getUpdate() + { + this.ItemInfo = this.text; + } + + /// + /// Checks to see if this item requires a sync update. + /// + /// + public virtual bool requiresUpdate() + { + if (this.info.requiresSyncUpdate()) + { + return true; + } + else + { + return false; + } + } + } +} From 9c7c3ace2a84d978ef7a35998cf3bf905895f150 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 7 Sep 2019 14:03:32 -0700 Subject: [PATCH 34/98] Added in working animation graphics for tools. --- .../Graphics/Items/Tools/BronzeAxeWorking.png | Bin 0 -> 932 bytes .../Graphics/Items/Tools/BronzeHoeWorking.png | Bin 0 -> 1027 bytes .../Items/Tools/BronzePickaxeWorking.png | Bin 0 -> 837 bytes .../Items/Tools/BronzeWateringCanWorking.png | Bin 0 -> 1228 bytes .../Graphics/Items/Tools/SteelAxeWorking.png | Bin 0 -> 973 bytes .../Graphics/Items/Tools/SteelHoeWorking.png | Bin 0 -> 1070 bytes .../Graphics/Items/Tools/SteelPickaxeWorking.png | Bin 0 -> 865 bytes .../Items/Tools/SteelWateringCanWorking.png | Bin 0 -> 1216 bytes .../Graphics/Items/Tools/TitaniumAxeWorking.png | Bin 0 -> 1040 bytes .../Graphics/Items/Tools/TitaniumHoeWorking.png | Bin 0 -> 1188 bytes .../Items/Tools/TitaniumPickaxeWorking.png | Bin 0 -> 915 bytes .../Items/Tools/TitaniumWateringCanWorking.png | Bin 0 -> 1296 bytes GeneralMods/Revitalize/Revitalize.csproj | 6 ++++++ 13 files changed, 6 insertions(+) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeAxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeHoeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzePickaxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeWateringCanWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCanWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumAxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumHoeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumPickaxeWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumWateringCanWorking.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeAxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeAxeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..3c640306b6d77d15040a6e81fdc987fb7835c676 GIT binary patch literal 932 zcmV;V16%xwP)Px&UP(kjRA_!ANY z{SA7^qHCAfTVR5Rg(WCEgt*W`h|r3JG++xul*~@N9iDyNVRz@p`);#Z%m|BIkV=5*8rY~tV-b0e%(!(8?9MQi z71Ktt-+dbk)jw-3C>R^|J7DtJ@^v+7=1LucFKhN<9XE1lv8L1=~GxZ|7=(tJ^@KMCI{r z`GI`?@>}?sJ%jpRnXbQbOZ0+UA4k@WJL4*zzXK?gHpbPq3MF7_K*iL6dMcy{g3h?=+Rk$i9O*p)0PGx!bTCxTd=N`IqXmVlM!`I#da_h_FNdy4sD9c&l%^M`o{u}o;4K2{w$=FbPU7Z(B z@fJ7f2ax-To@lrQa3Qk>l&k^8Zz1julXyH0DtAy_Q21Qmf3WN7YVi#ZJ$(wQ(bOLv ztrj<{6W}7sB;Px&y-7qtRA_*)^m)K*jsXEqmWulZvykPb2I;a%%0DQ7-PC z>NP46?lpxW+?TI`^g-7*D$H>9yp9$(L;>19d_BEGm7fB*2 zCI+HZ6w%UiX%Cp$FemZeHivl`=xG7%YL&}(gnALN9NE;1Uq&(8?ZgAvxnGGhYAKDvFkW7S-EqL$4(}TDG*#hw##S&3&Z@VGB{bqS0=*uA z1mBwADxjY&Bnou%8ZfiYa>nButX)gu-bM5ifyPsW*yi^z&vBc7%_5K;3sm~@F1zQy zMx4H1t?;ve=YiV-UaI9_IfX@`SSa{4x4TuqTGG`jW2iG)b^l}{40wxn7?ChSE zj|A>y6i6e}s_wiceg#zfZ;sdTtzgHG>X=`PV16y)IKHER^J@{`FOX3n@y|gq8i(hq xOWtA;`X6zeP__T20NTIGoNC1ToAEEI{~x{Y(flho*h2sS002ovPDHLkV1ft*Px%|4BqaRA_u4R^$V|~NJY#hah7tRsx@Odqkxf0jY!4Z zfC*Kt1s2iGoJ<<$#Y8u6b8#|h{Vb>$s#>G?60wK?%LnH7#`IeFBsB})&-B$Rf-bJe zBT3jR!6mR?zR!Lc;EYsUze|;LxnhZkSDVWR@O((-zgyo6`S=WgD`qpYNt}@+%uP3* z&9B3+Y6XDthyT6<9FvHtxW4)k!3Lv%dnLQZ{bay(@#fcI_2~9;?(=7l8)fkjabZJW zQ*qci4d(mxpqmoFD4}_^;LAZp z?AwRW=J!Sc6WTr}a{Io9P`+^coHjY29oRZ7X z@xUNpLfz~@&>`U00Y8g@q@EUCv0uI!fFR_ab_1}ucG0wqF$0JD&g;&I>~k5b-w3Ay z8~d?K__(cwa~G5#Boy`Rg_*KqXXExD825qDXhh_8Ol?UxTYr>-dfi#Z8c&BtU-> zgXSj*6DylBPy5CUT-l7(9SBabL?mCZpTuqVksZbMlR8-ZDboV`cTxX0@)Z^Sq_B8v P00000NkvXXu0mjfl5&fw literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeWateringCanWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeWateringCanWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..bd989fa95ed3a5a687a83e3b7ea17f0abb2f67ff GIT binary patch literal 1228 zcmV;-1T*`IP)Px(hDk(0RA_3Fz zC9TX4Wahnj^WOLV^Z(x4CxnEAgoK2IgoK2IgoK2+$tJPhbPWGnvPrD+!&}yA7P0N5 zI!?uvXt`X@RX%N;h=8d$R$m;R??9oXuJ=ZbQz>HPxH}Z_00z6&_1#N`{rt{TlhvK$ zANNhs)PetI?V1`g818}L9*9Lu05-PG*X`~-q9cgF?v!uuh8$Jp$^kn_H>5>VgP4HDnNrnDmcKd!EH24;buLYvOSuF+ShH zULy46B&Z35Os_lpp8VnezDq#Ibq;4QkMig5PY+A2-MF!BGTd_*#Kbt~FI?o+%NIQP ze(@;r9|;lf?p2ss15oA1<52C8`5Y~iy4qELp!!V3{jg5a0U${tSVw}C@?||m(V5V0EUr)0!WtU&tG%4>xXAGo|Ymd$V z@XIH=1QoF}2IYPD>?fzLFAl3dnPUs6r&aOboTuSHTgB7Pk3tE+7-ht<_Yx3EoyZr61N<47Hlemiq=eYLhOdt_6y;%2esQYS1lz0BF zHFdEoUtBaJiRBL&bJstWDLI_mx9N5~@yE-610DmOiE~Vzpy8 zP`op1s{PDb#m=_AxLOaFp4DuZ3!YtAi3s^EsZpDP60$YoLOF>{4H+yHO{84!zHCyt zX?9%+R46%<*GVVb^&+Sr(k`7)?Uptnov5+28E6X3tf^Slhg6PKeR$2_5m3at-XFDh z;QX^1!#(DaMFh1rLG#p&wW)Ex_*s>8@zM!(mC4J|urCgO?fH+di>$w2C^Z&cN7`s> zpDP9(&q+kYi&SgmaycT^8rS=ysJ~_+3VJq33_6|^ zUMM;N=vS!^%Ivz6Y75228_DVp5sJ=4y4oEPbtkpjh+O^Q^e3Xr$Gdw~t!Z*XX+@#r zEERq+c)p?x^wEGb5fSew=T|?s1$kdTe(ALO`4coInOAw=|9B>GOWF!u?fx098vg)4@HNBeG<&T80000Px&heQXujUx zyz|aG3ne8bB_$;#B_$;#B_;nS9LI?q$BDl7JicYBSrz*IKBb81qzdRbPSo%Bsn_eb zIiGKeJUcK|K;QQ{IXQ`+zXmIUXhjekAf=3?l(!OAq?D0u+cYg}<_=s)Yy4n&IsSe2 z94VzL*FMvf@v8&H^M`eox;1|J^(Z>+N`w%!+ieaG4s!PcU^;IpWh8_E;BKqMVy6QT zxvqPupDP8t$lX?p_wU}B%mJ8q5Ww#~xebs~Mysook%&{HmS zrODW|q{AQaGvKPy|)rLtLQ@fJHBb~o18-B@F>(=iqirVE%9Q7Kiq zDxFAT+cr84diCskssm*d54Ej-{`KWj*+nw1a?Lvxrl)B(I$phf^D;Kz?VFe9{xd-@ zpb2|>d-1c5!O61gBvZg5oF$&X)PQ7}3C%lZ>6<=0p1gR?`gX|rcF2<#uh0E=o!m$s z=y@KeUCH{k0^qbO3kUSzli97!b=`^%75AV13{1Q)2m-RUei1SSG&Mk4fP5YR;u$AIF8q&sxBlF|bGghiS^8De8Um z(zA~F>4$#{w_obk=JUYc{{9XqzJi|T&2^oM`9!EdgeapKbqtx44}pQ6V{;00000NkvXXu0mjf9@^O_ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..9b7f50dd1de78f305e41c5ac72ed806c36be3737 GIT binary patch literal 1070 zcmV+}1kwA6P)Px&=t)FDRA_?!*Na;O)UrH~$$y@fgK!IT5dL&?6GtC*@%p)jTD6FGe=xj!`*UEUX_}ZD z|G!0y2uKLwrfK5y*;%OFG)*{;bE^{;;sHQ?+r|-qqidkP9k%m*ADX7YFbw6h7IA`p zda=p@;FrG#%Dy212_d}EXrSl15yPJAqS0sox4i3p&qG<)0RU^2O60z#X^GFElycKF zCv8)mpdH%|gufJR7J{~4cXvb2h;^Ded>Ro&e4TU_m9P;34?7(Iz*3Jv2+-~x z;G{%=FWo82in5`9L#_4DL+XBD+-F>wQ@3RtTaaeR7( zb~jxS%or<(5}Tm@43YYdP}-CPkcAym^z*Z8LR2 ov;La`AW|&PBHldX-&Ozr04X^I2vctCHUIzs07*qoM6N<$f@2x%tN;K2 literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..210f065c4025a71098206f3b6d0e63db95ed3a4f GIT binary patch literal 865 zcmV-n1D^beP)Px&8%ab#RA_Xa)u(t18Cn;0RTfpjL@HBo2X+yZD@x4t^%b_wl~>e%!sjKuJkSNl8gbNl8gb z$$y3Gx~c2B>2vGxoOqrmUH{^w2G@1dy}iBcXX^X@f{x%;tCefqteAy-&-2p#{e6IR z(mWFl2vDolbY%nJIF3}fid{hp@Hs?lylU|>JkLuV$D!NpO8ZF-m?TMFxqpqfZ5whd zBHJ=5fzRP~jiy!Q-SJJ@w_E`7WJ0&wE$l><4WtIViXt7E0EA&k-7sjF=2ZQ&l&c#C zy*MTc;39s(MGSC*5Q4g4AcUAYHIpPMltt47kko*)A`C-myXSf7xUn0iN!>8`HEe(B z@SyD~its#78dYH!X3;-aqz3H8abW@1*VoeaapPS@5ns;Ep6r*sf3>wWGN#IiolXZ( zJMbyS9UvPoHK2}Q9U7)NT5Pt*Wd}$`c8~}m(q0^6+qTld=GRXEgo|6+x@CGzLTbQD z-~*6t;Pax>={&ioIU6egw7>lry&LN%tThBzQRTP&;faP^Ya*h_q?9iM;d{f#_doUE%`)#Yw(~M!A0cvEtg1$ z!SiAWVZI=!1U}7!WdL?05nNGC)U>L(1dl6lxLxDz!SZM;&_P!|fNk4_PU7?6j{2%R zL6ioB`@Kk4i6Ycj7qsMyVe~zIo;6AXsyr}>zU6Xsns9WQ6gq@@-}Ub@vLbqYeO-GF z6>}}5`<9CkqEI=c>%fd!t;Xf$WuZA_OqIgA%p!GkBQWw?wA*dg*47H^AVV2}MN+74 z7(lUtyhsE_ev6NcRRbER)<4$>oCQT3=xnTvzD9JJ$tkRZ5MuPrI?q#3MOI7d(6p*b z2TD`8X;nE7?r49z(N>~inuRYVbiX8Ea3uzM_nIG0mXz|P1{_SVq@}>{Q!5=_Xlhfm rj(k>j1?l5kk-Vt>l$odee=+_K%g|Aj=>y5a00000NkvXXu0mjf(Z`xJ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCanWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCanWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..ead84e5983791cf50dbb4bf756fa26f2aef32790 GIT binary patch literal 1216 zcmV;x1V8(UP)Px(dPzhUJoy!RMYv*RQ$#X5*cI&MHDntUGm&}vLr_d4sQwiEwN6zyXX1e z|2drk)YR0})YR0})YR0})YN2gT{r#QF}x;UyyoDp>!y}vy=f6&O+eE$QvmpQbCbD# zYrKkprfH^(F>uZ?k0Nl+;d$Ph6mf0U1Cn?E&}cRR0J^4$`=ikalgVV|^L{RtI`F6c zA7AVk#uzp`9c*?wP!t6K5QO1Nhx_01RoM;Kb<^z~2mgHeZ+doiR>?8sKE@bMPfv6A z4-O9S=+5-5xG*Q6{Kh;#KhLyP5wg*2LQxcax9#TcDT*S>deu;joO7{7$lFO(6A+H$ zWUBAt;-avBMnKnf#e{^SC`gioE-Skc0QUEGv97mpAKc;RUw*CH?b(ocmSs^>3ILwx ziR}Z=h}|^JR8>_mp6~lGO|!6Sgn%U8Z|A?44&2+>t`ta;B-r2E1pwR!cUae3*x%bl zbp8Ix;2p;PaG2I4rzcsv$u zj4@0mliagHK+ZYsPq?0b$UXRt@vV4n8S^N5{PkX}{@;K7i6lv$>}#54y3uY!*EHEV zL?(IHbu-tTbJ(_>0ubU++}G0&7z_rLM06Y{-DtM~0Gpi-TCEoD?(Pa>02WF(2t)LC zw$a0OCIKqpf}}D$T0CWpNkV3k_oyOtO~Yt3!u|a{0APK69fo1Rwr!Ds<2dPKd5MHL z=a8M(Xf{PYI4?HEBD8?~51xB|YilbL1GQ%aq@?FjRCtC30x@ z@H`K|rv*!r1Rrm15XZ4_h_o+bGMTKIrkTp(Q4S=cqx?`Q-gy*(eb1nOt%-`ElLf^f zlY0x(#J95<0N{2u1C>=3WEXPIaeRD?lamwB^`iUed)fDW#Bq#y6lE5W&^0a79)w{o znZ+D*O+yfd2*ObOt^$2M_4|DQz;HMe<1LyYCm@N}?RLc*`0DCPBvAzt5%_czT2{JA zlEAVov1!ZV(VUb#CC3=UbUH1ZUlv*JKaU~=LGWb!v@o*Es<@ra#NV=VDMQ|X-(6l}@qkXq zBGZAp?J&Y eUu6t668{0}s=PyyY7KV)0000KaP)Px&%1J~)RA_~#2p)p#u;d^T3gd1{m_lG1Hc(})U_qgR zJqDUXNpRyKe^}|IQ0S!vi+B(sL4^jZ1Uj@$bZK02D$5ecA!-q9z_6j4Z0qwddApN# zXLjCfH!Wp8mzjAp@6Ye|e!uT~Zy+EbARr(hARr(hARypHVth0s#z!;aS&!p+rmfKj zAAIs2ffJo^bl~`CMhp$4s62RdkmGr-@RETqIlZ`X{WinNRQ3K@FxZ0txcMg`09`W# zK&(&W>mM$MTG_X*8DeN4MaQcEh%YbB)a|cs1nQb0(kD(QN(m~Z|H!Z8eRUd*l!^7WliyIQ z_tllF6z&#@^=TB&TGx+1I<4%CW}G+w<97h)M!&25jw!skbC0R9I8$SBHh1p%9!Ozb zeHE`d&vyOh+pC`I%jlE%P2<0AP4NA6()An12wa|@L8jpH{0wv%N}VUt8UB#>Z^F%s zGoI?@ie^aH46%OaGGSo-j!76O+_fU})6Y(G|KEQ+wN)u84S65oZIkF*odB%engHsr z1Fk6?jg$eDQ*eAVBjgsyhT~S?adJg7WY^IA#umAv83M$)vlGPnG{?F!`aYkWAiQk? zu+wF*S0?t_@kHWX%ROrg&fnBcVS6XB-u5TT+>p+zlwk5qoXInBDkW=CP(9H^BW0qI zay1ijMKhEunxRH}!2C*{@V1HE28FjxB^{TxF8}uMiL%FOxQ#h;o5<7TD=Bm|LxB(BhJdkhrknL;;yt(O1v^8#KqScQfT zR5d_~y*1ml8NYG;wr3r+qZ)xwb7Gw`Wg6MvvXcnF(15iP`;9(OpFoLy83dKPaPPmd{r>~?X_M3DfezUK0000< KMNUMnLSTXk=lTr* literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumHoeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumHoeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..9e382e9127acfaeef9c5ac0406be119036047856 GIT binary patch literal 1188 zcmV;V1Y7%wP)Px(UP(kjRA_!qP(tLhSm7?BZcTt1OFM5PI4} z4}!IaU6tBPb17TQt*cH326jA9xmuA`Z&!W>qGLxBP zCNmSGz0Bv7{N}xR?|t9*_x=nxI5;>sI5;>sI5;>sI5;@iz-9DcVsuJU|DRi!F)Uka z!fg==!1pQzz|lJq-EzW4>caYD#9Mm7iP0&kx3dq=yPB|c5h8}$BGRqFA>xZ8eEflz zV8G2+Kctxc_OVjN>#yTDcgnrbC#C;e#4-WHZ4s%rvkx&VYT~_}eIyf^bM3G!9zg$a zjMsn&^bc#x9p_H*`s=uMqYGgprTea0WYAcLUjq2%x13>Jjey~{h;)B?woE(#F)MO^ zdX_J~Jl|R0KiZ|i*O>25Bvkg?>#s9?$HeHAG&uB8Y1mQ*MWa!vEOrwmHaVJ6m!P#XF&?~2xx<=wbKJBfDD6g+VN^2IqYycermsgem@V#0?7C_uu8Xs8hnjBdLSr*?W89G5SS$#3GwKGK!dN5iP0%T7s`Ui7e@#N>H+w0PgI_jqMO2M zf&n)?F&_ZH{N0!){aypVM1YDZoo*_EY6G8GW8SxG3om4FmDb{bk`smufL9YVv_`d-^(unH&x;#6Pb$dk~cB47+4Un;j;D2eRFUEaqWi z>7G(7TQ~v>4* z#CW(k0-#B!^lH{t2kkhp^c10fX7?~JV>bSpIdE=a#-+Z0=7ki>J9M;b>t1SS0?z}p z39M-fCleXv9-DVz(Ur3E%yz(95^C|&dg+jdPmZgq9}KunC$QqpJQ#4ZzIjqO5||@w zq+H7@OB%uC-`xZ4y5}e>SZ!aA=X-BgT{oWf5YKulwqH@ec-CXP1HwkiHFjql$h%J# za_r7{RpOm>6FP4y4yf9%DNy{XEK`kmXKDYU>i-9bDiV`jqUK@%0000S literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumPickaxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumPickaxeWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..a8eb5e9f4cc176444689b428bcb3967b7d935ba1 GIT binary patch literal 915 zcmV;E18n?>P)Px&O-V#SRA_xmKcvugTiqL>aP9jkov_TT6)FMTT=+9W_Er-xU z@!;8ip(Qj03qk}#n<{CNMRF)o0v4o556MBA>PGDLknEaBGPC(6sXgp-8nQF{&b;%@ zd@~!s#>U3R#>U3R#>U3xzalUe(gR~5{jU3Qmqe5(ZTx|;kiNHdsPAnZl1z*!QJpN_ z0Xm@{QKI_cr!@0D_gOD+JrI!xmR4T?fWEQ0?x3`v8-@-5AAf+ z!>q?N@ak8)vW@)y?!^4`GN4!=gc0phIf=E29{9XYym@z_Ywi#LApI?A*$j&QZFn9q z4OFu#MH2w9znj9-CyQ`YT$bt^%S4tuC~0Rnh$T@d_M%V(fD42df{-N-!dg%V04s*% z@@Y(t2gqZv5S2cYAg<|6bv_t>bSGCe?%R0;m938x@b%vymgV=htK#X7!ea#(0@8e*# zTuK3GF9@V^5$7>g9G_f6 z9%3&Lu7SYKUPSGL2=b7Fq#s@gHZ6A=u7SK6XocnuVf(0p?W2lN5-Rms>$i&hANNfw?!M)0fEFoF)z(3^|I*^M* zpm7Q?PXh#a1)tZ+oj~Ri z_IaH+KDmZ^dO_}l)z4Whs5c1!C=`1ER7h=ivM#PZGXi(Au387$XJd2S(TPo5^c;Do p%nd`o{Z*u0ME;i$)&Cdm{{n#OSO#y7oU{M{002ovPDHLkV1g~#pKAaB literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumWateringCanWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumWateringCanWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..170eccdcb9710696472805dbba17f9e81055b871 GIT binary patch literal 1296 zcmV+r1@HQaP)Px(%1J~)RA_8tbMRVDTUB=A6BFV#fr=h1e(%KuwrE>WyzNKwog6@ zApu)kwo3`!677mDf&=ew*mLxh51|iE98f1M~Hxx=LwJ)*g_%MDq_hu%^ zbZuEJb6(oHGjs3vojKpR-woiwg9i^DJb3Wn!Gi}69z2Mci!GSXI)?u(=3)!xw)%s4 zkx9ICUK0m~LM8y{IYYRnZp_6N%<-TC z0OluO+;ycGQr~z`!TTRh+U|e-<$cuZRRAzAiVAH6@~X=gRAI~wk$pV_=$3*MsAclZB6vG-D*}QdM}_KBOW!!YFAz8vTQJ{yR}mg~-ggOq9Q{R?uGI(t zHzPOTzkCJzPafmj^mlGwJ2i+rE_M?DmX}h@K5)uP8Xg(MKNW~)px@_5xmZEDxW>l96Qj`ga<*p~fm$Zd82`EU!1my)eQy8&%Ee0C z#cTB{jFJIKZfqVnJj9ECz5t_SkOw*eXI8zloPt0@3h=@O`fe|)ghGI;>xJ!W`fl=){f zc#m>|Buhws_Az!JJp^D8;4=p>n~bvr6gf&(!xGXmc|m!7Jp(XG1{Od1RG6Q(4DOC?S{+_kG?I2`#MYN=x^41GNVZB<8s)Blt- z(D?Ev$6)2D$WilpcucSZeJ|HVzQwP}ljxvmM`Q~s5;JjR3xm)yc>q@Vjt3PM0}tCS zObc&omfE(p9Z*@h0k1+WlSgdv1EiDdpzCJ!(Z;p8WtCv9UPZQ`+IDM6mV^&$l_0jv3^`D*p5ARrroMBZ#N&UWCH#Wj|M8xV;AP}X+=v@hM0 zV`~Q`)8@&eH7R*I8iprEad5QnxIRxZ|9-7r?dah^!{?h->+}I^ClMk~&l$Lz_#Ar9 zz-%&(ZEfe&CyABS6sD#pnXk42KQCYMylRLD`Vh?@gvI~}@6-IejVN-|Z0_?2U*lklt8#b&d@Th0K*ztF1_HtRpft zjg{3DW)t(aUP{a45t*9C=9VfXPl@v+@T57#!P^IK1-xqc{towGIyK0=N-Z^8*T4Ss z8}mgQfrNvjeQawx7#a-CF^8se_ z7;RMJK?S$(%!5uSolvV+S?*3T*x09qs3j;DD{O+(oL`-Ox^k;tr{p@dKW<}+OieQ{ zbW$ImKab&&LB|*z1A5xz&kE + + + @@ -239,9 +242,12 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 4b3b1dbafffcab60d57cbc22dfb6237c5c04541b Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 7 Sep 2019 14:45:51 -0700 Subject: [PATCH 35/98] Added in icons for tools. --- .../Content/Graphics/Items/Tools/BronzeAxe.png | Bin 0 -> 273 bytes .../Content/Graphics/Items/Tools/BronzeHoe.png | Bin 0 -> 278 bytes .../Graphics/Items/Tools/BronzePickaxe.png | Bin 0 -> 311 bytes .../Graphics/Items/Tools/BronzeWateringCan.png | Bin 0 -> 362 bytes .../Content/Graphics/Items/Tools/SteelAxe.png | Bin 0 -> 280 bytes .../Content/Graphics/Items/Tools/SteelHoe.png | Bin 0 -> 307 bytes .../Content/Graphics/Items/Tools/SteelPickaxe.png | Bin 0 -> 328 bytes .../Graphics/Items/Tools/SteelWateringCan.png | Bin 0 -> 374 bytes .../Content/Graphics/Items/Tools/TitaniumAxe.png | Bin 0 -> 301 bytes .../Content/Graphics/Items/Tools/TitaniumHoe.png | Bin 0 -> 306 bytes .../Graphics/Items/Tools/TitaniumPickaxe.png | Bin 0 -> 330 bytes .../Graphics/Items/Tools/TitaniumWateringCan.png | Bin 0 -> 413 bytes 12 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeAxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeHoe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzePickaxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeWateringCan.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCan.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumAxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumHoe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumPickaxe.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumWateringCan.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeAxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeAxe.png new file mode 100644 index 0000000000000000000000000000000000000000..e59ebe71abf794b95da9e4e54c71a173f39c592b GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|PJ6mIhFJ6_ zCnzwjC@}sL{xI!Fzi;0}iL-zG1j-)Tv9W0~a{Rs!+!3di6vM#$*N=zCZBxyXoeXzH z4FY!bH#$bn@DTUlG%zTc@BHDaiiE^AH^&<~Ehe`;7qiWq#lp<2KWS@4Y=ZjP5Ax5R zr^^SJs^_IA-1y1iFL1-t_>caE2fz7?8FjSgFE##CKK-!VQjJ;5D>naiFWg1dgG}N_s=z9x$l$u zqd$kkQT#x|L>>7#cV8YqKVc=aVM~I9MYrLf`Oo?_|NXSLcmBDo|3_?s`q>Zv&9#}G zuetf0wfPe-DIxKp;-KHGhxTV~R>vC}9O7xrw5xc@&+Ml!67k`0xZuBo8(tmKZ*%q+ z%t|mkbl|{&g4d#HQx2KFKl$)ae8NHZni56p>MnEXpR>4ie*C-bIe9|BibaxX3^!+K avNE(y@eBWF=Gq4I8-u5-pUXO@geCwPId;?l literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzePickaxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzePickaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..b56fef653276f8bd3c5e902927e90d85048e627e GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|K6<)1hFJ6_ zryO9Kb5!D=v4Mes&2PSk@&C^p=`e$OE85w@U%!i(>eCxzqvN^ z;f2e2dMtdeJ!#FD^e81^#y`dACthX!6R3LhWP@g8!olzNk3TU#Jk59w zkFa0Op_P);q73KQ9-aNRzL8bF@?(!&!k3FY#tk`Vr!X-{FU|2ZU0>k|^gM&7tDnm{ Hr-UW|>!5!P literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeWateringCan.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/BronzeWateringCan.png new file mode 100644 index 0000000000000000000000000000000000000000..7e157bca1947f8b751614dc674f730e86fb81839 GIT binary patch literal 362 zcmV-w0hRuVP)Px$BuPX;R5*?8lCev}KorJ*IkRNQP%r@(hZH&$>RQ~49Xklc%|D=9cSrGW=pW$b z;^15dXNLxzB8cD+ND2`%)Io9%&oePmTpWFH+`ad{@4N3F2mfI;3zII|bK1c9T^kEv z*OSmkj{+D6P?RmKu8U0jlG{zxIDn%Ih{{a>25Lpeh10!CWYR^?hLYRnW+QO<0A~jP zt4|lMl6tn5CyoNC0c=eB=#zc8&!JRMyu$Spyu88Vv#dB5XEzD#ZVNHa;Wqo2fvaFP zgySn|?reR1l5qyGOdw97=R;nAsy7XJnN(!cGeU6+ixkW3R_LP-2SUo$;5k1#IFE!> zAG*Crv52Z6dX9)SotSeoTAw5I(LKKnG?srAFe1&`cjP~bckYC2<%HrSW&i*H07*qo IM6N<$f~@G7fB*mh literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxe.png new file mode 100644 index 0000000000000000000000000000000000000000..11919fea4e9e87fc4e0bbf007d25651a28ec64eb GIT binary patch literal 280 zcmV+z0q6dSP)Px#(n&-?R5*>Tk}(RxKoCV=M8s+fQ^mo;D~Lsk#S3V^*T`YKM6My$7MfD9kS$|j zE4UW2fy5-N;%k@p=g+VZfY#b+tzFw&6e5cV0M=RtmpuSG`*sH*4Ll;kVy3=p&}`wc z)*>Qd0V}})B-#KliDLk6Wyvs9_DtfKX_8a{y*F41&hPx3>zZ5?1$mxFodI4xT<_Jz zPsd|T?w!0{k6g39F~%8VTK_{uma0~{i`oiVs@!Jz;9QQY+QInRS*n62f5=&?f@}Xz e_5nZ3|KJ70hE!~B{0Sxi0000Px#?MXyIR5*>rkfCk@K@>#~ZL>|y2u9Hft`-8Q6_d3i5S9B6O~rl;S^l98k7`yE z#PS0WLh1-blrgVrDP#lP(4<`T^4>c)xfiajT9qejtrT;XWk<|i71$U9KwWD9IW#$I zP{4JqnT=9bKT5ERRpY9+sNUy1wEH*{+;+z8@2m-wKoQ#l!N}lu=Z&T0v^5^HURDfZc zmiZ)9GJbuKBvev5{-($vgMM&1oPPx$0!c(cR5*>jk+Dj|KomvKh=^4fu#$DZ>7M_W6x`j6V@SV|mRs%OWZ5 zHd6{=D?wo_;sn>t7*X(cGjGnF``%MbsH&;};JpVxMAXzffYVgLT8p)ozV87-ycZF* zG{br2QIiHu(y2!%a%_~pO=Sf&ZRNJ=GvF~rsLS1CxxH_YyA=E_{;=cb6jt0Mm a|EhQ4Y;=fk3lEwA0000Px$FiAu~R5*?8k}+?>Fc5{mw1~x98K@%_iP@RhAuB`n{6+FJ!f#0CNK_&silan? z1rfPJaRf=FE**P|?YsBhy|WGf;S3W&5EvoE2pC1t2n#TIJSe5i$6|piCDZA2h&7KQ zVHlbyik!(1SuU5X*Xv#+2m-TOtpJQ;J6nN`@8e1d(7U)^uN?E7 z&%*%#>oQ3aUc)dn+wGRF>kvZF-EI^`!L944n})h+IJYgXl+<<2`(6Cpwv=Vbi|uf? z1i;&D_B4_!CC5AmpwgOs98+mcmSx`pwrI(f);-zQ>{v;Xkfy0)S4SyjHoi}#HJ8f; zA;idmZL*JJ(lmW~&dEK|U!v!ER9cUm*!?g@pF=5SJkJ{et>s?@tjI9;6Zuc#3k02% Uk%THxO#lD@07*qoM6N<$f=%+GssI20 literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumAxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumAxe.png new file mode 100644 index 0000000000000000000000000000000000000000..ab07d5dc9afe5e33f2b238a8406133a4e421af7a GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|o_o4DhFJ6_ zCnzw@SZ(>oJiPcvzi(fw#My)Y77CnmYy1Bup5FijWU5XbIB@_7Tza?@6mHm0Ip{Hs z-?e9=M6brWhNi93;l>`Erv=j+=9(O?X9I%yD^~J=fSZ~dm=0F=QI}yeIBSrQl62(2 zspbcdd6}&<+x{Ea|9?{EaM5OAs@36NkGl(gAMl&?u)dM?e*FyYguu#z*B}2kPAiO9 zEaLiEB!Aog7w7o5^eC^{d7z1Zby^IADi4>=kAJ^s{7KvKc^dP)fDSf;bn%D}f~m%B mX-^my&rh4dn3BB===r>?fCWmu43a=EGkCiCxvXs{ZVs zYjU{WI@55Km-n~0|B|hQc_j-T6=l_|w_x+cc z)Y1TS*niD?IZv|nHaz&9uYT4c{j34=iEBQZ3=AQC(K{9^UJn8Ko59o7&t;ucLK6UN C9);fk literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumPickaxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/TitaniumPickaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..69674bd0f6dc7f7379dd330a9d60a598caf6e94c GIT binary patch literal 330 zcmV-Q0k!^#P)Px$1W80eR5*>jk}*reKp2Lf6XR5F&@s44e?SN%E+M;ugYd~0Qb{7yw1vN1(>ku3}0`t5x^D(C}$<-qcKr873Vj)!bO!Urbv_q zfMXA`Sj)lQ2eS#x@SU1f!B|ehHTFjdMU)TVC c9sa960el^9k*&4%P)Px$S4l)cR5*?8lFutdQ545NkB5yc?AR%$h|TTRlw`~by+2_729zwsET%Lyi&0ko z4Ov*oSeYUEdR=aa&PB3i2DPTwI?6Fg!3qkM3h7zhp%` znbEV;9)Na@vk~yCK5NVC0CtMk04imlv*SxVnbE2AB(K3ouRXh%)AI{+yg4DkeMnD# zCs((ZJlzM>Zxr<#g=#2-6uj`r@Zcx_s-ZYJJf+Pze2xS_Z&%;9F9|8|t3CkDP_ezU zMKe@9Jl}l?n5H2&LuJXPC!_%2pmao~R(4EoJ189iu(!W!9isa%M8E1=GGMb?sg)ge zuuFum8)$~gibRE@5j&1#VoIlHCSt&-`>z5V literal 0 HcmV?d00001 From f4828fae492f62038cd7d34188565009f69aba19 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 7 Sep 2019 15:19:33 -0700 Subject: [PATCH 36/98] Renamed steel tools to be hardened tools. Added in the three new tool tiers into the object manager. --- .../Tools/{SteelAxe.png => HardenedAxe.png} | Bin ...lAxeWorking.png => HardenedAxeWorking.png} | Bin .../Tools/{SteelHoe.png => HardenedHoe.png} | Bin ...lHoeWorking.png => HardenedHoeWorking.png} | Bin .../{SteelPickaxe.png => HardenedPickaxe.png} | Bin ...Working.png => HardenedPickaxeWorking.png} | Bin ...ateringCan.png => HardenedWateringCan.png} | Bin ...ing.png => HardenedWateringCanWorking.png} | Bin .../Framework/Objects/ObjectManager.cs | 41 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 11 ----- 10 files changed, 41 insertions(+), 11 deletions(-) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelAxe.png => HardenedAxe.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelAxeWorking.png => HardenedAxeWorking.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelHoe.png => HardenedHoe.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelHoeWorking.png => HardenedHoeWorking.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelPickaxe.png => HardenedPickaxe.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelPickaxeWorking.png => HardenedPickaxeWorking.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelWateringCan.png => HardenedWateringCan.png} (100%) rename GeneralMods/Revitalize/Content/Graphics/Items/Tools/{SteelWateringCanWorking.png => HardenedWateringCanWorking.png} (100%) diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedAxe.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxe.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedAxe.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedAxeWorking.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelAxeWorking.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedAxeWorking.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedHoe.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoe.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedHoe.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedHoeWorking.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelHoeWorking.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedHoeWorking.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxe.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedPickaxe.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxe.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedPickaxe.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxeWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedPickaxeWorking.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelPickaxeWorking.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedPickaxeWorking.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCan.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedWateringCan.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCan.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedWateringCan.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCanWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedWateringCanWorking.png similarity index 100% rename from GeneralMods/Revitalize/Content/Graphics/Items/Tools/SteelWateringCanWorking.png rename to GeneralMods/Revitalize/Content/Graphics/Items/Tools/HardenedWateringCanWorking.png diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index d2efea64..0608cb30 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -3,10 +3,14 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Xna.Framework; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.Interfaces; +using Revitalize.Framework.Objects.Items.Tools; using StardewModdingAPI; using StardewValley; +using StardustCore.Animations; +using StardustCore.UIUtilities; namespace Revitalize.Framework.Objects { @@ -100,6 +104,43 @@ namespace Revitalize.Framework.Objects public void loadInItems() { this.resources.loadInItems(); + + this.loadInTools(); + } + + private void loadInTools() + { + PickaxeExtended bronzePick = new PickaxeExtended(new BasicItemInformation("Bronze Pickaxe", "Omegasis.Revitalize.Items.Tools.BronzePickaxe", "A sturdy pickaxe made from bronze.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "BronzePickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzePickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzePickaxeWorking")); + PickaxeExtended steelPick = new PickaxeExtended(new BasicItemInformation("Hardened Pickaxe", "Omegasis.Revitalize.Items.Tools.HardenedPickaxe", "A sturdy pickaxe made from hardened alloy.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "HardenedPickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedPickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 3, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedPickaxeWorking")); + PickaxeExtended titaniumPick = new PickaxeExtended(new BasicItemInformation("Titanium Pickaxe", "Omegasis.Revitalize.Items.Tools.TitaniumPickaxe", "A sturdy pickaxe made from titanium.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "TitaniumPickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumPickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 4, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumPickaxeWorking")); + + AxeExtended bronzeAxe= new AxeExtended(new BasicItemInformation("Bronze Axe", "Omegasis.Revitalize.Items.Tools.BronzeAxe", "A sturdy axe made from bronze.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "BronzeAxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzeAxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzeAxeWorking")); + AxeExtended steelAxe = new AxeExtended(new BasicItemInformation("Hardened Axe", "Omegasis.Revitalize.Items.Tools.HardenedAxe", "A sturdy axe made from hardened alloy.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "HardenedAxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedAxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),3,TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedAxeWorking")); + AxeExtended titaniumAxe = new AxeExtended(new BasicItemInformation("Titanium Axe", "Omegasis.Revitalize.Items.Tools.TitaniumAxe", "A sturdy axe made from Titanium.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "TitaniumAxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumAxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 4, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumAxeWorking")); + + HoeExtended bronzeHoe = new HoeExtended(new BasicItemInformation("Bronze Hoe", "Omegasis.Revitalize.Items.Tools.BronzeHoe", "A sturdy hoe made from bronze.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "BronzeHoe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzeHoe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzeHoeWorking")); + HoeExtended steelHoe = new HoeExtended(new BasicItemInformation("Hardened Hoe", "Omegasis.Revitalize.Items.Tools.HardenedHoe", "A sturdy hoe made from hardened alloy.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "HardenedHoe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedHoe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 3, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "HardenedHoeWorking")); + HoeExtended titaniumHoe = new HoeExtended(new BasicItemInformation("Titanium Hoe", "Omegasis.Revitalize.Items.Tools.TitaniumHoe", "A sturdy hoe made from titanium.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "TitaniumHoe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumHoe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 4, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "TitaniumHoeWorking")); + + WateringCanExtended bronzeCan = new WateringCanExtended(new BasicItemInformation("Bronze Watering Can", "Omegasis.Revitalize.Items.Tools.BronzeWateringCan", "A sturdy watering can made from bronze.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "BronzeWateringCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzeWateringCan"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 1, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzeWateringCanWorking"),70); + 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); + + this.Tools.Add("BronzePickaxe", bronzePick); + this.Tools.Add("HardenedPickaxe", steelPick); + this.Tools.Add("TitaniumPickaxe", titaniumPick); + + this.Tools.Add("BronzeAxe", bronzeAxe); + this.Tools.Add("HardenedAxe", steelAxe); + this.Tools.Add("TitaniumAxe", titaniumAxe); + + this.Tools.Add("BronzeHoe", bronzeHoe); + this.Tools.Add("HardenedHoe", steelHoe); + this.Tools.Add("TitaniumHoe", titaniumHoe); + + this.Tools.Add("BronzeWateringCan", bronzeCan); + this.Tools.Add("HardenedWateringCan", steelCan); + this.Tools.Add("TitaniumWateringCan", titaniumCan); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 755674ea..eed1280b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -546,18 +546,7 @@ namespace Revitalize //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench")); - //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); - //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); - //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); - //Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous)); - //Game1.player.addItemToInventory(ObjectManager.getStorageFuriture("Omegasis.Revitalize.Furniture.Storage.OakCabinet")); - /* - StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe(); - Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe); - axe =(StardewValley.Tools.Axe)Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"),typeof(StardewValley.Tools.Axe)); - //Game1.player.addItemToInventory(axe); - */ Game1.player.addItemToInventory(new StardewValley.Object((int)Enums.SDVObject.Coal, 1)); Game1.player.addItemByMenuIfNecessary(ModCore.ObjectManager.GetItem("SteelIngot", 20)); PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); From b6a817608f80f08e2050a92c9b96760c411a5331 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 7 Sep 2019 15:54:45 -0700 Subject: [PATCH 37/98] Fixed bug when getting tools from object manager. Added in all of the crafting recipes for tools. --- .../Framework/Crafting/CraftingRecipeBook.cs | 123 +++++++++++++++++- .../Framework/Objects/ObjectManager.cs | 2 +- GeneralMods/Revitalize/ModCore.cs | 8 +- GeneralMods/Revitalize/Revitalize.csproj | 84 +++++++++++- 4 files changed, 201 insertions(+), 16 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index 825f483e..ebd98466 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -207,6 +207,10 @@ namespace Revitalize.Framework.Crafting private static void InitializeRecipeBooks() { + //~~~~~~~~~~~~~~~~~~~// + // Workbench Recipes // + //~~~~~~~~~~~~~~~~~~~// + #region CraftingRecipeBook WorkbenchRecipes = new CraftingRecipeBook("Workbench"); WorkbenchRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f),true); WorkbenchRecipes.addCraftingRecipe("Anvil", new UnlockableCraftingRecipe("Default", new Recipe(new List() @@ -215,6 +219,27 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)), true)); + + WorkbenchRecipes.addCraftingRecipe("Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,10),10) + },new CraftingRecipeComponent(new StardewValley.Tools.Pickaxe() {UpgradeLevel=0},1)),true)); + WorkbenchRecipes.addCraftingRecipe("Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,10),10) + }, new CraftingRecipeComponent(new StardewValley.Tools.Axe() { UpgradeLevel = 0 }, 1)), true)); + WorkbenchRecipes.addCraftingRecipe("Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,10),10) + }, new CraftingRecipeComponent(new StardewValley.Tools.Hoe() { UpgradeLevel = 0 }, 1)), true)); + WorkbenchRecipes.addCraftingRecipe("Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), + }, new CraftingRecipeComponent(new StardewValley.Tools.WateringCan() { UpgradeLevel = 0 }, 1)), true)); + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) @@ -233,17 +258,101 @@ namespace Revitalize.Framework.Crafting { CraftingRecipesByGroup.Add("Workbench", WorkbenchRecipes); } + #endregion + //~~~~~~~~~~~~~~~~~~// + // Anvil Recipes // + //~~~~~~~~~~~~~~~~~~// CraftingRecipeBook AnvilRecipes = new CraftingRecipeBook("Anvil"); AnvilRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); - /* - WorkbenchRecipes.addCraftingRecipe("Nothing", new UnlockableCraftingRecipe("Default", new Recipe(new List() - { - //Inputs here - new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,1),1), - }, new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), true)); - */ + + //~~~~~~~~~~~~~~~~~~~~~~~// + //Alternate Vanilla Tools// + //~~~~~~~~~~~~~~~~~~~~~~~// + #region + //Watering Cans + AnvilRecipes.addCraftingRecipe("Bronze Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot",15),15), + new CraftingRecipeComponent(new StardewValley.Tools.WateringCan(){ UpgradeLevel=0},1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeWateringCan"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Hardened Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot",10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot",5),5), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeWateringCan"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedWateringCan"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Titanium Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot",15),15), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedWateringCan"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumWateringCan"), 1)), true)); + + //Pickaxes + AnvilRecipes.addCraftingRecipe("Bronze Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot",15),15), + new CraftingRecipeComponent(new StardewValley.Tools.Pickaxe(){ UpgradeLevel=0},1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzePickaxe"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Hardened Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot",10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot",5),5), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzePickaxe"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedPickaxe"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Titanium Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot",15),15), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedPickaxe"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumPickaxe"), 1)), true)); + + //Axes + AnvilRecipes.addCraftingRecipe("Bronze Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot",15),15), + new CraftingRecipeComponent(new StardewValley.Tools.Axe(){ UpgradeLevel=0},1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeAxe"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Hardened Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot",10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot",5),5), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeAxe"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedAxe"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Titanium Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot",15),15), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedAxe"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumAxe"), 1)), true)); + + ///Plows + AnvilRecipes.addCraftingRecipe("Bronze Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot",15),15), + new CraftingRecipeComponent(new StardewValley.Tools.Hoe(){ UpgradeLevel=0},1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeHoe"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Hardened Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot",10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot",5),5), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeHoe"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedHoe"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Titanium Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot",15),15), + new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedHoe"),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumHoe"), 1)), true)); + + #endregion + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 0608cb30..49e48b60 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -303,7 +303,7 @@ namespace Revitalize.Framework.Objects /// public Item GetTool(string Name) { - if (this.Tools.ContainsKey("Name")) return this.Tools[Name].getOne(); + if (this.Tools.ContainsKey(Name)) return this.Tools[Name].getOne(); else return null; } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index eed1280b..e3da2283 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -547,13 +547,11 @@ namespace Revitalize Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench")); - Game1.player.addItemToInventory(new StardewValley.Object((int)Enums.SDVObject.Coal, 1)); - Game1.player.addItemByMenuIfNecessary(ModCore.ObjectManager.GetItem("SteelIngot", 20)); - PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); + //PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); Game1.player.addItemsByMenuIfNecessary(new List() { - pick, - new StardewValley.Object((int)Enums.SDVObject.Wood,100) + new StardewValley.Object((int)Enums.SDVObject.Wood,100), + ModCore.ObjectManager.GetItem("SteelIngot", 20) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 50a53b47..735320a3 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -242,18 +242,96 @@ PreserveNewest - - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest From 50dcdf0eb68cab2579dc178f439af077658cda82 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 7 Sep 2019 19:04:24 -0700 Subject: [PATCH 38/98] Added in robin selling the workbench, the anvil crafting trashcans, and craftable trashcans which toss away anything put inside of them. --- .../Objects/Furniture/Misc/TrashCan.png | Bin 0 -> 563 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 6 + .../Framework/Energy/EnergyManager.cs | 180 +++++++++ .../Framework/Energy/IEnergyInterface.cs | 19 + .../Revitalize/Framework/Enums/Enums.cs | 11 + .../Revitalize/Framework/Hacks/ShopHacks.cs | 13 +- .../Framework/Menus/InventoryMenuPage.cs | 3 +- .../Framework/Objects/BasicItemInformation.cs | 31 +- .../Framework/Objects/CustomObject.cs | 139 ++++++- .../Framework/Objects/Extras/TrashCanTile.cs | 350 ++++++++++++++++++ .../Framework/Objects/MultiTiledComponent.cs | 4 +- .../Framework/Objects/MultiTiledObject.cs | 2 +- .../Framework/Objects/ObjectManager.cs | 43 ++- GeneralMods/Revitalize/ModCore.cs | 29 +- GeneralMods/Revitalize/Revitalize.csproj | 6 + 15 files changed, 799 insertions(+), 37 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Furniture/Misc/TrashCan.png create mode 100644 GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs create mode 100644 GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Furniture/Misc/TrashCan.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Furniture/Misc/TrashCan.png new file mode 100644 index 0000000000000000000000000000000000000000..f9f59003f7e8f27d3e5cf2bc0468f03dd37f3976 GIT binary patch literal 563 zcmV-30?hr1P)Px$?MXyIR7i>Kl+S7tQ5431Ne4lLg*xEaW=tm(VWT5BvWwbqTl9n<~!ea{@mfh4Q}v1pj1RS zjvJ?A-}hGLT16t)b@I6hmo`fb9LJ4a*Fo3S%8ul_=>-6>m{=k{eDgXZXf=;AvGBUC z#4PrGuVgun8*8nW#Q70g%_Gu9=6qZpMEy*n=>>>ksv24=X+HxCz?dt-eePsL>G_Lx zV*w1JJ{YiVI}uz5(+luCpGmtz>G9J?akWw-JxaAwLu-{7rr~)$gQ(A~?ghZYKsw2r zpVh{71kn7Z1v30P| zi@lemuRSqHI+-spztBdbkvR(uq?)cPv{vk@9kf>5yMH@53k}k(?W&zjVm`jMgMUHU zI*VFzZSqF~90xx#iTQY`gW+%pz^|X() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),5) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TrashCan"), 1)),true)); + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) diff --git a/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs b/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs new file mode 100644 index 00000000..5bb23e53 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Energy +{ + public class EnergyManager + { + + /// + /// The remaining energy left in this system. + /// + public int remainingEnergy; + /// + /// The maximum amount of energy this system can store. + /// + public int maxEnergy; + + public bool requiresUpdate; + /// + /// How does this energy manager interface energy systems. + /// + public Enums.EnergyInteractionType energyInteractionType; + + /// + /// Checks to see if this energy manager consumes energy. + /// + public bool consumesEnergy + { + get + { + return this.energyInteractionType == Enums.EnergyInteractionType.Consumes; + } + } + /// + /// Checks to see if this energy manager produces energy. + /// + public bool producesEnergy + { + get + { + return this.energyInteractionType == Enums.EnergyInteractionType.Produces; + } + } + + /// + /// Checks to see if this energy manager transfers energy. + /// + public bool transfersEnergy + { + get + { + return this.energyInteractionType == Enums.EnergyInteractionType.Transfers; + } + } + /// + /// Does this energy system have energy. + /// + public bool hasEnergy + { + get + { + return this.remainingEnergy > 0; + } + } + /// + /// Checks to see if this energy system has any energy left. + /// + public bool hasMaxEnergy + { + get + { + return this.remainingEnergy == this.maxEnergy; + } + } + /// + /// Checks to see if this system can receive any energy externally. + /// + public bool canReceieveEnergy + { + get + { + return !this.hasMaxEnergy; + } + } + + public int capacityRemaining + { + get + { + return this.maxEnergy - this.remainingEnergy; + } + } + + public EnergyManager() + { + + } + + public EnergyManager(int Capacity) : this(0, Capacity) + { + } + + public EnergyManager(int CurrentEnergy, int MaxEnergy) + { + this.remainingEnergy = CurrentEnergy; + this.maxEnergy = MaxEnergy; + } + + + /// + /// Checks to see if this energy source has enough energy remaining. + /// + /// + /// + public bool hasEnoughEnergy(int Required) + { + return this.remainingEnergy >= Required; + } + + + public void consumeEnergy(int amount) + { + int amountBeforeConsumption = this.remainingEnergy; + this.remainingEnergy = Math.Max(0, this.remainingEnergy - amount); + if (this.remainingEnergy != amountBeforeConsumption) + { + this.requiresUpdate = true; + } + } + + public void produceEnergy(int amount) + { + int amountBeforeProduction = this.remainingEnergy; + this.remainingEnergy = Math.Min(this.maxEnergy, this.remainingEnergy + amount); + if (this.remainingEnergy != amountBeforeProduction) + { + this.requiresUpdate = true; + } + } + + public void transferEnergyFromAnother(EnergyManager other,int amount) + { + if (this.canReceieveEnergy) + { + int actualAmount = Math.Min(amount,other.remainingEnergy); + int selfCapacity = this.capacityRemaining; + this.produceEnergy(Math.Min(actualAmount, selfCapacity)); + other.consumeEnergy(Math.Min(actualAmount, selfCapacity)); + } + else + { + return; + } + } + + public void transferEnergyToAnother(EnergyManager other, int amount) + { + if (other.canReceieveEnergy) + { + int actualAmount = Math.Min(amount, this.remainingEnergy); + int selfCapacity = other.capacityRemaining; + other.produceEnergy(Math.Min(actualAmount, selfCapacity)); + this.consumeEnergy(Math.Min(actualAmount, selfCapacity)); + } + else + { + return; + } + } + + public EnergyManager Copy() + { + return new EnergyManager(this.maxEnergy); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs b/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs new file mode 100644 index 00000000..86fc4322 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Energy +{ + public interface IEnergyInterface + { + EnergyManager EnergyManager + { + get; + set; + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index 825f1574..a2bee1b0 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -22,6 +22,17 @@ namespace Revitalize.Framework Left } + /// + /// The types of interaction for energy that exists. + /// + public enum EnergyInteractionType + { + None, + Produces, + Consumes, + Transfers + } + /// /// References Stardew Valley Object id's for easier coding. /// diff --git a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs index 1e178c61..cb5e5652 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs @@ -13,10 +13,21 @@ namespace Revitalize.Framework.Hacks public class ShopHacks { + public static void AddInCustomItemsToShops() + { + AddItemsToRobinsShop(); + AddOreToClintsShop(); + } + + + private static void AddItemsToRobinsShop() + { + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.GetItem("Workbench", 1), 500), "Robin"); + } /// /// Adds in ore to clint's shop. /// - public static void AddOreToClintsShop() + private static void AddOreToClintsShop() { PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),ModCore.Configs.shops_blacksmithConfig.tinOreSellPrice), "Clint"); PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), ModCore.Configs.shops_blacksmithConfig.bauxiteOreSellPrice), "Clint"); diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs index 0214a6d8..3d07efb3 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs @@ -39,8 +39,7 @@ namespace Revitalize.Framework.Menus } /// - /// //TODO: Combine two of these to make an item grab menu. - /// TODO: Display Item information on hover. + /// An inventory menu that displays the contents of an inventory but doesn't do much else. /// public class InventoryMenu : IClickableMenuExtended { diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index c5e8c3c9..23419ab0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -304,6 +304,20 @@ namespace Revitalize.Framework.Objects } } + private Energy.EnergyManager _energyManager; + public Energy.EnergyManager EnergyManager + { + get + { + return this._energyManager; + } + set + { + this._energyManager = value; + this.requiresUpdate = true; + } + } + [JsonIgnore] public bool requiresUpdate; public BasicItemInformation() @@ -326,9 +340,10 @@ namespace Revitalize.Framework.Objects this.facingDirection = Enums.Direction.Down; this.id = ""; this.shakeTimer = 0; + this.EnergyManager = new Energy.EnergyManager(); } - public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null) { this.name = name; this.id = id; @@ -357,7 +372,8 @@ namespace Revitalize.Framework.Objects this.lightManager = Lights ?? new LightManager(); this.facingDirection = Enums.Direction.Down; this.shakeTimer = 0; - + + this.EnergyManager = EnergyManager ?? new Energy.EnergyManager(); } /// @@ -375,12 +391,12 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy()); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy()); } public bool requiresSyncUpdate() { - return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate(); + return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate() || this.energyManagerRequiresUpdate(); } public void forceUpdate() @@ -403,12 +419,19 @@ namespace Revitalize.Framework.Objects else return this._lightManager.requiresUpdate; } + private bool energyManagerRequiresUpdate() + { + if (this._energyManager == null) return false; + else return this._energyManager.requiresUpdate; + } + public void cleanAfterUpdate() { this.requiresUpdate = false; this._inventory.requiresUpdate = false; this._animationManager.requiresUpdate = false; this._lightManager.requiresUpdate = false; + this._energyManager.requiresUpdate = false; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 9ffadbf1..b1e06ece 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -9,6 +9,7 @@ using StardustCore.Animations; using StardewValley; using StardewValley.Objects; using Revitalize.Framework.Utilities; +using Revitalize.Framework.Energy; namespace Revitalize.Framework.Objects { @@ -18,7 +19,7 @@ namespace Revitalize.Framework.Objects // -Inventories /// A custom object template. - public class CustomObject : PySObject + public class CustomObject : PySObject,IEnergyInterface { public virtual string text @@ -167,6 +168,29 @@ namespace Revitalize.Framework.Objects } } + /// + /// Accesses the energy manager for all objects. + /// + public EnergyManager EnergyManager + { + get + { + if (this.info == null) + { + this.updateInfo(); + return this.info.EnergyManager; + } + else + { + return this.info.EnergyManager; + } + } + set + { + this.info.EnergyManager = value; + } + } + /// The display texture for this object. [JsonIgnore] public Texture2D displayTexture => this.animationManager.getTexture(); @@ -355,6 +379,11 @@ namespace Revitalize.Framework.Objects /// What happens when a player uses a tool on this object. public override bool performToolAction(Tool t, GameLocation location) { + if (t == null) + { + return true; + } + if (t.GetType() == typeof(StardewValley.Tools.Axe) || t.GetType() == typeof(StardewValley.Tools.Pickaxe)) { Game1.createItemDebris(this, Game1.player.getStandingPosition(), Game1.player.getDirection()); @@ -702,5 +731,113 @@ namespace Revitalize.Framework.Objects return serializedInfo; } #endregion + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + if (this.location == null) + { + this.location = environment; + } + base.updateWhenCurrentLocation(time, environment); + } + + /// + /// Gets a list of neighboring tiled objects that produce or transfer energy. This should be used for machines/objects that consume or transfer energy + /// + /// + public List GetNeighboringEnergyTransferProducers() + { + Vector2 tileLocation = this.TileLocation; + List customObjects = new List(); + if (this.location != null) + { + for(int i = -1; i <= 1; i++) + { + for(int j = -1; j <= 1; j++) + { + if (i == j || i== (-j)) continue; + + Vector2 neighborTile = tileLocation + new Vector2(i, j); + if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) + { + StardewValley.Object obj=this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); + if (obj is CustomObject) + { + if((obj as CustomObject).EnergyManager.energyInteractionType== Enums.EnergyInteractionType.Produces || (obj as CustomObject).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers) + { + customObjects.Add((CustomObject)obj); + } + } + else continue; + } + } + } + } + + + return customObjects; + + } + + /// + /// Gets a list of neighboring tiled objects that consume or transfer energy. This should be used for machines/objects that produce or transfer energy + /// + /// + public List GetNeighboringEnergyTransferConsumers() + { + Vector2 tileLocation = this.TileLocation; + List customObjects = new List(); + if (this.location != null) + { + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i == j || i == (-j)) continue; + + Vector2 neighborTile = tileLocation + new Vector2(i, j); + if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) + { + StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); + if (obj is CustomObject) + { + if ((obj as CustomObject).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes || (obj as CustomObject).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers) + { + customObjects.Add((CustomObject)obj); + } + } + else continue; + } + } + } + } + + + return customObjects; + } + + /// + /// Gets the appropriate energy neighbors to move energy around from/to. + /// + /// + public List getAppropriateEnergyNeighbors() + { + if (this.EnergyManager.consumesEnergy) + { + return this.GetNeighboringEnergyTransferProducers(); + } + else if(this.EnergyManager.producesEnergy) + { + return this.GetNeighboringEnergyTransferConsumers(); + } + else if (this.EnergyManager.transfersEnergy) + { + List objs = new List(); + objs.AddRange(this.GetNeighboringEnergyTransferConsumers()); + objs.AddRange(this.GetNeighboringEnergyTransferProducers()); + return objs; + } + return new List(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs new file mode 100644 index 00000000..2363542e --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs @@ -0,0 +1,350 @@ +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 Microsoft.Xna.Framework.Input; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Utilities; +using Revitalize.Framework.Utilities.Serialization; +using StardewValley; + +namespace Revitalize.Framework.Objects.Extras +{ + public class TrashCanTile : MultiTiledComponent + { + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + } + } + public TrashCanTile() : base() + { + + } + + public TrashCanTile(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData, Info) + { + this.Price = Info.price; + } + + public TrashCanTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation) : base(PyTKData, Info, TileLocation) + { + this.Price = Info.price; + } + + + public override bool performObjectDropInAction(Item dropInItem, bool probe, Farmer who) + { + return false; //this.pickUpItem()==PickUpState.DoNothing; + //return base.performObjectDropInAction(dropInItem, probe, who); + } + + public override bool performDropDownAction(Farmer who) + { + return base.performDropDownAction(who); + } + + //Checks for any sort of interaction IF and only IF there is a held object on this tile. + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + MouseState mState = Mouse.GetState(); + KeyboardState keyboardState = Game1.GetKeyboardState(); + + if (mState.RightButton == ButtonState.Pressed && (!keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift))) + { + return this.rightClicked(who); + } + + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) + return this.shiftRightClicked(who); + + + //return base.checkForAction(who, justCheckingForActivity); + + if (justCheckingForActivity) + return true; + + return true; + + //return this.clicked(who); + //return false; + } + + public override bool performToolAction(Tool t, GameLocation location) + { + return base.performToolAction(t, location); + } + + public override bool performUseAction(GameLocation location) + { + return base.performUseAction(location); + } + + /// + /// Gets called when there is no actively held item on the tile. + /// + /// + /// + public override bool clicked(Farmer who) + { + return base.clicked(who); + } + + public override bool rightClicked(Farmer who) + { + if (Game1.player.ActiveObject != null) + { + if (this.containerObject.info.inventory != null && Game1.activeClickableMenu == null) + { + this.containerObject.info.inventory.addItem(Game1.player.ActiveObject); + Game1.player.Items.Remove(Game1.player.ActiveObject); + } + } + else + { + if (this.containerObject.info.inventory != null && Game1.activeClickableMenu == null) + { + this.containerObject.info.inventory.clear(); + Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, this.containerObject.info.inventory.items, this.containerObject.info.inventory.capacity); + } + } + return false; + } + + + public override bool shiftRightClicked(Farmer who) + { + return base.shiftRightClicked(who); + } + + + public override Item getOne() + { + TrashCanTile component = new TrashCanTile(this.data, this.info.Copy()); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + TrashCanTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + /* + /// What happens when the object is drawn at a tile location. + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + if (this.heldObject.Value != null) SpriteBatchUtilities.Draw(spriteBatch, this, this.heldObject.Value, alpha, addedDepth); + } + } + */ + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + if (objectPosition.X < 0) objectPosition.X *= -1; + if (objectPosition.Y < 0) objectPosition.Y *= -1; + base.drawWhenHeld(spriteBatch, objectPosition, f); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index dfd52595..8caed2fe 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -196,7 +196,9 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); + + + spriteBatch.Draw(this.displayTexture, location, new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); } public override Item getOne() diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 23234803..9e3ca2c0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -213,7 +213,7 @@ namespace Revitalize.Framework.Objects { this.updateInfo(); foreach (KeyValuePair pair in this.objects) - pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16)+new Vector2(32,32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 49e48b60..c41e3713 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -4,9 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Revitalize.Framework.Objects.CraftingTables; +using Revitalize.Framework.Objects.Extras; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Objects.Items.Tools; +using Revitalize.Framework.Utilities; using StardewModdingAPI; using StardewValley; using StardustCore.Animations; @@ -104,10 +107,48 @@ namespace Revitalize.Framework.Objects public void loadInItems() { this.resources.loadInItems(); - + this.loadInCraftingTables(); + this.loadInMachines(); this.loadInTools(); } + private void loadInCraftingTables() + { + MultiTiledObject WorkbenchObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(), Color.White, false, null, null)); + CraftingTableTile workbenchTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Workbench"); + CraftingTableTile workbenchTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Workbench"); + WorkbenchObj.addComponent(new Vector2(0, 0), workbenchTile_0_0); + WorkbenchObj.addComponent(new Vector2(1, 0), workbenchTile_1_0); + WorkbenchObj.addComponent(new Vector2(0, 1), workbenchTile_0_1); + WorkbenchObj.addComponent(new Vector2(1, 1), workbenchTile_1_1); + + MultiTiledObject AnvilObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(), Color.White, false, null, null)); + CraftingTableTile anvilTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Anvil"); + CraftingTableTile anvilTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Anvil"); + CraftingTableTile anvilTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Anvil"); + CraftingTableTile anvilTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Objects.Crafting", "Anvil"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Anvil"); + AnvilObj.addComponent(new Vector2(0, 0), anvilTile_0_0); + AnvilObj.addComponent(new Vector2(1, 0), anvilTile_1_0); + AnvilObj.addComponent(new Vector2(0, 1), anvilTile_0_1); + AnvilObj.addComponent(new Vector2(1, 1), anvilTile_1_1); + + this.AddItem("Workbench", WorkbenchObj); + this.AddItem("Anvil", AnvilObj); + } + + private void loadInMachines() + { + MultiTiledObject trashCan = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); + TrashCanTile trash1 = new TrashCanTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(TrashCanTile), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "TrashCan"), new Animation(0, 0, 16, 16)), Color.White, true, new InventoryManager(36), null, null)); + TrashCanTile trash2 = new TrashCanTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(TrashCanTile), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "TrashCan"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null)); + trashCan.addComponent(new Vector2(0, 0), trash1); + trashCan.addComponent(new Vector2(0, 1), trash2); + + this.AddItem("TrashCan", trashCan); + } + private void loadInTools() { PickaxeExtended bronzePick = new PickaxeExtended(new BasicItemInformation("Bronze Pickaxe", "Omegasis.Revitalize.Items.Tools.BronzePickaxe", "A sturdy pickaxe made from bronze.", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "BronzePickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzePickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "BronzePickaxeWorking")); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index e3da2283..9906fa8d 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -478,29 +478,6 @@ namespace Revitalize //ModCore.log("Added in SSC!"); - - MultiTiledObject WorkbenchObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(), Color.White, false, null, null)); - CraftingTableTile workbenchTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Workbench"); - CraftingTableTile workbenchTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Workbench"); - CraftingTableTile workbenchTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Workbench"); - CraftingTableTile workbenchTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Workbench"); - WorkbenchObj.addComponent(new Vector2(0,0),workbenchTile_0_0); - WorkbenchObj.addComponent(new Vector2(1, 0), workbenchTile_1_0); - WorkbenchObj.addComponent(new Vector2(0, 1), workbenchTile_0_1); - WorkbenchObj.addComponent(new Vector2(1, 1), workbenchTile_1_1); - - MultiTiledObject AnvilObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(), Color.White, false, null, null)); - CraftingTableTile anvilTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Anvil"); - CraftingTableTile anvilTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Anvil"); - CraftingTableTile anvilTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Anvil"); - CraftingTableTile anvilTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Anvil", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), typeof(CraftingTableTile), Color.White, true), new BasicItemInformation("Anvil", "Omegasis.Revitalize.Objects.Crafting.Anvil", "An anvil that can be used for crafting different machines and other metalic objects.", "Crafting", Color.Brown, -300, 0, false, 2000, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Anvil"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Anvil"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Anvil"); - AnvilObj.addComponent(new Vector2(0, 0), anvilTile_0_0); - AnvilObj.addComponent(new Vector2(1, 0), anvilTile_1_0); - AnvilObj.addComponent(new Vector2(0, 1), anvilTile_0_1); - AnvilObj.addComponent(new Vector2(1, 1), anvilTile_1_1); - - ObjectManager.AddItem("Workbench", WorkbenchObj); - ObjectManager.AddItem("Anvil", AnvilObj); } private void createDirectories() @@ -538,7 +515,7 @@ namespace Revitalize { this.loadContent(); Serializer.afterLoad(); - ShopHacks.AddOreToClintsShop(); + ShopHacks.AddInCustomItemsToShops(); ObjectInteractionHacks.AfterLoad_RestoreTrackedMachines(); @@ -546,12 +523,12 @@ namespace Revitalize //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench")); - //PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); Game1.player.addItemsByMenuIfNecessary(new List() { new StardewValley.Object((int)Enums.SDVObject.Wood,100), - ModCore.ObjectManager.GetItem("SteelIngot", 20) + ModCore.ObjectManager.GetItem("SteelIngot", 20), + ModCore.ObjectManager.GetItem("TrashCan",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 735320a3..690a59ad 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -66,6 +66,7 @@ + @@ -123,10 +124,12 @@ + + @@ -374,6 +377,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From a89cbc2c82937ba00a7f0e05b151399d87102146 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 9 Sep 2019 13:31:55 -0700 Subject: [PATCH 39/98] Started work on energy graph searching. Hoping the performance is decent. --- .../Revitalize/Framework/Enums/Enums.cs | 3 +- .../Framework/Objects/CustomObject.cs | 99 --------- .../Framework/Objects/MultiTiledComponent.cs | 206 ++++++++++++++++++ 3 files changed, 208 insertions(+), 100 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index a2bee1b0..dcc95fcb 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -30,7 +30,8 @@ namespace Revitalize.Framework None, Produces, Consumes, - Transfers + Transfers, + Storage } /// diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index b1e06ece..1937149c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -740,104 +740,5 @@ namespace Revitalize.Framework.Objects } base.updateWhenCurrentLocation(time, environment); } - - /// - /// Gets a list of neighboring tiled objects that produce or transfer energy. This should be used for machines/objects that consume or transfer energy - /// - /// - public List GetNeighboringEnergyTransferProducers() - { - Vector2 tileLocation = this.TileLocation; - List customObjects = new List(); - if (this.location != null) - { - for(int i = -1; i <= 1; i++) - { - for(int j = -1; j <= 1; j++) - { - if (i == j || i== (-j)) continue; - - Vector2 neighborTile = tileLocation + new Vector2(i, j); - if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) - { - StardewValley.Object obj=this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); - if (obj is CustomObject) - { - if((obj as CustomObject).EnergyManager.energyInteractionType== Enums.EnergyInteractionType.Produces || (obj as CustomObject).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers) - { - customObjects.Add((CustomObject)obj); - } - } - else continue; - } - } - } - } - - - return customObjects; - - } - - /// - /// Gets a list of neighboring tiled objects that consume or transfer energy. This should be used for machines/objects that produce or transfer energy - /// - /// - public List GetNeighboringEnergyTransferConsumers() - { - Vector2 tileLocation = this.TileLocation; - List customObjects = new List(); - if (this.location != null) - { - for (int i = -1; i <= 1; i++) - { - for (int j = -1; j <= 1; j++) - { - if (i == j || i == (-j)) continue; - - Vector2 neighborTile = tileLocation + new Vector2(i, j); - if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) - { - StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); - if (obj is CustomObject) - { - if ((obj as CustomObject).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes || (obj as CustomObject).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers) - { - customObjects.Add((CustomObject)obj); - } - } - else continue; - } - } - } - } - - - return customObjects; - } - - /// - /// Gets the appropriate energy neighbors to move energy around from/to. - /// - /// - public List getAppropriateEnergyNeighbors() - { - if (this.EnergyManager.consumesEnergy) - { - return this.GetNeighboringEnergyTransferProducers(); - } - else if(this.EnergyManager.producesEnergy) - { - return this.GetNeighboringEnergyTransferConsumers(); - } - else if (this.EnergyManager.transfersEnergy) - { - List objs = new List(); - objs.AddRange(this.GetNeighboringEnergyTransferConsumers()); - objs.AddRange(this.GetNeighboringEnergyTransferProducers()); - return objs; - } - return new List(); - } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 8caed2fe..8548401f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -371,5 +371,211 @@ namespace Revitalize.Framework.Objects MultiplayerUtilities.RequestUpdateSync(this.guid); } } + + + + + /// + /// Gets a list of neighboring tiled objects that produce or transfer energy. This should be used for machines/objects that consume or transfer energy + /// + /// + protected virtual List GetNeighboringOutputEnergySources() + { + Vector2 tileLocation = this.TileLocation; + List customObjects = new List(); + if (this.location != null) + { + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i == j || i == (-j)) continue; + + Vector2 neighborTile = tileLocation + new Vector2(i, j); + if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) + { + StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); + if (obj is MultiTiledComponent) + { + if ((obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + { + customObjects.Add((MultiTiledComponent)obj); + } + } + else continue; + } + } + } + } + + + return customObjects; + + } + + /// + /// Gets a list of neighboring tiled objects that consume or transfer energy. This should be used for machines/objects that produce or transfer energy + /// + /// + protected virtual List GetNeighboringInputEnergySources() + { + Vector2 tileLocation = this.TileLocation; + List customObjects = new List(); + if (this.location != null) + { + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i == j || i == (-j)) continue; + + Vector2 neighborTile = tileLocation + new Vector2(i, j); + if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) + { + StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); + if (obj is MultiTiledComponent) + { + if ((obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + { + customObjects.Add((MultiTiledComponent)obj); + } + } + else continue; + } + } + } + } + + + return customObjects; + } + + /// + /// Gets the appropriate energy neighbors to move energy around from/to. + /// + /// + protected virtual List getAppropriateEnergyNeighbors() + { + if (this.EnergyManager.consumesEnergy) + { + return this.GetNeighboringOutputEnergySources(); + } + else if (this.EnergyManager.producesEnergy) + { + return this.GetNeighboringInputEnergySources(); + } + else if (this.EnergyManager.transfersEnergy) + { + List objs = new List(); + objs.AddRange(this.GetNeighboringInputEnergySources()); + objs.AddRange(this.GetNeighboringOutputEnergySources()); + return objs; + } + return new List(); + } + + /// + /// Gets all of the energy nodes in a network that are either producers or is storage. + /// + /// + protected virtual List EnergyGraphSearchSources() + { + List energySources = new List(); + List searchedComponents = new List(); + List entitiesToSearch = new List(); + entitiesToSearch.AddRange(this.getAppropriateEnergyNeighbors()); + searchedComponents.Add(this); + while (entitiesToSearch.Count > 0) + { + MultiTiledComponent searchComponent = entitiesToSearch[0]; + entitiesToSearch.Remove(searchComponent); + if (searchedComponents.Contains(searchComponent)) + { + continue; + } + else + { + searchedComponents.Add(searchComponent); + entitiesToSearch.AddRange(searchComponent.getAppropriateEnergyNeighbors()); + + if (searchComponent.containerObject.info.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces || searchComponent.containerObject.info.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + { + energySources.Add(searchComponent.containerObject); + } + } + + } + return energySources; + } + + /// + /// Gets all of the energy nodes in a network that are either consumers or storage. This should ALWAYS be ran after EnergyGraphSearchSources + /// + /// + protected virtual List EnergyGraphSearchConsumers() + { + List energySources = new List(); + List searchedComponents = new List(); + List entitiesToSearch = new List(); + entitiesToSearch.AddRange(this.getAppropriateEnergyNeighbors()); + searchedComponents.Add(this); + while (entitiesToSearch.Count > 0) + { + MultiTiledComponent searchComponent = entitiesToSearch[0]; + entitiesToSearch.Remove(searchComponent); + if (searchedComponents.Contains(searchComponent)) + { + continue; + } + else + { + searchedComponents.Add(searchComponent); + entitiesToSearch.AddRange(searchComponent.getAppropriateEnergyNeighbors()); + + if (searchComponent.containerObject.info.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes || searchComponent.containerObject.info.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + { + energySources.Add(searchComponent.containerObject); + } + } + + } + return energySources; + } + + /// + /// Gets all nodes in a connected energy network and tries to drain the necessary amount of energy from the network. + /// + public void drainEnergyFromNetwork() + { + //Machines that consume should ALWAYS try to drain energy from a network first. + //Then producers should always try to store energy to a network. + //Storage should never try to push or pull energy from a network as consumers will pull from storage and producers will push to storage. + //Transfer nodes are used just to connect the network. + List energySources = this.EnergyGraphSearchSources(); + + int index = 0; + + for(int i = 0; i < energySources.Count; i++) + { + this.EnergyManager.transferEnergyFromAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); + if (this.EnergyManager.hasMaxEnergy) break; + } + } + + /// + /// Gets all of the nodes in a connected energy network and tries to store the necessary amount of energy from the network. + /// + public void storeEnergyToNetwork() + { + List energySources = this.EnergyGraphSearchConsumers(); + + int index = 0; + + for (int i = 0; i < energySources.Count; i++) + { + this.EnergyManager.transferEnergyToAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); + if (this.EnergyManager.hasEnergy) break; + } + } } } From 877e40ae395a8480817e65cbb335415a4ee900ba Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 9 Sep 2019 15:44:25 -0700 Subject: [PATCH 40/98] Added in simple machines and tested to make sure they produce items. They do for non-energy consuming items. Also added in the sandbox which is a wip. --- .../Graphics/Objects/Machines/Sandbox.png | Bin 0 -> 588 bytes .../Framework/Configs/ConfigManager.cs | 6 + .../Framework/Configs/GlobalMachineConfig.cs | 33 ++ .../Objects/Resources/OreFactoryInfo.cs | 2 +- .../Framework/Objects/CustomObject.cs | 3 +- .../OreResourceInformation.cs | 2 +- ...ceInformaton.cs => ResourceInformation.cs} | 17 +- .../Framework/Objects/Machines/Machine.cs | 356 +++++++++++++++++- .../Framework/Objects/MultiTiledComponent.cs | 61 +++ .../Framework/Objects/ObjectManager.cs | 33 ++ .../Framework/Objects/ResourceManager.cs | 14 +- .../Objects/Resources/OreVeins/OreVeinObj.cs | 2 +- .../Objects/Resources/OreVeins/OreVeinTile.cs | 14 +- GeneralMods/Revitalize/ModCore.cs | 8 +- GeneralMods/Revitalize/Revitalize.csproj | 6 +- 15 files changed, 533 insertions(+), 24 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Sandbox.png create mode 100644 GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs rename GeneralMods/Revitalize/Framework/Objects/InformationFiles/{ResourceInformaton.cs => ResourceInformation.cs} (89%) diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Sandbox.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Sandbox.png new file mode 100644 index 0000000000000000000000000000000000000000..0d6148dd5dc36492674cc4e79ad8a53853abbcc6 GIT binary patch literal 588 zcmV-S0<-;zP)Px%21!IgR9J=WmoZ2iQ5eU67F#M954p({ydDlt9ULk~M5t~qadmRDgpMhJ4($*J zA=I&I>g3d=YaIj?Qt<=_brA|J=MhX@j*{tUhtfgse0O^4|CVec$`? za)GY8>gt}=bMu;6N{y{`+Wez&($nj{F)l7yNF_REe(`evfL<{;H2AQC0Mr5iEUdi7 zwoFt_=g+SnJQ^H{oiuE{ZJDGqWdIJgr}^~ez4uuS0D!9LOynv+A5a0{sF17+;Ff?Bf}8t`0E{aNXEHX)lFs{M|P?TsMoS#qtSz_7dMy}}~OeBCT zaUTkR0-uGiUK=$QxvW3021FYs|{^KJ^D(!zVcB_Zm{{;Y<2J^T-d8HOu a*8c&1M!53P-5mJ<0000 + /// The config file to be used for machines. + /// + public GlobalMachineConfig machinesConfig; + public ConfigManager() { this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); this.shops_blacksmithConfig = Shops_BlacksmithConfig.InitializeConfig(); this.furnitureConfig = FurnitureConfig.InitializeConfig(); + this.machinesConfig = GlobalMachineConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs new file mode 100644 index 00000000..47c23192 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Configs +{ + public class GlobalMachineConfig + { + + public bool doMachinesConsumeEnergy; + + + public GlobalMachineConfig() + { + this.doMachinesConsumeEnergy = true; + } + + public static GlobalMachineConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "MachinesConfig.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "MachinesConfig.json")); + else + { + GlobalMachineConfig Config = new GlobalMachineConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "MachinesConfig.json"), Config); + return Config; + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Resources/OreFactoryInfo.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Resources/OreFactoryInfo.cs index 80824a4e..09880810 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Resources/OreFactoryInfo.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Resources/OreFactoryInfo.cs @@ -24,7 +24,7 @@ namespace Revitalize.Framework.Factories.Objects.Resources /// /// Extra information that holds drop chances on extra drops. /// - public List ExtraDrops; + public List ExtraDrops; /// /// The health of the ore vein. /// diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 1937149c..82730f56 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -168,10 +168,11 @@ namespace Revitalize.Framework.Objects } } + [JsonIgnore] /// /// Accesses the energy manager for all objects. /// - public EnergyManager EnergyManager + public virtual EnergyManager EnergyManager { get { diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs index 6f2fda10..24a5fcae 100644 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs @@ -9,7 +9,7 @@ using StardewValley; namespace Revitalize.Framework.Objects.InformationFiles { - public class OreResourceInformation:ResourceInformaton + public class OreResourceInformation:ResourceInformation { diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformation.cs similarity index 89% rename from GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs rename to GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformation.cs index a6fa0b48..e74af499 100644 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformation.cs @@ -10,7 +10,7 @@ namespace Revitalize.Framework.Objects.InformationFiles /// /// Deals with information reguarding resources. /// - public class ResourceInformaton + public class ResourceInformation { /// /// The item to drop. @@ -60,7 +60,7 @@ namespace Revitalize.Framework.Objects.InformationFiles /// /// Empty constructor. /// - public ResourceInformaton() + public ResourceInformation() { } @@ -79,7 +79,7 @@ namespace Revitalize.Framework.Objects.InformationFiles /// /// /// - public ResourceInformaton(StardewValley.Object I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f) + public ResourceInformation(StardewValley.Object I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f) { this.droppedItem = I; this.minResourcePerDrop = MinDropAmount; @@ -174,5 +174,16 @@ namespace Revitalize.Framework.Objects.InformationFiles if (this.chanceToDrop >= chance) return true; else return false; } + + /// + /// Gets an item that should be dropped from this resource with the appropriate drop amount; + /// + /// + public Item getItemDrops() + { + Item I = this.droppedItem.getOne(); + I.Stack = this.getNumberOfDropsToSpawn(); + return I; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 02c5cf55..70d3350b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -3,10 +3,364 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; namespace Revitalize.Framework.Objects.Machines { - public class Machine + public class Machine:MultiTiledComponent { + + [JsonIgnore] + public override string ItemInfo + { + get + { + string info = Revitalize.ModCore.Serializer.ToJSONString(this.info); + string guidStr = this.guid.ToString(); + string pyTkData = ModCore.Serializer.ToJSONString(this.data); + string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; + string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; + string resources = ModCore.Serializer.ToJSONString(this.producedResources); + string energyRequired = this.energyRequiredPer10Minutes.ToString(); + string timeToProduce = this.timeToProduce.ToString(); + string updatesContainer = this.updatesContainerObjectForProduction.ToString(); + + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container+"<"+resources+"<"+energyRequired+"<"+timeToProduce+"<"+updatesContainer; + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pyTKData = data[2]; + string offsetVec = data[3]; + string containerObject = data[4]; + string resourcesString = data[5]; + string energyRequired = data[6]; + string time = data[7]; + string updates = data[8]; + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); + this.energyRequiredPer10Minutes = Convert.ToInt32(energyRequired); + this.timeToProduce = Convert.ToInt32(time); + this.updatesContainerObjectForProduction = Convert.ToBoolean(updates); + if (string.IsNullOrEmpty(offsetVec)) return; + if (string.IsNullOrEmpty(containerObject)) return; + this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (this.containerObject == null) + { + //ModCore.log(containerObject); + Guid containerGuid = Guid.Parse(containerObject); + if (ModCore.CustomObjects.ContainsKey(containerGuid)) + { + this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid]; + this.containerObject.removeComponent(this.offsetKey); + this.containerObject.addComponent(this.offsetKey, this); + //ModCore.log("Set container object from existing object!"); + } + else + { + //ModCore.log("Container hasn't been synced???"); + MultiplayerUtilities.RequestGuidObject(containerGuid); + MultiplayerUtilities.RequestGuidObject_Tile(this.guid); + } + } + else + { + this.containerObject.updateInfo(); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + + if (string.IsNullOrEmpty(resourcesString) == false) + { + this.producedResources = ModCore.Serializer.DeserializeFromJSONString>(resourcesString); + } + else + { + if (this.producedResources == null) this.producedResources = new List(); + } + } + } + + public List producedResources; + public int energyRequiredPer10Minutes; + public int timeToProduce; + public bool updatesContainerObjectForProduction; + + [JsonIgnore] + public bool ProducesItems + { + get + { + return this.producedResources.Count > 0; + } + } + + [JsonIgnore] + public bool ConsumesEnergy + { + get + { + if (ModCore.Configs.machinesConfig.doMachinesConsumeEnergy == false) return false; + if (this.energyRequiredPer10Minutes == 0) return false; + if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes) return true; + return false; + } + } + + public Machine() { } + + public Machine(CustomObjectData PyTKData, BasicItemInformation info,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0,int TimeToProduce=0,bool UpdatesContainer=false) : base(PyTKData, info) { + this.producedResources = ProducedResources?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + } + + public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources=null,int EnergyRequiredPer10Minutes=0,int TimeToProduce=0,bool UpdatesContainer=false,MultiTiledObject obj=null) : base(PyTKData, info, TileLocation) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + } + + public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce=0,bool UpdatesContainer=false,MultiTiledObject obj = null) : base(PyTKData, info, TileLocation) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources?? new List(); + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + if (this.updatesContainerObjectForProduction) + { + //ModCore.log("Update container object for production!"); + //this.MinutesUntilReady -= minutes; + int remaining = minutes; + //ModCore.log("Minutes elapsed: " + remaining); + List energySources = new List(); + if (this.ConsumesEnergy) + { + energySources = this.EnergyGraphSearchSources(); //Only grab the network once. + } + + + if (this.ProducesItems) + { + //ModCore.log("This produces items!"); + while (remaining > 0) + { + + if (this.ConsumesEnergy) + { + this.drainEnergyFromNetwork(energySources); //Continually drain from the network. + if (this.EnergyManager.remainingEnergy < this.energyRequiredPer10Minutes) return false; + } + else + { + //ModCore.log("Does not produce energy!"); + } + remaining -= 10; + this.containerObject.MinutesUntilReady -= 10; + + if (this.containerObject.MinutesUntilReady <= 0) + { + this.produceItem(); + this.containerObject.MinutesUntilReady = this.timeToProduce; + } + } + } + if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces) + { + while (remaining > 0) + { + remaining -= 10; + this.produceEnergy(); + } + } + return false; + } + else + { + + return false; + } + + //return base.minutesElapsed(minutes, environment); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + if (this.containerObject.info.inventory != null && Game1.activeClickableMenu == null) + { + Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, this.containerObject.info.inventory.items, this.containerObject.info.inventory.capacity); + } + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + + return true; + } + + public override Item getOne() + { + Machine component = new Machine(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources,this.energyRequiredPer10Minutes,this.timeToProduce,this.updatesContainerObjectForProduction,this.containerObject); + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + Machine self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + if (this.info.ignoreBoundingBox == true) + { + x *= -1; + y *= -1; + } + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public virtual void produceItem() + { + foreach(ResourceInformation r in this.producedResources) + { + if (r.shouldDropResource()) + { + Item i = r.getItemDrops(); + this.InventoryManager.addItem(i); + //ModCore.log("Produced an item!"); + } + } + + } + + public virtual void produceEnergy() + { + if (this.EnergyManager.canReceieveEnergy) + { + this.EnergyManager.produceEnergy(this.energyRequiredPer10Minutes); + } + + } + + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 8548401f..3915889d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -4,7 +4,9 @@ using System.IO; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; using PyTK.CustomElementHandler; +using Revitalize.Framework.Energy; using Revitalize.Framework.Utilities; using StardewValley; using StardewValley.Objects; @@ -14,6 +16,7 @@ namespace Revitalize.Framework.Objects public class MultiTiledComponent : CustomObject,ISaveElement { + [JsonIgnore] public override string ItemInfo { get @@ -89,6 +92,53 @@ namespace Revitalize.Framework.Objects public Vector2 offsetKey; + [JsonIgnore] + public override EnergyManager EnergyManager + { + get + { + if (this.info == null || this.containerObject==null) + { + this.updateInfo(); + if (this.containerObject == null) return null; + return this.containerObject.info.EnergyManager; + } + else + { + return this.containerObject.info.EnergyManager; + } + } + set + { + this.containerObject.info.EnergyManager = value; + } + } + + /// + /// The inventory for the object. + /// + [JsonIgnore] + public virtual InventoryManager InventoryManager + { + get + { + if (this.info == null || this.containerObject == null) + { + this.updateInfo(); + if (this.containerObject == null) return null; + return this.containerObject.info.inventory; + } + else + { + return this.containerObject.info.inventory; + } + } + set + { + this.containerObject.info.inventory = value; + } + } + public MultiTiledComponent() { } public MultiTiledComponent(CustomObjectData PyTKData,BasicItemInformation info) : base(PyTKData,info) { } @@ -562,6 +612,17 @@ namespace Revitalize.Framework.Objects } } + public void drainEnergyFromNetwork(List energySources) + { + int index = 0; + + for (int i = 0; i < energySources.Count; i++) + { + this.EnergyManager.transferEnergyFromAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); + if (this.EnergyManager.hasMaxEnergy) break; + } + } + /// /// Gets all of the nodes in a connected energy network and tries to store the necessary amount of energy from the network. /// diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index c41e3713..481ae93a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -9,6 +9,7 @@ using Revitalize.Framework.Objects.Extras; using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Objects.Items.Tools; +using Revitalize.Framework.Objects.Machines; using Revitalize.Framework.Utilities; using StardewModdingAPI; using StardewValley; @@ -147,6 +148,38 @@ namespace Revitalize.Framework.Objects trashCan.addComponent(new Vector2(0, 1), trash2); this.AddItem("TrashCan", trashCan); + + + + MultiTiledObject sandBox = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); + Machine sandBox_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"),new Animation(0,0,16,16)), Color.White, false, new InventoryManager(36), null, null), new List() + { + new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + + }, 0, 10, true); + Machine sandBox_1_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() + { + new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + + }, 0, 10, false); + Machine sandBox_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() + { + new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + + }, 0, 10, false); + Machine sandBox_1_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() + { + new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + + }, 0, 10, false); + + sandBox.addComponent(new Vector2(0,0),sandBox_0_0); + sandBox.addComponent(new Vector2(1, 0), sandBox_1_0); + sandBox.addComponent(new Vector2(0, 1), sandBox_0_1); + sandBox.addComponent(new Vector2(1, 1), sandBox_1_1); + + this.AddItem("SandBox", sandBox); + } private void loadInTools() diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index ec5dae79..fb0b0412 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -141,7 +141,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null,null, 0.80d, 0.20d, 0.25d, 1d, 1d, 1, 1, 1, 1), new List(), 4); + }, null,null, 0.80d, 0.20d, 0.25d, 1d, 1d, 1, 1, 1, 1), new List(), 4); OreFactoryInfo tinOre_0_0_file = new OreFactoryInfo(tinOre_0_0); OreFactoryInfo tinOre_file = new OreFactoryInfo(tinOre); @@ -161,7 +161,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .70d, 0.16d, 0.20d, 1d, 1d, 0, 0, 0, 0), new List(), 5); + }, null, null, .70d, 0.16d, 0.20d, 1d, 1d, 0, 0, 0, 0), new List(), 5); OreFactoryInfo bauxiteOre_0_0_file = new OreFactoryInfo(bauxiteOre_0_0); OreFactoryInfo bauxiteOre_file = new OreFactoryInfo(bauxiteOre); @@ -181,7 +181,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .50d, 0.10d, 0.14d, 1d, 1d, 0, 0, 0, 0), new List(), 6); + }, null, null, .50d, 0.10d, 0.14d, 1d, 1d, 0, 0, 0, 0), new List(), 6); OreFactoryInfo silverOre_0_0_file = new OreFactoryInfo(silverOre_0_0); OreFactoryInfo silverOre_file = new OreFactoryInfo(silverOre); @@ -201,7 +201,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .60d, 0.13d, 0.17d, 1d, 1d, 0, 0, 0, 0), new List(), 7); + }, null, null, .60d, 0.13d, 0.17d, 1d, 1d, 0, 0, 0, 0), new List(), 7); OreFactoryInfo leadOre_0_0_file = new OreFactoryInfo(leadOre_0_0); OreFactoryInfo leadOre_file = new OreFactoryInfo(leadOre); @@ -222,7 +222,7 @@ namespace Revitalize.Framework.Objects }, new List() { new IntRange(0,9999) - }, null, null, .40d, 0.05d, 0.10d, 1d, 1d, 0, 0, 0, 0), new List(), 8); + }, null, null, .40d, 0.05d, 0.10d, 1d, 1d, 0, 0, 0, 0), new List(), 8); OreFactoryInfo titaniumOre_0_0_file = new OreFactoryInfo(titaniumOre_0_0); OreFactoryInfo titaniumOre_file = new OreFactoryInfo(titaniumOre); @@ -241,7 +241,7 @@ namespace Revitalize.Framework.Objects new IntRange(1,9999) }, new List() { - }, null, null, .05d, 0.01d, 0.01d, 0.10, 1d, 1, 1, 1,1), new List(), 10); + }, null, null, .05d, 0.01d, 0.01d, 0.10, 1d, 1, 1, 1,1), new List(), 10); OreFactoryInfo prismaticOre_0_0_file = new OreFactoryInfo(prismaticOre_0_0); OreFactoryInfo prismaticOre_file = new OreFactoryInfo(prismaticOre); @@ -336,7 +336,7 @@ namespace Revitalize.Framework.Objects } } - public List getExtraDropInformationFromOres(string id) + public List getExtraDropInformationFromOres(string id) { if (this.oreVeins.ContainsKey(id)) { diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs index 26dd84b4..89dd1d47 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs @@ -15,7 +15,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins public class OreVeinObj:MultiTiledObject { [JsonIgnore] - public ResourceInformaton resourceInfo + public ResourceInformation resourceInfo { get { diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs index da2bcc55..47d7fcdd 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs @@ -21,7 +21,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins /// Deals with information tied to the resource itself. /// public OreResourceInformation resourceInfo; - public List extraDrops; + public List extraDrops; private int _healthValue; public int healthValue @@ -70,7 +70,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins //Instead of serializing this info it's static pretty much always so just pull the info from the resource manager. OreResourceInformation oreResource = ModCore.ObjectManager.resources.getOreResourceInfo(this.info.id); - List extraDrops = ModCore.ObjectManager.resources.getExtraDropInformationFromOres(this.info.id); + List extraDrops = ModCore.ObjectManager.resources.getExtraDropInformationFromOres(this.info.id); if (this.resourceInfo == null) { this.resourceInfo = oreResource; @@ -137,21 +137,21 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins } - public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info, OreResourceInformation Resource,List ExtraDrops,int Health) : base(PyTKData, Info) + public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info, OreResourceInformation Resource,List ExtraDrops,int Health) : base(PyTKData, Info) { this.healthValue = Health; this.resourceInfo = Resource; - this.extraDrops = ExtraDrops != null ? ExtraDrops : new List(); + this.extraDrops = ExtraDrops != null ? ExtraDrops : new List(); this.setHealth(this.healthValue); this.Price = Info.price; } - public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation, OreResourceInformation Resource, List ExtraDrops,int Health) : base(PyTKData, Info, TileLocation) + public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation, OreResourceInformation Resource, List ExtraDrops,int Health) : base(PyTKData, Info, TileLocation) { this.healthValue = Health; this.resourceInfo = Resource; - this.extraDrops = ExtraDrops != null ? ExtraDrops : new List(); + this.extraDrops = ExtraDrops != null ? ExtraDrops : new List(); this.setHealth(this.healthValue); this.Price = Info.price; } @@ -292,7 +292,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins if (this.extraDrops != null) { - foreach (ResourceInformaton extra in this.extraDrops) + foreach (ResourceInformation extra in this.extraDrops) { if (extra.shouldDropResource()) { diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 9906fa8d..b9b5ad2d 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -294,6 +294,8 @@ namespace Revitalize { TextureManager.AddTextureManager(Manifest, "Furniture"); TextureManager.GetTextureManager(Manifest, "Furniture").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Furniture")); + TextureManager.AddTextureManager(Manifest, "Machines"); + TextureManager.GetTextureManager(Manifest, "Machines").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Machines")); TextureManager.AddTextureManager(Manifest, "InventoryMenu"); TextureManager.GetTextureManager(Manifest, "InventoryMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "InventoryMenu")); TextureManager.AddTextureManager(Manifest, "Resources.Ore"); @@ -523,12 +525,16 @@ namespace Revitalize //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench")); + + + //PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); Game1.player.addItemsByMenuIfNecessary(new List() { new StardewValley.Object((int)Enums.SDVObject.Wood,100), ModCore.ObjectManager.GetItem("SteelIngot", 20), - ModCore.ObjectManager.GetItem("TrashCan",1) + ModCore.ObjectManager.GetItem("TrashCan",1), + ModCore.ObjectManager.GetItem("SandBox",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 690a59ad..aef4baaa 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -55,6 +55,7 @@ + @@ -145,7 +146,7 @@ - + @@ -386,6 +387,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 0f5eb5b60bc8d027beb97ea381899fe92bd28a6e Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 9 Sep 2019 16:07:39 -0700 Subject: [PATCH 41/98] Added in sand as a resource and made the sandbox generate sand. --- .../Graphics/Items/Resources/Misc/Sand.png | Bin 0 -> 259 bytes .../Framework/Objects/ObjectManager.cs | 10 +++--- .../Framework/Objects/ResourceManager.cs | 32 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 2 ++ GeneralMods/Revitalize/Revitalize.csproj | 3 ++ 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Misc/Sand.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Misc/Sand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Misc/Sand.png new file mode 100644 index 0000000000000000000000000000000000000000..88d9065bc61288bc88a4fbd45f5197d3d5f989ed GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|_IkQFhFJ6_ zCrGgN>`>XJ=kcrm%y+*T?V-A1jx*BI^|jf6pl$E%zK13)oYT4I>|G;Kw|75x`eP;u zHU;asz5$ZUW#YsoGQ1DnY>8=1VmQN=Sm_GZvz`CFa0zQ0cY@j9s(SG}0lRPmrP)~v zbUClL@ZGc9!#~}*PjuN@?n(a+FLIBFo0#~1TQX1ecG={L-yiH^9^T769$<1is%!Bq xzG6nBzc16C{s*a5?oJGDzb=r&*dA)E%D}LEZ4rlIy&cG#44$rjF6*2Ung9fxUBCbU literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 481ae93a..6b6e67be 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -107,7 +107,7 @@ namespace Revitalize.Framework.Objects /// public void loadInItems() { - this.resources.loadInItems(); + this.resources.loadInItems(); //Must be first. this.loadInCraftingTables(); this.loadInMachines(); this.loadInTools(); @@ -154,22 +154,22 @@ namespace Revitalize.Framework.Objects MultiTiledObject sandBox = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); Machine sandBox_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"),new Animation(0,0,16,16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) }, 0, 10, true); Machine sandBox_1_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) }, 0, 10, false); Machine sandBox_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) }, 0, 10, false); Machine sandBox_1_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay,1),1,1,1,1,1,1,0,0,0,0) + new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) }, 0, 10, false); diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index fb0b0412..eed1164b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -30,6 +30,7 @@ namespace Revitalize.Framework.Objects public Dictionary oreVeins; public Dictionary oreResourceInformationTable; public Dictionary ores; + public Dictionary resources; /// /// A list of all visited floors on the current visit to the mines. @@ -46,6 +47,7 @@ namespace Revitalize.Framework.Objects this.oreResourceInformationTable = new Dictionary(); this.ores = new Dictionary(); this.visitedFloors = new List(); + this.resources = new Dictionary(); } @@ -54,6 +56,7 @@ namespace Revitalize.Framework.Objects public void loadInItems() { this.loadInOreItems(); + this.loadInResourceItems(); this.serializeOreVeins(); this.loadOreVeins(); } @@ -304,6 +307,12 @@ namespace Revitalize.Framework.Objects ModCore.ObjectManager.AddItem("SteelIngot", steelIngot); } + private void loadInResourceItems() + { + CustomObject sand=new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Misc.Sand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Misc", "Sand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Sand", "Omegasis.Revitalize.Items.Resources.Misc.Sand", "Sand which is made from tiny rocks and can be used for smelting. Also unfun to have inside of swimwear.", "Resource", Color.Brown, -300, 0, false, 2, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Misc", "Sand"), new AnimationManager(), Color.White, true, null, null)); + this.resources.Add("Sand", sand); + } + /// /// Gets an ore from the list of stored ores in this mod. /// @@ -324,6 +333,29 @@ namespace Revitalize.Framework.Objects } } + /// + /// Get a resource from the resource maanger. + /// + /// + /// + /// + public CustomObject getResource(string name, int Stack=1) + { + Ore o = this.getOre(name, Stack); + if (o != null) return o; + + if (this.resources.ContainsKey(name)) + { + CustomObject obj = (CustomObject)this.resources[name].getOne(); + obj.Stack = Stack; + return obj; + } + else + { + return null; + } + } + public OreResourceInformation getOreResourceInfo(string id) { if (this.oreVeins.ContainsKey(id)) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b9b5ad2d..327ebb03 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -300,6 +300,8 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest, "InventoryMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "InventoryMenu")); TextureManager.AddTextureManager(Manifest, "Resources.Ore"); TextureManager.GetTextureManager(Manifest, "Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Resources", "Ore")); + TextureManager.AddTextureManager(Manifest, "Items.Resources.Misc"); + TextureManager.GetTextureManager(Manifest, "Items.Resources.Misc").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Misc")); TextureManager.AddTextureManager(Manifest, "Items.Resources.Ore"); TextureManager.GetTextureManager(Manifest, "Items.Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Ore")); TextureManager.AddTextureManager(Manifest, "Tools"); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index aef4baaa..00ee0937 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -201,6 +201,9 @@ + + PreserveNewest + PreserveNewest From 82d4fceabf2d703da120c64c8cf6760fe9e77d59 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 9 Sep 2019 16:08:49 -0700 Subject: [PATCH 42/98] Adjusted sandbox to only produce 1 sand every hour instead of every 10 minutes. --- GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 6b6e67be..516a2f5d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -156,22 +156,22 @@ namespace Revitalize.Framework.Objects { new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, 10, true); + }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), true); Machine sandBox_1_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, 10, false); + }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), false); Machine sandBox_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, 10, false); + }, 0, TimeUtilities.GetMinutesFromTime(0,1,0), false); Machine sandBox_1_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, 10, false); + }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), false); sandBox.addComponent(new Vector2(0,0),sandBox_0_0); sandBox.addComponent(new Vector2(1, 0), sandBox_1_0); From c7b6ba849592d21a51e8579c24a7005dde57af96 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 11 Sep 2019 14:40:22 -0700 Subject: [PATCH 43/98] Started work on the machine summary menu. --- .../Menus/EnergyMenu/BatteryEnergyGuage.png | Bin 0 -> 175 bytes .../Menus/EnergyMenu/BatteryEnergyMeter.png | Bin 0 -> 140 bytes .../Menus/EnergyMenu/BatteryFrame.png | Bin 0 -> 353 bytes .../Menus/EnergyMenu/LightningBolt.png | Bin 0 -> 173 bytes .../Framework/Energy/EnergyManager.cs | 23 +++ .../Framework/Menus/MachineSummaryMenu.cs | 163 ++++++++++++++++++ .../Framework/Objects/CustomObject.cs | 37 ++-- .../Framework/Objects/MultiTiledComponent.cs | 13 ++ .../Framework/Objects/MultiTiledObject.cs | 6 + .../Framework/Utilities/ObjectUtilities.cs | 40 +++++ GeneralMods/Revitalize/ModCore.cs | 11 ++ GeneralMods/Revitalize/Revitalize.csproj | 13 ++ 12 files changed, 287 insertions(+), 19 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryEnergyGuage.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryEnergyMeter.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryFrame.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/LightningBolt.png create mode 100644 GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryEnergyGuage.png b/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryEnergyGuage.png new file mode 100644 index 0000000000000000000000000000000000000000..d93da93e181272f998d01dba992d2f51d0c1fe93 GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3HF&`%2dVDaPU;cPEB*=VV?2Ihmd=jv*P1 zZ!c{WY)}wzxww@x`ht|nBE91s8}*deIz}(x>}3&p#QR6zsx8@L9}5G+hw|9hkGd{@ zK6^N3ZR@^UQ7XAlcPzKL=U%t2(02BJ1{V%%r50JiLwy{H?kyXXoo)y!zUdGs`^FJJ YJ2r*;K*9f8KuZ}sUHx3vIVCg!02{AAhyVZp literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryEnergyMeter.png b/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryEnergyMeter.png new file mode 100644 index 0000000000000000000000000000000000000000..0dafc73ff36af10a9ee5b49803a59ffd76b46876 GIT binary patch literal 140 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3HF&`%2dVDaPU;cPEB*=VV?2Ic}aVjv*P1 zZ_jPyWH8`icC`NeevQwBLjncG_q}7Ls(4PC_WGrQ=e+d0kM|qP{^0}azyJxd1&rLg VS)x|T1-XGFJzf1=);T3K0RZlvB_03( literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryFrame.png b/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/BatteryFrame.png new file mode 100644 index 0000000000000000000000000000000000000000..99ca700c73dd9147db16e55afe233aa95b5eea9d GIT binary patch literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3HF&`%2dVDaPU;cPEB*=VV?2+0vdajv*P1 zZ*M4eFgc2_J^25nDYTz^8*{f#j8IPaowS`Q-6xYa%*yXBNPFF;t7dqrF?V}pi}$H* z-HQ}chN-w9{@PuBS?;r5^mw6k=4$Gd*|lJ9{WXP}U|<#zRp(TwDdmmdov0zi=<}^M{GLZo3{Is{h;akB`OTOiY4Y z{I`6&eOn_gs@7C$ANtOe``7(a0N0GZU*XqnboaeuXK46T?Hp;$`0wo1{SWRbHZU-8 lC}1NT{)E+>uHK;M?t0Pl{NJB8AAn)T;OXk;vd$@?2>=^!mFNHf literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/LightningBolt.png b/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/LightningBolt.png new file mode 100644 index 0000000000000000000000000000000000000000..9f767b7a0b9e2b98c0ff28271282789032c00fae GIT binary patch literal 173 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|(mh=qLo9le z6BLB5glhd+zdGbczuq~QHP0OES=SWxEXj)7|B}%;_&4(oyFF|ImwK)hE%*-sfQQ*b$0}Z;r3U)C(A?q_;3uM + /// Returns the energy remaining as a percent value. + /// + public double energyPercentRemaining + { + get + { + return (double)this.remainingEnergy / (double)this.maxEnergy; + } + } + + public string energyDisplayString + { + get + { + StringBuilder b = new StringBuilder(); + b.Append(this.remainingEnergy); + b.Append("/"); + b.Append(this.maxEnergy); + return b.ToString(); + } + } + public EnergyManager() { diff --git a/GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs new file mode 100644 index 00000000..9106f227 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs @@ -0,0 +1,163 @@ +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 Revitalize.Framework.Energy; +using Revitalize.Framework.Objects; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus +{ + public class MachineSummaryMenu : IClickableMenuExtended + { + + /// + /// The custom object to be gathering information from. + /// + private CustomObject objectSource; + /// + /// The background color for the menu. + /// + private Color backgroundColor; + /// + /// The hover text to display for the menu. + /// + private string hoverText; + + + private AnimatedButton batteryBackground; + private AnimatedButton battergyEnergyGuage; + private Vector2 energyPosition; + private Texture2D energyTexture; + private Rectangle energyMeterBounds; + private Vector2 itemDisplayOffset; + + private EnergyManager energy + { + get + { + return this.objectSource.EnergyManager; + } + } + + public MachineSummaryMenu() + { + + } + + public MachineSummaryMenu(int x, int y, int width, int height, Color BackgroundColor, CustomObject SourceObject):base(x,y,width,height,false) + { + + this.objectSource = SourceObject; + this.backgroundColor = BackgroundColor; + this.energyTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); + this.colorSwap(); + + this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72*4); + this.batteryBackground =new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)),Color.White),new Rectangle(0,0,32,64),4f); + this.battergyEnergyGuage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryEnergyGuage", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryEnergyGuage"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); + + this.itemDisplayOffset=this.getDimensionOffsetFromItem(); + } + + public override void performHoverAction(int x, int y) + { + bool hovered = false; + if (this.batteryBackground.containsPoint(x, y)) + { + this.hoverText ="Energy: "+this.energy.energyDisplayString; + hovered = true; + } + + if (hovered == false) + { + this.hoverText = ""; + } + + } + + + /// + /// Draws the menu to the screen. + /// + /// + public override void draw(SpriteBatch b) + { + this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + + this.batteryBackground.draw(b, 1f, 1f); + this.colorSwap(); + b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X+(int)(11*this.batteryBackground.scale), (int)this.energyPosition.Y+(int)(18*this.batteryBackground.scale), (int)(9*this.batteryBackground.scale), (int)(46*this.batteryBackground.scale)), new Rectangle(0, 0, 1, 1), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.2f); + this.battergyEnergyGuage.draw(b, 1f, 1f); + + + this.objectSource.drawFullyInMenu(b,new Vector2((int)(this.xPositionOnScreen+ (this.width / 2) - (this.itemDisplayOffset.X / 2)),(int)(this.yPositionOnScreen+128f)),.24f); + Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName); + + b.DrawString(Game1.dialogueFont, this.objectSource.DisplayName, new Vector2(this.xPositionOnScreen + (this.width / 2)-nameOffset.X/2, (this.yPositionOnScreen + 150f)) + new Vector2(0,ObjectUtilities.GetHeightOffsetFromItem(this.objectSource)), Color.Black); + + if (string.IsNullOrEmpty(this.hoverText) == false) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + + + this.drawMouse(b); + + + } + + private void colorSwap() + { + Color col = new Color(); + ModCore.log("Energy is: " + this.energy.energyPercentRemaining); + if (this.energy.energyPercentRemaining > .75d) + { + col = Color.Green; + } + else if (this.energy.energyPercentRemaining > .5d && this.energy.energyPercentRemaining <= .75d) + { + col = Color.GreenYellow; + } + else if(this.energy.energyPercentRemaining>.25d && this.energy.energyPercentRemaining <= .5d) + { + col = Color.Yellow; + } + else if (this.energy.energyPercentRemaining > .10d && this.energy.energyPercentRemaining <= .25d) + { + col = Color.Orange; + } + else + { + col = Color.Red; + } + + Color[] color = new Color[1] + { + col + }; + this.energyTexture.SetData(color); + } + + + private Vector2 getDimensionOffsetFromItem() + { + if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.objectSource.GetType())) + { + return new Vector2(64f, 64f); + } + if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), this.objectSource.GetType())) + { + return new Vector2(64f * (this.objectSource as MultiTiledObject).Width, 64f * (this.objectSource as MultiTiledObject).Height); + } + + return new Vector2(64f, 64f); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 82730f56..1ff0100d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -539,25 +539,6 @@ namespace Revitalize.Framework.Objects public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) { this.updateInfo(); - /* - if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64)) - return; - if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2) - spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32), (float)(yNonTile + 51 + 4))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, layerDepth - 1E-06f); - SpriteBatch spriteBatch1 = spriteBatch; - Texture2D objectSpriteSheet = Game1.objectSpriteSheet; - Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(yNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)))); - Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(this.ParentSheetIndex)); - Color color = Color.White * alpha; - double num1 = 0.0; - Vector2 origin = new Vector2(8f, 8f); - Vector2 scale = this.scale; - double num2 = (double)this.scale.Y > 1.0 ? (double)this.getScale().Y : 4.0; - int num3 = (bool)(this.flipped) ? 1 : 0; - double num4 = (double)layerDepth; - - spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, this.info.drawColor * alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); - */ //The actual planter box being drawn. if (this.animationManager == null) { @@ -591,6 +572,9 @@ namespace Revitalize.Framework.Objects } + + + /// What happens when the object is drawn in a menu. public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { @@ -637,6 +621,21 @@ namespace Revitalize.Framework.Objects //base.drawWhenHeld(spriteBatch, objectPosition, f); } + /// What happens when the object is drawn when held by a player. + public virtual void drawFullyInMenu(SpriteBatch spriteBatch, Vector2 objectPosition,float Depth) + { + this.updateInfo(); + if (this.animationManager == null) + { + Revitalize.ModCore.log("Animation Manager Null"); + } + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None,Depth); + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) { //Do nothing because this shouldn't be placeable anywhere. diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 3915889d..f785f52e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -404,6 +404,19 @@ namespace Revitalize.Framework.Objects } + public override void drawFullyInMenu(SpriteBatch spriteBatch, Vector2 objectPosition, float Depth) + { + this.updateInfo(); + if (this.animationManager == null) + { + Revitalize.ModCore.log("Animation Manager Null"); + } + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Depth); + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + public override void updateInfo() { if (this.info == null || this.containerObject==null) diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 9e3ca2c0..afc140fa 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -262,7 +262,13 @@ namespace Revitalize.Framework.Objects } } + public override void drawFullyInMenu(SpriteBatch spriteBatch, Vector2 objectPosition, float Depth) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + (pair.Value as CustomObject).drawFullyInMenu(spriteBatch, objectPosition + (pair.Key * Game1.tileSize),Depth); + } public virtual void pickUp(Farmer who) { diff --git a/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs index 5ef2f1d7..1afdc6a5 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Revitalize.Framework.Objects; namespace Revitalize.Framework.Utilities { @@ -44,5 +46,43 @@ namespace Revitalize.Framework.Utilities return potentialDescendant.IsSubclassOf(potentialBase); } + /// + /// Gets a dimension offset depending on the size of the object passed in. + /// + /// + /// + public static Vector2 GetDimensionOffsetFromItem(StardewValley.Object obj) + { + if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), obj.GetType())) + { + return new Vector2(64f, 64f); + } + if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), obj.GetType())) + { + return new Vector2(64f * (obj as MultiTiledObject).Width, 64f * (obj as MultiTiledObject).Height); + } + + return new Vector2(64f, 64f); + } + + /// + /// Gets the height of an object. + /// + /// + /// + public static float GetHeightOffsetFromItem(StardewValley.Object obj) + { + return GetDimensionOffsetFromItem(obj).Y; + } + + /// + /// Gets the width of an item. + /// + /// + /// + public static float GetWidthOffsetFromItem(StardewValley.Object obj) + { + return GetDimensionOffsetFromItem(obj).X; + } } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 327ebb03..897e2399 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -309,6 +309,10 @@ namespace Revitalize TextureManager.AddTextureManager(Manifest, "Menus"); TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc")); + + TextureManager.AddTextureManager(Manifest, "Menus.EnergyMenu"); + TextureManager.GetTextureManager(Manifest, "Menus.EnergyMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "EnergyMenu")); + TextureManager.AddTextureManager(Manifest, "CraftingMenu"); TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu")); @@ -326,6 +330,13 @@ namespace Revitalize Game1.currentMinigame = new Revitalize.Framework.Minigame.SeasideScrambleMinigame.SeasideScramble(); } */ + if (e.Button == SButton.U) + { + CustomObject test = ObjectManager.GetItem("SandBox"); + test.EnergyManager.maxEnergy = 100; + test.EnergyManager.produceEnergy(100); + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = new MachineSummaryMenu((Game1.viewport.Width/2)-400, 0, 800, 600,Color.White,test); + } /* if (e.Button == SButton.Y) { diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 00ee0937..7a3cf76e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -86,6 +86,7 @@ + @@ -342,6 +343,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + Always From 1a63bcc34dab7e0292c5b08343ad691075ea1138 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 11 Sep 2019 16:02:55 -0700 Subject: [PATCH 44/98] Got the general machine menu tabs to look better with summary and inventory menus. Also fixed inventory transfer menu messing up inventories and not adding things in when they should. --- .../Framework/Menus/CraftingMenuV1.cs | 2 +- .../Framework/Menus/InventoryTransferMenu.cs | 17 +- .../Framework/Menus/Machines/MachineMenu.cs | 151 ++++++++++++++++++ .../{ => Machines}/MachineSummaryMenu.cs | 25 +-- GeneralMods/Revitalize/ModCore.cs | 12 +- GeneralMods/Revitalize/Revitalize.csproj | 3 +- 6 files changed, 186 insertions(+), 24 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs rename GeneralMods/Revitalize/Framework/Menus/{ => Machines}/MachineSummaryMenu.cs (87%) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 996e3b1c..202207c5 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -258,7 +258,7 @@ namespace Revitalize.Framework.Menus } else { - Vector2 newPos = new Vector2(100 + (48) * (count + 1), this.yPositionOnScreen + (24 * 4) * (count + 1)); + Vector2 newPos = new Vector2(100 + (48), this.yPositionOnScreen + (24 * 4) * (count + 1)); Button.Position = newPos; this.CraftingTabs.Add(name, Button); this.craftingItemsToDisplay.Add(name, new List()); diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs index a3edbeda..9870c167 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -209,7 +209,22 @@ namespace Revitalize.Framework.Menus } if (To.isFull == false) { - To.items.Add(From.activeItem); + // + bool addedItem = false; + for(int i = 0; i < To.items.Count; i++) + { + if (To.items[i] == null) + { + To.items[i] = From.activeItem; + addedItem = true; + break; + } + } + if (addedItem == false) + { + To.items.Add(From.activeItem); + } + From.items.Remove(From.activeItem); From.activeItem = null; From.populateClickableItems(); diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs new file mode 100644 index 00000000..835bf21c --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs @@ -0,0 +1,151 @@ +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 Microsoft.Xna.Framework.Input; +using StardewValley; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus.Machines +{ + public class MachineMenu : IClickableMenuExtended + { + + public Dictionary> menuPages; + public string currentTab; + public string hoverText; + + public IClickableMenuExtended CurrentMenu + { + get + { + if(string.IsNullOrEmpty(this.currentTab)) return null; + else + { + if (this.menuPages.ContainsKey(this.currentTab)) + { + return this.menuPages[this.currentTab].Value; + } + else + { + return null; + } + } + } + } + + + public MachineMenu() + { + + } + + public MachineMenu(int x, int y, int width, int height) : base(x, y, width, height, false) + { + this.menuPages = new Dictionary>(); + } + + public void addInMenuTab(string Name,AnimatedButton Button, IClickableMenuExtended Menu,bool DefaultTab=false) + { + int count = this.menuPages.Count; + + Vector2 newPos = new Vector2(208 + (24 * 2) * (count+1), this.yPositionOnScreen+(80)); + Button.Position = newPos; + this.menuPages.Add(Name,new KeyValuePair(Button, Menu)); + + if (DefaultTab) + { + this.currentTab = Name; + } + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + foreach (var v in this.menuPages) + { + if (v.Value.Key.containsPoint(x, y)) + { + this.currentTab = v.Key; + } + } + + if (this.CurrentMenu != null) + { + this.CurrentMenu.receiveLeftClick(x, y, playSound); + } + + + } + public override void receiveKeyPress(Keys key) + { + if (this.CurrentMenu != null) + { + this.CurrentMenu.receiveKeyPress(key); + } + } + + public override void performHoverAction(int x, int y) + { + + bool hovered = false; + + foreach(var v in this.menuPages) + { + if (v.Value.Key.containsPoint(x, y)) + { + this.hoverText = v.Key; + hovered = true; + } + } + + if (this.CurrentMenu != null) + { + this.CurrentMenu.performHoverAction(x, y); + } + + if (hovered == false) + { + this.hoverText = ""; + } + } + + public override void receiveRightClick(int x, int y, bool playSound = true) + { + if (this.CurrentMenu != null) + { + this.CurrentMenu.receiveRightClick(x, y,playSound); + } + } + + public override void update(GameTime time) + { + if (this.CurrentMenu != null) + { + this.CurrentMenu.update(time); + } + } + + public override void draw(SpriteBatch b) + { + foreach(KeyValuePair button in this.menuPages.Values) + { + button.Key.draw(b); + } + if (this.CurrentMenu != null) + { + this.CurrentMenu.draw(b); + } + + if (string.IsNullOrEmpty(this.hoverText) == false) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + + this.drawMouse(b); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs similarity index 87% rename from GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs rename to GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 9106f227..9f2b42f7 100644 --- a/GeneralMods/Revitalize/Framework/Menus/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -12,7 +12,7 @@ using StardewValley; using StardustCore.UIUtilities; using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; -namespace Revitalize.Framework.Menus +namespace Revitalize.Framework.Menus.Machines { public class MachineSummaryMenu : IClickableMenuExtended { @@ -35,7 +35,6 @@ namespace Revitalize.Framework.Menus private AnimatedButton battergyEnergyGuage; private Vector2 energyPosition; private Texture2D energyTexture; - private Rectangle energyMeterBounds; private Vector2 itemDisplayOffset; private EnergyManager energy @@ -63,7 +62,7 @@ namespace Revitalize.Framework.Menus this.batteryBackground =new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)),Color.White),new Rectangle(0,0,32,64),4f); this.battergyEnergyGuage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryEnergyGuage", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryEnergyGuage"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); - this.itemDisplayOffset=this.getDimensionOffsetFromItem(); + this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource); } public override void performHoverAction(int x, int y) @@ -112,11 +111,14 @@ namespace Revitalize.Framework.Menus } + /// + /// Swaps the color for the energy bar meter depending on how much energy is left. + /// private void colorSwap() { Color col = new Color(); - ModCore.log("Energy is: " + this.energy.energyPercentRemaining); + //ModCore.log("Energy is: " + this.energy.energyPercentRemaining); if (this.energy.energyPercentRemaining > .75d) { col = Color.Green; @@ -144,20 +146,5 @@ namespace Revitalize.Framework.Menus }; this.energyTexture.SetData(color); } - - - private Vector2 getDimensionOffsetFromItem() - { - if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.objectSource.GetType())) - { - return new Vector2(64f, 64f); - } - if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), this.objectSource.GetType())) - { - return new Vector2(64f * (this.objectSource as MultiTiledObject).Width, 64f * (this.objectSource as MultiTiledObject).Height); - } - - return new Vector2(64f, 64f); - } } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 897e2399..98f8a122 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -31,6 +31,7 @@ using Revitalize.Framework.Menus; using Revitalize.Framework.Objects.CraftingTables; using Revitalize.Framework.Objects.Items.Tools; using StardewValley.Tools; +using Revitalize.Framework.Menus.Machines; namespace Revitalize { @@ -332,10 +333,17 @@ namespace Revitalize */ if (e.Button == SButton.U) { - CustomObject test = ObjectManager.GetItem("SandBox"); + MultiTiledObject test =(MultiTiledObject) ObjectManager.GetItem("SandBox"); test.EnergyManager.maxEnergy = 100; test.EnergyManager.produceEnergy(100); - if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = new MachineSummaryMenu((Game1.viewport.Width/2)-400, 0, 800, 600,Color.White,test); + MachineSummaryMenu m= new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width/2)-400, 48, 800, 600,Color.White,test); + InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, test.info.inventory.items, 36); + MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); + + machineMenu.addInMenuTab("Summary",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab",new Vector2(),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest,"Menus","MenuTab"),new Animation(0,0,24,24)),Color.White),new Rectangle(0,0,24,24),2f),m,true); + machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, true); + + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu; } /* if (e.Button == SButton.Y) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 7a3cf76e..acdcba05 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -86,7 +86,8 @@ - + + From a2b66afb659cfb887d8946dbbd64df3ba5cc0d0c Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 11 Sep 2019 18:04:12 -0700 Subject: [PATCH 45/98] Added in crafting menu for machines. For some reason though custom obbjects are broken in crafting menus. --- .../Framework/Crafting/CraftingRecipeBook.cs | 55 +++++++++++ .../Revitalize/Framework/Crafting/Recipe.cs | 11 ++- .../Framework/Crafting/RecipeBook.cs | 13 --- .../Menus/CraftingInformationPage.cs | 91 ++++++++++++++++++- .../Framework/Menus/CraftingMenuV1.cs | 15 ++- .../Framework/Menus/Machines/MachineMenu.cs | 1 + .../Menus/Machines/MachineSummaryMenu.cs | 49 +++++++--- .../Framework/Objects/Machines/Machine.cs | 66 +++++++++++--- .../Framework/Objects/ObjectManager.cs | 16 ++-- .../Framework/Utilities/InventoryManager.cs | 38 +++++++- GeneralMods/Revitalize/ModCore.cs | 16 +++- GeneralMods/Revitalize/Revitalize.csproj | 1 - .../ComponentsV2/Buttons/ItemDisplayButton.cs | 16 ++++ 13 files changed, 328 insertions(+), 60 deletions(-) delete mode 100644 GeneralMods/Revitalize/Framework/Crafting/RecipeBook.cs diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index cfe70fff..c6903062 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Revitalize.Framework.Menus; +using Revitalize.Framework.Objects.Machines; using Revitalize.Framework.Utilities; using StardewValley; using StardustCore.Animations; @@ -164,6 +165,60 @@ namespace Revitalize.Framework.Crafting if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; } + public CraftingMenuV1 getCraftingMenuForMachine(int x, int y, int width, int height,ref IList Items,ref IList Output,Machine Machine) + { + CraftingMenuV1 menu = new Framework.Menus.CraftingMenuV1(x, y, width, height, Color.White, ref Items,ref Output,Machine); + //menu.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + + foreach (KeyValuePair pair in this.craftingMenuTabs) + { + menu.addInCraftingPageTab(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in this.craftingRecipes) + { + if (pair.Value.hasUnlocked) + { + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab); + ModCore.log("Add in a crafting recipe to the menu!"); + } + else + { + ModCore.log("Recipe is locked!"); + } + } + menu.currentTab = this.defaultTab; + menu.sortRecipes(); + return menu; + } + + public void openCraftingMenu(int x, int y, int width, int height, ref IList items) + { + CraftingMenuV1 menu = new Framework.Menus.CraftingMenuV1(x, y, width, height, Color.White, items); + //menu.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + + foreach (KeyValuePair pair in this.craftingMenuTabs) + { + menu.addInCraftingPageTab(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in this.craftingRecipes) + { + if (pair.Value.hasUnlocked) + { + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab); + ModCore.log("Add in a crafting recipe to the menu!"); + } + else + { + ModCore.log("Recipe is locked!"); + } + } + menu.currentTab = this.defaultTab; + menu.sortRecipes(); + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; + } + #region //~~~~~~~~~~~~~~~~~~~~// // Static Functions // diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index 00999d22..475019e5 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -44,12 +44,17 @@ namespace Revitalize.Framework.Crafting /// public StatCost statCost; + /// + /// The number of in-game minutes it takes to craft this item. + /// + public int timeToCraft; + public Recipe() { } /// Constructor for single item output. /// All the ingredients required to make the output. /// The item given as output with how many - public Recipe(List inputs, CraftingRecipeComponent output, StatCost StatCost = null) + public Recipe(List inputs, CraftingRecipeComponent output, StatCost StatCost = null,int TimeToCraft=0) { this.ingredients = inputs; this.DisplayItem = output.item; @@ -60,9 +65,10 @@ namespace Revitalize.Framework.Crafting output }; this.statCost = StatCost ?? new StatCost(); + this.timeToCraft = TimeToCraft; } - public Recipe(List inputs, List outputs, string OutputName, string OutputDescription, Item DisplayItem = null, StatCost StatCost = null) + public Recipe(List inputs, List outputs, string OutputName, string OutputDescription, Item DisplayItem = null, StatCost StatCost = null,int TimeToCraft=0) { this.ingredients = inputs; this.outputs = outputs; @@ -70,6 +76,7 @@ namespace Revitalize.Framework.Crafting this.outputDescription = OutputDescription; this.DisplayItem = DisplayItem; this.statCost = StatCost ?? new StatCost(); + this.timeToCraft = TimeToCraft; } /// Checks if a player contains all recipe ingredients. diff --git a/GeneralMods/Revitalize/Framework/Crafting/RecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/RecipeBook.cs deleted file mode 100644 index 30b3b71a..00000000 --- a/GeneralMods/Revitalize/Framework/Crafting/RecipeBook.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Revitalize.Framework.Crafting -{ - public class RecipeBook - { - - } -} diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 3d4608d3..5bb7c30d 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics; using Revitalize.Framework.Crafting; using Revitalize.Framework.Menus.MenuComponents; using Revitalize.Framework.Objects; +using Revitalize.Framework.Objects.Machines; using Revitalize.Framework.Utilities; using StardewValley; using StardustCore.UIUtilities; @@ -28,6 +29,7 @@ namespace Revitalize.Framework.Menus public Vector2 itemDisplayLocation; public IList inventory; + public IList outputInventory; private Dictionary requiredItems; @@ -35,6 +37,10 @@ namespace Revitalize.Framework.Menus public bool isPlayerInventory; + private Machine machine; + + string hoverText; + public Item actualItem { get @@ -63,6 +69,31 @@ namespace Revitalize.Framework.Menus this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount); } this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f); + this.outputInventory = this.inventory; + } + + public CraftingInformationPage(int x, int y, int width, int height, Color BackgroundColor, CraftingRecipeButton ItemToDisplay, ref IList Inventory,ref IList OutputInventory ,bool IsPlayerInventory, Machine Machine) : base(x, y, width, height, false) + { + this.backgroundColor = BackgroundColor; + this.infoButton = ItemToDisplay; + this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128)); + this.inventory = Inventory; + this.isPlayerInventory = IsPlayerInventory; + + this.requiredItems = new Dictionary(); + for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) + { + ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); + this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount); + } + this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2 - 96, this.getCraftingButtonHeight()), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"), new StardustCore.Animations.Animation(0, 0, 48, 16)), Color.White), new Rectangle(0, 0, 48, 16), 4f); + + if (OutputInventory == null) + { + this.outputInventory = this.inventory; + } + this.outputInventory = OutputInventory; + this.machine = Machine; } public override void receiveLeftClick(int x, int y, bool playSound = true) @@ -72,7 +103,19 @@ namespace Revitalize.Framework.Menus if (this.canCraftRecipe()) { Game1.soundBank.PlayCue("coin"); - this.infoButton.craftItem(); + + this.infoButton.craftItem(this.inventory, this.outputInventory); + if (this.machine != null) + { + if (this.infoButton.recipe.timeToCraft == 0) + { + this.machine.InventoryManager.dumpBufferToItems(); + } + else + { + this.machine.MinutesUntilReady = this.infoButton.recipe.timeToCraft; + } + } if (this.isPlayerInventory) { @@ -82,6 +125,41 @@ namespace Revitalize.Framework.Menus } } + public override void performHoverAction(int x, int y) + { + bool hovered = false; + if (this.craftingButton.containsPoint(x, y)) + { + if (this.infoButton.recipe.CanCraft(this.inventory) == false) + { + this.hoverText = "Not enough items."; + hovered = true; + } + if (this.machine != null) + { + if (this.machine.MinutesUntilReady > 0) + { + this.hoverText = "Crafting in progress..."; + hovered = true; + } + if (this.machine.MinutesUntilReady == 0 && this.machine.InventoryManager.hasItemsInBuffer) + { + this.hoverText = "Items in buffer. Please make room in the inventory for: " + System.Environment.NewLine + this.machine.InventoryManager + " items."; + hovered = true; + } + if (this.machine.InventoryManager.IsFull) + { + this.hoverText = "Inventory is full!"; + hovered = true; + } + } + } + if (hovered == false) + { + this.hoverText = ""; + } + } + public override void draw(SpriteBatch b) { this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); @@ -110,7 +188,16 @@ namespace Revitalize.Framework.Menus public bool canCraftRecipe() { - return this.infoButton.recipe.CanCraft(this.inventory); + bool canCraft = true; + if (this.infoButton.recipe.CanCraft(this.inventory) == false) canCraft = false; + + if (this.machine != null) + { + if (this.machine.InventoryManager.hasItemsInBuffer) canCraft = false; + if (this.machine.InventoryManager.IsFull) canCraft = false; + } + + return canCraft; } /// diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 202207c5..0b43795a 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Revitalize.Framework.Menus.MenuComponents; +using Revitalize.Framework.Objects.Machines; using StardewValley; using StardewValley.Menus; using StardustCore.UIUtilities; @@ -90,6 +91,8 @@ namespace Revitalize.Framework.Menus /// public StardewValley.Menus.TextBox searchBox; + private Machine machine; + /// /// The maximum amount of pages to display. /// @@ -167,7 +170,7 @@ namespace Revitalize.Framework.Menus /// /// /// - public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList FromInventory, ref IList ToInventory) : base(X, Y, Width, Height, false) + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList FromInventory, ref IList ToInventory,Machine Machine) : base(X, Y, Width, Height, false) { this.backgroundColor = BackgroundColor; this.CraftingTabs = new Dictionary(); @@ -176,6 +179,8 @@ namespace Revitalize.Framework.Menus this.fromInventory = FromInventory; this.toInventory = ToInventory; this.initializeButtons(); + this.machine = Machine; + this.playerInventory = false; } /// @@ -386,17 +391,19 @@ namespace Revitalize.Framework.Menus this.fromInventory = Game1.player.Items; } - this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width + this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button, ref this.fromInventory, this.playerInventory); + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width + this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button, ref this.fromInventory,ref this.toInventory,this.playerInventory,this.machine); Game1.soundBank.PlayCue("coin"); if (this.playerInventory) { Game1.player.Items = this.toInventory; return; } - + //ModCore.log("Button has been clicked!"); + return; } } } + //ModCore.log("Menu has been clicked"); if (this.craftingInfo != null) { @@ -420,7 +427,7 @@ namespace Revitalize.Framework.Menus this.leftButton.draw(b); //Draw page numbers here. //b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/) - b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages + 1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen), Color.White); + b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages + 1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen+32), Color.White); this.rightButton.draw(b); this.searchBox.Draw(b, true); diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs index 835bf21c..98f13775 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs @@ -19,6 +19,7 @@ namespace Revitalize.Framework.Menus.Machines public string currentTab; public string hoverText; + public IClickableMenuExtended CurrentMenu { get diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 9f2b42f7..96f4d136 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -14,6 +14,12 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus.Machines { + /// + /// TODO: + /// Add in minutes remaining display + /// Add in remaining inventory space display. + /// Make crafting menu require the object passed in to count down before crafting the recipe. + /// public class MachineSummaryMenu : IClickableMenuExtended { @@ -45,12 +51,24 @@ namespace Revitalize.Framework.Menus.Machines } } + + /// + /// Should this menu draw the battery for the energy guage? + /// + private bool shouldDrawBattery + { + get + { + return this.energy.maxEnergy != 0 || ModCore.Configs.machinesConfig.doMachinesConsumeEnergy==false; + } + } + public MachineSummaryMenu() { } - public MachineSummaryMenu(int x, int y, int width, int height, Color BackgroundColor, CustomObject SourceObject):base(x,y,width,height,false) + public MachineSummaryMenu(int x, int y, int width, int height, Color BackgroundColor, CustomObject SourceObject) : base(x, y, width, height, false) { this.objectSource = SourceObject; @@ -58,8 +76,8 @@ namespace Revitalize.Framework.Menus.Machines this.energyTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); this.colorSwap(); - this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72*4); - this.batteryBackground =new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)),Color.White),new Rectangle(0,0,32,64),4f); + this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4); + this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.battergyEnergyGuage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryEnergyGuage", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryEnergyGuage"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource); @@ -68,9 +86,9 @@ namespace Revitalize.Framework.Menus.Machines public override void performHoverAction(int x, int y) { bool hovered = false; - if (this.batteryBackground.containsPoint(x, y)) + if (this.batteryBackground.containsPoint(x, y) && this.shouldDrawBattery) { - this.hoverText ="Energy: "+this.energy.energyDisplayString; + this.hoverText = "Energy: " + this.energy.energyDisplayString; hovered = true; } @@ -90,16 +108,21 @@ namespace Revitalize.Framework.Menus.Machines { this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); - this.batteryBackground.draw(b, 1f, 1f); - this.colorSwap(); - b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X+(int)(11*this.batteryBackground.scale), (int)this.energyPosition.Y+(int)(18*this.batteryBackground.scale), (int)(9*this.batteryBackground.scale), (int)(46*this.batteryBackground.scale)), new Rectangle(0, 0, 1, 1), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.2f); - this.battergyEnergyGuage.draw(b, 1f, 1f); + //Draw the energy on the screen. + + if (this.shouldDrawBattery) + { + this.batteryBackground.draw(b, 1f, 1f); + this.colorSwap(); + b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale), (int)(9 * this.batteryBackground.scale), (int)(46 * this.batteryBackground.scale)), new Rectangle(0, 0, 1, 1), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.2f); + this.battergyEnergyGuage.draw(b, 1f, 1f); + } - this.objectSource.drawFullyInMenu(b,new Vector2((int)(this.xPositionOnScreen+ (this.width / 2) - (this.itemDisplayOffset.X / 2)),(int)(this.yPositionOnScreen+128f)),.24f); + this.objectSource.drawFullyInMenu(b, new Vector2((int)(this.xPositionOnScreen + (this.width / 2) - (this.itemDisplayOffset.X / 2)), (int)(this.yPositionOnScreen + 128f)), .24f); Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName); - b.DrawString(Game1.dialogueFont, this.objectSource.DisplayName, new Vector2(this.xPositionOnScreen + (this.width / 2)-nameOffset.X/2, (this.yPositionOnScreen + 150f)) + new Vector2(0,ObjectUtilities.GetHeightOffsetFromItem(this.objectSource)), Color.Black); + b.DrawString(Game1.dialogueFont, this.objectSource.DisplayName, new Vector2(this.xPositionOnScreen + (this.width / 2) - nameOffset.X / 2, (this.yPositionOnScreen + 150f)) + new Vector2(0, ObjectUtilities.GetHeightOffsetFromItem(this.objectSource)), Color.Black); if (string.IsNullOrEmpty(this.hoverText) == false) { @@ -109,7 +132,7 @@ namespace Revitalize.Framework.Menus.Machines this.drawMouse(b); - + } /// /// Swaps the color for the energy bar meter depending on how much energy is left. @@ -127,7 +150,7 @@ namespace Revitalize.Framework.Menus.Machines { col = Color.GreenYellow; } - else if(this.energy.energyPercentRemaining>.25d && this.energy.energyPercentRemaining <= .5d) + else if (this.energy.energyPercentRemaining > .25d && this.energy.energyPercentRemaining <= .5d) { col = Color.Yellow; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 70d3350b..95626ec5 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -7,9 +7,15 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; +using Revitalize.Framework.Crafting; +using Revitalize.Framework.Menus; +using Revitalize.Framework.Menus.Machines; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Utilities; using StardewValley; +using StardustCore.Animations; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Objects.Machines { @@ -31,7 +37,7 @@ namespace Revitalize.Framework.Objects.Machines string timeToProduce = this.timeToProduce.ToString(); string updatesContainer = this.updatesContainerObjectForProduction.ToString(); - return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container+"<"+resources+"<"+energyRequired+"<"+timeToProduce+"<"+updatesContainer; + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container+"<"+resources+"<"+energyRequired+"<"+timeToProduce+"<"+updatesContainer+"<"+this.craftingRecipeBook; } set { @@ -46,6 +52,7 @@ namespace Revitalize.Framework.Objects.Machines string energyRequired = data[6]; string time = data[7]; string updates = data[8]; + this.craftingRecipeBook = data[9]; this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); this.energyRequiredPer10Minutes = Convert.ToInt32(energyRequired); @@ -114,6 +121,8 @@ namespace Revitalize.Framework.Objects.Machines public int timeToProduce; public bool updatesContainerObjectForProduction; + public string craftingRecipeBook; + [JsonIgnore] public bool ProducesItems { @@ -137,15 +146,16 @@ namespace Revitalize.Framework.Objects.Machines public Machine() { } - public Machine(CustomObjectData PyTKData, BasicItemInformation info,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0,int TimeToProduce=0,bool UpdatesContainer=false) : base(PyTKData, info) { + public Machine(CustomObjectData PyTKData, BasicItemInformation info,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0,int TimeToProduce=0,bool UpdatesContainer=false, string CraftingBook = "") : base(PyTKData, info) { this.producedResources = ProducedResources?? new List(); this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; this.timeToProduce = TimeToProduce; this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; } - public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources=null,int EnergyRequiredPer10Minutes=0,int TimeToProduce=0,bool UpdatesContainer=false,MultiTiledObject obj=null) : base(PyTKData, info, TileLocation) + 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) { this.containerObject = obj; this.producedResources = ProducedResources ?? new List(); @@ -153,9 +163,10 @@ namespace Revitalize.Framework.Objects.Machines this.timeToProduce = TimeToProduce; this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; } - public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce=0,bool UpdatesContainer=false,MultiTiledObject obj = null) : base(PyTKData, info, TileLocation) + 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) { this.offsetKey = offsetKey; this.containerObject = obj; @@ -163,6 +174,7 @@ namespace Revitalize.Framework.Objects.Machines this.timeToProduce = TimeToProduce; this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; } public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) @@ -185,7 +197,6 @@ namespace Revitalize.Framework.Objects.Machines energySources = this.EnergyGraphSearchSources(); //Only grab the network once. } - if (this.ProducesItems) { //ModCore.log("This produces items!"); @@ -219,6 +230,17 @@ namespace Revitalize.Framework.Objects.Machines this.produceEnergy(); } } + if (this.MinutesUntilReady>0) + { + this.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); + + if(this.InventoryManager.hasItemsInBuffer && this.MinutesUntilReady == 0) + { + this.InventoryManager.dumpBufferToItems(); + } + + } + return false; } else @@ -235,18 +257,40 @@ namespace Revitalize.Framework.Objects.Machines if (this.location == null) this.location = Game1.player.currentLocation; if (Game1.menuUp || Game1.currentMinigame != null) return false; - if (this.containerObject.info.inventory != null && Game1.activeClickableMenu == null) - { - Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, this.containerObject.info.inventory.items, this.containerObject.info.inventory.capacity); - } - //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + this.createMachineMenu(); return true; } + /// + /// Creates the necessary components to display the machine menu properly. + /// + protected virtual void createMachineMenu() + { + MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); + + MachineSummaryMenu m = new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width / 2) - 400, 48, 800, 600, Color.White, this.containerObject); + machineMenu.addInMenuTab("Summary", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), m, true); + + if (this.InventoryManager.capacity > 0) + { + InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, 36); + machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, false); + } + + if (string.IsNullOrEmpty(this.craftingRecipeBook)==false) + { + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items,ref this.InventoryManager.bufferItems,this); + machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); + } + + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu; + } + public override Item getOne() { - Machine component = new Machine(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources,this.energyRequiredPer10Minutes,this.timeToProduce,this.updatesContainerObjectForProduction,this.containerObject); + Machine component = new Machine(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources,this.energyRequiredPer10Minutes,this.timeToProduce,this.updatesContainerObjectForProduction,this.craftingRecipeBook,this.containerObject); return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 516a2f5d..fd630ab9 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -154,24 +154,24 @@ namespace Revitalize.Framework.Objects MultiTiledObject sandBox = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); Machine sandBox_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"),new Animation(0,0,16,16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) + //new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), true); + }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), true,"Workbench"); Machine sandBox_1_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) + //new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), false); + }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), false, "Workbench"); Machine sandBox_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) + //new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, TimeUtilities.GetMinutesFromTime(0,1,0), false); + }, 0, TimeUtilities.GetMinutesFromTime(0,1,0), false, "Workbench"); Machine sandBox_1_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() { - new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) + //new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) - }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), false); + }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), false, "Workbench"); sandBox.addComponent(new Vector2(0,0),sandBox_0_0); sandBox.addComponent(new Vector2(1, 0), sandBox_1_0); diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index c16409e2..76202707 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -20,12 +20,26 @@ namespace Revitalize.Framework.Utilities /// The actual contents of the inventory. public IList items; + /// + /// Items that are to be buffered into the inventory manager if possible. + /// + public IList bufferItems; + /// Checks if the inventory is full or not. public bool IsFull => this.ItemCount >= this.capacity && this.items.Where(i=>i==null).Count()==0; /// Checks to see if this core object actually has a valid inventory. public bool HasInventory => this.capacity > 0; + [JsonIgnore] + public bool hasItemsInBuffer + { + get + { + return this.bufferItems.Count > 0; + } + } + [JsonIgnore] public bool requiresUpdate; public InventoryManager() @@ -33,6 +47,7 @@ namespace Revitalize.Framework.Utilities this.capacity = 0; this.setMaxLimit(0); this.items = new List(); + this.bufferItems = new List(); } /// Construct an instance. @@ -41,6 +56,7 @@ namespace Revitalize.Framework.Utilities this.capacity = int.MaxValue; this.setMaxLimit(int.MaxValue); this.items = items; + this.bufferItems = new List(); } public InventoryManager(IList items) @@ -48,6 +64,7 @@ namespace Revitalize.Framework.Utilities this.capacity = int.MaxValue; this.setMaxLimit(int.MaxValue); this.items = items; + this.bufferItems = new List(); } /// Construct an instance. @@ -56,6 +73,7 @@ namespace Revitalize.Framework.Utilities this.capacity = capacity; this.MaxCapacity = int.MaxValue; this.items = new List(); + this.bufferItems = new List(); } /// Construct an instance. @@ -64,6 +82,7 @@ namespace Revitalize.Framework.Utilities this.capacity = capacity; this.setMaxLimit(MaxCapacity); this.items = new List(); + this.bufferItems = new List(); } /// Add the item to the inventory. @@ -75,15 +94,23 @@ namespace Revitalize.Framework.Utilities } else { - foreach (Item self in this.items) + for(int i = 0; i < this.items.Count; i++) { + Item self = this.items[i]; if (self != null && self.canStackWith(item)) { self.addToStack(item.Stack); this.requiresUpdate = true; return true; } + if (self == null) + { + self = item; + this.requiresUpdate=true; + return true; + } } + this.requiresUpdate = true; this.items.Add(item); return true; @@ -156,5 +183,14 @@ namespace Revitalize.Framework.Utilities { return new InventoryManager(this.capacity, this.MaxCapacity); } + + public void dumpBufferToItems() + { + foreach(Item I in this.bufferItems) + { + this.addItem(I); + } + this.bufferItems.Clear(); + } } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 98f8a122..b8d69715 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -254,7 +254,6 @@ namespace Revitalize //Loads in objects to be use by the mod. ObjectGroups = new Dictionary(); ObjectManager = new ObjectManager(Manifest); - ObjectManager.loadInItems(); ObjectsToDraw = new Dictionary(); //Adds in event handling for the mod. @@ -278,9 +277,7 @@ namespace Revitalize ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.ResetNormalToolsColorOnLeftClick; - //Adds in recipes to the mod. - VanillaRecipeBook = new VanillaRecipeBook(); - CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary(); + ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory; @@ -339,9 +336,12 @@ namespace Revitalize MachineSummaryMenu m= new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width/2)-400, 48, 800, 600,Color.White,test); InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, test.info.inventory.items, 36); MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); + CraftingMenuV1 craftingMenu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items); machineMenu.addInMenuTab("Summary",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab",new Vector2(),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest,"Menus","MenuTab"),new Animation(0,0,24,24)),Color.White),new Rectangle(0,0,24,24),2f),m,true); machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, true); + machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, true); + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu; } @@ -537,6 +537,11 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { this.loadContent(); + ObjectManager.loadInItems(); + //Adds in recipes to the mod. + VanillaRecipeBook = new VanillaRecipeBook(); + CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary(); + Serializer.afterLoad(); ShopHacks.AddInCustomItemsToShops(); ObjectInteractionHacks.AfterLoad_RestoreTrackedMachines(); @@ -555,7 +560,8 @@ namespace Revitalize new StardewValley.Object((int)Enums.SDVObject.Wood,100), ModCore.ObjectManager.GetItem("SteelIngot", 20), ModCore.ObjectManager.GetItem("TrashCan",1), - ModCore.ObjectManager.GetItem("SandBox",1) + ModCore.ObjectManager.GetItem("SandBox",1), + ModCore.ObjectManager.GetItem("Anvil",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index acdcba05..6923477e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -62,7 +62,6 @@ - diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs index 32fd685c..6780eac0 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs @@ -122,6 +122,10 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) { if(this.background!=null)this.background.draw(b, this.scale, Depth,Alpha); + if (this.item == null) + { + ModCore.log("ITEM IS NULL!!!!"); + } if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow); } @@ -137,12 +141,20 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons { if (this.background != null) this.background.draw(b,Position,this.scale, Depth, Alpha); if (this.item != null) this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + if (this.item == null) + { + ModCore.log("ITEM IS NULL!!!!"); + } } public void draw(SpriteBatch b,float ItemScale ,float Depth, float Alpha, bool DrawShadow) { this.background.draw(b, this.scale, Depth, Alpha); if (this.item != null) this.item.drawInMenu(b, this.position, ItemScale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + if (this.item == null) + { + ModCore.log("ITEM IS NULL!!!!"); + } } /// @@ -155,6 +167,10 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// Should the shadow be drawn for the item? public void drawJustItem(SpriteBatch b,float Scale,float Depth, float Alpha, bool DrawShadow) { + if (this.item == null) + { + ModCore.log("ITEM IS NULL!!!!"); + } if (this.item != null) this.item.drawInMenu(b, this.position, Scale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); } From 048dfc9dc0dc0e5587e037763781d773ebbd6b27 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 11 Sep 2019 22:48:38 -0700 Subject: [PATCH 46/98] Fixed crafting menu multi tiled objects not displaying. --- .../Framework/Crafting/CraftingRecipeBook.cs | 38 +++++++++++++++++++ .../Revitalize/Framework/Crafting/Recipe.cs | 9 +---- .../Framework/Objects/MultiTiledObject.cs | 7 +++- .../Framework/Objects/ObjectManager.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 24 +++++------- .../ComponentsV2/Buttons/ItemDisplayButton.cs | 20 +++------- 6 files changed, 61 insertions(+), 41 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index c6903062..271d3e6d 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Revitalize.Framework.Menus; +using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Machines; using Revitalize.Framework.Utilities; using StardewValley; @@ -257,6 +258,43 @@ namespace Revitalize.Framework.Crafting } InitializeRecipeBooks(); + + + for(int bookIndex=0;bookIndex pair = CraftingRecipesByGroup.ElementAt(bookIndex); + for(int recipeIndex=0;recipeIndex recipe = pair.Value.craftingRecipes.ElementAt(recipeIndex); + for (int i = 0; i < recipe.Value.recipe.ingredients.Count; i++) + { + if (recipe.Value.recipe.ingredients[i].item is MultiTiledObject) + { + ModCore.log("Found a multi tiled object as an output!"); + //ModCore.log("Found a multi tiled object!"); + Type t = recipe.Value.recipe.ingredients[i].item.GetType(); + string id = (recipe.Value.recipe.ingredients[i].item as MultiTiledObject).info.id; + recipe.Value.recipe.ingredients[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t); + } + } + for (int i = 0; i < recipe.Value.recipe.outputs.Count; i++) + { + if (recipe.Value.recipe.outputs[i].item is MultiTiledObject) + { + ModCore.log("Found a multi tiled object as an output!"); + //ModCore.log("Found a multi tiled object!"); + Type t = recipe.Value.recipe.outputs[i].item.GetType(); + string id = (recipe.Value.recipe.outputs[i].item as MultiTiledObject).info.id; + recipe.Value.recipe.outputs[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t); + + ModCore.log("Components are: "+(recipe.Value.recipe.outputs[i].item as MultiTiledObject).objects.Count); + } + } + } + } + + } private static void InitializeRecipeBooks() diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index 475019e5..af8db6e5 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -19,15 +19,10 @@ namespace Revitalize.Framework.Crafting /// public List outputs; - /// - /// The item that is displayed for the crafting recipe. - /// - private Item displayItem; public Item DisplayItem { - get => this.displayItem ?? this.outputs.ElementAt(0).item; - set => this.displayItem = value; + get => this.outputs.ElementAt(0).item; } /// @@ -57,7 +52,6 @@ namespace Revitalize.Framework.Crafting public Recipe(List inputs, CraftingRecipeComponent output, StatCost StatCost = null,int TimeToCraft=0) { this.ingredients = inputs; - this.DisplayItem = output.item; this.outputDescription = output.item.getDescription(); this.outputName = output.item.DisplayName; this.outputs = new List() @@ -74,7 +68,6 @@ namespace Revitalize.Framework.Crafting this.outputs = outputs; this.outputName = OutputName; this.outputDescription = OutputDescription; - this.DisplayItem = DisplayItem; this.statCost = StatCost ?? new StatCost(); this.timeToCraft = TimeToCraft; } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index afc140fa..f081be7a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -213,7 +213,10 @@ namespace Revitalize.Framework.Objects { this.updateInfo(); foreach (KeyValuePair pair in this.objects) - pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16)+new Vector2(32,32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + { + //ModCore.log(location + (pair.Key * 16) + new Vector2(32, 32)); + pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16) + new Vector2(32, 32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + } //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); } @@ -366,7 +369,7 @@ namespace Revitalize.Framework.Objects Dictionary objs = new Dictionary(); foreach (var pair in this.objects) { - objs.Add(pair.Key, (MultiTiledComponent)pair.Value); + objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne()); } return new MultiTiledObject(this.data, this.info.Copy(), this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index fd630ab9..902b8cba 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -356,13 +356,13 @@ namespace Revitalize.Framework.Objects /// /// /// - public CustomObject GetItem(string Key,int Stack=1) + public Item GetItem(string Key,int Stack=1) { if (this.ItemsByName.ContainsKey(Key)) { Item I= this.ItemsByName[Key].getOne(); I.Stack = Stack; - return (CustomObject)I; + return I; } else { diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b8d69715..195560b2 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -330,20 +330,16 @@ namespace Revitalize */ if (e.Button == SButton.U) { - MultiTiledObject test =(MultiTiledObject) ObjectManager.GetItem("SandBox"); - test.EnergyManager.maxEnergy = 100; - test.EnergyManager.produceEnergy(100); - MachineSummaryMenu m= new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width/2)-400, 48, 800, 600,Color.White,test); - InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, test.info.inventory.items, 36); - MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); - CraftingMenuV1 craftingMenu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items); - - machineMenu.addInMenuTab("Summary",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab",new Vector2(),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest,"Menus","MenuTab"),new Animation(0,0,24,24)),Color.White),new Rectangle(0,0,24,24),2f),m,true); - machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, true); - machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, true); - - - if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu; + CraftingMenuV1 craft = new CraftingMenuV1(100, 100, 600, 800, Color.White, Game1.player.Items); + craft.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + craft.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new List() + { + //Inputs here + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)),null,new Vector2(),new Rectangle(0,0,32,32),1f,false,Color.White),"Default"); + craft.currentTab = "Default"; + craft.sortRecipes(); + Game1.activeClickableMenu = craft; } /* if (e.Button == SButton.Y) diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs index 6780eac0..729e823f 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs @@ -108,7 +108,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons { //this.background.draw(b); //if(this.item!=null)this.item.drawInMenu(b, this.position, this.scale); - this.draw(b, 1f, Alpha, false); + this.draw(b, 0f, Alpha, false); } @@ -122,11 +122,10 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) { if(this.background!=null)this.background.draw(b, this.scale, Depth,Alpha); - if (this.item == null) + if (this.item != null) { - ModCore.log("ITEM IS NULL!!!!"); + this.item.drawInMenu(b, this.position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); } - if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow); } /// @@ -140,10 +139,9 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public void draw(SpriteBatch b,Vector2 Position ,float Depth, float Alpha, bool DrawShadow) { if (this.background != null) this.background.draw(b,Position,this.scale, Depth, Alpha); - if (this.item != null) this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); - if (this.item == null) + if (this.item != null) { - ModCore.log("ITEM IS NULL!!!!"); + this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); } } @@ -151,10 +149,6 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons { this.background.draw(b, this.scale, Depth, Alpha); if (this.item != null) this.item.drawInMenu(b, this.position, ItemScale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); - if (this.item == null) - { - ModCore.log("ITEM IS NULL!!!!"); - } } /// @@ -167,10 +161,6 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// Should the shadow be drawn for the item? public void drawJustItem(SpriteBatch b,float Scale,float Depth, float Alpha, bool DrawShadow) { - if (this.item == null) - { - ModCore.log("ITEM IS NULL!!!!"); - } if (this.item != null) this.item.drawInMenu(b, this.position, Scale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); } From 5e5c15f69233c8718287f2ea4e30b99b5e459071 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 11 Sep 2019 22:59:39 -0700 Subject: [PATCH 47/98] Updated machine inventory menu to update when an item is crafted. --- .../Framework/Menus/CraftingInformationPage.cs | 3 +++ .../Framework/Menus/InventoryTransferMenu.cs | 7 +++++++ .../Framework/Menus/Machines/MachineMenu.cs | 11 +++++++++++ .../Revitalize/Framework/Objects/Machines/Machine.cs | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 5bb7c30d..7fad536c 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Revitalize.Framework.Crafting; +using Revitalize.Framework.Menus.Machines; using Revitalize.Framework.Menus.MenuComponents; using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Machines; @@ -121,6 +122,8 @@ namespace Revitalize.Framework.Menus { this.inventory = Game1.player.Items; } + + if (Game1.activeClickableMenu is MachineMenu) (Game1.activeClickableMenu as MachineMenu).updateInventoryMenuIfPossible(); } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs index 9870c167..1a3b21c7 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -457,5 +457,12 @@ namespace Revitalize.Framework.Menus { if (this.displayTrashedItem && this.trashedItem.item!=null) IClickableMenu.drawToolTip(b, this.trashedItem.item.getDescription(), this.trashedItem.item.DisplayName, this.trashedItem.item, false, -1, 0, -1, -1, (CraftingRecipe)null, -1); } + + + public void updateInventory() + { + this.playerInventory.populateClickableItems(); + this.otherInventory.populateClickableItems(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs index 98f13775..e6494c82 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs @@ -12,6 +12,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus.Machines { + /// + /// Need to + /// public class MachineMenu : IClickableMenuExtended { @@ -148,5 +151,13 @@ namespace Revitalize.Framework.Menus.Machines this.drawMouse(b); } + + public void updateInventoryMenuIfPossible() + { + if (this.menuPages.ContainsKey("Inventory")) + { + (this.menuPages["Inventory"].Value as InventoryTransferMenu).updateInventory(); + } + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 95626ec5..3087e042 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -281,7 +281,7 @@ namespace Revitalize.Framework.Objects.Machines if (string.IsNullOrEmpty(this.craftingRecipeBook)==false) { - CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items,ref this.InventoryManager.bufferItems,this); + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items,ref this.InventoryManager.items,this); machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); } From fcf27bdc52bead062d33084d96406ceecb2a38e8 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 16 Sep 2019 15:48:26 -0700 Subject: [PATCH 48/98] Added in solar pannels and fixed the energy display meter on the machine summary menu. --- .../Objects/Machines/SolarArrayTier1.png | Bin 0 -> 321 bytes .../Objects/Machines/SolarPanelTier1.png | Bin 0 -> 291 bytes .../Framework/Configs/GlobalMachineConfig.cs | 5 + .../Framework/Energy/EnergyManager.cs | 7 +- .../Menus/Machines/MachineSummaryMenu.cs | 2 +- .../Machines/EnergyGeneration/SolarPanel.cs | 163 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 19 ++ .../Framework/Utilities/WeatherUtilities.cs | 68 ++++++++ GeneralMods/Revitalize/ModCore.cs | 15 +- GeneralMods/Revitalize/Revitalize.csproj | 8 + 10 files changed, 277 insertions(+), 10 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SolarArrayTier1.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SolarPanelTier1.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs create mode 100644 GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SolarArrayTier1.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SolarArrayTier1.png new file mode 100644 index 0000000000000000000000000000000000000000..adc2a3497da0126be5a2015478cd1f45e480447b GIT binary patch literal 321 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}zdcL-_U+w z1+$y1!7Bz4_K0ZL%Xge2b_=X#&UnjFa#~V?ZAIj{0}UCojD>mNV~NqYob^M!)=phHP?U# zxAz?X{rUd$!!--?1r%-0uil?~YLm}5%|$K?*G2T8aH$_ULYx5I@lENFYQF2S!O#b$R)G{$Bsu;aZ<9x6;vrhloezv*M9t3A(xudlLC_<7*wY0F-&68_NjGbylN additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + SolarPanel self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override void produceEnergy() + { + if (this.EnergyManager.canReceieveEnergy) + { + int energy= this.energyRequiredPer10Minutes; + if (WeatherUtilities.IsWetWeather()) + { + energy = (int)(energy * ModCore.Configs.machinesConfig.solarPanelNonSunnyDayEnergyMultiplier); + } + + if (Game1.timeOfDay >= Game1.getModeratelyDarkTime()) + { + energy = (int)(energy * ModCore.Configs.machinesConfig.solarPanelNightEnergyGenerationMultiplier); + } + if (this.location != null) + { + if (this.location.IsOutdoors == false) return; + } + this.EnergyManager.produceEnergy(energy); + } + + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + if (this.info.ignoreBoundingBox == true) + { + x *= -1; + y *= -1; + } + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 902b8cba..4708384e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -10,6 +10,7 @@ using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Objects.Items.Tools; using Revitalize.Framework.Objects.Machines; +using Revitalize.Framework.Objects.Machines.EnergyGeneration; using Revitalize.Framework.Utilities; using StardewModdingAPI; using StardewValley; @@ -180,6 +181,24 @@ namespace Revitalize.Framework.Objects this.AddItem("SandBox", sandBox); + + MultiTiledObject solarpanel1Container = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarPanelV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarPanelTier1"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Solar Panel", "Omegasis.Revitalize.Objects.Machines.SolarPanel", "Generates energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarPanelTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarPanelTier1"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces))); + SolarPanel solarP1 = new SolarPanel(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarPanelTier1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarPanelTier1"), typeof(SolarPanel), Color.White, true), new BasicItemInformation("Solar Panel", "Omegasis.Revitalize.Objects.Machines.SolarPanelV1", "Generates energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarPanelTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarPanelTier1"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces)),2,0,true); + solarpanel1Container.addComponent(new Vector2(0, 0), solarP1); + this.AddItem("SolarPanelTier1", solarpanel1Container); + + + MultiTiledObject solarArray1Container = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarArrayV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Solar Array", "Omegasis.Revitalize.Objects.Machines.SolarArrayV1", "A collection of solar panels that generates even more energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces))); + SolarPanel solarA1V1 = new SolarPanel(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarArrayTier1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), typeof(SolarPanel), Color.White, true), new BasicItemInformation("Solar Array", "Omegasis.Revitalize.Objects.Machines.SolarArrayV1", "A collection of solar panels that generates even more energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces)), 8, 0, true); + SolarPanel solarA2V1 = new SolarPanel(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarArrayTier1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), typeof(SolarPanel), Color.White, true), new BasicItemInformation("Solar Array", "Omegasis.Revitalize.Objects.Machines.SolarArrayV1", "A collection of solar panels that generates even more energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new Animation(16, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces)), 8, 0, false); + SolarPanel solarA3V1 = new SolarPanel(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarArrayTier1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), typeof(SolarPanel), Color.White, true), new BasicItemInformation("Solar Array", "Omegasis.Revitalize.Objects.Machines.SolarArrayV1", "A collection of solar panels that generates even more energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces)), 8, 0, false); + SolarPanel solarA4V1 = new SolarPanel(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SolarArrayTier1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), typeof(SolarPanel), Color.White, true), new BasicItemInformation("Solar Array", "Omegasis.Revitalize.Objects.Machines.SolarArrayV1", "A collection of solar panels that generates even more energy while the sun is up.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SolarArrayTier1"), new Animation(16, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Produces)), 8, 0, false); + + solarArray1Container.addComponent(new Vector2(0, 0), solarA1V1); + solarArray1Container.addComponent(new Vector2(1, 0), solarA2V1); + solarArray1Container.addComponent(new Vector2(0, 1), solarA3V1); + solarArray1Container.addComponent(new Vector2(1, 1), solarA4V1); + this.AddItem("SolarArrayTier1", solarArray1Container); } private void loadInTools() diff --git a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs new file mode 100644 index 00000000..d01b4d50 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using StardewValley; + +namespace Revitalize.Framework.Utilities +{ + public class WeatherUtilities + { + + public static bool IsItRaining() + { + + return Game1.isRaining; + } + + public static bool IsItSnowing() + { + return Game1.isSnowing; + } + + public static bool IsStorm() + { + return Game1.isLightning; + } + + public static bool IsWedding() + { + return Game1.weddingToday; + } + + public static bool IsSunny() + { + return Game1.weatherIcon == Game1.weather_sunny; + } + + public static bool IsWindyDay() + { + return Game1.isDebrisWeather; + } + + public static bool IsFestivalWeather() + { + return Game1.weatherIcon == Game1.weather_festival; + } + + /// + /// Checks if the weather for the day is good weather. Aka no rain or snow. + /// + /// + public static bool IsClearWeather() + { + return IsWindyDay() || IsSunny() || IsWedding() || IsFestivalWeather(); + } + + /// + /// Checks if the weather for the day is unclear. + /// + /// + public static bool IsWetWeather() + { + return IsItRaining() || IsItSnowing() || IsStorm(); + } + + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 195560b2..f2caff2f 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -281,6 +281,10 @@ namespace Revitalize ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory; + ObjectManager.loadInItems(); + //Adds in recipes to the mod. + VanillaRecipeBook = new VanillaRecipeBook(); + CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary(); } @@ -532,11 +536,8 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - this.loadContent(); - ObjectManager.loadInItems(); - //Adds in recipes to the mod. - VanillaRecipeBook = new VanillaRecipeBook(); - CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary(); + //this.loadContent(); + Serializer.afterLoad(); ShopHacks.AddInCustomItemsToShops(); @@ -557,7 +558,9 @@ namespace Revitalize ModCore.ObjectManager.GetItem("SteelIngot", 20), ModCore.ObjectManager.GetItem("TrashCan",1), ModCore.ObjectManager.GetItem("SandBox",1), - ModCore.ObjectManager.GetItem("Anvil",1) + ModCore.ObjectManager.GetItem("Anvil",1), + ModCore.ObjectManager.GetItem("SolarPanelTier1",1), + ModCore.ObjectManager.GetItem("SolarArrayTier1",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 6923477e..b8c112d7 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -154,6 +154,7 @@ + @@ -185,6 +186,7 @@ + @@ -406,6 +408,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest From 45aad966c05c02066d142891edf1098bc8d228a5 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 16 Sep 2019 16:33:19 -0700 Subject: [PATCH 49/98] Added in status for time remaining for the machine summary menu. --- .../Content/Graphics/Menus/Misc/Clock.png | Bin 0 -> 349 bytes .../Menus/Machines/MachineSummaryMenu.cs | 27 ++++- .../Framework/Utilities/TimeUtilities.cs | 105 ++++++++++++++++++ .../Framework/Utilities/WeatherUtilities.cs | 3 + GeneralMods/Revitalize/Revitalize.csproj | 3 + 5 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/Misc/Clock.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/Clock.png b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/Clock.png new file mode 100644 index 0000000000000000000000000000000000000000..069cbca4013ce18cd12cd1f3ba48a8c4c43d95ee GIT binary patch literal 349 zcmV-j0iyniP)Px$7fD1xR5*>T)G=!UF%-b@{~ZM>6r|uPh%GoA4syk%h~VbhsYCq$YViv=NTHuV ztb>b#AHktciX1KlaVQRj_HdS4gn~=)9PWZmaLAB1lEq4g(?|+ueAzmw@&z9W=^C^UfUf2nvDhkt#So`?tBWsTfa}V|3#9S z6N$mzdypg|7Qeofi}k(t8P9xSR&@Gf4mkBdmAP&PfcvW~0E1yp5}WUl2vxFNZq8Tw zbtyG3+RnxRj3#+WruIzawZvHZgfWrzbe8~N{$qy#z0w~5PX2tsIzB$nUL+~s9L(M| vD}8+lKp}MiU=`R}?@=KYNmfB*F(x_!CUI9mCV#f500000NkvXXu0mjf+gXli literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index fb1b2bef..d07c76ce 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -43,6 +43,10 @@ namespace Revitalize.Framework.Menus.Machines private Texture2D energyTexture; private Vector2 itemDisplayOffset; + + private AnimatedButton clockSprite; + private Vector2 timeDisplayLocation; + private EnergyManager energy { get @@ -74,13 +78,17 @@ namespace Revitalize.Framework.Menus.Machines this.objectSource = SourceObject; this.backgroundColor = BackgroundColor; this.energyTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); - this.colorSwap(); + this.energyMeterColorSwap(); + + this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f)); this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4); this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.battergyEnergyGuage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryEnergyGuage", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryEnergyGuage"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource); + + this.clockSprite= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Time Remaining",this.timeDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Clock"), new StardustCore.Animations.Animation(0, 0, 18, 18)), Color.White), new Rectangle(0, 0, 18, 18), 2f); } public override void performHoverAction(int x, int y) @@ -91,12 +99,19 @@ namespace Revitalize.Framework.Menus.Machines this.hoverText = "Energy: " + this.energy.energyDisplayString; hovered = true; } + if (this.clockSprite.containsPoint(x, y)) + { + this.hoverText = "Time Remaining: " + System.Environment.NewLine + TimeUtilities.GetVerboseTimeString(this.objectSource.MinutesUntilReady); + hovered = true; + } if (hovered == false) { this.hoverText = ""; } + + } @@ -113,11 +128,15 @@ namespace Revitalize.Framework.Menus.Machines if (this.shouldDrawBattery) { this.batteryBackground.draw(b, 1f, 1f); - this.colorSwap(); + this.energyMeterColorSwap(); b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale)+ (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f,1f), SpriteEffects.None, 0.2f); this.battergyEnergyGuage.draw(b, 1f, 1f); } + this.clockSprite.draw(b); + b.DrawString(Game1.smallFont,TimeUtilities.GetTimeString(this.objectSource.MinutesUntilReady), this.timeDisplayLocation+new Vector2(0,36f), Color.Black); + + this.objectSource.drawFullyInMenu(b, new Vector2((int)(this.xPositionOnScreen + (this.width / 2) - (this.itemDisplayOffset.X / 2)), (int)(this.yPositionOnScreen + 128f)), .24f); Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName); @@ -138,7 +157,7 @@ namespace Revitalize.Framework.Menus.Machines /// Swaps the color for the energy bar meter depending on how much energy is left. /// - private void colorSwap() + private void energyMeterColorSwap() { Color col = new Color(); //ModCore.log("Energy is: " + this.energy.energyPercentRemaining); @@ -169,5 +188,7 @@ namespace Revitalize.Framework.Menus.Machines }; this.energyTexture.SetData(color); } + + } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs index 681054cd..22f5ff7e 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs @@ -3,11 +3,94 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using PyTK.Types; namespace Revitalize.Framework.Utilities { public class TimeUtilities { + /// + /// Wraps SDV time to be able to display it better. + /// + public class StardewTime + { + public int days; + public int hours; + public int minutes; + public int weeks; + public int seasons; + public int years; + + public StardewTime() + { + + } + + public StardewTime(int Minutes) + { + this.parse(Minutes); + } + + + private void parse(int Minutes) + { + this.years = Minutes / 60 / 24 / 7 / 4 / 4; + Minutes -= (Minutes / 60 / 24 / 7 / 4 / 4); + this.seasons = Minutes / 60 / 24 / 7 / 4; + Minutes -= (Minutes / 60 / 24 / 7 / 4); + this.weeks = Minutes / 60 / 24 / 7; + Minutes -= (Minutes / 60 / 24 / 7); + this.days = Minutes / 60 / 24; + Minutes -= (Minutes / 60 / 24); + this.hours = Minutes / 60; + this.minutes -= (Minutes / 60); + this.minutes = Minutes; + } + + public string GetTimeString() + { + StringBuilder b = new StringBuilder(); + if (this.years > 0) b.Append("Y: " + this.years); + if (this.seasons > 0) b.Append("S: " + this.seasons); + if (this.weeks > 0) b.Append("W: " + this.weeks); + if (this.days > 0) b.Append("D: " + this.days); + if (this.hours > 0) b.Append("H: " + this.hours); + if (this.minutes > 0) b.Append("M: " + this.minutes); + else + { + b.Append("M: " + 0); + } + + return b.ToString(); + } + + public string GetVerboseString() + { + StringBuilder b = new StringBuilder(); + if (this.years > 0) b.Append("Years: " + this.years); + if (this.seasons > 0) b.Append("Seasons: " + this.seasons); + if (this.weeks > 0) b.Append("Weeks: " + this.weeks); + if (this.days > 0) b.Append("Days: " + this.days); + if (this.hours > 0) b.Append("Hours: " + this.hours); + if (this.minutes > 0) b.Append("Minutes: " + this.minutes); + else + { + b.Append("Minutes: " + 0); + } + + return b.ToString(); + } + + } + + + /// + /// Gets the minutes for the time passed in. + /// + /// + /// + /// + /// public static int GetMinutesFromTime(int Days, int Hours, int Minutes) { int amount=0; @@ -16,5 +99,27 @@ namespace Revitalize.Framework.Utilities amount += Minutes; return amount; } + + /// + /// Gets a shortened string representing the time. + /// + /// + /// + public static string GetTimeString(int Minutes) + { + StardewTime s = new StardewTime(Minutes); + return s.GetTimeString(); + } + + /// + /// Gets a more detailed string representation of the time. + /// + /// + /// + public static string GetVerboseTimeString(int Minutes) + { + StardewTime s = new StardewTime(Minutes); + return s.GetVerboseString(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs index d01b4d50..55aef69c 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs @@ -7,6 +7,9 @@ using StardewValley; namespace Revitalize.Framework.Utilities { + /// + /// Deals with usefull utilities to help determine the weather and the effects it has. + /// public class WeatherUtilities { diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b8c112d7..79641934 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -375,6 +375,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 5435157853a2cba8cae394d19b1bce7e86e44aa9 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 16 Sep 2019 19:17:23 -0700 Subject: [PATCH 50/98] Added in glass. --- .../Graphics/Items/Resources/Misc/Glass.png | Bin 0 -> 199 bytes .../Framework/Crafting/VanillaRecipeBook.cs | 7 +++++++ .../Framework/Objects/ResourceManager.cs | 3 +++ GeneralMods/Revitalize/ModCore.cs | 7 ++++--- GeneralMods/Revitalize/Revitalize.csproj | 3 +++ 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Misc/Glass.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Misc/Glass.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Misc/Glass.png new file mode 100644 index 0000000000000000000000000000000000000000..b51a80e97eedd8811e5b077d2cd8dd2f737b0853 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|8a-VcLo9li zPIeSxGUQ-kKi&TH`Dcc|jdrf9ZFAl_nk%L}ozmpv+|ZJ%vU2M((cSjpy*TJg;Xh%Vbq9T)#>` w-mLXz-;(4tIuZxs=b!wxjeT3>R@;y4CzH2ddXk&14|EKJr>mdKI;Vst0B4R$iU0rr literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs index 97fde867..ee24e917 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs @@ -160,6 +160,13 @@ namespace Revitalize.Framework.Crafting this.recipesByObjectName["Furnace"].Add("Silver Ingot", furnace_electrumIngot); + VanillaRecipe furnace_glass = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("Sand"),5} + + }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("Glass"),1), TimeUtilities.GetMinutesFromTime(0, 1, 0), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Sand", furnace_glass); } /// diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index eed1164b..5cecd49b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -311,6 +311,9 @@ namespace Revitalize.Framework.Objects { CustomObject sand=new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Misc.Sand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Misc", "Sand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Sand", "Omegasis.Revitalize.Items.Resources.Misc.Sand", "Sand which is made from tiny rocks and can be used for smelting. Also unfun to have inside of swimwear.", "Resource", Color.Brown, -300, 0, false, 2, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Misc", "Sand"), new AnimationManager(), Color.White, true, null, null)); this.resources.Add("Sand", sand); + + CustomObject glass_normal = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Misc.Glass", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Misc", "Glass"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Glass", "Omegasis.Revitalize.Items.Resources.Misc.Glass", "Glass smelted from sand. Used in decorations and glass objects.", "Resource", Color.Brown, -300, 0, false, 20, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Misc", "Glass"), new AnimationManager(), Color.White, true, null, null)); + this.resources.Add("Glass", glass_normal); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index f2caff2f..73cba1dc 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -554,13 +554,14 @@ namespace Revitalize //PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); Game1.player.addItemsByMenuIfNecessary(new List() { - new StardewValley.Object((int)Enums.SDVObject.Wood,100), + new StardewValley.Object((int)Enums.SDVObject.Coal,100), ModCore.ObjectManager.GetItem("SteelIngot", 20), ModCore.ObjectManager.GetItem("TrashCan",1), - ModCore.ObjectManager.GetItem("SandBox",1), + ModCore.ObjectManager.resources.getResource("Sand",5), ModCore.ObjectManager.GetItem("Anvil",1), ModCore.ObjectManager.GetItem("SolarPanelTier1",1), - ModCore.ObjectManager.GetItem("SolarArrayTier1",1) + ModCore.ObjectManager.GetItem("SolarArrayTier1",1), + new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 79641934..f27d4f03 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -204,6 +204,9 @@ + + PreserveNewest + PreserveNewest From 72da92e842bd152993840acb314f90d54a6edb69 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 16 Sep 2019 21:53:21 -0700 Subject: [PATCH 51/98] Added in the lighthouse. <3 --- .../Objects/Furniture/Misc/Lighthouse.png | Bin 0 -> 743 bytes .../Framework/Illuminate/LightManager.cs | 4 +++ .../Framework/Objects/BasicItemInformation.cs | 20 ++++++++++++-- .../Objects/Furniture/LampTileComponent.cs | 8 +++++- .../Framework/Objects/ObjectManager.cs | 26 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 3 ++ 7 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Furniture/Misc/Lighthouse.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Furniture/Misc/Lighthouse.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Furniture/Misc/Lighthouse.png new file mode 100644 index 0000000000000000000000000000000000000000..207f6b992d647e8bc29d96eb2f6962ea7ced5263 GIT binary patch literal 743 zcmV?P)Px%p-DtRRA_fYA{CX$_fC$J32zsvNEkU z)nJ1$T3%Y3uzf!{$ppbQkT={SATtL9t5#KYWRqnX0O0%n$mV&TP&5jU0GABL$TUqN zqSmpsNxugc{rXX-V{4NDpxf;Vp9=05QKQj-BuN{C-ah{P+yMX#dix-vR=eF6@tqDJ zaI#Qc8xB182n*FUNRqT6>^%(t01#2@B6}~rdiM}7U!UTFvGV~KM(3Xc1StqVXH7xk zuAQ~9nwBL+^~vQlgeNvllg59CpOeNWDN{MlLnT1$X4&4|%T({5+`pauMpUcFqr$^0 z-}mw5n?JiFkG6OB$Z;IvmE$;+HFA*f;C;jDS*!a5Zk9#k-09a Ze*yIfq0Q|m6pjD@002ovPDHLkV1n_UPelL# literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs index 7968a389..e0bcfadf 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs @@ -252,6 +252,10 @@ namespace Revitalize.Framework.Illuminate return copy; } + public static LightSource CreateLightSource(float Radius, Color ActualColor,int Texture=4) + { + return new LightSource(Texture, new Vector2(0, 0), Radius, ActualColor.Invert()); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 23419ab0..b43599b6 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -318,6 +318,20 @@ namespace Revitalize.Framework.Objects } } + private bool _alwaysDrawAbovePlayer; + public bool AlwaysDrawAbovePlayer + { + get + { + return this._alwaysDrawAbovePlayer; + } + set + { + this._alwaysDrawAbovePlayer = value; + this.requiresUpdate = true; + } + } + [JsonIgnore] public bool requiresUpdate; public BasicItemInformation() @@ -341,9 +355,10 @@ namespace Revitalize.Framework.Objects this.id = ""; this.shakeTimer = 0; this.EnergyManager = new Energy.EnergyManager(); + this._alwaysDrawAbovePlayer = false; } - public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false) { this.name = name; this.id = id; @@ -374,6 +389,7 @@ namespace Revitalize.Framework.Objects this.shakeTimer = 0; this.EnergyManager = EnergyManager ?? new Energy.EnergyManager(); + this.AlwaysDrawAbovePlayer = AlwaysDrawAbovePlayer; } /// @@ -391,7 +407,7 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy()); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer); } public bool requiresSyncUpdate() diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs index cba8113a..f3a2072a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs @@ -219,7 +219,13 @@ namespace Revitalize.Framework.Objects.Furniture { 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); + + int yDepth = y; + if (this.info.AlwaysDrawAbovePlayer) + { + addedDepth += 5f; + } + 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)((yDepth + addedDepth) * Game1.tileSize) / 10000f) + .00001f); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 4708384e..05a4639e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Revitalize.Framework.Illuminate; using Revitalize.Framework.Objects.CraftingTables; using Revitalize.Framework.Objects.Extras; using Revitalize.Framework.Objects.Furniture; @@ -112,6 +113,31 @@ namespace Revitalize.Framework.Objects this.loadInCraftingTables(); this.loadInMachines(); this.loadInTools(); + this.loadInAestheticsObjects(); + } + + private void loadInAestheticsObjects() + { + LampMultiTiledObject lighthouse = new LampMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(), Color.White, false, null, null)); + LampTileComponent lighthouse_0_0 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 0, 16, 16)), Color.White, true, null, new Illuminate.LightManager(),null,true)); + LampTileComponent lighthouse_1_0 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 0, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); + LampTileComponent lighthouse_0_1 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 16, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); + LampTileComponent lighthouse_1_1 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 16, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); + LampTileComponent lighthouse_0_2 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 32, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, false)); + LampTileComponent lighthouse_1_2 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 32, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, false)); + LampTileComponent lighthouse_0_3 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 48, 16, 16)), Color.White, false, null, new Illuminate.LightManager())); + LampTileComponent lighthouse_1_3 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 48, 16, 16)), Color.White, false, null, new Illuminate.LightManager())); + lighthouse_0_0.lightManager.addLight(new Vector2(16, 16), LightManager.CreateLightSource(10f, Color.White), lighthouse_0_0); + lighthouse.addComponent(new Vector2(0,-3),lighthouse_0_0); + lighthouse.addComponent(new Vector2(1, -3), lighthouse_1_0); + lighthouse.addComponent(new Vector2(0, -2), lighthouse_0_1); + lighthouse.addComponent(new Vector2(1, -2), lighthouse_1_1); + lighthouse.addComponent(new Vector2(0, -1), lighthouse_0_2); + lighthouse.addComponent(new Vector2(1, -1), lighthouse_1_2); + lighthouse.addComponent(new Vector2(0, 0), lighthouse_0_3); + lighthouse.addComponent(new Vector2(1, 0), lighthouse_1_3); + + this.AddItem("Lighthouse", lighthouse); } private void loadInCraftingTables() diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 73cba1dc..d5584915 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -561,7 +561,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("Anvil",1), ModCore.ObjectManager.GetItem("SolarPanelTier1",1), ModCore.ObjectManager.GetItem("SolarArrayTier1",1), - new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false) + new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false), + ModCore.ObjectManager.GetItem("Lighthouse",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index f27d4f03..b91c15d3 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -402,6 +402,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From ea100b10842c68ac0c1740ac1aff21693f43f690 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 13:05:31 -0700 Subject: [PATCH 52/98] Added in wires, the battery bin, fixed machines not consuming energy. --- .../Graphics/Objects/Machines/BatteryBin.png | Bin 0 -> 353 bytes .../Objects/Machines/Wires/CopperWire.png | Bin 0 -> 270 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 6 + .../Framework/Objects/Machines/Machine.cs | 33 +++- .../Framework/Objects/Machines/Wire.cs | 146 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 24 +++ .../Framework/Utilities/TimeUtilities.cs | 10 +- GeneralMods/Revitalize/ModCore.cs | 4 +- GeneralMods/Revitalize/Revitalize.csproj | 7 + 9 files changed, 217 insertions(+), 13 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/BatteryBin.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Wires/CopperWire.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/BatteryBin.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/BatteryBin.png new file mode 100644 index 0000000000000000000000000000000000000000..1ae15cf02f9d4a6d5b3a088bfa6054228c29e390 GIT binary patch literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D%zr9E97Lo9le z6AmyRI(+zldwcu;F6P%w6Gfov58qBm!{ZZ~Us}Tqu{(79x(|@l%$zetEkNuC2#kz^;=iDxv z3Y218XQ}Pm(|GcYW(-dxFOR{(?6$`GxRF`hCjGqyY~?+}eW@FM{AXEhrNSKGD<&kCHbHEnE5{y3Glr8(IUMCQ)K~(p z2F{uAAa2L!H|ot@BGxgF?%v)WanoR{!GRM84jf2OQ+Ew(v;6u(Quz)m+oeY;nfpF` sQ9Z(HXlUrWo$u{x)#I#LWqxNFlD5R9FFKV!3m9e$p00i_>zopr0NY895dZ)H literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Wires/CopperWire.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Wires/CopperWire.png new file mode 100644 index 0000000000000000000000000000000000000000..fca1663882166b7c38e019657572c7fa9224f3aa GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|PI$UFhFJ8T zow$&%DL|yHUZOQkNjCS;v5Zd)c_wa8bu;#Ht$!dqp_Z8=kEM~#d?rtx$hPbPE9U1c zW^=dS`S92J_qlq8XRdr-o+i9hYVDKB&`U33VAylORp@sR%QTk5ci0%#wDe>+xF{@o z%I39FUc!U7UaG)yvB$#6H{563R#4JddhdT>eVh1>&1=rMnUr!D?-tB<2;Q#q`WI*0 zmP5IFtJfKXyb*X^(rU=A#QrPvLG6kIPyapWi8s~QESPGhXP)s&EY`l0S#CRvx9@F6 SnMXiBF?hQAxvX() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"),2),null,0),true)); + + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 3087e042..5bf4401b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -137,9 +137,22 @@ namespace Revitalize.Framework.Objects.Machines { get { - if (ModCore.Configs.machinesConfig.doMachinesConsumeEnergy == false) return false; - if (this.energyRequiredPer10Minutes == 0) return false; - if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes) return true; + if (ModCore.Configs.machinesConfig.doMachinesConsumeEnergy == false) + { + ModCore.log("Machine config disables energy consumption."); + return false; + } + if (this.energyRequiredPer10Minutes == 0) + { + ModCore.log("Machine rquires 0 energy to run."); + return false; + } + if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes) + { + ModCore.log("Machine does consume energy."); + return true; + } + ModCore.log("Unknown energy configuration."); return false; } } @@ -171,6 +184,7 @@ namespace Revitalize.Framework.Objects.Machines this.offsetKey = offsetKey; this.containerObject = obj; this.producedResources = ProducedResources?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; this.timeToProduce = TimeToProduce; this.updatesContainerObjectForProduction = UpdatesContainer; this.MinutesUntilReady = TimeToProduce; @@ -194,23 +208,28 @@ namespace Revitalize.Framework.Objects.Machines List energySources = new List(); if (this.ConsumesEnergy) { - energySources = this.EnergyGraphSearchSources(); //Only grab the network once. + ModCore.log("This machine drains energy: " + this.info.name); + energySources = this.EnergyGraphSearchSources(); //Only grab the network once. } if (this.ProducesItems) { - //ModCore.log("This produces items!"); + ModCore.log("This machine produces items: "+this.info.name); while (remaining > 0) { if (this.ConsumesEnergy) { - this.drainEnergyFromNetwork(energySources); //Continually drain from the network. + this.drainEnergyFromNetwork(energySources); //Continually drain from the network. if (this.EnergyManager.remainingEnergy < this.energyRequiredPer10Minutes) return false; + else + { + this.EnergyManager.consumeEnergy(this.energyRequiredPer10Minutes); //Consume the required amount of energy necessary. + } } else { - //ModCore.log("Does not produce energy!"); + //ModCore.log("Does not produce energy or consume energy so do whatever!"); } remaining -= 10; this.containerObject.MinutesUntilReady -= 10; diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs new file mode 100644 index 00000000..fc6bb1cd --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs @@ -0,0 +1,146 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines +{ + public class Wire: Machine + { + + public Wire() { } + + public Wire(CustomObjectData PyTKData, BasicItemInformation info) : base(PyTKData, info,null,0,0,true,"") + { + } + + public Wire(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, MultiTiledObject obj = null) : base(PyTKData, info, TileLocation,null,0,0,true,"",obj) + { + } + + public Wire(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey, MultiTiledObject obj = null) : base(PyTKData, info, TileLocation,offsetKey,null,0,0,true,"",obj) + { + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + return false; + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + return true; + } + + /// + /// Creates the necessary components to display the machine menu properly. + /// + + public override Item getOne() + { + Wire component = new Wire(this.data, this.info.Copy(), this.TileLocation, this.offsetKey,this.containerObject); + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + Wire self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + //this.determineWireOrientation(); + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + private void determineWireOrientation() + { + //TODO: Make this so that the correct wire orientation is used if I want to get fancy with wires and their graphics. + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 05a4639e..2ab18da0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -168,6 +168,10 @@ namespace Revitalize.Framework.Objects private void loadInMachines() { + this.loadInWires(); + + + MultiTiledObject trashCan = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); TrashCanTile trash1 = new TrashCanTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(TrashCanTile), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "TrashCan"), new Animation(0, 0, 16, 16)), Color.White, true, new InventoryManager(36), null, null)); TrashCanTile trash2 = new TrashCanTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(TrashCanTile), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "TrashCan"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null)); @@ -225,6 +229,26 @@ namespace Revitalize.Framework.Objects solarArray1Container.addComponent(new Vector2(0, 1), solarA3V1); solarArray1Container.addComponent(new Vector2(1, 1), solarA4V1); this.AddItem("SolarArrayTier1", solarArray1Container); + + + ///Consumes energy. Produces batteries. + MultiTiledObject batteryBin = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(1), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes))); + Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(1), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List() + { + new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1,1,1,1,1,1,0,0,0,0) + + }, 1, TimeUtilities.GetMinutesFromTime(0, 1, 0), true, ""); + batteryBin.addComponent(new Vector2(0, 0), batteryBin_0_0); + this.AddItem("BatteryBin", batteryBin); + + } + + private void loadInWires() + { + MultiTiledObject copperWire = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers), false)); + Wire copperWire_0_0 = new Wire(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers), false)); + copperWire.addComponent(new Vector2(0, 0), copperWire_0_0); + this.AddItem("CopperWire", copperWire); } private void loadInTools() diff --git a/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs index 22f5ff7e..ca340909 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/TimeUtilities.cs @@ -35,15 +35,15 @@ namespace Revitalize.Framework.Utilities private void parse(int Minutes) { this.years = Minutes / 60 / 24 / 7 / 4 / 4; - Minutes -= (Minutes / 60 / 24 / 7 / 4 / 4); + Minutes -= (this.years * 60 * 24 * 7 * 4 * 4); this.seasons = Minutes / 60 / 24 / 7 / 4; - Minutes -= (Minutes / 60 / 24 / 7 / 4); + Minutes -= (this.seasons * 60 * 24 * 7 * 4); this.weeks = Minutes / 60 / 24 / 7; - Minutes -= (Minutes / 60 / 24 / 7); + Minutes -= (this.weeks * 60 * 24 * 7); this.days = Minutes / 60 / 24; - Minutes -= (Minutes / 60 / 24); + Minutes -= (this.days * 60 * 24); this.hours = Minutes / 60; - this.minutes -= (Minutes / 60); + Minutes -= (this.hours * 60); this.minutes = Minutes; } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index d5584915..81a2b7c4 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -562,7 +562,9 @@ namespace Revitalize ModCore.ObjectManager.GetItem("SolarPanelTier1",1), ModCore.ObjectManager.GetItem("SolarArrayTier1",1), new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false), - ModCore.ObjectManager.GetItem("Lighthouse",1) + ModCore.ObjectManager.GetItem("Lighthouse",1), + ModCore.ObjectManager.GetItem("CopperWire"), + ModCore.ObjectManager.GetItem("BatteryBin",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b91c15d3..5e72e8c9 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -156,6 +156,7 @@ + @@ -414,6 +415,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -423,6 +427,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 3251d194f763c09a4d70894ee0dacc8d2921f752 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 13:51:42 -0700 Subject: [PATCH 53/98] Fixed the display/ transfer code for inventory transfer menus to display proper inventory bounds. --- .../Framework/Menus/InventoryMenuPage.cs | 95 +++++++++---------- .../Framework/Menus/InventoryTransferMenu.cs | 4 +- .../Framework/Objects/Machines/Machine.cs | 2 +- .../Framework/Objects/ObjectManager.cs | 4 +- .../Framework/Utilities/InventoryManager.cs | 21 +++- 5 files changed, 68 insertions(+), 58 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs index 3d07efb3..2d5e7541 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs @@ -72,11 +72,11 @@ namespace Revitalize.Framework.Menus { get { - return this.items.Count >= this.capacity && this.items.Where(i=>i==null).Count()==0; + return this.items.Count >= this.capacity && this.items.Where(i => i == null).Count() == 0; } } - public InventoryMenu(int xPos, int yPos, int width, int height, int Rows, int Collumns, bool showCloseButton, IList Inventory, int maxCapacity,Color BackgroundColor) : base(xPos, yPos, width, height, showCloseButton) + public InventoryMenu(int xPos, int yPos, int width, int height, int Rows, int Collumns, bool showCloseButton, IList Inventory, int maxCapacity, Color BackgroundColor) : base(xPos, yPos, width, height, showCloseButton) { //Amount to display is the lower cap per page. // @@ -97,8 +97,8 @@ namespace Revitalize.Framework.Menus Game1.keyboardDispatcher.Subscriber = (IKeyboardSubscriber)this.searchBox; this.searchBox.Selected = false; - this.nextPage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Next Page", new Vector2(128 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"),new Animation(0,0,32,32)),Color.White),new Rectangle(0, 0, 32, 32), 2f); - this.previousPage= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Previous Page", new Vector2(64 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); + this.nextPage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Next Page", new Vector2(128 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); + this.previousPage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Previous Page", new Vector2(64 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); } @@ -115,7 +115,7 @@ namespace Revitalize.Framework.Menus this.searchBox.Y = this.yPositionOnScreen; this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); this.nextPage.Position = new Vector2(128 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y); - this.previousPage.Position= new Vector2(64 + (this.searchBox.X + this.searchBox.Width),this.searchBox.Y); + this.previousPage.Position = new Vector2(64 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y); } public void populateClickableItems() @@ -241,6 +241,7 @@ namespace Revitalize.Framework.Menus { if (button.receiveLeftClick(x, y)) { + if (index > this.capacity) continue; if (this.activeItem == null) { this.activeItem = button.item; @@ -312,42 +313,42 @@ namespace Revitalize.Framework.Menus } } - /// - /// Swaps the item's position in the menu. - /// - /// - /// - public void swapItemPosition(int insertIndex, Item I) + /// + /// Swaps the item's position in the menu. + /// + /// + /// + public void swapItemPosition(int insertIndex, Item I) + { + if (I == null) + { + //ModCore.log("Odd item is null"); + return; + } + if (insertIndex + 1 > this.items.Count) { - if (I == null) - { - //ModCore.log("Odd item is null"); - return; - } - if (insertIndex + 1 > this.items.Count) - { - this.items.Remove(I); - this.items.Add(I); - this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); - return; - } - this.items.Insert(insertIndex + 1, I); this.items.Remove(I); + this.items.Add(I); this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); + return; } + this.items.Insert(insertIndex + 1, I); + this.items.Remove(I); + this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); + } - /// - /// Takes the active item from this menu. - /// - /// - public Item takeActiveItem() - { - this.items.Remove(this.activeItem); - this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); - Item i = this.activeItem; - this.activeItem = null; - return i; - } + /// + /// Takes the active item from this menu. + /// + /// + public Item takeActiveItem() + { + this.items.Remove(this.activeItem); + this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); + Item i = this.activeItem; + this.activeItem = null; + return i; + } /// /// What happens when this menu is right clicked. @@ -377,22 +378,19 @@ namespace Revitalize.Framework.Menus { this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + int index = -1; foreach (ItemDisplayButton button in this.pages[this.pageIndex].storageDisplay) { - if (string.IsNullOrEmpty(this.searchBox.Text) == false) - { - button.draw(b, 0.25f, this.getItemDrawAlpha(button.item), true); - } - else - { - button.draw(b, 0.25f, 1f, true); - } + index++; + float alpha = this.getItemDrawAlpha(button.item, index + this.pageIndex * this.rows*this.collumns); + button.draw(b, 0.25f, alpha, true); + } this.searchBox.Draw(b, true); - this.nextPage.draw(b,0.25f,1f); - this.previousPage.draw(b,0.25f,1f); + this.nextPage.draw(b, 0.25f, 1f); + this.previousPage.draw(b, 0.25f, 1f); b.DrawString(Game1.dialogueFont, ("Page: " + (this.pageIndex + 1) + " / " + this.pages.Count).ToString(), new Vector2(this.xPositionOnScreen, this.yPositionOnScreen + this.height), Color.White); @@ -412,8 +410,9 @@ namespace Revitalize.Framework.Menus /// /// /// - private float getItemDrawAlpha(Item I) - { + private float getItemDrawAlpha(Item I, int index) + { + if (index >= this.capacity) return 0.0f; if (string.IsNullOrEmpty(this.searchBox.Text) == false) { if (I == null) return 0.25f; diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs index 1a3b21c7..d7120e5b 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -36,11 +36,11 @@ namespace Revitalize.Framework.Menus } private CurrentMode currentMode; - public InventoryTransferMenu(int x, int y, int width, int height, IList OtherItems, int OtherCapacity) : base(x, y, width, height, true) + public InventoryTransferMenu(int x, int y, int width, int height, IList OtherItems, int OtherCapacity,int OtherRows=6,int OtherCollumns=6) : base(x, y, width, height, true) { this.playerInventory = new InventoryMenu(x, y, width, height, 6, 6, true, Game1.player.Items, Game1.player.MaxItems, Color.SandyBrown); this.otherItems = OtherItems; - this.otherInventory = new InventoryMenu(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 128, y, width, height, 6, 6, true, this.otherItems, OtherCapacity, Color.SandyBrown); + this.otherInventory = new InventoryMenu(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 128, y, width, height, OtherRows, OtherCollumns, true, this.otherItems, OtherCapacity, Color.SandyBrown); this.isPlayerInventory = true; this.currentMode = CurrentMode.TransferItems; this.transferButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Transfer Button", new Vector2(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 64, this.playerInventory.yPositionOnScreen + (this.playerInventory.height * .3f)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemTransferButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 5bf4401b..14bdcab8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -294,7 +294,7 @@ namespace Revitalize.Framework.Objects.Machines if (this.InventoryManager.capacity > 0) { - InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, 36); + InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, this.InventoryManager.capacity,this.InventoryManager.displayRows,this.InventoryManager.displayColumns); machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, false); } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 2ab18da0..7f3acc34 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -232,8 +232,8 @@ namespace Revitalize.Framework.Objects ///Consumes energy. Produces batteries. - MultiTiledObject batteryBin = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(1), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes))); - Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(1), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List() + MultiTiledObject batteryBin = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes))); + Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List() { new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1,1,1,1,1,1,0,0,0,0) diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index 76202707..b2c106ba 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -40,6 +40,9 @@ namespace Revitalize.Framework.Utilities } } + public int displayRows; + public int displayColumns; + [JsonIgnore] public bool requiresUpdate; public InventoryManager() @@ -51,38 +54,46 @@ namespace Revitalize.Framework.Utilities } /// Construct an instance. - public InventoryManager(List items) + public InventoryManager(List items,int DisplayRows=6,int DisplayColumns=6) { this.capacity = int.MaxValue; this.setMaxLimit(int.MaxValue); this.items = items; this.bufferItems = new List(); + this.displayRows = DisplayRows; + this.displayColumns = DisplayColumns; } - public InventoryManager(IList items) + public InventoryManager(IList items, int DisplayRows = 6, int DisplayColumns = 6) { this.capacity = int.MaxValue; this.setMaxLimit(int.MaxValue); this.items = items; this.bufferItems = new List(); + this.displayRows = DisplayRows; + this.displayColumns = DisplayColumns; } /// Construct an instance. - public InventoryManager(int capacity) + public InventoryManager(int capacity, int DisplayRows = 6, int DisplayColumns = 6) { this.capacity = capacity; this.MaxCapacity = int.MaxValue; this.items = new List(); this.bufferItems = new List(); + this.displayRows = DisplayRows; + this.displayColumns = DisplayColumns; } /// Construct an instance. - public InventoryManager(int capacity, int MaxCapacity) + public InventoryManager(int capacity, int MaxCapacity, int DisplayRows = 6, int DisplayColumns = 6) { this.capacity = capacity; this.setMaxLimit(MaxCapacity); this.items = new List(); this.bufferItems = new List(); + this.displayRows = DisplayRows; + this.displayColumns = DisplayColumns; } /// Add the item to the inventory. @@ -181,7 +192,7 @@ namespace Revitalize.Framework.Utilities /// public InventoryManager Copy() { - return new InventoryManager(this.capacity, this.MaxCapacity); + return new InventoryManager(this.capacity, this.MaxCapacity,this.displayRows,this.displayColumns); } public void dumpBufferToItems() From 505eaf1c2fb2157bbe6f7851f835db21812750e0 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 14:13:11 -0700 Subject: [PATCH 54/98] Got the machine summary menu to display energy consumed/produced per 10 mins. --- .../Menus/Machines/MachineSummaryMenu.cs | 44 +++++++++++++++---- .../Framework/Objects/Machines/Machine.cs | 2 +- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index d07c76ce..5c936da3 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -46,6 +46,10 @@ namespace Revitalize.Framework.Menus.Machines private AnimatedButton clockSprite; private Vector2 timeDisplayLocation; + private AnimatedButton energyRequiredButton; + private Vector2 energyRequiredDisplayLocation; + + private int requiredEnergyPer10Min; private EnergyManager energy { @@ -72,7 +76,7 @@ namespace Revitalize.Framework.Menus.Machines } - public MachineSummaryMenu(int x, int y, int width, int height, Color BackgroundColor, CustomObject SourceObject) : base(x, y, width, height, false) + public MachineSummaryMenu(int x, int y, int width, int height, Color BackgroundColor, CustomObject SourceObject,int RequiredEnergyPer10Min) : base(x, y, width, height, false) { this.objectSource = SourceObject; @@ -81,14 +85,17 @@ namespace Revitalize.Framework.Menus.Machines this.energyMeterColorSwap(); this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f)); + this.energyRequiredDisplayLocation = this.timeDisplayLocation + new Vector2(0, 64); this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4); this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.battergyEnergyGuage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryEnergyGuage", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryEnergyGuage"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource); - this.clockSprite= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Time Remaining",this.timeDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Clock"), new StardustCore.Animations.Animation(0, 0, 18, 18)), Color.White), new Rectangle(0, 0, 18, 18), 2f); + this.energyRequiredButton=new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Energy Required", this.energyRequiredDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "LightningBolt"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); + + this.requiredEnergyPer10Min = RequiredEnergyPer10Min; } public override void performHoverAction(int x, int y) @@ -104,16 +111,32 @@ namespace Revitalize.Framework.Menus.Machines this.hoverText = "Time Remaining: " + System.Environment.NewLine + TimeUtilities.GetVerboseTimeString(this.objectSource.MinutesUntilReady); hovered = true; } + if (this.energyRequiredButton.containsPoint(x, y)) + { + this.hoverText = this.getProperEnergyDescriptionString(this.requiredEnergyPer10Min); + hovered = true; + } if (hovered == false) { this.hoverText = ""; } - - - } + protected virtual string getProperEnergyDescriptionString(int EnergyAmount) + { + if (this.energy.consumesEnergy) + { + return "Energy required per 10 minutes to run: " + System.Environment.NewLine + EnergyAmount; + + } + else if (this.energy.producesEnergy) + { + + return "Produces " + EnergyAmount + " per 10 minutes."; + } + else return ""; + } /// /// Draws the menu to the screen. @@ -123,6 +146,10 @@ namespace Revitalize.Framework.Menus.Machines { this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + this.clockSprite.draw(b); + b.DrawString(Game1.smallFont, TimeUtilities.GetTimeString(this.objectSource.MinutesUntilReady), this.timeDisplayLocation + new Vector2(0, 36f), Color.Black); + + //Draw the energy on the screen. if (this.shouldDrawBattery) @@ -131,12 +158,13 @@ namespace Revitalize.Framework.Menus.Machines this.energyMeterColorSwap(); b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale)+ (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f,1f), SpriteEffects.None, 0.2f); this.battergyEnergyGuage.draw(b, 1f, 1f); + + this.energyRequiredButton.draw(b); + b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min+" E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black); } - this.clockSprite.draw(b); - b.DrawString(Game1.smallFont,TimeUtilities.GetTimeString(this.objectSource.MinutesUntilReady), this.timeDisplayLocation+new Vector2(0,36f), Color.Black); - + this.objectSource.drawFullyInMenu(b, new Vector2((int)(this.xPositionOnScreen + (this.width / 2) - (this.itemDisplayOffset.X / 2)), (int)(this.yPositionOnScreen + 128f)), .24f); Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 14bdcab8..080e403d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -289,7 +289,7 @@ namespace Revitalize.Framework.Objects.Machines { MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); - MachineSummaryMenu m = new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width / 2) - 400, 48, 800, 600, Color.White, this.containerObject); + MachineSummaryMenu m = new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width / 2) - 400, 48, 800, 600, Color.White, this.containerObject,this.energyRequiredPer10Minutes); machineMenu.addInMenuTab("Summary", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), m, true); if (this.InventoryManager.capacity > 0) From 620c1b4b701f6f6b85163a91bc79d73bc4ac8fc0 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 14:30:37 -0700 Subject: [PATCH 55/98] Added ability to see how much inventory space remains on summary menu. Also made machines unable to produce items if inventory is full. --- .../Content/Graphics/Menus/Misc/Chest.png | Bin 0 -> 590 bytes .../Menus/Machines/MachineSummaryMenu.cs | 9 +++++++++ .../Framework/Objects/Machines/Machine.cs | 2 +- .../Framework/Utilities/InventoryManager.cs | 2 +- GeneralMods/Revitalize/Revitalize.csproj | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/Misc/Chest.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/Chest.png b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/Chest.png new file mode 100644 index 0000000000000000000000000000000000000000..597f4da9d498d3509c94694c2c90aba004375f53 GIT binary patch literal 590 zcmV-U0Px%2uVaiR7i>KlR<0RU>L`L2FY!68^J+YQ3*MPj>1I9xd%^$;Xv#@$MzL=DfDA( zBD9y>20QE&D0P)dPC=`56e>Y#cN=JSi0_*>jd8H!*dN3s{{PSW{2rgcfBge0r0({e z2%vN2Z8UdlPJA)&WUi=&+m=Bu2zh<*A`=cKzhDJz%bWU^xr6Cn`MS1ul340%tgvY zz=Yj*A0)y?4|;l))ec(AOPX_+=G>*Vyp#w+BC~Ok#Is;B%57a_@)0&Fi%=BpoSY>g z+bqZ1`QXIyx4RU=$=Pf>!ZwND3w5eT8aE#SxdV+sKR2j)R_wej)TthAJ?alC0Q_x{ c3nrg_17z9w%SWQ%s{jB107*qoM6N<$g0xf#ZU6uP literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 5c936da3..623fc1bd 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -48,6 +48,8 @@ namespace Revitalize.Framework.Menus.Machines private Vector2 timeDisplayLocation; private AnimatedButton energyRequiredButton; private Vector2 energyRequiredDisplayLocation; + private AnimatedButton storageButton; + private Vector2 storageRemainingDisplayLocation; private int requiredEnergyPer10Min; @@ -86,6 +88,7 @@ namespace Revitalize.Framework.Menus.Machines this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f)); this.energyRequiredDisplayLocation = this.timeDisplayLocation + new Vector2(0, 64); + this.storageRemainingDisplayLocation = this.energyRequiredDisplayLocation + new Vector2(0, 64); this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4); this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); @@ -94,6 +97,7 @@ namespace Revitalize.Framework.Menus.Machines this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource); this.clockSprite= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Time Remaining",this.timeDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Clock"), new StardustCore.Animations.Animation(0, 0, 18, 18)), Color.White), new Rectangle(0, 0, 18, 18), 2f); this.energyRequiredButton=new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Energy Required", this.energyRequiredDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "LightningBolt"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); + this.storageButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Storage Remaining", this.storageRemainingDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Chest"), new StardustCore.Animations.Animation(0, 0, 16, 32)), Color.White), new Rectangle(0, 0, 16, 32), 1f); this.requiredEnergyPer10Min = RequiredEnergyPer10Min; } @@ -163,6 +167,11 @@ namespace Revitalize.Framework.Menus.Machines b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min+" E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black); } + if (this.objectSource.info.inventory.HasInventory) + { + this.storageButton.draw(b); + b.DrawString(Game1.smallFont, "Storage remaining: "+ (this.objectSource.info.inventory.capacity-this.objectSource.info.inventory.ItemCount)+"/"+this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black); + } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 080e403d..d8bed024 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -234,7 +234,7 @@ namespace Revitalize.Framework.Objects.Machines remaining -= 10; this.containerObject.MinutesUntilReady -= 10; - if (this.containerObject.MinutesUntilReady <= 0) + if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull==false) { this.produceItem(); this.containerObject.MinutesUntilReady = this.timeToProduce; diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index b2c106ba..93e79f34 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -15,7 +15,7 @@ namespace Revitalize.Framework.Utilities public int MaxCapacity { get; private set; } /// How many items are currently stored in the inventory. - public int ItemCount => this.items.Count; + public int ItemCount => this.items.Where(i => i != null).Count(); /// The actual contents of the inventory. public IList items; diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 5e72e8c9..8840ee7c 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -379,6 +379,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 0de19a904fd4a9f3e368d231a57bc4fe1b0098a3 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 15:05:51 -0700 Subject: [PATCH 56/98] Added in hover bubble for machines which displays when they are full. Also made a config to adjust alpha and if it displays. --- .../Graphics/HUD/MachineStatusBubble.png | Bin 0 -> 614 bytes .../Framework/Configs/GlobalMachineConfig.cs | 4 ++ .../Framework/Objects/Machines/Machine.cs | 35 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 3 ++ GeneralMods/Revitalize/Revitalize.csproj | 3 ++ 5 files changed, 45 insertions(+) create mode 100644 GeneralMods/Revitalize/Content/Graphics/HUD/MachineStatusBubble.png diff --git a/GeneralMods/Revitalize/Content/Graphics/HUD/MachineStatusBubble.png b/GeneralMods/Revitalize/Content/Graphics/HUD/MachineStatusBubble.png new file mode 100644 index 0000000000000000000000000000000000000000..6490c4684dd351cbc8acb34a2ea6f4f3604f12ca GIT binary patch literal 614 zcmV-s0-61ZP)Px%AW1|)R9J=WSiegGQ5^sD!#_X>gun*9&8eXv2tg2ZiKblo0S0XaK}*n34TVeK z;8rA94e63i1(6VuVS|%RcMb+eE^Q4V@fz&iJx@AHVP3y?4Mr z{x$|gUm(5|BUbX$nQT{0cKL>_6k7omwi2Jm)Z}+^00{hFyGf5GHPc>h($ literal 0 HcmV?d00001 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 From e20d593c7f0ae42ceb92b17e229086169e41aea7 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 17:33:45 -0700 Subject: [PATCH 57/98] Added in dye option. WIP. --- .../Framework/Configs/ConfigManager.cs | 2 + .../Framework/Configs/GlobalMachineConfig.cs | 2 - .../Framework/Configs/ObjectsConfig.cs | 31 ++ .../Revitalize/Framework/Enums/Enums.cs | 1 + .../Framework/Illuminate/ColorsList.cs | 298 ++++++++++++++++++ .../Framework/Illuminate/NamedColor.cs | 48 +++ .../Framework/Objects/BasicItemInformation.cs | 63 +++- .../CraftingTables/CraftingTableTile.cs | 4 +- .../Framework/Objects/CustomObject.cs | 37 ++- .../Objects/Extras/ArcadeCabinetTile.cs | 4 +- .../Framework/Objects/Extras/TrashCanTile.cs | 4 +- .../Objects/Furniture/ChairTileComponent.cs | 4 +- .../Objects/Furniture/LampTileComponent.cs | 4 +- .../Objects/Furniture/RugTileComponent.cs | 4 +- .../Objects/Furniture/StorageFurnitureTile.cs | 4 +- .../Objects/Furniture/TableTileComponent.cs | 4 +- .../Framework/Objects/Items/Resources/Dye.cs | 278 ++++++++++++++++ .../Framework/Objects/Items/Resources/Ore.cs | 6 +- .../Machines/EnergyGeneration/SolarPanel.cs | 4 +- .../Framework/Objects/Machines/Machine.cs | 4 +- .../Framework/Objects/Machines/Wire.cs | 4 +- .../Framework/Objects/MultiTiledComponent.cs | 8 +- .../Framework/Objects/MultiTiledObject.cs | 23 ++ .../Objects/Resources/OreVeins/OreVeinTile.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 16 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + 26 files changed, 810 insertions(+), 55 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Configs/ObjectsConfig.cs create mode 100644 GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs create mode 100644 GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Resources/Dye.cs diff --git a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs index e00f08dd..29e52c18 100644 --- a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs +++ b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs @@ -18,6 +18,7 @@ namespace Revitalize.Framework.Configs public Shops_BlacksmithConfig shops_blacksmithConfig; public FurnitureConfig furnitureConfig; + public ObjectsConfig objectsConfig; /// /// The config file to be used for machines. @@ -30,6 +31,7 @@ namespace Revitalize.Framework.Configs this.shops_blacksmithConfig = Shops_BlacksmithConfig.InitializeConfig(); this.furnitureConfig = FurnitureConfig.InitializeConfig(); this.machinesConfig = GlobalMachineConfig.InitializeConfig(); + this.objectsConfig = ObjectsConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs index cd68e7af..3c674f7b 100644 --- a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs @@ -9,10 +9,8 @@ namespace Revitalize.Framework.Configs { public class GlobalMachineConfig { - public bool doMachinesConsumeEnergy; - public double solarPanelNonSunnyDayEnergyMultiplier; public double solarPanelNightEnergyGenerationMultiplier; public bool showMachineNotificationBubble_InventoryFull; diff --git a/GeneralMods/Revitalize/Framework/Configs/ObjectsConfig.cs b/GeneralMods/Revitalize/Framework/Configs/ObjectsConfig.cs new file mode 100644 index 00000000..8fedcf3c --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/ObjectsConfig.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Configs +{ + public class ObjectsConfig + { + public bool showDyedColorName; + public ObjectsConfig() + { + this.showDyedColorName = true; + } + + public static ObjectsConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "ObjectsConfig.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "ObjectsConfig.json")); + else + { + ObjectsConfig Config = new ObjectsConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "ObjectsConfig.json"), Config); + return Config; + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index dcc95fcb..4e6573b0 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Xna.Framework; namespace Revitalize.Framework { diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs new file mode 100644 index 00000000..7a80a54f --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs @@ -0,0 +1,298 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Illuminate +{ + public class ColorsList + { + public static NamedColor AliceBlue = new NamedColor("Alice Blue", new Color(15, 7, 0, 255).Invert()); + + public static NamedColor AntiqueWhite = new NamedColor("Antique White", 5, 20, 40, 255); + + public static NamedColor Aqua = new NamedColor("Aqua", 255, 0, 0, 255); + + public static NamedColor Aquamarine = new NamedColor("Aquamarine", 128, 0, 43, 255); + + /// A whiteish sort of color witha hint of blue + public static NamedColor Azure = new NamedColor("Azure", 15, 0, 0, 255); + + public static NamedColor Beige = new NamedColor("Beige", 10, 10, 35, 255); + + public static NamedColor Bisque = new NamedColor("Bisque", 0, 27, 59, 255); + + public static NamedColor Black = new NamedColor("Black", 255, 255, 255, 255); + + public static NamedColor BlanchedAlmond = new NamedColor("Blanched Almond", 0, 20, 40, 255); + + public static NamedColor Blue = new NamedColor("Blue", 255, 255, 0, 255); + + public static NamedColor BlueViolet = new NamedColor("Blue Violet", 117, 212, 29, 255); + + public static NamedColor Brown = new NamedColor("Brown", 90, 213, 213, 255); + + public static NamedColor BurlyWood = new NamedColor("Burly Wood", 33, 71, 120, 255); + + public static NamedColor CadetBlue = new NamedColor("Cadet Blue", 160, 97, 95, 255); + + public static NamedColor Chartreuse = new NamedColor("Chartreuse", 128, 0, 255, 255); + + public static NamedColor Chocolate = new NamedColor("Chocolate", 45, 150, 225, 255); + + public static NamedColor Coral = new NamedColor("Coral", 0, 128, 175, 255); + + public static NamedColor CornflowerBlue = new NamedColor("Cornflower Blue", 155, 106, 18, 255); + + /// A yellowish color. + public static NamedColor Cornsilk = new NamedColor("Cornsilk", 0, 7, 35, 255); + + public static NamedColor Crimson = new NamedColor("Crimson", 35, 235, 195, 255); + + public static NamedColor Cyan = new NamedColor("Cyan",255, 0, 0, 255); + + public static NamedColor DarkBlue = new NamedColor("Dark Blue", 255, 255, 116, 255); + + public static NamedColor DarkCyan = new NamedColor("Dark Cyan", 255, 114, 114, 255); + + public static NamedColor DarkGoldenRod = new NamedColor("Dark Goldenrod", 71, 121, 244, 255); + + public static NamedColor DarkGray = new NamedColor("Dark Gray", 86, 86, 86, 255); + + public static NamedColor DarkGreen = new NamedColor("Dark Green", 255, 155, 255, 255); + + public static NamedColor DarkKhaki = new NamedColor("Dark Khaki", 66, 72, 148, 255); + + public static NamedColor DarkMagenta = new NamedColor("Dark Magenta", 116, 255, 116, 255); + + public static NamedColor DarkOliveGreen = new NamedColor("Dark Olive Green", 170, 148, 208, 255); + + public static NamedColor DarkOrange = new NamedColor("Dark Orange", 0, 115, 255, 255); + + public static NamedColor DarkOrchid = new NamedColor("Dark Orchid", 102, 105, 51, 255); + + public static NamedColor DarkRed = new NamedColor("Dark Red", 116, 255, 255, 255); + + public static NamedColor DarkSalmon = new NamedColor("Dark Salmon", 22, 105, 133, 255); + + public static NamedColor DarkSeaGreen = new NamedColor("Dark Sea Green", 112, 67, 112, 255); + + public static NamedColor DarkSlateBlue = new NamedColor("Dark Slate Blue", 183, 194, 116, 255); + + public static NamedColor DarkSlateGray = new NamedColor("Dark Slate Gray", 208, 176, 176, 255); + + public static NamedColor DarkTurquoise = new NamedColor("Dark Turquoise", 255, 49, 46, 255); + + public static NamedColor DarkViolet = new NamedColor("Dark Violet", 107, 255, 44, 255); + + public static NamedColor DeepPink = new NamedColor("Deep Pink", 0, 235, 108, 255); + + public static NamedColor DeepSkyBlue = new NamedColor("Deep Sky Blue", 255, 64, 0, 255); + + public static NamedColor DimGray = new NamedColor("Dim Gray", 150, 150, 150, 255); + + public static NamedColor DodgerBlue = new NamedColor("Dodger Blue", 225, 111, 0, 255); + + public static NamedColor FireBrick = new NamedColor("FireBrick",77, 221, 221, 255); + + public static NamedColor FloralWhite = new NamedColor("Floral White", 0, 5, 15, 255); + + public static NamedColor ForestGreen = new NamedColor("Forest Green", 221, 116, 221, 255); + + public static NamedColor Fuchsia = new NamedColor("Fuchsia", 0, 255, 0, 255); + + /// More of a white-ish color + public static NamedColor Gainsboro = new NamedColor("Gainsboro", 35, 35, 35, 255); + + public static NamedColor GhostWhite = new NamedColor("Ghost White", 7, 7, 0); + + public static NamedColor Gold = new NamedColor("Gold", 0, 40, 255, 255); + + public static NamedColor GoldenRod = new NamedColor("Golden Rod", 37, 90, 223, 255); + + public static NamedColor Gray = new NamedColor("Gray", 127, 127, 127, 255); + + public static NamedColor Green = new NamedColor("Green", 255, 127, 255, 255); + + public static NamedColor GreenYellow = new NamedColor("Green Yellow", 82, 0, 208, 255); + + public static NamedColor HoneyDew = new NamedColor("Honey Dew", 15, 0, 15, 255); + + public static NamedColor HotPink = new NamedColor("Hot Pink", 0, 140, 75, 255); + + public static NamedColor IndianRed = new NamedColor("Indian Red", 40, 163, 163, 255); + + public static NamedColor Indigo = new NamedColor("Indigo", 180, 255, 125, 255); + + public static NamedColor Ivory = new NamedColor("Ivory", 0, 0, 15, 255); + + public static NamedColor Khaki = new NamedColor("Khaki", 15, 25, 115, 255); + + public static NamedColor Lavender = new NamedColor("Lavender", 25, 25, 5, 255); + + public static NamedColor LavenderBlush = new NamedColor("Lavender Blush", 0, 15, 10, 255); + + public static NamedColor LawnGreen = new NamedColor("Lawn Green", 131, 3, 255, 255); + + public static NamedColor LemonChiffron = new NamedColor("Lemon Chiffron", 0, 5, 50, 255); + + public static NamedColor LightBlue = new NamedColor("Light Blue",82, 39, 25, 255); + + public static NamedColor LightCoral = new NamedColor("Light Coral", 15, 127, 127, 255); + + public static NamedColor LightCyan = new NamedColor("Light Cyan", 31, 0, 0, 255); + + public static NamedColor LightGoldenRodYellow = new NamedColor("Light Goldenrod Yellow", 5, 5, 45, 255); + + public static NamedColor LightGray = new NamedColor("Light Gray", 44, 44, 44, 255); + + public static NamedColor LightGreen = new NamedColor("Light Green", 111, 17, 111, 255); + + public static NamedColor LightPink = new NamedColor("Light Pink", 0, 73, 62, 255); + + public static NamedColor LightSalmon = new NamedColor("Light Salmon", 0, 95, 133, 255); + + public static NamedColor LightSeaGreen = new NamedColor("Ligh tSea Green", 223, 77, 85, 255); + + public static NamedColor LightSkyBlue = new NamedColor("Light Sky Blue", 120, 49, 5, 255); + + public static NamedColor LightSlateGray = new NamedColor("Light Slate Gray", 146, 119, 102, 255); + + public static NamedColor LightSteelBlue = new NamedColor("Light Steel Blue", 79, 59, 33, 255); + + public static NamedColor LightYellow = new NamedColor("Light Yellow", 0, 0, 31, 255); + + public static NamedColor Lime = new NamedColor("Lime", 255, 0, 255, 255); + + public static NamedColor LimeGreen = new NamedColor("Lime Green", 105, 50, 105, 255); + + public static NamedColor Linen = new NamedColor("Linen", 5, 15, 25, 255); + + public static NamedColor Magenta = new NamedColor("Magenta", 0, 255, 0, 255); + + public static NamedColor Maroon = new NamedColor("Maroon", 127, 255, 255, 0); + + public static NamedColor MediumAquaMarine = new NamedColor("Medium Aqua Marine", 153, 50, 85, 255); + + public static NamedColor MediumBlue = new NamedColor("Medium Blue",255, 255, 50, 255); + + public static NamedColor MediumOrchid = new NamedColor("Medium Orchid", 69, 170, 44, 255); + + public static NamedColor MediumPurple = new NamedColor("Medium Purple", 108, 143, 36, 255); + + public static NamedColor MediumSeaGreen = new NamedColor("Medium Sea Green", 195, 78, 142, 255); + + public static NamedColor MediumSlateBlue = new NamedColor("Medium Slate Blue", 132, 151, 17, 255); + + public static NamedColor MediumSpringGreen = new NamedColor("Medium Spring Green", 255, 5, 101, 255); + + public static NamedColor MediumTurquoise = new NamedColor("Medium Turquoise", 183, 46, 51, 255); + + public static NamedColor MediumVioletRed = new NamedColor("Medium Violet Red", 46, 234, 122, 255); + + public static NamedColor MidnightBlue = new NamedColor("Midnight Blue", 230, 230, 143, 255); + + public static NamedColor MintCream = new NamedColor("Mint Cream", 10, 0, 5, 255); + + public static NamedColor MistyRose = new NamedColor("Misty Rose", 0, 27, 30, 255); + + public static NamedColor Moccasin = new NamedColor("Moccasin", 0, 33, 82, 255); + + public static NamedColor NavajoWhite = new NamedColor("Navajo White", 0, 33, 82, 255); + + public static NamedColor Navy = new NamedColor("Navy", 255, 255, 127, 255); + + public static NamedColor OldLace = new NamedColor("Old Lace", 2, 10, 25, 255); + + public static NamedColor Olive = new NamedColor("Olive", 127, 127, 255, 255); + + public static NamedColor OliveDrab = new NamedColor("Olive Drab", 148, 113, 220, 255); + + public static NamedColor Orange = new NamedColor("Orange", 0, 90, 255, 255); + + public static NamedColor OrangeRed = new NamedColor("Orange Red", 0, 186, 255, 255); + + public static NamedColor Orchid = new NamedColor("Orchid", 37, 143, 41, 255); + + public static NamedColor PaleGoldenRod = new NamedColor("Pale Golden Rod", 17, 23, 85, 255); + + public static NamedColor PaleGreen = new NamedColor("Pale Green", 103, 4, 103, 255); + + public static NamedColor PaleTurquoise = new NamedColor("Pale Turquoise", 80, 17, 17, 255); + + public static NamedColor PaleVioletRed = new NamedColor("Pale Violet Red", 36, 143, 108, 255); + + public static NamedColor PapayaWhip = new NamedColor("Papaya Whip", 0, 16, 42, 255); + + public static NamedColor PeachPuff = new NamedColor("Peach Puff", 0, 37, 70, 255); + + public static NamedColor Peru = new NamedColor("Peru", 50, 122, 192, 255); + + public static NamedColor Pink = new NamedColor("Pink", 0, 63, 52, 255); + + public static NamedColor Plum = new NamedColor("Plum", 34, 95, 34, 255); + + public static NamedColor PowderBlue = new NamedColor("Powder Blue", 79, 31, 25, 255); + + public static NamedColor Purple = new NamedColor("Purple", 127, 255, 127, 255); + + public static NamedColor RebeccaPurple = new NamedColor("Rebecca Purple", 153, 104, 102, 255); + + public static NamedColor Red = new NamedColor("Red", 0, 255, 255, 255); + + public static NamedColor RosyBrown = new NamedColor("Rosy Brown", 67, 112, 112, 255); + + public static NamedColor RoyalBlue = new NamedColor("Royal Blue", 190, 150, 30, 255); + + public static NamedColor SaddleBrown = new NamedColor("Saddle Brown", 115, 186, 231, 255); + + public static NamedColor Salmon = new NamedColor("Salmon", 5, 127, 141, 255); + + public static NamedColor SandyBrown = new NamedColor("Sandy Brown", 11, 91, 159, 255); + + public static NamedColor SeaGreen = new NamedColor("Sea Green", 209, 116, 168, 255); + + public static NamedColor SeaShell = new NamedColor("Sea Shell", 0, 10, 17, 255); + + public static NamedColor Sienna = new NamedColor("Sienna", 95, 173, 210, 255); + + public static NamedColor Silver = new NamedColor("Silver", 63, 63, 63, 255); + + public static NamedColor SkyBlue = new NamedColor("Sky Blue", 120, 49, 20, 255); + + public static NamedColor SlateBlue = new NamedColor("Slate Blue", 149, 165, 50, 255); + + public static NamedColor SlateGray = new NamedColor("Slate Gray", 143, 127, 111, 255); + + public static NamedColor Snow = new NamedColor("Snow", 0, 5, 5, 255); + + public static NamedColor SpringGreen = new NamedColor("Spring Green", 255, 0, 128, 255); + + public static NamedColor SteelBlue = new NamedColor("Steel Blue", 185, 125, 75, 255); + + public static NamedColor Tan = new NamedColor("Tan", 45, 75, 115, 255); + + public static NamedColor Teal = new NamedColor("Teal", 255, 127, 127, 255); + + public static NamedColor Thistle = new NamedColor("Thistle", 39, 64, 39, 255); + + public static NamedColor Tomato = new NamedColor("Tomato", 0, 156, 184, 255); + + public static NamedColor Turquoise = new NamedColor("Turquoise", 191, 31, 47, 255); + + public static NamedColor Violet = new NamedColor("Violet", 17, 125, 17, 255); + + public static NamedColor Wheat = new NamedColor("Wheat", 10, 33, 76, 255); + + public static NamedColor White = new NamedColor("White", 0, 0, 0, 255); + + public static NamedColor WhiteSmoke = new NamedColor("White Smoke", 10, 10, 10, 255); + + public static NamedColor Yellow = new NamedColor("Yellow", 0, 0, 255); + + public static NamedColor YellowGreen = new NamedColor("Yellow Green", 101, 50, 205, 255); + + } +} diff --git a/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs b/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs new file mode 100644 index 00000000..22d737e7 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Illuminate +{ + public class NamedColor + { + public string name; + public Color color; + + public NamedColor() + { + + } + + public NamedColor(string Name, Color Color) + { + this.name = Name; + this.color = Color; + } + + public NamedColor(Color Color) + { + this.name = ""; + this.color = Color; + } + + public NamedColor(string Name, int r, int g, int b, int a = 255) + { + this.name = Name; + this.color = new Color(r, g, b, a); + } + + public Color getColor() + { + return this.color; + } + + public Color getInvertedColor() + { + return this.color.Invert(); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index b43599b6..122d956e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -218,10 +218,20 @@ namespace Revitalize.Framework.Objects private Color _drawColor; - public Color drawColor + public Color DrawColor { get { + if (this._dyedColor != null) + { + if (this._dyedColor.color != null) + { + if (this._dyedColor.color.A != 0) + { + return new Color(this._drawColor.R * this._dyedColor.color.R, this._drawColor.G * this._dyedColor.color.G, this._drawColor.B * this._dyedColor.color.B, 255); + } + } + } return this._drawColor; } set @@ -332,6 +342,21 @@ namespace Revitalize.Framework.Objects } } + private NamedColor _dyedColor; + public NamedColor DyedColor { + + get + { + return this._dyedColor; + } + set + { + this._dyedColor = value; + this.requiresUpdate = true; + } + + } + [JsonIgnore] public bool requiresUpdate; public BasicItemInformation() @@ -347,7 +372,7 @@ namespace Revitalize.Framework.Objects this.animationManager = new AnimationManager(); this.drawPosition = Vector2.Zero; - this.drawColor = Color.White; + this.DrawColor = Color.White; this.inventory = new InventoryManager(); this.lightManager = new LightManager(); @@ -358,7 +383,7 @@ namespace Revitalize.Framework.Objects this._alwaysDrawAbovePlayer = false; } - public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null) { this.name = name; this.id = id; @@ -381,7 +406,7 @@ namespace Revitalize.Framework.Objects } this.drawPosition = Vector2.Zero; - this.drawColor = drawColor; + this.DrawColor = drawColor; this.ignoreBoundingBox = ignoreBoundingBox; this.inventory = Inventory ?? new InventoryManager(); this.lightManager = Lights ?? new LightManager(); @@ -390,6 +415,8 @@ namespace Revitalize.Framework.Objects this.EnergyManager = EnergyManager ?? new Energy.EnergyManager(); this.AlwaysDrawAbovePlayer = AlwaysDrawAbovePlayer; + + } /// @@ -407,7 +434,7 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer); } public bool requiresSyncUpdate() @@ -449,6 +476,32 @@ namespace Revitalize.Framework.Objects this._lightManager.requiresUpdate = false; this._energyManager.requiresUpdate = false; } + + /// + /// Gets the name attached to the dyed color. + /// + /// + public string getDyedColorName() + { + if (this.DyedColor == null) + { + return ""; + } + if (this.DyedColor.color == null) + { + return ""; + } + if (this.DyedColor.color.A == 0) + { + return ""; + } + else + { + return this._dyedColor.name; + } + } + + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs b/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs index 7b7a239d..d917b346 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs @@ -220,7 +220,7 @@ namespace Revitalize.Framework.Objects.CraftingTables if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -240,7 +240,7 @@ namespace Revitalize.Framework.Objects.CraftingTables { 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 1ff0100d..8b56fa99 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -10,6 +10,7 @@ using StardewValley; using StardewValley.Objects; using Revitalize.Framework.Utilities; using Revitalize.Framework.Energy; +using Revitalize.Framework.Illuminate; namespace Revitalize.Framework.Objects { @@ -499,7 +500,7 @@ namespace Revitalize.Framework.Objects this.updateInfo(); if (x <= -1) { - spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), 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)(this.TileLocation.Y * Game1.tileSize) / 10000f)); + spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), 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)(this.TileLocation.Y * Game1.tileSize) / 10000f)); } else { @@ -509,7 +510,7 @@ namespace Revitalize.Framework.Objects if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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)(this.TileLocation.Y * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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)(this.TileLocation.Y * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -519,7 +520,7 @@ namespace Revitalize.Framework.Objects int addedDepth = 0; if (this.info.ignoreBoundingBox) addedDepth++; if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++; - 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)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f)); + 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)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f)); try { this.animationManager.tickAnimation(); @@ -546,7 +547,7 @@ namespace Revitalize.Framework.Objects if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth)); + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -556,7 +557,7 @@ namespace Revitalize.Framework.Objects int addedDepth = 0; if (this.info.ignoreBoundingBox) addedDepth++; if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++; - this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth)); + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth)); try { this.animationManager.tickAnimation(); @@ -586,7 +587,7 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize * 4f, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.DrawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize * 4f, SpriteEffects.None, layerDepth); } /// What happens when the object is drawn when held by a player. @@ -600,11 +601,11 @@ namespace Revitalize.Framework.Objects if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); if (f.ActiveObject.bigCraftable.Value) { - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.DrawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); return; } - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.DrawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) { spriteBatch.Draw(this.displayTexture, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); @@ -631,7 +632,7 @@ namespace Revitalize.Framework.Objects } if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None,Depth); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.DrawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None,Depth); //base.drawWhenHeld(spriteBatch, objectPosition, f); } @@ -663,6 +664,10 @@ namespace Revitalize.Framework.Objects public string getDisplayNameFromStringsFile(string objectID) { + if (ModCore.Configs.objectsConfig.showDyedColorName) + { + return this.info.getDyedColorName() + this.info.name; + } //Load in a file that has all object names referenced here or something. return this.info.name; } @@ -701,6 +706,20 @@ namespace Revitalize.Framework.Objects } } + /// + /// + /// + /// + public virtual void dyeColor(NamedColor DyeColor) + { + this.info.DyedColor = DyeColor; + } + + public virtual void eraseDye() + { + this.info.DyedColor = new NamedColor("", new Color(0, 0, 0, 0)); + } + //~~~~~~~~~~~~~~~~~~~~~~~~~// // PyTk Functions // //~~~~~~~~~~~~~~~~~~~~~~~~~// diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs index 737c032b..3e1d3cb8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs @@ -277,7 +277,7 @@ namespace Revitalize.Framework.Objects.Extras if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -296,7 +296,7 @@ namespace Revitalize.Framework.Objects.Extras { 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs index 2363542e..48c37583 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/TrashCanTile.cs @@ -304,7 +304,7 @@ namespace Revitalize.Framework.Objects.Extras if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -324,7 +324,7 @@ namespace Revitalize.Framework.Objects.Extras { 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index c58afba3..93e2581e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -267,7 +267,7 @@ namespace Revitalize.Framework.Objects.Furniture if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); if (this.framesUntilNextRotation > 0) this.framesUntilNextRotation--; @@ -290,7 +290,7 @@ namespace Revitalize.Framework.Objects.Furniture { 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.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); if (this.framesUntilNextRotation > 0) this.framesUntilNextRotation--; if (this.framesUntilNextRotation < 0) this.framesUntilNextRotation = 0; diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs index f3a2072a..809b45cf 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs @@ -200,7 +200,7 @@ namespace Revitalize.Framework.Objects.Furniture if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -225,7 +225,7 @@ namespace Revitalize.Framework.Objects.Furniture { addedDepth += 5f; } - 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)((yDepth + addedDepth) * Game1.tileSize) / 10000f) + .00001f); + 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)((yDepth + addedDepth) * Game1.tileSize) / 10000f) + .00001f); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs index 04cc22df..405aeedf 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs @@ -116,7 +116,7 @@ namespace Revitalize.Framework.Objects.Furniture if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -124,7 +124,7 @@ namespace Revitalize.Framework.Objects.Furniture { //Log.AsyncC("Animation Manager is working!"); float addedDepth = 0; - 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, 0.0001f)); + 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, 0.0001f)); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs index 157d5a6e..96175166 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs @@ -173,7 +173,7 @@ namespace Revitalize.Framework.Objects.Furniture if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -192,7 +192,7 @@ namespace Revitalize.Framework.Objects.Furniture { 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 142f1461..b58fdcd0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -361,7 +361,7 @@ namespace Revitalize.Framework.Objects.Furniture if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -380,7 +380,7 @@ namespace Revitalize.Framework.Objects.Furniture { 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Dye.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Dye.cs new file mode 100644 index 00000000..2a29043d --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Dye.cs @@ -0,0 +1,278 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Illuminate; +using StardewValley; + +namespace Revitalize.Framework.Objects.Items.Resources +{ + public class Dye: CustomObject, ISaveElement + { + + public NamedColor dyeColor; + [JsonIgnore] + public virtual string ItemInfo + { + get + { + return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + ModCore.Serializer.ToJSONString(this.data)+"<"+ModCore.Serializer.ToJSONString(this.dyeColor); + } + set + { + if (string.IsNullOrEmpty(value)) return; + string[] data = value.Split('<'); + string infoString = data[0]; + string guidString = data[1]; + string pytkData = data[2]; + string dyeColorStr = data[3]; + + this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); + this.data = ModCore.Serializer.DeserializeFromJSONString(pytkData); + Guid oldGuid = this.guid; + this.guid = Guid.Parse(guidString); + if (ModCore.CustomObjects.ContainsKey(this.guid)) + { + //ModCore.log("Update item with guid: " + this.guid); + ModCore.CustomObjects[this.guid] = this; + } + else + { + //ModCore.log("Add in new guid: " + this.guid); + ModCore.CustomObjects.Add(this.guid, this); + } + + if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid)) + { + if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid) + { + //ModCore.CustomObjects.Remove(oldGuid); + } + } + this.dyeColor = ModCore.Serializer.DeserializeFromJSONString(dyeColorStr); + } + } + + public Dye() { } + + public Dye(CustomObjectData PyTKData, BasicItemInformation info,NamedColor Color ,int Stack = 1) : base(PyTKData, info) + { + this.Stack = Stack; + this.Price = info.price; + } + + public Dye(CustomObjectData PyTKData, BasicItemInformation info,NamedColor Color ,Vector2 TileLocation, int Stack = 1) : base(PyTKData, info, TileLocation) + { + this.Stack = Stack; + this.Price = info.price; + } + + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + //ModCore.log("Checking for a clicky click???"); + return base.checkForAction(who, justCheckingForActivity); + } + + public override bool clicked(Farmer who) + { + //ModCore.log("Clicked a multiTiledComponent!"); + return true; + //return base.clicked(who); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + + return true; + } + + + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + this.location = null; + base.performRemoveAction(this.TileLocation, environment); + } + + public virtual void removeFromLocation(GameLocation location, Vector2 offset) + { + this.cleanUpLights(); + location.removeObject(this.TileLocation, false); + this.location = null; + //this.performRemoveAction(this.TileLocation,location); + } + + public virtual void cleanUpLights() + { + if (this.info.lightManager != null) this.info.lightManager.removeForCleanUp(this.location); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + //Do nothing because this shouldn't be placeable anywhere. + } + + /// Places an object down. + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + /* + this.updateDrawPosition(x, y); + this.location = location; + + if (this.location == null) this.location = Game1.player.currentLocation; + this.TileLocation = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize)); + //ModCore.log("TileLocation: " + this.TileLocation); + /* + return base.placementAction(location, x, y, who); + + //this.updateLightManager(); + + this.performDropDownAction(who); + location.objects.Add(this.TileLocation, this); + */ + //return true; + return false; + } + + + + + public override Item getOne() + { + Ore component = new Ore(this.data, this.info.Copy(), this.TileLocation); + component.Stack = 1; + return component; + } + + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Ore self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + /* + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + */ + return (ICustomObject)self; + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + saveData.Add("GUID", this.guid.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + + return saveData; + + } + + protected string recreateParentId(string id) + { + StringBuilder b = new StringBuilder(); + string[] splits = id.Split('.'); + for (int i = 0; i < splits.Length - 1; i++) + { + b.Append(splits[i]); + if (i == splits.Length - 2) continue; + b.Append("."); + } + return b.ToString(); + } + + public override int sellToStorePrice() + { + return this.Price; + } + + public override int salePrice() + { + return this.Price * 2; + } + /// What happens when the object is drawn at a tile location. + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (this.info.ignoreBoundingBox == true) + { + x *= -1; + y *= -1; + } + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.dyeColor.color * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + 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.dyeColor.color * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) + { + if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) + Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); + if (drawStackNumber && this.Quality > 0) + { + float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); + spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); + } + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.DrawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize * 4f, SpriteEffects.None, layerDepth); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs index 02646e2b..a0dd7b45 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs @@ -193,7 +193,7 @@ namespace Revitalize.Framework.Objects.Items.Resources if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -201,7 +201,7 @@ namespace Revitalize.Framework.Objects.Items.Resources { //Log.AsyncC("Animation Manager is working!"); float addedDepth = 0; - 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.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); try { this.animationManager.tickAnimation(); @@ -226,7 +226,7 @@ namespace Revitalize.Framework.Objects.Items.Resources float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize * 4f, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.DrawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize * 4f, SpriteEffects.None, layerDepth); } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs index 4e6ea0dd..dda7195f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs @@ -124,7 +124,7 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -143,7 +143,7 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration { 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index b6ce9009..7f9f4221 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -383,7 +383,7 @@ namespace Revitalize.Framework.Objects.Machines if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -402,7 +402,7 @@ 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.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 diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs index fc6bb1cd..c5d34565 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs @@ -104,7 +104,7 @@ namespace Revitalize.Framework.Objects.Machines if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -120,7 +120,7 @@ namespace Revitalize.Framework.Objects.Machines if (this.info.ignoreBoundingBox) addedDepth += 1.5f; } //this.determineWireOrientation(); - 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.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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index f785f52e..76fe0eaf 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -248,7 +248,7 @@ namespace Revitalize.Framework.Objects } - spriteBatch.Draw(this.displayTexture, location, new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location, new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.DrawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); } public override Item getOne() @@ -369,7 +369,7 @@ namespace Revitalize.Framework.Objects if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -388,7 +388,7 @@ namespace Revitalize.Framework.Objects { 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.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); try { this.animationManager.tickAnimation(); @@ -413,7 +413,7 @@ namespace Revitalize.Framework.Objects } if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Depth); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.DrawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Depth); //base.drawWhenHeld(spriteBatch, objectPosition, f); } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index f081be7a..f44faf2e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; +using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities; using StardewValley; using StardewValley.Objects; @@ -569,5 +570,27 @@ namespace Revitalize.Framework.Objects } } + + /// + /// + /// + /// + public override void dyeColor(NamedColor DyeColor) + { + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as CustomObject).dyeColor(DyeColor); + } + this.info.DyedColor = DyeColor; + } + + public override void eraseDye() + { + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as CustomObject).eraseDye(); + } + this.info.DyedColor = new NamedColor("", new Color(0, 0, 0, 0)); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs index 47d7fcdd..ba4a9492 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs @@ -423,7 +423,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize)+this.info.shakeTimerOffset(), (y * Game1.tileSize)+this.info.shakeTimerOffset())), 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 * Game1.tileSize) / 10000f)); + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize)+this.info.shakeTimerOffset(), (y * Game1.tileSize)+this.info.shakeTimerOffset())), 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 * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -442,7 +442,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins { addedDepth += 1.0f; } - this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize)+this.info.shakeTimerOffset(), (y * Game1.tileSize)+this.info.shakeTimerOffset())), 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.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize)+this.info.shakeTimerOffset(), (y * Game1.tileSize)+this.info.shakeTimerOffset())), 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); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 2a393ef0..eddebc23 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -32,6 +32,7 @@ using Revitalize.Framework.Objects.CraftingTables; using Revitalize.Framework.Objects.Items.Tools; using StardewValley.Tools; using Revitalize.Framework.Menus.Machines; +using Revitalize.Framework.Objects.Machines; namespace Revitalize { @@ -40,10 +41,7 @@ namespace Revitalize // -Chair tops cut off objects // -load content MUST be enabled for the table to be placed?????? // TODO: - /* Add in crafting menu. - * Add in crafting table. - * - * + /* // -Make this mod able to load content packs for easier future modding // // -Multiple Lights On Object @@ -57,7 +55,7 @@ namespace Revitalize // -dressers/other storage containers (Done!) // -fun interactables // -Arcade machines - // -More crafting tables + // -More crafting tables (done) // -Baths (see chairs but swimming) // // -Machines @@ -95,7 +93,7 @@ namespace Revitalize // -Calcinator (oil+stone: produces titanum?) // -Materials // -Tin/Bronze/Alluminum/Silver?Platinum/Etc (all but platinum: may add in at a later date) - -titanium + -titanium (d0ne) -Alloys! -Brass (done) -Electrum (done) @@ -552,7 +550,9 @@ namespace Revitalize Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench")); - + + MultiTiledObject batteryBin =(MultiTiledObject) ModCore.ObjectManager.GetItem("BatteryBin", 1); + batteryBin.dyeColor(Framework.Illuminate.ColorsList.Lime); //PickaxeExtended pick = new PickaxeExtended(new BasicItemInformation("My First Pickaxe", "Omegasis.Revitalize.Items.Tools.MyFirstPickaxe", "A testing pickaxe. Does it work?", "Tool", Color.SlateGray, 0, 0, false, 500, false, false, TextureManager.GetTexture(Manifest, "Tools", "Pickaxe"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Tools", "Pickaxe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null),2,TextureManager.GetExtendedTexture(Manifest,"Tools","TestingPickaxeWorking")); Game1.player.addItemsByMenuIfNecessary(new List() @@ -567,7 +567,7 @@ namespace Revitalize new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false), ModCore.ObjectManager.GetItem("Lighthouse",1), ModCore.ObjectManager.GetItem("CopperWire"), - ModCore.ObjectManager.GetItem("BatteryBin",1) + batteryBin }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 87ff03a3..d354aedd 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -56,6 +56,7 @@ + @@ -81,8 +82,10 @@ + + @@ -149,6 +152,7 @@ + From cd87139168c9f6c04c549b284307000f70769f79 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 17:42:22 -0700 Subject: [PATCH 58/98] Fixed dyed color display name from showing. --- GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs | 2 +- .../Revitalize/Framework/Objects/BasicItemInformation.cs | 2 +- GeneralMods/Revitalize/Framework/Objects/CustomObject.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs index 7a80a54f..d3580cc0 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs @@ -11,7 +11,7 @@ namespace Revitalize.Framework.Illuminate { public static NamedColor AliceBlue = new NamedColor("Alice Blue", new Color(15, 7, 0, 255).Invert()); - public static NamedColor AntiqueWhite = new NamedColor("Antique White", 5, 20, 40, 255); + public static NamedColor AntiqueWhite = new NamedColor("Antique White", 5, 20, 40, 255); public static NamedColor Aqua = new NamedColor("Aqua", 255, 0, 0, 255); diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 122d956e..c54d99a3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -434,7 +434,7 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor); } public bool requiresSyncUpdate() diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 8b56fa99..15353e9b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -90,7 +90,7 @@ namespace Revitalize.Framework.Objects { if (this.info != null) { - return this.info.name; + return this.getDisplayNameFromStringsFile(this.info.id); } return this.netName.Value.Split('>')[0]; } @@ -666,7 +666,7 @@ namespace Revitalize.Framework.Objects { if (ModCore.Configs.objectsConfig.showDyedColorName) { - return this.info.getDyedColorName() + this.info.name; + return this.info.getDyedColorName() +" "+ this.info.name; } //Load in a file that has all object names referenced here or something. return this.info.name; From 0d252799de8afaca36532561eab7c8cb3ada9a6c Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 18 Sep 2019 22:55:06 -0700 Subject: [PATCH 59/98] Inverted all colors in ColorsList, added in ColorManager which deals with blending dyed objects, and prevented objects with different dyes from being stacked on each other. --- .../Revitalize/Framework/Enums/Enums.cs | 7 + .../Framework/Illuminate/ColorsList.cs | 282 +++++++++--------- .../Framework/Illuminate/NamedColor.cs | 6 +- .../Framework/Managers/ColorManager.cs | 102 +++++++ .../Framework/Objects/BasicItemInformation.cs | 27 +- .../Framework/Objects/CustomObject.cs | 10 + GeneralMods/Revitalize/Revitalize.csproj | 1 + 7 files changed, 289 insertions(+), 146 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Managers/ColorManager.cs diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index 4e6573b0..81814f93 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -1173,5 +1173,12 @@ namespace Revitalize.Framework StatueOfPerfection=160, SolidGoldLewis=164 } + + public enum DyeBlendMode + { + Multiplier, + Blend, + Average + } } } diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs index d3580cc0..21915744 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorsList.cs @@ -9,290 +9,290 @@ namespace Revitalize.Framework.Illuminate { public class ColorsList { - public static NamedColor AliceBlue = new NamedColor("Alice Blue", new Color(15, 7, 0, 255).Invert()); + public static NamedColor AliceBlue = new NamedColor("Alice Blue",15, 7, 0, 255,true); - public static NamedColor AntiqueWhite = new NamedColor("Antique White", 5, 20, 40, 255); + public static NamedColor AntiqueWhite = new NamedColor("Antique White",5, 20, 40, 255,true); - public static NamedColor Aqua = new NamedColor("Aqua", 255, 0, 0, 255); + public static NamedColor Aqua = new NamedColor("Aqua", 255, 0, 0, 255,true); - public static NamedColor Aquamarine = new NamedColor("Aquamarine", 128, 0, 43, 255); + public static NamedColor Aquamarine = new NamedColor("Aquamarine",128, 0, 43, 255,true); /// A whiteish sort of color witha hint of blue - public static NamedColor Azure = new NamedColor("Azure", 15, 0, 0, 255); + public static NamedColor Azure = new NamedColor("Azure",15, 0, 0, 255,true); - public static NamedColor Beige = new NamedColor("Beige", 10, 10, 35, 255); + public static NamedColor Beige = new NamedColor("Beige",10, 10, 35, 255,true); - public static NamedColor Bisque = new NamedColor("Bisque", 0, 27, 59, 255); + public static NamedColor Bisque = new NamedColor("Bisque", 0, 27, 59, 255,true); - public static NamedColor Black = new NamedColor("Black", 255, 255, 255, 255); + public static NamedColor Black = new NamedColor("Black", 255, 255, 255, 255,true); - public static NamedColor BlanchedAlmond = new NamedColor("Blanched Almond", 0, 20, 40, 255); + public static NamedColor BlanchedAlmond = new NamedColor("Blanched Almond", 0, 20, 40, 255,true); - public static NamedColor Blue = new NamedColor("Blue", 255, 255, 0, 255); + public static NamedColor Blue = new NamedColor("Blue", 255, 255, 0, 255,true); - public static NamedColor BlueViolet = new NamedColor("Blue Violet", 117, 212, 29, 255); + public static NamedColor BlueViolet = new NamedColor("Blue Violet", 117, 212, 29, 255,true); - public static NamedColor Brown = new NamedColor("Brown", 90, 213, 213, 255); + public static NamedColor Brown = new NamedColor("Brown", 90, 213, 213, 255,true); - public static NamedColor BurlyWood = new NamedColor("Burly Wood", 33, 71, 120, 255); + public static NamedColor BurlyWood = new NamedColor("Burly Wood", 33, 71, 120, 255,true); - public static NamedColor CadetBlue = new NamedColor("Cadet Blue", 160, 97, 95, 255); + public static NamedColor CadetBlue = new NamedColor("Cadet Blue", 160, 97, 95, 255,true); - public static NamedColor Chartreuse = new NamedColor("Chartreuse", 128, 0, 255, 255); + public static NamedColor Chartreuse = new NamedColor("Chartreuse", 128, 0, 255, 255,true); - public static NamedColor Chocolate = new NamedColor("Chocolate", 45, 150, 225, 255); + public static NamedColor Chocolate = new NamedColor("Chocolate", 45, 150, 225, 255,true); - public static NamedColor Coral = new NamedColor("Coral", 0, 128, 175, 255); + public static NamedColor Coral = new NamedColor("Coral", 0, 128, 175, 255,true); - public static NamedColor CornflowerBlue = new NamedColor("Cornflower Blue", 155, 106, 18, 255); + public static NamedColor CornflowerBlue = new NamedColor("Cornflower Blue", 155, 106, 18, 255,true); /// A yellowish color. - public static NamedColor Cornsilk = new NamedColor("Cornsilk", 0, 7, 35, 255); + public static NamedColor Cornsilk = new NamedColor("Cornsilk", 0, 7, 35, 255,true); - public static NamedColor Crimson = new NamedColor("Crimson", 35, 235, 195, 255); + public static NamedColor Crimson = new NamedColor("Crimson", 35, 235, 195, 255,true); - public static NamedColor Cyan = new NamedColor("Cyan",255, 0, 0, 255); + public static NamedColor Cyan = new NamedColor("Cyan",255, 0, 0, 255,true); - public static NamedColor DarkBlue = new NamedColor("Dark Blue", 255, 255, 116, 255); + public static NamedColor DarkBlue = new NamedColor("Dark Blue", 255, 255, 116, 255,true); - public static NamedColor DarkCyan = new NamedColor("Dark Cyan", 255, 114, 114, 255); + public static NamedColor DarkCyan = new NamedColor("Dark Cyan", 255, 114, 114, 255,true); - public static NamedColor DarkGoldenRod = new NamedColor("Dark Goldenrod", 71, 121, 244, 255); + public static NamedColor DarkGoldenRod = new NamedColor("Dark Goldenrod", 71, 121, 244, 255,true); - public static NamedColor DarkGray = new NamedColor("Dark Gray", 86, 86, 86, 255); + public static NamedColor DarkGray = new NamedColor("Dark Gray", 86, 86, 86, 255,true); - public static NamedColor DarkGreen = new NamedColor("Dark Green", 255, 155, 255, 255); + public static NamedColor DarkGreen = new NamedColor("Dark Green", 255, 155, 255, 255,true); - public static NamedColor DarkKhaki = new NamedColor("Dark Khaki", 66, 72, 148, 255); + public static NamedColor DarkKhaki = new NamedColor("Dark Khaki", 66, 72, 148, 255,true); - public static NamedColor DarkMagenta = new NamedColor("Dark Magenta", 116, 255, 116, 255); + public static NamedColor DarkMagenta = new NamedColor("Dark Magenta", 116, 255, 116, 255,true); - public static NamedColor DarkOliveGreen = new NamedColor("Dark Olive Green", 170, 148, 208, 255); + public static NamedColor DarkOliveGreen = new NamedColor("Dark Olive Green", 170, 148, 208, 255,true); - public static NamedColor DarkOrange = new NamedColor("Dark Orange", 0, 115, 255, 255); + public static NamedColor DarkOrange = new NamedColor("Dark Orange", 0, 115, 255, 255,true); - public static NamedColor DarkOrchid = new NamedColor("Dark Orchid", 102, 105, 51, 255); + public static NamedColor DarkOrchid = new NamedColor("Dark Orchid", 102, 105, 51, 255,true); - public static NamedColor DarkRed = new NamedColor("Dark Red", 116, 255, 255, 255); + public static NamedColor DarkRed = new NamedColor("Dark Red", 116, 255, 255, 255,true); - public static NamedColor DarkSalmon = new NamedColor("Dark Salmon", 22, 105, 133, 255); + public static NamedColor DarkSalmon = new NamedColor("Dark Salmon", 22, 105, 133, 255,true); - public static NamedColor DarkSeaGreen = new NamedColor("Dark Sea Green", 112, 67, 112, 255); + public static NamedColor DarkSeaGreen = new NamedColor("Dark Sea Green", 112, 67, 112, 255,true); - public static NamedColor DarkSlateBlue = new NamedColor("Dark Slate Blue", 183, 194, 116, 255); + public static NamedColor DarkSlateBlue = new NamedColor("Dark Slate Blue", 183, 194, 116, 255,true); - public static NamedColor DarkSlateGray = new NamedColor("Dark Slate Gray", 208, 176, 176, 255); + public static NamedColor DarkSlateGray = new NamedColor("Dark Slate Gray", 208, 176, 176, 255,true); - public static NamedColor DarkTurquoise = new NamedColor("Dark Turquoise", 255, 49, 46, 255); + public static NamedColor DarkTurquoise = new NamedColor("Dark Turquoise", 255, 49, 46, 255,true); - public static NamedColor DarkViolet = new NamedColor("Dark Violet", 107, 255, 44, 255); + public static NamedColor DarkViolet = new NamedColor("Dark Violet", 107, 255, 44, 255,true); - public static NamedColor DeepPink = new NamedColor("Deep Pink", 0, 235, 108, 255); + public static NamedColor DeepPink = new NamedColor("Deep Pink", 0, 235, 108, 255,true); - public static NamedColor DeepSkyBlue = new NamedColor("Deep Sky Blue", 255, 64, 0, 255); + public static NamedColor DeepSkyBlue = new NamedColor("Deep Sky Blue", 255, 64, 0, 255,true); - public static NamedColor DimGray = new NamedColor("Dim Gray", 150, 150, 150, 255); + public static NamedColor DimGray = new NamedColor("Dim Gray", 150, 150, 150, 255,true); - public static NamedColor DodgerBlue = new NamedColor("Dodger Blue", 225, 111, 0, 255); + public static NamedColor DodgerBlue = new NamedColor("Dodger Blue", 225, 111, 0, 255,true); - public static NamedColor FireBrick = new NamedColor("FireBrick",77, 221, 221, 255); + public static NamedColor FireBrick = new NamedColor("FireBrick",77, 221, 221, 255,true); - public static NamedColor FloralWhite = new NamedColor("Floral White", 0, 5, 15, 255); + public static NamedColor FloralWhite = new NamedColor("Floral White", 0, 5, 15, 255,true); - public static NamedColor ForestGreen = new NamedColor("Forest Green", 221, 116, 221, 255); + public static NamedColor ForestGreen = new NamedColor("Forest Green", 221, 116, 221, 255,true); - public static NamedColor Fuchsia = new NamedColor("Fuchsia", 0, 255, 0, 255); + public static NamedColor Fuchsia = new NamedColor("Fuchsia", 0, 255, 0, 255,true); /// More of a white-ish color - public static NamedColor Gainsboro = new NamedColor("Gainsboro", 35, 35, 35, 255); + public static NamedColor Gainsboro = new NamedColor("Gainsboro", 35, 35, 35, 255,true); - public static NamedColor GhostWhite = new NamedColor("Ghost White", 7, 7, 0); + public static NamedColor GhostWhite = new NamedColor("Ghost White", 7, 7, 0,255,true); - public static NamedColor Gold = new NamedColor("Gold", 0, 40, 255, 255); + public static NamedColor Gold = new NamedColor("Gold", 0, 40, 255, 255,true); - public static NamedColor GoldenRod = new NamedColor("Golden Rod", 37, 90, 223, 255); + public static NamedColor GoldenRod = new NamedColor("Golden Rod", 37, 90, 223, 255,true); - public static NamedColor Gray = new NamedColor("Gray", 127, 127, 127, 255); + public static NamedColor Gray = new NamedColor("Gray", 127, 127, 127, 255,true); - public static NamedColor Green = new NamedColor("Green", 255, 127, 255, 255); + public static NamedColor Green = new NamedColor("Green", 255, 127, 255, 255,true); - public static NamedColor GreenYellow = new NamedColor("Green Yellow", 82, 0, 208, 255); + public static NamedColor GreenYellow = new NamedColor("Green Yellow", 82, 0, 208, 255,true); - public static NamedColor HoneyDew = new NamedColor("Honey Dew", 15, 0, 15, 255); + public static NamedColor HoneyDew = new NamedColor("Honey Dew", 15, 0, 15, 255,true); - public static NamedColor HotPink = new NamedColor("Hot Pink", 0, 140, 75, 255); + public static NamedColor HotPink = new NamedColor("Hot Pink", 0, 140, 75, 255,true); - public static NamedColor IndianRed = new NamedColor("Indian Red", 40, 163, 163, 255); + public static NamedColor IndianRed = new NamedColor("Indian Red", 40, 163, 163, 255,true); - public static NamedColor Indigo = new NamedColor("Indigo", 180, 255, 125, 255); + public static NamedColor Indigo = new NamedColor("Indigo", 180, 255, 125, 255,true); - public static NamedColor Ivory = new NamedColor("Ivory", 0, 0, 15, 255); + public static NamedColor Ivory = new NamedColor("Ivory", 0, 0, 15, 255,true); - public static NamedColor Khaki = new NamedColor("Khaki", 15, 25, 115, 255); + public static NamedColor Khaki = new NamedColor("Khaki", 15, 25, 115, 255,true); - public static NamedColor Lavender = new NamedColor("Lavender", 25, 25, 5, 255); + public static NamedColor Lavender = new NamedColor("Lavender", 25, 25, 5, 255,true); - public static NamedColor LavenderBlush = new NamedColor("Lavender Blush", 0, 15, 10, 255); + public static NamedColor LavenderBlush = new NamedColor("Lavender Blush", 0, 15, 10, 255,true); - public static NamedColor LawnGreen = new NamedColor("Lawn Green", 131, 3, 255, 255); + public static NamedColor LawnGreen = new NamedColor("Lawn Green", 131, 3, 255, 255,true); - public static NamedColor LemonChiffron = new NamedColor("Lemon Chiffron", 0, 5, 50, 255); + public static NamedColor LemonChiffron = new NamedColor("Lemon Chiffron", 0, 5, 50, 255,true); - public static NamedColor LightBlue = new NamedColor("Light Blue",82, 39, 25, 255); + public static NamedColor LightBlue = new NamedColor("Light Blue",82, 39, 25, 255,true); - public static NamedColor LightCoral = new NamedColor("Light Coral", 15, 127, 127, 255); + public static NamedColor LightCoral = new NamedColor("Light Coral", 15, 127, 127, 255,true); - public static NamedColor LightCyan = new NamedColor("Light Cyan", 31, 0, 0, 255); + public static NamedColor LightCyan = new NamedColor("Light Cyan", 31, 0, 0, 255,true); - public static NamedColor LightGoldenRodYellow = new NamedColor("Light Goldenrod Yellow", 5, 5, 45, 255); + public static NamedColor LightGoldenRodYellow = new NamedColor("Light Goldenrod Yellow", 5, 5, 45, 255,true); - public static NamedColor LightGray = new NamedColor("Light Gray", 44, 44, 44, 255); + public static NamedColor LightGray = new NamedColor("Light Gray", 44, 44, 44, 255,true); - public static NamedColor LightGreen = new NamedColor("Light Green", 111, 17, 111, 255); + public static NamedColor LightGreen = new NamedColor("Light Green", 111, 17, 111, 255,true); - public static NamedColor LightPink = new NamedColor("Light Pink", 0, 73, 62, 255); + public static NamedColor LightPink = new NamedColor("Light Pink", 0, 73, 62, 255,true); - public static NamedColor LightSalmon = new NamedColor("Light Salmon", 0, 95, 133, 255); + public static NamedColor LightSalmon = new NamedColor("Light Salmon", 0, 95, 133, 255,true); - public static NamedColor LightSeaGreen = new NamedColor("Ligh tSea Green", 223, 77, 85, 255); + public static NamedColor LightSeaGreen = new NamedColor("Ligh tSea Green", 223, 77, 85, 255,true); - public static NamedColor LightSkyBlue = new NamedColor("Light Sky Blue", 120, 49, 5, 255); + public static NamedColor LightSkyBlue = new NamedColor("Light Sky Blue", 120, 49, 5, 255,true); - public static NamedColor LightSlateGray = new NamedColor("Light Slate Gray", 146, 119, 102, 255); + public static NamedColor LightSlateGray = new NamedColor("Light Slate Gray", 146, 119, 102, 255,true); - public static NamedColor LightSteelBlue = new NamedColor("Light Steel Blue", 79, 59, 33, 255); + public static NamedColor LightSteelBlue = new NamedColor("Light Steel Blue", 79, 59, 33, 255,true); - public static NamedColor LightYellow = new NamedColor("Light Yellow", 0, 0, 31, 255); + public static NamedColor LightYellow = new NamedColor("Light Yellow", 0, 0, 31, 255,true); - public static NamedColor Lime = new NamedColor("Lime", 255, 0, 255, 255); + public static NamedColor Lime = new NamedColor("Lime", 255, 0, 255, 255,true); - public static NamedColor LimeGreen = new NamedColor("Lime Green", 105, 50, 105, 255); + public static NamedColor LimeGreen = new NamedColor("Lime Green", 105, 50, 105, 255,true); - public static NamedColor Linen = new NamedColor("Linen", 5, 15, 25, 255); + public static NamedColor Linen = new NamedColor("Linen", 5, 15, 25, 255,true); - public static NamedColor Magenta = new NamedColor("Magenta", 0, 255, 0, 255); + public static NamedColor Magenta = new NamedColor("Magenta", 0, 255, 0, 255,true); - public static NamedColor Maroon = new NamedColor("Maroon", 127, 255, 255, 0); + public static NamedColor Maroon = new NamedColor("Maroon", 127, 255, 255, 0,true); - public static NamedColor MediumAquaMarine = new NamedColor("Medium Aqua Marine", 153, 50, 85, 255); + public static NamedColor MediumAquaMarine = new NamedColor("Medium Aqua Marine", 153, 50, 85, 255,true); - public static NamedColor MediumBlue = new NamedColor("Medium Blue",255, 255, 50, 255); + public static NamedColor MediumBlue = new NamedColor("Medium Blue",255, 255, 50, 255,true); - public static NamedColor MediumOrchid = new NamedColor("Medium Orchid", 69, 170, 44, 255); + public static NamedColor MediumOrchid = new NamedColor("Medium Orchid", 69, 170, 44, 255,true); - public static NamedColor MediumPurple = new NamedColor("Medium Purple", 108, 143, 36, 255); + public static NamedColor MediumPurple = new NamedColor("Medium Purple", 108, 143, 36, 255,true); - public static NamedColor MediumSeaGreen = new NamedColor("Medium Sea Green", 195, 78, 142, 255); + public static NamedColor MediumSeaGreen = new NamedColor("Medium Sea Green", 195, 78, 142, 255,true); - public static NamedColor MediumSlateBlue = new NamedColor("Medium Slate Blue", 132, 151, 17, 255); + public static NamedColor MediumSlateBlue = new NamedColor("Medium Slate Blue", 132, 151, 17, 255,true); - public static NamedColor MediumSpringGreen = new NamedColor("Medium Spring Green", 255, 5, 101, 255); + public static NamedColor MediumSpringGreen = new NamedColor("Medium Spring Green", 255, 5, 101, 255,true); - public static NamedColor MediumTurquoise = new NamedColor("Medium Turquoise", 183, 46, 51, 255); + public static NamedColor MediumTurquoise = new NamedColor("Medium Turquoise", 183, 46, 51, 255,true); - public static NamedColor MediumVioletRed = new NamedColor("Medium Violet Red", 46, 234, 122, 255); + public static NamedColor MediumVioletRed = new NamedColor("Medium Violet Red", 46, 234, 122, 255,true); - public static NamedColor MidnightBlue = new NamedColor("Midnight Blue", 230, 230, 143, 255); + public static NamedColor MidnightBlue = new NamedColor("Midnight Blue", 230, 230, 143, 255,true); - public static NamedColor MintCream = new NamedColor("Mint Cream", 10, 0, 5, 255); + public static NamedColor MintCream = new NamedColor("Mint Cream", 10, 0, 5, 255,true); - public static NamedColor MistyRose = new NamedColor("Misty Rose", 0, 27, 30, 255); + public static NamedColor MistyRose = new NamedColor("Misty Rose", 0, 27, 30, 255,true); - public static NamedColor Moccasin = new NamedColor("Moccasin", 0, 33, 82, 255); + public static NamedColor Moccasin = new NamedColor("Moccasin", 0, 33, 82, 255,true); - public static NamedColor NavajoWhite = new NamedColor("Navajo White", 0, 33, 82, 255); + public static NamedColor NavajoWhite = new NamedColor("Navajo White", 0, 33, 82, 255,true); - public static NamedColor Navy = new NamedColor("Navy", 255, 255, 127, 255); + public static NamedColor Navy = new NamedColor("Navy", 255, 255, 127, 255,true); - public static NamedColor OldLace = new NamedColor("Old Lace", 2, 10, 25, 255); + public static NamedColor OldLace = new NamedColor("Old Lace", 2, 10, 25, 255,true); - public static NamedColor Olive = new NamedColor("Olive", 127, 127, 255, 255); + public static NamedColor Olive = new NamedColor("Olive", 127, 127, 255, 255,true); - public static NamedColor OliveDrab = new NamedColor("Olive Drab", 148, 113, 220, 255); + public static NamedColor OliveDrab = new NamedColor("Olive Drab", 148, 113, 220, 255,true); - public static NamedColor Orange = new NamedColor("Orange", 0, 90, 255, 255); + public static NamedColor Orange = new NamedColor("Orange", 0, 90, 255, 255,true); - public static NamedColor OrangeRed = new NamedColor("Orange Red", 0, 186, 255, 255); + public static NamedColor OrangeRed = new NamedColor("Orange Red", 0, 186, 255, 255,true); - public static NamedColor Orchid = new NamedColor("Orchid", 37, 143, 41, 255); + public static NamedColor Orchid = new NamedColor("Orchid", 37, 143, 41, 255,true); - public static NamedColor PaleGoldenRod = new NamedColor("Pale Golden Rod", 17, 23, 85, 255); + public static NamedColor PaleGoldenRod = new NamedColor("Pale Golden Rod", 17, 23, 85, 255,true); - public static NamedColor PaleGreen = new NamedColor("Pale Green", 103, 4, 103, 255); + public static NamedColor PaleGreen = new NamedColor("Pale Green", 103, 4, 103, 255,true); - public static NamedColor PaleTurquoise = new NamedColor("Pale Turquoise", 80, 17, 17, 255); + public static NamedColor PaleTurquoise = new NamedColor("Pale Turquoise", 80, 17, 17, 255,true); - public static NamedColor PaleVioletRed = new NamedColor("Pale Violet Red", 36, 143, 108, 255); + public static NamedColor PaleVioletRed = new NamedColor("Pale Violet Red", 36, 143, 108, 255,true); - public static NamedColor PapayaWhip = new NamedColor("Papaya Whip", 0, 16, 42, 255); + public static NamedColor PapayaWhip = new NamedColor("Papaya Whip", 0, 16, 42, 255,true); - public static NamedColor PeachPuff = new NamedColor("Peach Puff", 0, 37, 70, 255); + public static NamedColor PeachPuff = new NamedColor("Peach Puff", 0, 37, 70, 255,true); - public static NamedColor Peru = new NamedColor("Peru", 50, 122, 192, 255); + public static NamedColor Peru = new NamedColor("Peru", 50, 122, 192, 255,true); - public static NamedColor Pink = new NamedColor("Pink", 0, 63, 52, 255); + public static NamedColor Pink = new NamedColor("Pink", 0, 63, 52, 255,true); - public static NamedColor Plum = new NamedColor("Plum", 34, 95, 34, 255); + public static NamedColor Plum = new NamedColor("Plum", 34, 95, 34, 255,true); - public static NamedColor PowderBlue = new NamedColor("Powder Blue", 79, 31, 25, 255); + public static NamedColor PowderBlue = new NamedColor("Powder Blue", 79, 31, 25, 255,true); - public static NamedColor Purple = new NamedColor("Purple", 127, 255, 127, 255); + public static NamedColor Purple = new NamedColor("Purple", 127, 255, 127, 255,true); - public static NamedColor RebeccaPurple = new NamedColor("Rebecca Purple", 153, 104, 102, 255); + public static NamedColor RebeccaPurple = new NamedColor("Rebecca Purple", 153, 104, 102, 255,true); - public static NamedColor Red = new NamedColor("Red", 0, 255, 255, 255); + public static NamedColor Red = new NamedColor("Red", 0, 255, 255, 255,true); - public static NamedColor RosyBrown = new NamedColor("Rosy Brown", 67, 112, 112, 255); + public static NamedColor RosyBrown = new NamedColor("Rosy Brown", 67, 112, 112, 255,true); - public static NamedColor RoyalBlue = new NamedColor("Royal Blue", 190, 150, 30, 255); + public static NamedColor RoyalBlue = new NamedColor("Royal Blue", 190, 150, 30, 255,true); - public static NamedColor SaddleBrown = new NamedColor("Saddle Brown", 115, 186, 231, 255); + public static NamedColor SaddleBrown = new NamedColor("Saddle Brown", 115, 186, 231, 255,true); - public static NamedColor Salmon = new NamedColor("Salmon", 5, 127, 141, 255); + public static NamedColor Salmon = new NamedColor("Salmon", 5, 127, 141, 255,true); - public static NamedColor SandyBrown = new NamedColor("Sandy Brown", 11, 91, 159, 255); + public static NamedColor SandyBrown = new NamedColor("Sandy Brown", 11, 91, 159, 255,true); - public static NamedColor SeaGreen = new NamedColor("Sea Green", 209, 116, 168, 255); + public static NamedColor SeaGreen = new NamedColor("Sea Green", 209, 116, 168, 255,true); - public static NamedColor SeaShell = new NamedColor("Sea Shell", 0, 10, 17, 255); + public static NamedColor SeaShell = new NamedColor("Sea Shell", 0, 10, 17, 255,true); - public static NamedColor Sienna = new NamedColor("Sienna", 95, 173, 210, 255); + public static NamedColor Sienna = new NamedColor("Sienna", 95, 173, 210, 255,true); - public static NamedColor Silver = new NamedColor("Silver", 63, 63, 63, 255); + public static NamedColor Silver = new NamedColor("Silver", 63, 63, 63, 255,true); - public static NamedColor SkyBlue = new NamedColor("Sky Blue", 120, 49, 20, 255); + public static NamedColor SkyBlue = new NamedColor("Sky Blue", 120, 49, 20, 255,true); - public static NamedColor SlateBlue = new NamedColor("Slate Blue", 149, 165, 50, 255); + public static NamedColor SlateBlue = new NamedColor("Slate Blue", 149, 165, 50, 255,true); - public static NamedColor SlateGray = new NamedColor("Slate Gray", 143, 127, 111, 255); + public static NamedColor SlateGray = new NamedColor("Slate Gray", 143, 127, 111, 255,true); - public static NamedColor Snow = new NamedColor("Snow", 0, 5, 5, 255); + public static NamedColor Snow = new NamedColor("Snow", 0, 5, 5, 255,true); - public static NamedColor SpringGreen = new NamedColor("Spring Green", 255, 0, 128, 255); + public static NamedColor SpringGreen = new NamedColor("Spring Green", 255, 0, 128, 255,true); - public static NamedColor SteelBlue = new NamedColor("Steel Blue", 185, 125, 75, 255); + public static NamedColor SteelBlue = new NamedColor("Steel Blue", 185, 125, 75, 255,true); - public static NamedColor Tan = new NamedColor("Tan", 45, 75, 115, 255); + public static NamedColor Tan = new NamedColor("Tan", 45, 75, 115, 255,true); - public static NamedColor Teal = new NamedColor("Teal", 255, 127, 127, 255); + public static NamedColor Teal = new NamedColor("Teal", 255, 127, 127, 255,true); - public static NamedColor Thistle = new NamedColor("Thistle", 39, 64, 39, 255); + public static NamedColor Thistle = new NamedColor("Thistle", 39, 64, 39, 255,true); - public static NamedColor Tomato = new NamedColor("Tomato", 0, 156, 184, 255); + public static NamedColor Tomato = new NamedColor("Tomato", 0, 156, 184, 255,true); - public static NamedColor Turquoise = new NamedColor("Turquoise", 191, 31, 47, 255); + public static NamedColor Turquoise = new NamedColor("Turquoise", 191, 31, 47, 255,true); - public static NamedColor Violet = new NamedColor("Violet", 17, 125, 17, 255); + public static NamedColor Violet = new NamedColor("Violet", 17, 125, 17, 255,true); - public static NamedColor Wheat = new NamedColor("Wheat", 10, 33, 76, 255); + public static NamedColor Wheat = new NamedColor("Wheat", 10, 33, 76, 255,true); - public static NamedColor White = new NamedColor("White", 0, 0, 0, 255); + public static NamedColor White = new NamedColor("White", 0, 0, 0, 255,true); - public static NamedColor WhiteSmoke = new NamedColor("White Smoke", 10, 10, 10, 255); + public static NamedColor WhiteSmoke = new NamedColor("White Smoke", 10, 10, 10, 255,true); - public static NamedColor Yellow = new NamedColor("Yellow", 0, 0, 255); + public static NamedColor Yellow = new NamedColor("Yellow", 0, 0, 255,255,true); - public static NamedColor YellowGreen = new NamedColor("Yellow Green", 101, 50, 205, 255); + public static NamedColor YellowGreen = new NamedColor("Yellow Green", 101, 50, 205, 255,true); } } diff --git a/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs b/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs index 22d737e7..1dd272ee 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/NamedColor.cs @@ -29,10 +29,14 @@ namespace Revitalize.Framework.Illuminate this.color = Color; } - public NamedColor(string Name, int r, int g, int b, int a = 255) + public NamedColor(string Name, int r, int g, int b, int a = 255, bool Invert=false) { this.name = Name; this.color = new Color(r, g, b, a); + if (Invert) + { + this.color = this.color.Invert(); + } } public Color getColor() diff --git a/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs b/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs new file mode 100644 index 00000000..e13265b4 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Managers +{ + public class ColorManager + { + /// + /// The color blending mode for this color manager. + /// + private Enums.DyeBlendMode _colorMixMode; + + public Enums.DyeBlendMode ColorMixMode + { + get + { + return this._colorMixMode; + } + set + { + this._colorMixMode = value; + this.requiresUpdate = true; + } + } + + /// + /// The amount of influence the first color has on the mix for the object. + /// + private double _blendInfluence; + public double BlendInfluence + { + get + { + return this._blendInfluence; + } + set + { + this._blendInfluence = value; + this.requiresUpdate = true; + } + } + + /// + /// Does this ColorManager require a sync update. + /// + public bool requiresUpdate; + + public ColorManager() + { + + } + + /// + /// Constructor. + /// + /// + public ColorManager(Enums.DyeBlendMode DyeBlendMode,double BlendInfluence=0d) + { + this._colorMixMode = DyeBlendMode; + this._blendInfluence = BlendInfluence; + } + + /// + /// Constructor which loosely enforeces the color blend mode to be a mixed blend but only requires a influence parameter. + /// + /// + /// + public ColorManager(double BlendInfluence, Enums.DyeBlendMode DyeBlendMode=Enums.DyeBlendMode.Blend) + { + this._colorMixMode = DyeBlendMode; + this._blendInfluence = BlendInfluence; + } + + public Color getBlendedColor(Color self, Color other,int Alpha=255) + { + //Used as reference. + //https://stackoverflow.com/questions/3722307/is-there-an-easy-way-to-blend-two-system-drawing-color-values + if (this._colorMixMode== Enums.DyeBlendMode.Blend) + { + int r =(int)(self.R * this._blendInfluence + other.R * (1 - this._blendInfluence)); + int g = (int)(self.G * this._blendInfluence + other.G * (1 - this._blendInfluence)); + int b = (int)(self.B * this._blendInfluence + other.B * (1 - this._blendInfluence)); + return new Color(r, g, b, Alpha); + } + if(this._colorMixMode== Enums.DyeBlendMode.Average) + { + return new Color((self.R + other.R) / 2, (self.G + other.G) / 2, (self.B + other.B) / 2, Alpha); + } + + if(this._colorMixMode== Enums.DyeBlendMode.Multiplier) + { + return new Color(self.R * other.R, self.G * other.G,self.B * other.B, Alpha); + } + + return self; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index c54d99a3..bfe9882f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -8,6 +8,7 @@ using Revitalize.Framework.Utilities; using StardewValley; using StardustCore.UIUtilities; using Newtonsoft.Json; +using Revitalize.Framework.Managers; namespace Revitalize.Framework.Objects { @@ -228,7 +229,9 @@ namespace Revitalize.Framework.Objects { if (this._dyedColor.color.A != 0) { - return new Color(this._drawColor.R * this._dyedColor.color.R, this._drawColor.G * this._dyedColor.color.G, this._drawColor.B * this._dyedColor.color.B, 255); + return this._colorManager.getBlendedColor(this._drawColor, this._dyedColor.color); + //return new Color( (this._drawColor.R + this._dyedColor.color.R)/2, (this._drawColor.G + this._dyedColor.color.G)/2, (this._drawColor.B + this._dyedColor.color.B)/2, 255); + //return new Color(this._drawColor.R * this._dyedColor.color.R, this._drawColor.G * this._dyedColor.color.G, this._drawColor.B * this._dyedColor.color.B, 255); } } } @@ -357,6 +360,21 @@ namespace Revitalize.Framework.Objects } + public ColorManager _colorManager; + + public ColorManager ColorManager + { + get + { + return this._colorManager; + } + set + { + this._colorManager = value; + this.requiresUpdate = true; + } + } + [JsonIgnore] public bool requiresUpdate; public BasicItemInformation() @@ -383,7 +401,7 @@ namespace Revitalize.Framework.Objects this._alwaysDrawAbovePlayer = false; } - public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null, ColorManager ColorManager=null) { this.name = name; this.id = id; @@ -416,7 +434,8 @@ namespace Revitalize.Framework.Objects this.EnergyManager = EnergyManager ?? new Energy.EnergyManager(); this.AlwaysDrawAbovePlayer = AlwaysDrawAbovePlayer; - + this.DyedColor = DyedColor ?? new NamedColor("", new Color(0, 0, 0, 0)); + this.ColorManager = ColorManager ?? new ColorManager(Enums.DyeBlendMode.Blend, 0.5f); } /// @@ -434,7 +453,7 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager); } public bool requiresSyncUpdate() diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 15353e9b..255941f3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -720,6 +720,16 @@ namespace Revitalize.Framework.Objects this.info.DyedColor = new NamedColor("", new Color(0, 0, 0, 0)); } + public override bool canStackWith(Item other) + { + CustomObject o = (CustomObject)other; + + if (this.info.DyedColor != o.info.DyedColor) return false; + if (this.info.EnergyManager.remainingEnergy != o.info.EnergyManager.remainingEnergy) return false; + + return base.canStackWith(other); + } + //~~~~~~~~~~~~~~~~~~~~~~~~~// // PyTk Functions // //~~~~~~~~~~~~~~~~~~~~~~~~~// diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index d354aedd..e70e8675 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -86,6 +86,7 @@ + From f93fac16372ce8b8eece5baa160b56e915d58510 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 19 Sep 2019 14:44:46 -0700 Subject: [PATCH 60/98] Added in capacitor. --- .../Graphics/Objects/Machines/Capacitor.png | Bin 0 -> 338 bytes .../Framework/Objects/Machines/Machine.cs | 59 +++--- .../Objects/Machines/WireMultiTiledObject.cs | 180 ++++++++++++++++++ .../Framework/Objects/MultiTiledComponent.cs | 14 +- .../Framework/Objects/MultiTiledObject.cs | 4 +- .../Framework/Objects/ObjectManager.cs | 9 +- .../Framework/Utilities/InventoryManager.cs | 9 + .../Framework/Utilities/PlayerUtilities.cs | 13 ++ GeneralMods/Revitalize/ModCore.cs | 5 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + 10 files changed, 265 insertions(+), 32 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png new file mode 100644 index 0000000000000000000000000000000000000000..2662d05b74d1feaadd9f9f8092fff2ea7f6fec83 GIT binary patch literal 338 zcmV-Y0j>UtP)Px$3`s;mR5*>rkIPEKP#A>2h)`3NkQ@*x5kWCXS1$7mc?Es4u6>g(+Eu#|EENPX z#0#E;6U7)@)Qw4Vt=T!N;ZNo}Gw|QiGUIvPr5!z8cMXmvb1esCVXLoqemVS17)|Ed zcJ+f}?*O2Zv=%b-9so=KE5FqM#qdrI;NS>h3S=aizOErfZ8Z-3 zl`sY8LkD4s)_-aZ484a+Qrwjf3!ldY>;i5Jps_)9=O*P1Zr@%wHUz$U?-YDcvJ3$D zJ{@8S!O6fuemnyp_6|$_K3Eb;3A1tg1WTBxI7Y>B%~#b32xauA&s3Ta%*F)3P2tw& kYk>W;i>szK8+8}(14Q&`ppJPsEdT%j07*qoM6N<$f_@K(=>Px# literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 7f9f4221..c50e3497 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -19,7 +19,7 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Objects.Machines { - public class Machine:MultiTiledComponent + public class Machine : MultiTiledComponent { [JsonIgnore] @@ -37,7 +37,7 @@ namespace Revitalize.Framework.Objects.Machines string timeToProduce = this.timeToProduce.ToString(); string updatesContainer = this.updatesContainerObjectForProduction.ToString(); - return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container+"<"+resources+"<"+energyRequired+"<"+timeToProduce+"<"+updatesContainer+"<"+this.craftingRecipeBook; + return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + resources + "<" + energyRequired + "<" + timeToProduce + "<" + updatesContainer + "<" + this.craftingRecipeBook; } set { @@ -142,28 +142,34 @@ namespace Revitalize.Framework.Objects.Machines { if (ModCore.Configs.machinesConfig.doMachinesConsumeEnergy == false) { - ModCore.log("Machine config disables energy consumption."); + //ModCore.log("Machine config disables energy consumption."); return false; } if (this.energyRequiredPer10Minutes == 0) { - ModCore.log("Machine rquires 0 energy to run."); + //ModCore.log("Machine rquires 0 energy to run."); return false; } if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes) { - ModCore.log("Machine does consume energy."); + //ModCore.log("Machine does consume energy."); return true; } - ModCore.log("Unknown energy configuration."); + if(this.EnergyManager.energyInteractionType== Enums.EnergyInteractionType.Storage) + { + + return true; + } + //ModCore.log("Unknown energy configuration."); return false; } } public Machine() { } - public Machine(CustomObjectData PyTKData, BasicItemInformation info,List ProducedResources=null, int EnergyRequiredPer10Minutes = 0,int TimeToProduce=0,bool UpdatesContainer=false, string CraftingBook = "") : base(PyTKData, info) { - this.producedResources = ProducedResources?? new List(); + public Machine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; this.timeToProduce = TimeToProduce; this.updatesContainerObjectForProduction = UpdatesContainer; @@ -173,7 +179,7 @@ namespace Revitalize.Framework.Objects.Machines } - 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) + 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) { this.containerObject = obj; this.producedResources = ProducedResources ?? new List(); @@ -185,11 +191,11 @@ namespace Revitalize.Framework.Objects.Machines 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) + 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) { this.offsetKey = offsetKey; this.containerObject = obj; - this.producedResources = ProducedResources?? new List(); + this.producedResources = ProducedResources ?? new List(); this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; this.timeToProduce = TimeToProduce; this.updatesContainerObjectForProduction = UpdatesContainer; @@ -223,15 +229,15 @@ namespace Revitalize.Framework.Objects.Machines int remaining = minutes; //ModCore.log("Minutes elapsed: " + remaining); List energySources = new List(); - if (this.ConsumesEnergy) + if (this.ConsumesEnergy || this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) { - ModCore.log("This machine drains energy: " + this.info.name); + //ModCore.log("This machine drains energy: " + this.info.name); energySources = this.EnergyGraphSearchSources(); //Only grab the network once. } if (this.ProducesItems) { - ModCore.log("This machine produces items: "+this.info.name); + ModCore.log("This machine produces items: " + this.info.name); while (remaining > 0) { @@ -251,7 +257,7 @@ namespace Revitalize.Framework.Objects.Machines remaining -= 10; this.containerObject.MinutesUntilReady -= 10; - if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull==false) + if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull == false) { this.produceItem(); this.containerObject.MinutesUntilReady = this.timeToProduce; @@ -264,13 +270,14 @@ namespace Revitalize.Framework.Objects.Machines { remaining -= 10; this.produceEnergy(); + this.storeEnergyToNetwork(); } } - if (this.MinutesUntilReady>0) + if (this.MinutesUntilReady > 0) { this.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); - if(this.InventoryManager.hasItemsInBuffer && this.MinutesUntilReady == 0) + if (this.InventoryManager.hasItemsInBuffer && this.MinutesUntilReady == 0) { this.InventoryManager.dumpBufferToItems(); } @@ -306,18 +313,18 @@ namespace Revitalize.Framework.Objects.Machines { MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); - MachineSummaryMenu m = new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width / 2) - 400, 48, 800, 600, Color.White, this.containerObject,this.energyRequiredPer10Minutes); + MachineSummaryMenu m = new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width / 2) - 400, 48, 800, 600, Color.White, this.containerObject, this.energyRequiredPer10Minutes); machineMenu.addInMenuTab("Summary", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), m, true); if (this.InventoryManager.capacity > 0) { - InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, this.InventoryManager.capacity,this.InventoryManager.displayRows,this.InventoryManager.displayColumns); + InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, this.InventoryManager.capacity, this.InventoryManager.displayRows, this.InventoryManager.displayColumns); machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, false); } - if (string.IsNullOrEmpty(this.craftingRecipeBook)==false) + if (string.IsNullOrEmpty(this.craftingRecipeBook) == false) { - CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items,ref this.InventoryManager.items,this); + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items, ref this.InventoryManager.items, this); machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); } @@ -326,7 +333,7 @@ namespace Revitalize.Framework.Objects.Machines public override Item getOne() { - Machine component = new Machine(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources,this.energyRequiredPer10Minutes,this.timeToProduce,this.updatesContainerObjectForProduction,this.craftingRecipeBook,this.containerObject); + Machine component = new Machine(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.containerObject); return component; } @@ -422,14 +429,14 @@ namespace Revitalize.Framework.Objects.Machines public virtual void produceItem() { - foreach(ResourceInformation r in this.producedResources) + foreach (ResourceInformation r in this.producedResources) { if (r.shouldDropResource()) { Item i = r.getItemDrops(); this.InventoryManager.addItem(i); //ModCore.log("Produced an item!"); - } + } } } @@ -443,7 +450,7 @@ namespace Revitalize.Framework.Objects.Machines } - protected virtual void drawStatusBubble(SpriteBatch b,int x, int y,float Alpha) + 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) @@ -451,7 +458,7 @@ namespace Revitalize.Framework.Objects.Machines 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); + 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/Framework/Objects/Machines/WireMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs new file mode 100644 index 00000000..e39f6ab7 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs @@ -0,0 +1,180 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines +{ + public class WireMultiTiledObject:MultiTiledObject + { + + + public WireMultiTiledObject():base() + { + + } + + public WireMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info) + : base(PyTKData, info) + { + + } + + public WireMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation) + : base(PyTKData, info, TileLocation) + { + + } + + public WireMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) + : base(PyTKData, info, TileLocation,ObjectsList) + { + + + } + + public override Item getOne() + { + Dictionary objs = new Dictionary(); + foreach (var pair in this.objects) + { + objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne()); + } + return new WireMultiTiledObject(this.data, this.info.Copy(), this.TileLocation, objs); + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + WireMultiTiledObject obj = (WireMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (obj == null) + { + return null; + } + + Dictionary guids = new Dictionary(); + + foreach (KeyValuePair pair in obj.childrenGuids) + { + guids.Add(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in guids) + { + obj.childrenGuids.Remove(pair.Key); + MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString()); + component.InitNetFields(); + obj.removeComponent(pair.Key); + obj.addComponent(pair.Key, component); + + + } + obj.InitNetFields(); + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) + { + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj); + return obj; + } + else + { + return Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]]; + } + + + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + saveData.Add("GUID", this.guid.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return saveData; + } + + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as MultiTiledComponent).draw(spriteBatch, x + ((int)pair.Key.X), y + ((int)pair.Key.Y), alpha); + } + } + + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + { + pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile + (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); + } + + //base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + { + //ModCore.log(location + (pair.Key * 16) + new Vector2(32, 32)); + pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16) + new Vector2(32, 32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) + Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); + //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f); + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override bool canStackWith(Item other) + { + if (other is WireMultiTiledObject) + { + return (other as WireMultiTiledObject).info.id == this.info.id && (other as WireMultiTiledObject).info.DyedColor== this.info.DyedColor; + } + else return false; + } + + public override int maximumStackSize() + { + return 999; + } + + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + this.updateInfo(); + WireMultiTiledObject m =(WireMultiTiledObject)this.getOne(); + + foreach (KeyValuePair pair in m.objects) + { + /* + if ((pair.Value as CustomObject).info.ignoreBoundingBox) + { + pair.Value.placementAction(location, -1 * (x + (int)pair.Key.X * Game1.tileSize), -1 * (y + (int)pair.Key.Y * Game1.tileSize), who); + } + else + { + pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + }*/ + (pair.Value as MultiTiledComponent).placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + //ModCore.log(pair.Value.TileLocation); + } + m.location = location; + return true; + //return base.placementAction(location, x, y, who); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 76fe0eaf..933189b8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -648,7 +648,19 @@ namespace Revitalize.Framework.Objects for (int i = 0; i < energySources.Count; i++) { this.EnergyManager.transferEnergyToAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); - if (this.EnergyManager.hasEnergy) break; + if (this.EnergyManager.hasEnergy==false) break; + } + } + + public void storeEnergyToNetwork(List energySources) + { + + int index = 0; + + for (int i = 0; i < energySources.Count; i++) + { + this.EnergyManager.transferEnergyToAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); + if (this.EnergyManager.hasEnergy==false) break; } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index f44faf2e..0c0a7e3c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -295,11 +295,13 @@ namespace Revitalize.Framework.Objects this.location = null; } else - Game1.showRedMessage("NOOOOOOOO"); + Game1.showRedMessage("Can't pickup item for some reason."); } public override bool removeAndAddToPlayersInventory() { + bool f = Game1.player.addItemToInventoryBool(this, false); + return f; if (Game1.player.isInventoryFull()) { Game1.showRedMessage("Inventory full."); diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 7f3acc34..c11aa94a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -241,12 +241,17 @@ namespace Revitalize.Framework.Objects batteryBin.addComponent(new Vector2(0, 0), batteryBin_0_0); this.AddItem("BatteryBin", batteryBin); + MultiTiledObject capacitor= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Capacitor", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Capacitor", "Omegasis.Revitalize.Objects.Machines.Capacitor", "A box which stores energy for use over time.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Capacitor"), new Animation(0, 0, 16, 16)), Color.White, false,null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage))); + Machine capacitor_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Capacitor", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Capacitor", "Omegasis.Revitalize.Objects.Machines.Capacitor", "A box which stores energy for use over time.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Capacitor"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)),null,0,0,true,""); + capacitor.addComponent(new Vector2(0, 0), capacitor_0_0); + this.AddItem("Capacitor", capacitor); + } private void loadInWires() { - MultiTiledObject copperWire = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers), false)); - Wire copperWire_0_0 = new Wire(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers), false)); + WireMultiTiledObject copperWire = new WireMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers), false)); + Wire copperWire_0_0 = new Wire(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers),false)); copperWire.addComponent(new Vector2(0, 0), copperWire_0_0); this.AddItem("CopperWire", copperWire); } diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index 93e79f34..f8c9e128 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -186,6 +186,15 @@ namespace Revitalize.Framework.Utilities this.requiresUpdate = true; } + public bool canReceieveThisItem(Item I) + { + if (this.IsFull) return false; + else + { + return true; + } + } + /// /// Returns a new inventory manager without the items but with the capacity limits. /// diff --git a/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs index e71f1977..d27be79e 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs @@ -17,5 +17,18 @@ namespace Revitalize.Framework.Utilities { return Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID; } + + + public static bool CanPlayerInventoryReceiveThisItem(Item I) + { + for(int i = 0; i < Game1.player.Items.Count; i++) + { + if (I == Game1.player.Items[i]) return true; + if (I == null) return true; + if (I.canStackWith(Game1.player.Items[i])) return true; + } + return false; + + } } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index eddebc23..13f77ce6 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -566,8 +566,9 @@ namespace Revitalize ModCore.ObjectManager.GetItem("SolarArrayTier1",1), new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false), ModCore.ObjectManager.GetItem("Lighthouse",1), - ModCore.ObjectManager.GetItem("CopperWire"), - batteryBin + ModCore.ObjectManager.GetItem("CopperWire",10), + batteryBin, + ModCore.ObjectManager.GetItem("Capacitor",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e70e8675..88e1127a 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -162,6 +162,7 @@ + @@ -429,6 +430,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From b76a5ef39d00973ce4a55ce948b59d021bdcf4a6 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 19 Sep 2019 15:44:02 -0700 Subject: [PATCH 61/98] Added in charging station. --- .../Objects/Machines/ChargingStation.png | Bin 0 -> 616 bytes .../Objects/Machines/ChargingStation.cs | 196 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 12 ++ GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + 5 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ChargingStation.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ChargingStation.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ChargingStation.png new file mode 100644 index 0000000000000000000000000000000000000000..570785b49134bb6be5dae250538b215e2e261112 GIT binary patch literal 616 zcmV-u0+;=XP)Px%B1uF+R9J=WSHVl$U=;sFN-Lt>W-Bs{peZ{{7#j?sJy{U{f}9G4UYn1xQxAjv z3uTAF+QLqP;4VGwu#;C?CW?B{gCq`&1GkmAOk{e=E=%_%{azN*bYA+qBzfh#`i!Wk}A+QM+OPZ}NxPvLuy?h5CzU%jFCEF&Q{NeI1(Q(|LmQ-Iewc;|?J<)$oJ_0!!eKtE!4-vk73Z5(vjIm&>8mYIUy{AEZLlA0Br|pKA=g zv(8`l(}DSE+IR8gj|9(OzH>QNSMs>8A{0|CQj;lcz4HZWyRmtEf~e&=^BTQ35B{4Z}BHmSxDYj5n`eiO0~JAfqVI4a1j^ z$G_rD(}Zc70Em4+RJ~*KCZ_IIWaHQR7Qo|e^Mfy$U#odSs!&n_2fLf^g=AEVc{?u! z)xn+ug6c1_2kDS^UGM8Spq^CnAmHP=W4QBiE70Po5d(mDJkc0S-Yd_h=a8C8;oxWw zSJwAN)MO%#k+t;=jSuR4rC%OVf#>Lc6>E&yv*|flmll5h`hj|_CJ9&f0gW+xV)PD@ z<4K%-J4L-#lUxs>b!kP-DFn%*F=lIw4fOxO%kdi$8t90Crt7r;0000 ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + + } + + public ChargingStation(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) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public ChargingStation(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) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + if (this.updatesContainerObjectForProduction) + { + //ModCore.log("Update container object for production!"); + //this.MinutesUntilReady -= minutes; + int remaining = minutes; + //ModCore.log("Minutes elapsed: " + remaining); + List energySources = new List(); + if (this.ConsumesEnergy || this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + { + //ModCore.log("This machine drains energy: " + this.info.name); + energySources = this.EnergyGraphSearchSources(); //Only grab the network once. + } + this.drainEnergyFromNetwork(energySources); + foreach(Item I in this.InventoryManager.items) + { + if (I is null) continue; + if (I is CustomObject == false) continue; + IEnergyInterface o = (IEnergyInterface)I; + if (o.EnergyManager.canReceieveEnergy) + { + this.EnergyManager.transferEnergyToAnother(o.EnergyManager, Math.Min(this.EnergyManager.remainingEnergy, o.EnergyManager.capacityRemaining)); + } + if (this.EnergyManager.hasEnergy == false) break; + } + + return false; + } + else + { + return false; + } + } + + + public override Item getOne() + { + ChargingStation component = new ChargingStation(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.containerObject); + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + ChargingStation self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index c11aa94a..eef1f22e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -246,6 +246,18 @@ namespace Revitalize.Framework.Objects capacitor.addComponent(new Vector2(0, 0), capacitor_0_0); this.AddItem("Capacitor", capacitor); + + MultiTiledObject chargingStation = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, false,new InventoryManager(4,4,1), null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage))); + ChargingStation chargingStation_0_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, true, ""); + ChargingStation chargingStation_1_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); + ChargingStation chargingStation_0_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); + ChargingStation chargingStation_1_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); + chargingStation.addComponent(new Vector2(0, 0), chargingStation_0_0); + chargingStation.addComponent(new Vector2(1, 0), chargingStation_1_0); + chargingStation.addComponent(new Vector2(0, 1), chargingStation_0_1); + chargingStation.addComponent(new Vector2(1, 1), chargingStation_1_1); + this.AddItem("ChargingStation", chargingStation); + } private void loadInWires() diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 13f77ce6..cf673582 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -568,7 +568,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("Lighthouse",1), ModCore.ObjectManager.GetItem("CopperWire",10), batteryBin, - ModCore.ObjectManager.GetItem("Capacitor",1) + ModCore.ObjectManager.GetItem("Capacitor",1), + ModCore.ObjectManager.GetItem("ChargingStation",1) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 88e1127a..e1c10b8e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -159,6 +159,7 @@ + @@ -433,6 +434,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 7209fec308c3e5245559e1213295fc1397e00422 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 19 Sep 2019 17:03:29 -0700 Subject: [PATCH 62/98] Added in dust variations of ore which can be used to double ore when smelted. --- .../Items/Resources/Ore/BauxiteSand.png | Bin 0 -> 254 bytes .../Items/Resources/Ore/CopperSand.png | Bin 0 -> 236 bytes .../Graphics/Items/Resources/Ore/GoldSand.png | Bin 0 -> 244 bytes .../Items/Resources/Ore/IridiumSand.png | Bin 0 -> 270 bytes .../Graphics/Items/Resources/Ore/IronSand.png | Bin 0 -> 243 bytes .../Graphics/Items/Resources/Ore/LeadSand.png | Bin 0 -> 263 bytes .../Items/Resources/Ore/SilverSand.png | Bin 0 -> 235 bytes .../Graphics/Items/Resources/Ore/TinSand.png | Bin 0 -> 233 bytes .../Items/Resources/Ore/TitaniumSand.png | Bin 0 -> 260 bytes .../Framework/Objects/ResourceManager.cs | 22 +++++++++++++- GeneralMods/Revitalize/Revitalize.csproj | 27 ++++++++++++++++++ 11 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/BauxiteSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/CopperSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/GoldSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/IridiumSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/IronSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/LeadSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/SilverSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/TinSand.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/TitaniumSand.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/BauxiteSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/BauxiteSand.png new file mode 100644 index 0000000000000000000000000000000000000000..04fee32d388929d3b0389195ea40b3eb20b7ef6d GIT binary patch literal 254 zcmVPx#xJg7oR5*?8Q6Un;AQ0TdCK+a!h}!5F3^Km9{Gl(a?0FcTSP1;g|W$G}JA>2#Y8N|_F=3VSn z6U_9(J4%rl_z9Hs003>)!xXy&e$q&WU{p)d#I7@SLG%r6*3gT$(hAO;Uk@ccq_U98 zLYp-ZrLu|m!cM8XPY|EC>)8p;TwKfXswTOQ%Zh)&1`2dqa5W&z&;S4c07*qoM6N<$ Ef)C4Uc>n+a literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/CopperSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/CopperSand.png new file mode 100644 index 0000000000000000000000000000000000000000..66681d5798c90d03ee4b48491fac0d3bafde025a GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|mU+53hFJ6_ zCrGgN>`<9=RN|lV=kNOttrJ_V;8Waa+hYGvA4~AM>niI ioXxRI#_#MD28JstA=cMg|5*WD%;4$j=d#Wzp$Pz(c3jW^ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/GoldSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/GoldSand.png new file mode 100644 index 0000000000000000000000000000000000000000..1ea7bf368586b0b43a1fdc8fa3a44583c975ee56 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_J-(hFJ6_ zCrGgN>`>{OdgHJAv*@ofhgONLR`A)J+N{hB1cyJi{k7mtJoJ?5G@Cmc+qEPXY4!sK z3`bw?uP!|Ou(&bxks?cbgLVK^CI&9SZF@T!?Y3=D;i=_ht>Ub7YGat2RVKbLh*2~7aJAYs4& literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/IridiumSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/IridiumSand.png new file mode 100644 index 0000000000000000000000000000000000000000..0f2c472a744395c7cd8719291cf360bcc6c31fd5 GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|PI$UFhFJ6_ zCrGgN>`>wPvHPF$XZ;$T!>guo&VTkfc#q_@XKsn60_z!hfFQegv4q%@jDt6KFtjnA zFuVEG?x<$_b=GA(b_L%Sp1cH9A@E+Hgz-#USBxDS5VZB3od00mj`GR!tF;Yc7&gDW zkdnE>(I7m5o7*iV*jKXV!K@38$DjBY?0j(Yw1kAjf4JI&HqPan2W>7Gy1BVPMcqEX*|1e{vP* OCk9VfKbLh*2~7Yu^KL%? literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/IronSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/IronSand.png new file mode 100644 index 0000000000000000000000000000000000000000..296b1bda36b593280f6e34442ad1bb9a0efff5f3 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_S@)hFJ6_ zCrGgN>`>up;{LDvS%1yjYE=N`p8xM@B7re{&j7$2hY=kwnx~df;d0jzYtoT_ucaLby4}qU&8x-_@+f!PPH}$dWON% L)z4*}Q$iB}gfeKa literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/SilverSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/SilverSand.png new file mode 100644 index 0000000000000000000000000000000000000000..f1ed13852bffe6be0bc894347ade75bfab08b4dc GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|mU_B4hFJ8z zop@02hysUeeUQ_d!&?+$1Ny$+VBNOBc-!N7DJ6@aZMgn)5!3(AZVmM^tC@_i|C4o^ z@y&0tua64@gJ9&WIoeE0O~roiS64`Ud0}`gHP^d9a`AWbu7eAFcdTV)STZMGQ;sEf zQn6oenTY%QD#^u*-g{VPuf2cjFVdQ&MBb@0Fj_qCjbBd literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/TitaniumSand.png b/GeneralMods/Revitalize/Content/Graphics/Items/Resources/Ore/TitaniumSand.png new file mode 100644 index 0000000000000000000000000000000000000000..3136a626ca313860a5bf86a28602f42732945a08 GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|_IbKEhFJ6_ zCrGgN>`>AAl=V;fv$fjRgwXC#fn_%@-<{nE1c|@Tt+n7yJoJ>wzdXO~e!M_V48viD zl;xX0J(za*HIsODOK(d|V-mv|wi##D`R6FV;NlTKkn`(rYvaK?2RjyMM@;Y)O`6`~ zt#JFyDdxi7oy~%0Cj95&nGlh<>cr}w{M~ZJ?8Q&l~Y-yUh#5unB4#PiQ%8+BY9?9?P*KkwpcSulab+cQ~K%1>H7tNK4I{5^>bP0 Hl+XkKv0-XI literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 5cecd49b..33d24cfa 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -260,7 +260,7 @@ namespace Revitalize.Framework.Objects /// private void loadInOreItems() { - Ore tinOre = new Ore(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TinOre", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinOre"), typeof(Ore), Color.White, true), new BasicItemInformation("Tin Ore", "Omegasis.Revitalize.Items.Resources.Ore.TinOre", "Tin ore that can be smelted into tin ingots for further use.", "Ore", Color.Silver, -300, 0, false, 7, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinOre"), new AnimationManager(), Color.White, true, null, null), 1); + Ore tinOre = new Ore(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TinOre", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinOre"), typeof(Ore), Color.White, true), new BasicItemInformation("Tin Ore", "Omegasis.Revitalize.Items.Resources.Ore.TinOre", "Tin ore that can be smelted into tin ingots for further use.", "Ore", Color.Silver, -300, 0, false, 7,false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinOre"), new AnimationManager(), Color.White, true, null, null), 1); this.ores.Add("Tin", tinOre); Ore bauxiteOre = new Ore(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.Bauxite", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BauxiteOre"), typeof(Ore), Color.White, true), new BasicItemInformation("Bauxite Ore", "Omegasis.Revitalize.Items.Resources.Ore.BauxiteOre", "Bauxite ore that can be smelted into aluminum ingots for further use.", "Ore", Color.Silver, -300, 0, false, 11, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BauxiteOre"), new AnimationManager(), Color.White, true, null, null), 1); @@ -305,6 +305,26 @@ namespace Revitalize.Framework.Objects CustomObject steelIngot = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.SteelIngot", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SteelIngot"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Steel Ingot", "Omegasis.Revitalize.Items.Resources.Ore.SteelIngot", "A steel ingot that was made by processing iron again with more coal. It can be used for crafting purposes especially for making new machines.", "Ore", Color.Silver, -300, 0, false, 180, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SteelIngot"), new AnimationManager(), Color.White, true, null, null), 1); ModCore.ObjectManager.AddItem("SteelIngot", steelIngot); + + CustomObject bauxiteSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.BauxiteSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BauxiteSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Bauxite Sand", "Omegasis.Revitalize.Items.Resources.Ore.BauxiteSand", "Bauxite ore which has been crushed into sand. Smelt it to get aluminum ingots.", "Ore", Color.Silver, -300, 0, false, 11, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "BauxiteSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject copperSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.CopperSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "CopperSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Copper Sand", "Omegasis.Revitalize.Items.Resources.Ore.CopperSand", "Copper ore which has been crushed into sand. Smelt it to get copper bars.", "Ore", Color.Silver, -300, 0, false, 5, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "CopperSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject goldSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.GoldSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "GoldSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Gold Sand", "Omegasis.Revitalize.Items.Resources.Ore.GoldSand", "Gold ore which has been crushed into sand. Smelt it to get gold bars.", "Ore", Color.Silver, -300, 0, false, 25, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "GoldSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject ironSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.IronSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IronSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Iron Sand", "Omegasis.Revitalize.Items.Resources.Ore.IronSand", "Iron ore which has been crushed into sand. Smelt it to get iron bars.", "Ore", Color.Silver, -300, 0, false, 10, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IronSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject iridiumSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.IridiumSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IriduiumSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Iridium Sand", "Omegasis.Revitalize.Items.Resources.Ore.IridiumSand", "Iridium ore which has been crushed into sand. Smelt it to get iridium bars.", "Ore", Color.Silver, -300, 0, false, 100, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IridiumSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject leadSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.LeadSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "LeadSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Lead Sand", "Omegasis.Revitalize.Items.Resources.Ore.LeadSand", "Lead ore which has been crushed into sand. Smelt it to get lead ingots.", "Ore", Color.Silver, -300, 0, false, 15, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "LeadSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject silverSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.SilverSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SilverSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Silver Sand", "Omegasis.Revitalize.Items.Resources.Ore.SilverSand", "Silver ore which has been crushed into sand. Smelt it to get silver ingots.", "Ore", Color.Silver, -300, 0, false, 20, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SilverSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject tinSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TinSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Tin Sand", "Omegasis.Revitalize.Items.Resources.Ore.TinSand", "Tin ore which has been crushed into sand. Smelt it to get tin ingots.", "Ore", Color.Silver, -300, 0, false, 7, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject titaniumSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TitaniumSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitniumSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Copper Sand", "Omegasis.Revitalize.Items.Resources.Ore.TitaniumSand", "Titanium ore which has been crushed into sand. Smelt it to get titanium bars.", "Ore", Color.Silver, -300, 0, false, 35, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumSand"), new AnimationManager(), Color.White, true, null, null), 1); + + this.resources.Add("BauxiteSand", bauxiteSand); + this.resources.Add("CopperSand", copperSand); + this.resources.Add("GoldSand", goldSand); + this.resources.Add("IronSand", ironSand); + this.resources.Add("IridiumSand", iridiumSand); + this.resources.Add("LeadSand", leadSand); + this.resources.Add("SilverSand", silverSand); + this.resources.Add("TinSand", tinSand); + this.resources.Add("TitaniumSand", titaniumSand); } private void loadInResourceItems() diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e1c10b8e..a55ab562 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -227,21 +227,39 @@ PreserveNewest + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + PreserveNewest @@ -251,6 +269,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -260,12 +281,18 @@ PreserveNewest + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + PreserveNewest From d059017a729fa255ef3736cfeea0ff0455de1641 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 19 Sep 2019 17:32:44 -0700 Subject: [PATCH 63/98] Added in ore sand variants that can be smelted into ore bars. --- .../Framework/Crafting/VanillaRecipeBook.cs | 74 +++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 1 - 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs index ee24e917..856ac7f2 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs @@ -167,6 +167,80 @@ namespace Revitalize.Framework.Crafting }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("Glass"),1), TimeUtilities.GetMinutesFromTime(0, 1, 0), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Sand", furnace_glass); + + ///Sand recipes here.... + /// + VanillaRecipe furnace_bauxiteSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("BauxiteSand"),5} + + }, new KeyValuePair(ModCore.ObjectManager.GetItem("AluminumIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 1, 30), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Bauxite Sand", furnace_bauxiteSand); + + VanillaRecipe furnace_copperSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("CopperSand"),5} + + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), TimeUtilities.GetMinutesFromTime(0, 0, 30), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Copper Sand", furnace_copperSand); + + VanillaRecipe furnace_ironSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("IronSand"),5} + + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.IronBar, 1), 1), TimeUtilities.GetMinutesFromTime(0, 2, 00), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Iron Sand", furnace_ironSand); + + VanillaRecipe furnace_goldSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("GoldSand"),5} + + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.GoldBar, 1), 1), TimeUtilities.GetMinutesFromTime(0, 5, 0), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Gold Sand", furnace_goldSand); + + VanillaRecipe furnace_iridiumSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("IridiumSand"),5} + + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.IridiumBar, 1), 1), TimeUtilities.GetMinutesFromTime(0, 8, 0), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Iridium Sand", furnace_iridiumSand); + + VanillaRecipe furnace_leadSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("LeadSand"),5} + + }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("LeadIngot"),1), TimeUtilities.GetMinutesFromTime(0, 2, 0), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Lead Sand", furnace_leadSand); + + VanillaRecipe furnace_silverSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("SilverSand"),5} + + }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("SilverIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 3, 0), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Silver Sand", furnace_silverSand); + + VanillaRecipe furnace_tinSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("TinSand"),5} + + }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("TinIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 0, 50), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Tin Sand", furnace_tinSand); + + VanillaRecipe furnace_titaniumSand = new VanillaRecipe(new Dictionary() + { + {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, + {ModCore.ObjectManager.resources.getResource("TitaniumSand"),5} + + }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("TitaniumIngot"), 1), TimeUtilities.GetMinutesFromTime(0, 4, 0), new StatCost(), false); + this.recipesByObjectName["Furnace"].Add("Titanium Sand", furnace_titaniumSand); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index cf673582..0628973e 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -570,7 +570,6 @@ namespace Revitalize batteryBin, ModCore.ObjectManager.GetItem("Capacitor",1), ModCore.ObjectManager.GetItem("ChargingStation",1) - }); } From c0ecee5d9dd8d1477a3e155ab0e7c88fbc29ae48 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 19 Sep 2019 19:07:15 -0700 Subject: [PATCH 64/98] Added in the grinder which grinds ores into sand for ore doubling. --- .../Graphics/Objects/Machines/Grinder.png | Bin 0 -> 437 bytes .../Framework/Configs/GlobalMachineConfig.cs | 5 + .../Framework/Objects/CustomObject.cs | 1 + .../Framework/Objects/Machines/Grinder.cs | 323 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 26 +- .../Framework/Objects/ResourceManager.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 4 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + 8 files changed, 356 insertions(+), 11 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Grinder.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Grinder.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Grinder.png new file mode 100644 index 0000000000000000000000000000000000000000..095ab8c2ed30977f9fc6b0ca87daa8ecfe9fa3b0 GIT binary patch literal 437 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T<`JOJ0ArY;~ z2@(khX3U)WwO&E?z>xz74onEK=zMth_I932N}Ir#hli)YO!w&nz85Py(=;+8PXQGj zDERq|RbWL4IpjckHzpBgwZ$Xb}q)7D5x8&<&ii-aC@_f0)5qz5`bH;8w`8QJI&ujTb z8ry1aU0KO|NAy=Pne<@lWf`^HLN!GdmOrEZKBuAZVtU2jmz4!pA9`zjE%u XA ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = ModCore.Configs.machinesConfig.grinderEnergyConsumption; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + + } + + public Grinder(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) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = ModCore.Configs.machinesConfig.grinderEnergyConsumption; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public Grinder(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) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = ModCore.Configs.machinesConfig.grinderEnergyConsumption; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + if (this.updatesContainerObjectForProduction) + { + if (this.energyRequiredPer10Minutes != ModCore.Configs.machinesConfig.grinderEnergyConsumption) this.energyRequiredPer10Minutes = ModCore.Configs.machinesConfig.grinderEnergyConsumption; + ModCore.log("Update container object for production!"); + + //this.MinutesUntilReady -= minutes; + int remaining = minutes; + //ModCore.log("Minutes elapsed: " + remaining); + List energySources = new List(); + if (this.ConsumesEnergy) + { + //ModCore.log("This machine drains energy: " + this.info.name); + energySources = this.EnergyGraphSearchSources(); //Only grab the network once. + } + + while (remaining > 0) + { + + if (this.ConsumesEnergy) + { + this.drainEnergyFromNetwork(energySources); //Continually drain from the network. + if (this.EnergyManager.remainingEnergy < ModCore.Configs.machinesConfig.grinderEnergyConsumption) return false; + else + { + this.EnergyManager.consumeEnergy(ModCore.Configs.machinesConfig.grinderEnergyConsumption); //Consume the required amount of energy necessary. + } + } + else + { + //ModCore.log("Does not produce energy or consume energy so do whatever!"); + } + remaining -= 10; + this.containerObject.MinutesUntilReady -= 10; + + if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull == false) + { + this.produceItem(); + this.consumeItemForGrinding(); + } + } + + + return false; + } + else + { + + return false; + } + + //return base.minutesElapsed(minutes, environment); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + this.createMachineMenu(); + return true; + } + + public override Item getOne() + { + Grinder component = new Grinder(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, ModCore.Configs.machinesConfig.grinderEnergyConsumption, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.containerObject); + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + Grinder self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + } + + public override void produceItem() + { + if (this.InventoryManager.hasItemsInBuffer) + { + this.InventoryManager.dumpBufferToItems(); + } + } + + protected bool consumeItemForGrinding() + { + + Item itemToRemove = null; + foreach(Item I in this.InventoryManager.items) + { + if(I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.CopperOre, 1))){ + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("CopperSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.IronOre, 1))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("IronSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.GoldOre, 1))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("GoldSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.IridiumOre, 1))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("IridiumSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + + if (I.canStackWith(ModCore.ObjectManager.resources.getOre("BauxiteOre"))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("BauxiteSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(ModCore.ObjectManager.resources.getOre("LeadOre"))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("LeadSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(ModCore.ObjectManager.resources.getOre("SilverOre"))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("SilverSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(ModCore.ObjectManager.resources.getOre("TinOre"))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("TinSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + if (I.canStackWith(ModCore.ObjectManager.resources.getOre("TitaniumOre"))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("TitaniumSand", 2)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + + if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.Stone, 1))) + { + this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("Sand", 1)); + itemToRemove = I; + this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; + break; + } + } + + if (itemToRemove == null) return false; + + if (itemToRemove.Stack > 1) + { + itemToRemove.Stack--; + } + else if (itemToRemove.Stack == 1) + { + this.InventoryManager.items.Remove(itemToRemove); + } + return true; + + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index eef1f22e..c36de75e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -180,8 +180,6 @@ namespace Revitalize.Framework.Objects this.AddItem("TrashCan", trashCan); - - MultiTiledObject sandBox = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); Machine sandBox_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"),new Animation(0,0,16,16)), Color.White, false, new InventoryManager(36), null, null), new List() { @@ -233,7 +231,7 @@ namespace Revitalize.Framework.Objects ///Consumes energy. Produces batteries. MultiTiledObject batteryBin = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes))); - Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List() + Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(Machine), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List() { new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1,1,1,1,1,1,0,0,0,0) @@ -242,22 +240,34 @@ namespace Revitalize.Framework.Objects this.AddItem("BatteryBin", batteryBin); MultiTiledObject capacitor= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Capacitor", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Capacitor", "Omegasis.Revitalize.Objects.Machines.Capacitor", "A box which stores energy for use over time.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Capacitor"), new Animation(0, 0, 16, 16)), Color.White, false,null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage))); - Machine capacitor_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Capacitor", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Capacitor", "Omegasis.Revitalize.Objects.Machines.Capacitor", "A box which stores energy for use over time.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Capacitor"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)),null,0,0,true,""); + Machine capacitor_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Capacitor", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), typeof(Machine), Color.White, true), new BasicItemInformation("Capacitor", "Omegasis.Revitalize.Objects.Machines.Capacitor", "A box which stores energy for use over time.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Capacitor"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Capacitor"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)),null,0,0,true,""); capacitor.addComponent(new Vector2(0, 0), capacitor_0_0); this.AddItem("Capacitor", capacitor); MultiTiledObject chargingStation = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, false,new InventoryManager(4,4,1), null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage))); - ChargingStation chargingStation_0_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, true, ""); - ChargingStation chargingStation_1_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); - ChargingStation chargingStation_0_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); - ChargingStation chargingStation_1_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); + ChargingStation chargingStation_0_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(ChargingStation), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, true, ""); + ChargingStation chargingStation_1_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(ChargingStation), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); + ChargingStation chargingStation_0_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(ChargingStation), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); + ChargingStation chargingStation_1_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(ChargingStation), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, ""); chargingStation.addComponent(new Vector2(0, 0), chargingStation_0_0); chargingStation.addComponent(new Vector2(1, 0), chargingStation_1_0); chargingStation.addComponent(new Vector2(0, 1), chargingStation_0_1); chargingStation.addComponent(new Vector2(1, 1), chargingStation_1_1); this.AddItem("ChargingStation", chargingStation); + + MultiTiledObject grinder= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes))); + Grinder grinder_0_0 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)),null,ModCore.Configs.machinesConfig.grinderEnergyConsumption,ModCore.Configs.machinesConfig.grinderTimeToGrind,true,""); + Grinder grinder_1_0 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); + Grinder grinder_0_1 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); + Grinder grinder_1_1 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); + grinder.addComponent(new Vector2(0, 0), grinder_0_0); + grinder.addComponent(new Vector2(1, 0), grinder_1_0); + grinder.addComponent(new Vector2(0, 1), grinder_0_1); + grinder.addComponent(new Vector2(1, 1), grinder_1_1); + this.AddItem("Grinder", grinder); + } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 33d24cfa..cf67ba45 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -310,11 +310,11 @@ namespace Revitalize.Framework.Objects CustomObject copperSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.CopperSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "CopperSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Copper Sand", "Omegasis.Revitalize.Items.Resources.Ore.CopperSand", "Copper ore which has been crushed into sand. Smelt it to get copper bars.", "Ore", Color.Silver, -300, 0, false, 5, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "CopperSand"), new AnimationManager(), Color.White, true, null, null), 1); CustomObject goldSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.GoldSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "GoldSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Gold Sand", "Omegasis.Revitalize.Items.Resources.Ore.GoldSand", "Gold ore which has been crushed into sand. Smelt it to get gold bars.", "Ore", Color.Silver, -300, 0, false, 25, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "GoldSand"), new AnimationManager(), Color.White, true, null, null), 1); CustomObject ironSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.IronSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IronSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Iron Sand", "Omegasis.Revitalize.Items.Resources.Ore.IronSand", "Iron ore which has been crushed into sand. Smelt it to get iron bars.", "Ore", Color.Silver, -300, 0, false, 10, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IronSand"), new AnimationManager(), Color.White, true, null, null), 1); - CustomObject iridiumSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.IridiumSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IriduiumSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Iridium Sand", "Omegasis.Revitalize.Items.Resources.Ore.IridiumSand", "Iridium ore which has been crushed into sand. Smelt it to get iridium bars.", "Ore", Color.Silver, -300, 0, false, 100, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IridiumSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject iridiumSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.IridiumSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IridiumSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Iridium Sand", "Omegasis.Revitalize.Items.Resources.Ore.IridiumSand", "Iridium ore which has been crushed into sand. Smelt it to get iridium bars.", "Ore", Color.Silver, -300, 0, false, 100, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "IridiumSand"), new AnimationManager(), Color.White, true, null, null), 1); CustomObject leadSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.LeadSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "LeadSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Lead Sand", "Omegasis.Revitalize.Items.Resources.Ore.LeadSand", "Lead ore which has been crushed into sand. Smelt it to get lead ingots.", "Ore", Color.Silver, -300, 0, false, 15, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "LeadSand"), new AnimationManager(), Color.White, true, null, null), 1); CustomObject silverSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.SilverSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SilverSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Silver Sand", "Omegasis.Revitalize.Items.Resources.Ore.SilverSand", "Silver ore which has been crushed into sand. Smelt it to get silver ingots.", "Ore", Color.Silver, -300, 0, false, 20, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "SilverSand"), new AnimationManager(), Color.White, true, null, null), 1); CustomObject tinSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TinSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Tin Sand", "Omegasis.Revitalize.Items.Resources.Ore.TinSand", "Tin ore which has been crushed into sand. Smelt it to get tin ingots.", "Ore", Color.Silver, -300, 0, false, 7, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinSand"), new AnimationManager(), Color.White, true, null, null), 1); - CustomObject titaniumSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TitaniumSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitniumSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Copper Sand", "Omegasis.Revitalize.Items.Resources.Ore.TitaniumSand", "Titanium ore which has been crushed into sand. Smelt it to get titanium bars.", "Ore", Color.Silver, -300, 0, false, 35, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumSand"), new AnimationManager(), Color.White, true, null, null), 1); + CustomObject titaniumSand = new CustomObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TitaniumSand", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumSand"), typeof(CustomObject), Color.White, true), new BasicItemInformation("Copper Sand", "Omegasis.Revitalize.Items.Resources.Ore.TitaniumSand", "Titanium ore which has been crushed into sand. Smelt it to get titanium bars.", "Ore", Color.Silver, -300, 0, false, 35, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TitaniumSand"), new AnimationManager(), Color.White, true, null, null), 1); this.resources.Add("BauxiteSand", bauxiteSand); this.resources.Add("CopperSand", copperSand); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 0628973e..78ab90eb 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -569,7 +569,9 @@ namespace Revitalize ModCore.ObjectManager.GetItem("CopperWire",10), batteryBin, ModCore.ObjectManager.GetItem("Capacitor",1), - ModCore.ObjectManager.GetItem("ChargingStation",1) + ModCore.ObjectManager.GetItem("ChargingStation",1), + ModCore.ObjectManager.GetItem("Grinder",1), + new StardewValley.Object((int)Enums.SDVObject.CopperOre,10) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index a55ab562..37347172 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -161,6 +161,7 @@ + @@ -464,6 +465,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 259f3864717ebb2d7d2f29ef4bcf63f4785c7cb4 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 14:39:16 -0700 Subject: [PATCH 65/98] 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 From d37606844b2974bce81eb6c08dfe543a62be7e59 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 14:42:49 -0700 Subject: [PATCH 66/98] Adjusted drill power rate to be 1+upgrade level for more balance. --- .../Objects/Items/Tools/MiningDrill.cs | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs index a473e386..bda29488 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -90,24 +90,6 @@ namespace Revitalize.Framework.Objects.Items.Tools { 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; @@ -165,7 +147,7 @@ namespace Revitalize.Framework.Objects.Items.Tools 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) + if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) { this.hadEnoughEnergy = true; } @@ -179,7 +161,7 @@ namespace Revitalize.Framework.Objects.Items.Tools 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)); + this.EnergyManager.consumeEnergy(this.getEnergyConsumptionRate()); Utility.clampToTile(new Vector2((float)x, (float)y)); int num1 = x / 64; @@ -400,5 +382,9 @@ namespace Revitalize.Framework.Objects.Items.Tools } + private int getEnergyConsumptionRate() + { + return this.UpgradeLevel + 1; + } } } From 885436c2b28fe64d4928ef2eba330bcdfbfcc86a Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 15:59:40 -0700 Subject: [PATCH 67/98] Couldn't figure out dagger animation for drill. Instead settled for regular pickaxe animation which is odd looking but works. --- .../Framework/Objects/Items/Tools/MiningDrill.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs index bda29488..61e52b93 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -88,7 +88,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override void endUsing(GameLocation location, Farmer who) { - if (this.hadEnoughEnergy == false) + if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == false) { Game1.toolAnimationDone(who); who.canReleaseTool = false; @@ -162,6 +162,16 @@ namespace Revitalize.Framework.Objects.Items.Tools //who.Stamina -= (float)(2 * (power + 1)) - (float)who.MiningLevel * 0.1f; //Drain energy here; this.EnergyManager.consumeEnergy(this.getEnergyConsumptionRate()); + //Double check to prevent animation from happening with even no power + if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) + { + this.hadEnoughEnergy = true; + } + else + { + this.hadEnoughEnergy = false; + } + Utility.clampToTile(new Vector2((float)x, (float)y)); int num1 = x / 64; From f0cd3ec80ebb7d9f893ac55edb57496f533f785d Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 16:57:23 -0700 Subject: [PATCH 68/98] Added in the chainsaw which chops trees using electricity. --- .../Graphics/Items/Tools/ChainSawWorking.png | Bin 0 -> 792 bytes .../Content/Graphics/Items/Tools/Chainsaw.png | Bin 0 -> 295 bytes .../Objects/Items/Tools/AxeExtended.cs | 4 +- .../Framework/Objects/Items/Tools/Chainsaw.cs | 253 ++++++++++++++++++ .../Objects/Items/Tools/MiningDrill.cs | 13 +- .../Framework/Objects/ObjectManager.cs | 3 +- GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 7 + 8 files changed, 268 insertions(+), 15 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/ChainSawWorking.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Items/Tools/Chainsaw.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Items/Tools/ChainSawWorking.png b/GeneralMods/Revitalize/Content/Graphics/Items/Tools/ChainSawWorking.png new file mode 100644 index 0000000000000000000000000000000000000000..1d84809b06b2373875a5c91ab4ec15aa52affc03 GIT binary patch literal 792 zcmV+z1LypSP)Px%(n&-?RA_NjqOA$yTND2w0 z30#rRK32)Xev4qV2#Q4(1T8XHh}hU2d&N4-y1TP4>c!)3elUzX?mYAC|9R#O5C{YU zfj}S-2m}IwKp+qZ1pf;X?+=X-%iCtE3IJd*9C7>ogIEaB=}SHiN&x^0vJ3#| zP>R8DB$Z1=pRha|-nIh;AXI>;zV&(??RJ}M;}frEL6%XFWxTCciAQAtI7y{YBLp=< z030N9t$Mu<*diwGdvkq@*=&ZJ>szi3u7HefMcgF-dm@$qyuOu6WusyJ?6biYu-flC zzu7e2hBzXYOGV3DwjR(Xwg4O?!!R})*3Z5f6u1WJluFf1W@9i@RZvzHEABL`_WO7` zJ_cZm*jp|`-}l-rmx^pGw*GkQFeJk;tZ!exI}JPmI0Od3Fbv<=+ziwy#nIV0ex07; z=p&-lXP>LTHS5OrdER)=Iv(*Um<=`0@I|5-2sEP^z zP5=;*0Zcr`cxvM1^*OLa?5=ys!1-bh0GKc4+hw5Ffdm0iOX(x?O05K&RCA?jOxSH%T&podAB`-{Ix;8O>J1SBLqs z-pOqNx?M~jAE2$5h$z@Pou4n9Gi;3zJiWgMUJiHye%K-m*qcsoxpX$1Y9<4nQpsh< zSMvr=DnJBGP^VOK7q>5*I+8d7gc0Wq8+H?snym)X>2&0j3F^CJ0QSN@ zZbHlk&rX~V+Q(%)?pQm+rm#kcPx#;Ymb6R5*>Lkv)n6K@f#Me?aKOxG;7Y{K3E#G}tpVOt=T~C<=nY+(OjA4HgzJ zFpH&uCo(QE!$1GUyN8jSh*-7;USsJ;q!;}JkVrd`^Ne|6zbcL{(L%ajc1mCL(IBRs8#3 zdhv_dU-uI~54`AlTYrD2w3tggn1F3;KJc_DnWf~(7bPJcj+ahqaAyh#86002ovPDHLkV1k+`eHj1% 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 42f997f7..ec68f1a9 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs @@ -247,12 +247,12 @@ namespace Revitalize.Framework.Objects.Items.Tools return new AxeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); } - public object getReplacement() + public virtual object getReplacement() { return new StardewValley.Tools.Axe { 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 Axe).UpgradeLevel; diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs new file mode 100644 index 00000000..796657fa --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs @@ -0,0 +1,253 @@ +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 Newtonsoft.Json; +using Revitalize.Framework.Energy; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardewValley.Tools; +using StardustCore.UIUtilities; +using xTile.ObjectModel; + +namespace Revitalize.Framework.Objects.Items.Tools +{ + public class Chainsaw:AxeExtended,IEnergyInterface + { + + private Texture2D energyTexture; + [JsonIgnore] + public EnergyManager EnergyManager + { + get => this.info.EnergyManager; + set + { + this.info.EnergyManager = value; + this.info.requiresUpdate = true; + } + } + public Chainsaw() + { + + } + + public Chainsaw(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); + } + 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); + } + + public override bool beginUsing(GameLocation location, int x, int y, Farmer who) + { + this.updateInfo(); + Revitalize.Framework.Hacks.ColorChanger.SwapAxeTextures(this.workingTexture.texture); + this.Update(who.FacingDirection, 0, who); + who.EndUsingTool(); + return true; + } + public override void endUsing(GameLocation location, Farmer who) + { + if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == false) + { + 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 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) + { + if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) + { + } + else + { + Game1.showRedMessage("Out of energy!"); + return; + } + //base.DoFunction(location, x, y, power, who); + //who.Stamina -= (float)(2 * power) - (float)who.ForagingLevel * 0.1f; + this.baseDoFunction(location, x, y, power, who); + this.EnergyManager.consumeEnergy(this.getEnergyConsumptionRate()); + + int tileX = x / 64; + int tileY = y / 64; + Rectangle rectangle = new Rectangle(tileX * 64, tileY * 64, 64, 64); + Vector2 index1 = new Vector2((float)tileX, (float)tileY); + if (location.Map.GetLayer("Buildings").Tiles[tileX, tileY] != null) + { + PropertyValue propertyValue = (PropertyValue)null; + location.Map.GetLayer("Buildings").Tiles[tileX, tileY].TileIndexProperties.TryGetValue("TreeStump", out propertyValue); + if (propertyValue != null) + { + Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Axe.cs.14023")); + return; + } + } + location.performToolAction((Tool)this, tileX, tileY); + if (location.terrainFeatures.ContainsKey(index1) && location.terrainFeatures[index1].performToolAction((Tool)this, 0, index1, location)) + location.terrainFeatures.Remove(index1); + Rectangle boundingBox; + if (location.largeTerrainFeatures != null) + { + for (int index2 = location.largeTerrainFeatures.Count - 1; index2 >= 0; --index2) + { + boundingBox = location.largeTerrainFeatures[index2].getBoundingBox(); + if (boundingBox.Intersects(rectangle) && location.largeTerrainFeatures[index2].performToolAction((Tool)this, 0, index1, location)) + location.largeTerrainFeatures.RemoveAt(index2); + } + } + Vector2 index3 = new Vector2((float)tileX, (float)tileY); + if (!location.Objects.ContainsKey(index3) || location.Objects[index3].Type == null || !location.Objects[index3].performToolAction((Tool)this, location)) + return; + if (location.Objects[index3].Type.Equals((object)"Crafting") && location.Objects[index3].Fragility != 2) + { + NetCollection debris1 = location.debris; + int objectIndex = location.Objects[index3].bigCraftable.Value ? -location.Objects[index3].ParentSheetIndex : location.Objects[index3].ParentSheetIndex; + Vector2 toolLocation = who.GetToolLocation(false); + 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); + } + location.Objects[index3].performRemoveAction(index3, location); + location.Objects.Remove(index3); + } + + public override void actionWhenStopBeingHeld(Farmer who) + { + Revitalize.Framework.Hacks.ColorChanger.ResetAxeTexture(); + 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 Chainsaw(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); + } + + public override object getReplacement() + { + return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel }; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel; + } + + private int getEnergyConsumptionRate() + { + return this.UpgradeLevel + 1; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs index 61e52b93..4399efcb 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Netcode; +using Newtonsoft.Json; using Revitalize.Framework.Energy; using Revitalize.Framework.Utilities; using StardewValley; @@ -20,8 +21,8 @@ namespace Revitalize.Framework.Objects.Items.Tools private int boulderTileY; private int hitsToBoulder; private Texture2D energyTexture; - private bool hadEnoughEnergy; + [JsonIgnore] public EnergyManager EnergyManager { get => this.info.EnergyManager; @@ -149,11 +150,9 @@ namespace Revitalize.Framework.Objects.Items.Tools //base.DoFunction(location, x, y, power, who); if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) { - this.hadEnoughEnergy = true; } else { - this.hadEnoughEnergy = false; Game1.showRedMessage("Out of energy!"); return; } @@ -163,14 +162,6 @@ namespace Revitalize.Framework.Objects.Items.Tools //Drain energy here; this.EnergyManager.consumeEnergy(this.getEnergyConsumptionRate()); //Double check to prevent animation from happening with even no power - if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) - { - this.hadEnoughEnergy = true; - } - else - { - this.hadEnoughEnergy = false; - } Utility.clampToTile(new Vector2((float)x, (float)y)); diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 7725d39c..a6ed3818 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -297,7 +297,7 @@ namespace Revitalize.Framework.Objects 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")); - + Chainsaw chainsawV1 = new Chainsaw(new BasicItemInformation("Simple Chainsaw", "Omegasis.Revitalize.Items.Tools.ChainsawV1", "A chainsaw used to fell trees and chop wood. Consumes energy instead of stamina.", "Tool", Color.SlateGray, 0, 0, false, 1000, false, false, TextureManager.GetTexture(ModCore.Manifest, "Tools", "Chainsaw"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "Chainsaw"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(200, Enums.EnergyInteractionType.Consumes)), 2, TextureManager.GetExtendedTexture(ModCore.Manifest, "Tools", "ChainsawWorking")); this.Tools.Add("BronzePickaxe", bronzePick); this.Tools.Add("HardenedPickaxe", steelPick); @@ -316,6 +316,7 @@ namespace Revitalize.Framework.Objects this.Tools.Add("TitaniumWateringCan", titaniumCan); this.Tools.Add("MiningDrillV1", miningDrillV1); + this.Tools.Add("ChainsawV1", chainsawV1); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 8349c541..a01cf47f 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -572,7 +572,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("ChargingStation",1), ModCore.ObjectManager.GetItem("Grinder",1), new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), - ModCore.ObjectManager.GetTool("MiningDrillV1") + ModCore.ObjectManager.GetTool("MiningDrillV1"), + ModCore.ObjectManager.GetTool("ChainsawV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 1d21d711..28c0b0d9 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -156,6 +156,7 @@ + @@ -320,6 +321,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest From 3ca7468fb9a35cf58fae839119169e1d6ea04a33 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 17:07:02 -0700 Subject: [PATCH 69/98] Robin now sells sand and clay. --- GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs index cb5e5652..a9066187 100644 --- a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs +++ b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs @@ -23,6 +23,8 @@ namespace Revitalize.Framework.Hacks private static void AddItemsToRobinsShop() { PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.GetItem("Workbench", 1), 500), "Robin"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(new StardewValley.Object((int)Enums.SDVObject.Clay,1),50), "Robin"); + PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getResource("Sand", 1), 25), "Robin"); } /// /// Adds in ore to clint's shop. From 1c6e04929cf58f50e43fa9bae85be578d53ba80c Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 21 Sep 2019 18:48:21 -0700 Subject: [PATCH 70/98] Added in the mining drill. --- .../Objects/Machines/MiningDrillMachine.png | Bin 0 -> 829 bytes .../Framework/Configs/ConfigManager.cs | 3 + .../Framework/Configs/GlobalMachineConfig.cs | 5 + .../Framework/Configs/MiningDrillConfig.cs | 106 ++++++++++++++++++ .../Framework/Objects/CustomObject.cs | 10 ++ .../Framework/Objects/Machines/Machine.cs | 9 ++ .../Objects/Machines/WireMultiTiledObject.cs | 4 +- .../Framework/Objects/MultiTiledObject.cs | 2 +- .../Framework/Objects/ObjectManager.cs | 28 +++++ .../Framework/Objects/ResourceManager.cs | 26 ++++- GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + .../Animations/AnimationManager.cs | 29 +++-- 13 files changed, 214 insertions(+), 15 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/MiningDrillMachine.png create mode 100644 GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/MiningDrillMachine.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/MiningDrillMachine.png new file mode 100644 index 0000000000000000000000000000000000000000..62d79960b498f4ced24961519f11f8e6519f61ab GIT binary patch literal 829 zcmV-D1H$}?P)Px%_en%SRA_8625wg;mIYg^;N?6|w#+3a>USps>df&J#a zeQ&;*2^$U$;^vKOZ7X%zBEcwX zabVNJar2ht&R54)jH0&v2B8Z-kmxTQ}$1MC{m!*0D>`qTgh#Q>|m zV;!Ks!_Dfg+yed5H@pSx5U8OXV#;Z41S_{dKlKf7fr}W>A7V{U2IHs80D!n$!EP`K zz}hX)PyG=!fttAK$&hheu8^^nQ@H8LU@Re^>B%52SCEc0G#o~7OP^a@m?f>Z-S#3m zmm&ne-b+Z;?;{;)V67IyZZL_;)?3VQCx&F(Z7=TJzKfb%HCzGZr>xohe(R6UM=w8} zj`|Std-3txAIvAN8LrtJyr`jSfpp4ZksfK>#)N|a_ zCx@UyFv9_*_0@9(O6%-Y|EI1;_RTx8H>ZS2&8c4A*yPHcv3lFNt*^NSSPbZq%NHPu zB4WZ7Jb&@5TX|3PA3u76FVY^0#UizCg!UkpFQ9dNhAR00000NkvXX Hu0mjfaI public GlobalMachineConfig machinesConfig; + public MiningDrillConfig miningDrillConfig; + public ConfigManager() { this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); @@ -32,6 +34,7 @@ namespace Revitalize.Framework.Configs this.furnitureConfig = FurnitureConfig.InitializeConfig(); this.machinesConfig = GlobalMachineConfig.InitializeConfig(); this.objectsConfig = ObjectsConfig.InitializeConfig(); + this.miningDrillConfig = MiningDrillConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs index ffeedb80..b0b799bc 100644 --- a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs @@ -19,6 +19,9 @@ namespace Revitalize.Framework.Configs public int grinderEnergyConsumption; public int grinderTimeToGrind; + public int miningDrillEnergyConsumption; + public int miningDrillTimeToMine; + public GlobalMachineConfig() { this.doMachinesConsumeEnergy = true; @@ -28,6 +31,8 @@ namespace Revitalize.Framework.Configs this.machineNotificationBubbleAlpha = 0.75f; this.grinderEnergyConsumption = 20; this.grinderTimeToGrind = 30; + this.miningDrillEnergyConsumption = 50; + this.miningDrillTimeToMine = 60; } public static GlobalMachineConfig InitializeConfig() diff --git a/GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs b/GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs new file mode 100644 index 00000000..296e3e99 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Configs +{ + public class MiningDrillConfig + { + + public double bauxiteMineChance; + public double tinMineChance; + public double leadMineChance; + public double silverMineChance; + public double titaniumMineChance; + public double prismaticNuggetMineChance; + public double copperMineChance; + public double ironMineChance; + public double goldMineChance; + public double iridiumMineChance; + public double stoneMineChance; + public double clayMineChance; + public double sandMineChance; + public double geodeMineChance; + public double frozenGeodeMineChance; + public double magmaGeodeMineChance; + public double omniGeodeMineChance; + //If requested put in all gems/minerals here. Otherwise hope that geodes do the trick. + + + public IntRange amountOfBauxiteToMine; + public IntRange amountOfTinToMine; + public IntRange amountOfLeadToMine; + public IntRange amountOfSilverToMine; + public IntRange amountOfTitaniumToMine; + public IntRange amountOfPrismaticNuggetsToMine; + public IntRange amountOfCopperToMine; + public IntRange amountOfIronToMine; + public IntRange amountOfGoldToMine; + public IntRange amountOfIridiumToMine; + public IntRange amountOfStoneToMine; + public IntRange amountOfClayToMine; + public IntRange amountOfSandToMine; + public IntRange amountOfGeodesToMine; + public IntRange amountOfFrozenGeodesToMine; + public IntRange amountOfMagmaGeodesToMine; + public IntRange amountOfOmniGeodesToMine; + + public MiningDrillConfig() + { + this.bauxiteMineChance = 0.25f; + this.tinMineChance = 0.3f; + this.leadMineChance = 0.15f; + this.silverMineChance = 0.10f; + this.titaniumMineChance = 0.05f; + this.prismaticNuggetMineChance = 0.005f; + this.copperMineChance = 0.35f; + this.ironMineChance = 0.20f; + this.goldMineChance = 0.10f; + this.iridiumMineChance = 0.005f; + this.stoneMineChance = 1.0f; + this.clayMineChance = 0.30f; + this.sandMineChance = 0.20f; + this.geodeMineChance = 0.25f; + this.frozenGeodeMineChance = 0.15f; + this.magmaGeodeMineChance = 0.05f; + this.omniGeodeMineChance = 0.01f; + + this.amountOfBauxiteToMine = new IntRange(1, 3); + this.amountOfClayToMine = new IntRange(1, 3); + this.amountOfCopperToMine = new IntRange(1, 3); + this.amountOfFrozenGeodesToMine = new IntRange(1, 1); + this.amountOfGeodesToMine = new IntRange(1, 1); + this.amountOfGoldToMine = new IntRange(1, 3); + this.amountOfIronToMine = new IntRange(1, 3); + this.amountOfIridiumToMine = new IntRange(1, 3); + this.amountOfLeadToMine = new IntRange(1, 3); + this.amountOfMagmaGeodesToMine = new IntRange(1, 1); + this.amountOfOmniGeodesToMine = new IntRange(1, 1); + this.amountOfPrismaticNuggetsToMine = new IntRange(1, 1); + this.amountOfSandToMine = new IntRange(1, 2); + this.amountOfSilverToMine = new IntRange(1, 3); + this.amountOfStoneToMine = new IntRange(1, 5); + this.amountOfTinToMine = new IntRange(1, 3); + this.amountOfTitaniumToMine = new IntRange(1, 3); + } + + + public static MiningDrillConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "MiningDrillMachine.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "MiningDrillMachine.json")); + else + { + MiningDrillConfig Config = new MiningDrillConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "MiningDrillMachine.json"), Config); + return Config; + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 945d7d6f..6ace0224 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -131,6 +131,11 @@ namespace Revitalize.Framework.Objects { get { + if (this.info == null) + { + this.updateInfo(); + } + //ModCore.log("Location Name is: " + this.info.locationName); if (this._location == null) { @@ -764,6 +769,11 @@ namespace Revitalize.Framework.Objects public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { + if (this.info == null) + { + this.updateInfo(); + } + if (this.location == null) { this.location = environment; diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index e0f0d739..552a7110 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -216,12 +216,21 @@ namespace Revitalize.Framework.Objects.Machines public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { + + base.updateWhenCurrentLocation(time, environment); } public override bool minutesElapsed(int minutes, GameLocation environment) { + if (this.info == null) + { + this.updateInfo(); + } + + ModCore.log(this.info.animationManager.currentAnimationName); + if (this.updatesContainerObjectForProduction) { //ModCore.log("Update container object for production!"); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs index e39f6ab7..2905a779 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs @@ -92,8 +92,8 @@ namespace Revitalize.Framework.Objects.Machines public override Dictionary getAdditionalSaveData() { Dictionary saveData = base.getAdditionalSaveData(); - saveData.Add("GUID", this.guid.ToString()); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + //saveData.Add("GUID", this.guid.ToString()); + //Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return saveData; } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 0c0a7e3c..1bcf6898 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -451,7 +451,7 @@ namespace Revitalize.Framework.Objects { Dictionary saveData = base.getAdditionalSaveData(); saveData.Add("GUID", this.guid.ToString()); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + //Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return saveData; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index a6ed3818..c4ca919b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -268,6 +268,34 @@ namespace Revitalize.Framework.Objects grinder.addComponent(new Vector2(1, 1), grinder_1_1); this.AddItem("Grinder", grinder); + MultiTiledObject miningDrillMachine = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes))); + Machine miningDrillMachine_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16), new Dictionary>() { + {"Default",new List(){new Animation(0,0,16,16) } }, + { "Mining",new List(){ + new Animation(0,0,16,16,30), + new Animation(16,0,16,16,30), + new Animation(32,0,16,16,30), + new Animation(48,0,16,16,30), + } } + }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, true, ""); + + Machine miningDrillMachine_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 16, 16, 16),new Dictionary>() { + {"Default",new List(){new Animation(0,16,16,16) } }, + { "Mining",new List(){ + new Animation(0,16,16,16,30), + new Animation(16,16,16,16,30), + new Animation(32,16,16,16,30), + new Animation(48,16,16,16,30), + } } + }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, false, ""); + miningDrillMachine.addComponent(new Vector2(0, 0), miningDrillMachine_0_0); + miningDrillMachine.addComponent(new Vector2(0, 1), miningDrillMachine_0_1); + miningDrillMachine_0_0.animationManager.setAnimation("Mining"); + miningDrillMachine_0_0.animationManager.playAnimation("Mining"); + miningDrillMachine_0_1.animationManager.setAnimation("Mining"); + miningDrillMachine_0_1.animationManager.playAnimation("Mining"); + this.AddItem("MiningDrillMachineV1",miningDrillMachine); + } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index cf67ba45..9df39c04 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -32,6 +32,8 @@ namespace Revitalize.Framework.Objects public Dictionary ores; public Dictionary resources; + public Dictionary miningDrillResources; + /// /// A list of all visited floors on the current visit to the mines. /// @@ -48,7 +50,7 @@ namespace Revitalize.Framework.Objects this.ores = new Dictionary(); this.visitedFloors = new List(); this.resources = new Dictionary(); - + this.miningDrillResources = new Dictionary(); } @@ -59,6 +61,28 @@ namespace Revitalize.Framework.Objects this.loadInResourceItems(); this.serializeOreVeins(); this.loadOreVeins(); + this.loadInMiningDrillLootTable(); + } + + private void loadInMiningDrillLootTable() + { + this.miningDrillResources.Add("Bauxite", new ResourceInformation(this.getResource("Bauxite"), ModCore.Configs.miningDrillConfig.amountOfBauxiteToMine.min, ModCore.Configs.miningDrillConfig.amountOfBauxiteToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.bauxiteMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Tin", new ResourceInformation(this.getResource("Tin"), ModCore.Configs.miningDrillConfig.amountOfTinToMine.min, ModCore.Configs.miningDrillConfig.amountOfTinToMine.max, 1, 1,1,ModCore.Configs.miningDrillConfig.tinMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Lead", new ResourceInformation(this.getResource("Lead"), ModCore.Configs.miningDrillConfig.amountOfLeadToMine.min, ModCore.Configs.miningDrillConfig.amountOfLeadToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.leadMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Silver", new ResourceInformation(this.getResource("Silver"), ModCore.Configs.miningDrillConfig.amountOfSilverToMine.min, ModCore.Configs.miningDrillConfig.amountOfSilverToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.silverMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Titanium", new ResourceInformation(this.getResource("Titanium"), ModCore.Configs.miningDrillConfig.amountOfTitaniumToMine.min, ModCore.Configs.miningDrillConfig.amountOfTitaniumToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.titaniumMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Prismatic", new ResourceInformation(this.getResource("PrismaticNugget"), ModCore.Configs.miningDrillConfig.amountOfPrismaticNuggetsToMine.min, ModCore.Configs.miningDrillConfig.amountOfPrismaticNuggetsToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.prismaticNuggetMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Copper", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.CopperOre, 1), ModCore.Configs.miningDrillConfig.amountOfCopperToMine.min, ModCore.Configs.miningDrillConfig.amountOfCopperToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.copperMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Iron", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.IronOre, 1), ModCore.Configs.miningDrillConfig.amountOfIronToMine.min, ModCore.Configs.miningDrillConfig.amountOfIronToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.ironMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Gold", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.GoldOre, 1), ModCore.Configs.miningDrillConfig.amountOfGoldToMine.min, ModCore.Configs.miningDrillConfig.amountOfGoldToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.goldMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Iridium", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.IridiumOre,1), ModCore.Configs.miningDrillConfig.amountOfIridiumToMine.min, ModCore.Configs.miningDrillConfig.amountOfIridiumToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.iridiumMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Stone", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Stone, 1), ModCore.Configs.miningDrillConfig.amountOfStoneToMine.min, ModCore.Configs.miningDrillConfig.amountOfStoneToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.stoneMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Clay", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay, 1), ModCore.Configs.miningDrillConfig.amountOfClayToMine.min, ModCore.Configs.miningDrillConfig.amountOfClayToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.clayMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Sand", new ResourceInformation(this.getResource("Sand"), ModCore.Configs.miningDrillConfig.amountOfSandToMine.min, ModCore.Configs.miningDrillConfig.amountOfSandToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.sandMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Geode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Geode,1), ModCore.Configs.miningDrillConfig.amountOfGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.geodeMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("FrozenGeode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.FrozenGeode, 1), ModCore.Configs.miningDrillConfig.amountOfFrozenGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfFrozenGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.frozenGeodeMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("MagmaGeode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.MagmaGeode, 1), ModCore.Configs.miningDrillConfig.amountOfMagmaGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfMagmaGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.magmaGeodeMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("OmniGeode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.OmniGeode, 1), ModCore.Configs.miningDrillConfig.amountOfOmniGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfOmniGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.omniGeodeMineChance, 0, 0, 0, 0)); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index a01cf47f..a43138bc 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -573,7 +573,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("Grinder",1), new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), ModCore.ObjectManager.GetTool("MiningDrillV1"), - ModCore.ObjectManager.GetTool("ChainsawV1") + ModCore.ObjectManager.GetTool("ChainsawV1"), + ModCore.ObjectManager.GetItem("MiningDrillMachineV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 28c0b0d9..a5dffd19 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -56,6 +56,7 @@ + @@ -483,6 +484,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index 4e53cfec..4c222d11 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -84,7 +84,11 @@ namespace StardustCore.Animations this.animations = animationString; if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + { this.setAnimation(startingAnimationKey, startingAnimationFrame); + this.playAnimation(startingAnimationKey, true, startingAnimationFrame); + } + else { this.currentAnimation = this.defaultDrawFrame; @@ -100,9 +104,9 @@ namespace StardustCore.Animations if (this.currentAnimation.frameDuration == -1 || !this.enabled || this.currentAnimation == this.defaultDrawFrame) return; //This is if this is a default animation or the animation stops here. if (this.currentAnimation.frameCountUntilNextAnimation == 0) - this.getNextAnimation(); + this.getNextAnimationFrame(); this.currentAnimation.tickAnimationFrame(); - this.requiresUpdate = true; + //this.requiresUpdate = true; } catch (Exception err) { @@ -112,25 +116,30 @@ namespace StardustCore.Animations } /// Get the next animation frame in the list of animations. - private void getNextAnimation() + private void getNextAnimationFrame() { this.currentAnimationListIndex++; - if (this.currentAnimationListIndex == this.currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. + if (this.currentAnimationListIndex == this.currentAnimationList.Count) + { //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. if (this.loopAnimation) { this.currentAnimationListIndex = 0; + this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; + this.currentAnimation.startAnimation(); + return; } else { - this.requiresUpdate = true; + //this.requiresUpdate = true; this.playDefaultAnimation(); return; } + } //Get the next animation from the list and reset it's counter to the starting frame value. this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; this.currentAnimation.startAnimation(); - this.requiresUpdate = true; + //this.requiresUpdate = true; } /// Gets the animation from the dictionary of all animations available. @@ -171,7 +180,7 @@ namespace StardustCore.Animations /// /// /// - public bool playAnimation(string AnimationName,bool overrideSameAnimation=false,int StartingFrame = 0) + public bool playAnimation(string AnimationName, bool overrideSameAnimation = false, int StartingFrame = 0) { if (this.animations.TryGetValue(AnimationName, out List dummyList)) { @@ -379,7 +388,7 @@ namespace StardustCore.Animations /// /// /// - public void draw(SpriteBatch b,Vector2 Position,Color drawColor,float scale,SpriteEffects flipped,float depth) + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale, SpriteEffects flipped, float depth) { b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, 0f, Vector2.Zero, scale, flipped, depth); try @@ -393,7 +402,7 @@ namespace StardustCore.Animations } } - public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale,float Rotation ,SpriteEffects flipped, float depth) + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale, float Rotation, SpriteEffects flipped, float depth) { b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, Rotation, Vector2.Zero, scale, flipped, depth); try @@ -430,7 +439,7 @@ namespace StardustCore.Animations } } - public void draw(SpriteBatch b, Vector2 Position, Color drawColor, Vector2 scale, float Rotation,SpriteEffects flipped, float depth) + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, Vector2 scale, float Rotation, SpriteEffects flipped, float depth) { b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, Rotation, Vector2.Zero, scale, flipped, depth); try From 0d373b5d8348d30632320f109e11c989b7fb431c Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 00:18:48 -0700 Subject: [PATCH 71/98] Probably going to quit. Multiplayer can't sync inventories effectively so what's the point? --- .../Framework/Energy/EnergyManager.cs | 18 +-- .../Framework/Energy/IEnergyInterface.cs | 9 +- .../Menus/CraftingInformationPage.cs | 12 +- .../Menus/Machines/MachineSummaryMenu.cs | 2 +- .../Framework/Objects/BasicItemInformation.cs | 55 ++++--- .../Framework/Objects/CustomObject.cs | 86 ++++++----- .../Framework/Objects/Items/Tools/Chainsaw.cs | 10 ++ .../Objects/Items/Tools/MiningDrill.cs | 33 ++-- .../Objects/Machines/ChargingStation.cs | 11 +- .../Machines/EnergyGeneration/SolarPanel.cs | 9 +- .../Framework/Objects/Machines/Grinder.cs | 41 ++--- .../Framework/Objects/Machines/Machine.cs | 141 ++++++++++++------ .../Framework/Objects/Machines/Wire.cs | 1 + .../Framework/Objects/MultiTiledComponent.cs | 122 +++++++-------- .../Framework/Objects/ObjectManager.cs | 2 +- .../Framework/Utilities/MachineUtilities.cs | 48 ++++++ GeneralMods/Revitalize/ModCore.cs | 2 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + .../Animations/AnimationManager.cs | 13 ++ 19 files changed, 366 insertions(+), 250 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Utilities/MachineUtilities.cs diff --git a/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs b/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs index d4c935c5..2877a24d 100644 --- a/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs +++ b/GeneralMods/Revitalize/Framework/Energy/EnergyManager.cs @@ -122,7 +122,7 @@ namespace Revitalize.Framework.Energy } - public EnergyManager(int Capacity,Enums.EnergyInteractionType EnergyType) : this(0, Capacity,EnergyType) + public EnergyManager(int Capacity, Enums.EnergyInteractionType EnergyType) : this(0, Capacity, EnergyType) { } @@ -149,27 +149,21 @@ namespace Revitalize.Framework.Energy { int amountBeforeConsumption = this.remainingEnergy; this.remainingEnergy = Math.Max(0, this.remainingEnergy - amount); - if (this.remainingEnergy != amountBeforeConsumption) - { - this.requiresUpdate = true; - } + this.requiresUpdate = true; } public void produceEnergy(int amount) { int amountBeforeProduction = this.remainingEnergy; this.remainingEnergy = Math.Min(this.maxEnergy, this.remainingEnergy + amount); - if (this.remainingEnergy != amountBeforeProduction) - { - this.requiresUpdate = true; - } + this.requiresUpdate = true; } - public void transferEnergyFromAnother(EnergyManager other,int amount) + public void transferEnergyFromAnother(EnergyManager other, int amount) { if (this.canReceieveEnergy) { - int actualAmount = Math.Min(amount,other.remainingEnergy); + int actualAmount = Math.Min(amount, other.remainingEnergy); int selfCapacity = this.capacityRemaining; this.produceEnergy(Math.Min(actualAmount, selfCapacity)); other.consumeEnergy(Math.Min(actualAmount, selfCapacity)); @@ -197,7 +191,7 @@ namespace Revitalize.Framework.Energy public EnergyManager Copy() { - return new EnergyManager(this.maxEnergy,this.energyInteractionType); + return new EnergyManager(this.maxEnergy, this.energyInteractionType); } } diff --git a/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs b/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs index 86fc4322..bc7861a3 100644 --- a/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs +++ b/GeneralMods/Revitalize/Framework/Energy/IEnergyInterface.cs @@ -8,12 +8,7 @@ namespace Revitalize.Framework.Energy { public interface IEnergyInterface { - EnergyManager EnergyManager - { - get; - set; - } - - + ref EnergyManager GetEnergyManager(); + void SetEnergyManager(ref EnergyManager Manager); } } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 7fad536c..248d74f9 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -110,7 +110,7 @@ namespace Revitalize.Framework.Menus { if (this.infoButton.recipe.timeToCraft == 0) { - this.machine.InventoryManager.dumpBufferToItems(); + this.machine.GetInventoryManager().dumpBufferToItems(); } else { @@ -145,12 +145,12 @@ namespace Revitalize.Framework.Menus this.hoverText = "Crafting in progress..."; hovered = true; } - if (this.machine.MinutesUntilReady == 0 && this.machine.InventoryManager.hasItemsInBuffer) + if (this.machine.MinutesUntilReady == 0 && this.machine.GetInventoryManager().hasItemsInBuffer) { - this.hoverText = "Items in buffer. Please make room in the inventory for: " + System.Environment.NewLine + this.machine.InventoryManager + " items."; + this.hoverText = "Items in buffer. Please make room in the inventory for: " + System.Environment.NewLine + this.machine.GetInventoryManager() + " items."; hovered = true; } - if (this.machine.InventoryManager.IsFull) + if (this.machine.GetInventoryManager().IsFull) { this.hoverText = "Inventory is full!"; hovered = true; @@ -196,8 +196,8 @@ namespace Revitalize.Framework.Menus if (this.machine != null) { - if (this.machine.InventoryManager.hasItemsInBuffer) canCraft = false; - if (this.machine.InventoryManager.IsFull) canCraft = false; + if (this.machine.GetInventoryManager().hasItemsInBuffer) canCraft = false; + if (this.machine.GetInventoryManager().IsFull) canCraft = false; } return canCraft; diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 623fc1bd..d812cff6 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -57,7 +57,7 @@ namespace Revitalize.Framework.Menus.Machines { get { - return this.objectSource.EnergyManager; + return this.objectSource.GetEnergyManager(); } } diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index bfe9882f..3f3609ae 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -259,19 +259,7 @@ namespace Revitalize.Framework.Objects } } - private InventoryManager _inventory; - public InventoryManager inventory - { - get - { - return this._inventory; - } - set - { - this._inventory = value; - this.requiresUpdate = true; - } - } + public InventoryManager inventory; private LightManager _lightManager; @@ -317,7 +305,8 @@ namespace Revitalize.Framework.Objects } } - private Energy.EnergyManager _energyManager; + //private Energy.EnergyManager _energyManager; + /* public Energy.EnergyManager EnergyManager { get @@ -330,6 +319,9 @@ namespace Revitalize.Framework.Objects this.requiresUpdate = true; } } + */ + + public Energy.EnergyManager EnergyManager; private bool _alwaysDrawAbovePlayer; public bool AlwaysDrawAbovePlayer @@ -399,6 +391,7 @@ namespace Revitalize.Framework.Objects this.shakeTimer = 0; this.EnergyManager = new Energy.EnergyManager(); this._alwaysDrawAbovePlayer = false; + this.ColorManager = new ColorManager(Enums.DyeBlendMode.Blend, 0.5f); } public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null, ColorManager ColorManager=null) @@ -453,12 +446,12 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this._inventory.Copy(), this._lightManager.Copy(),this._energyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager); } public bool requiresSyncUpdate() { - return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate() || this.energyManagerRequiresUpdate(); + return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate() || this.energyManagerRequiresUpdate() || this.colorManagerRequiresUpdate(); } public void forceUpdate() @@ -472,8 +465,8 @@ namespace Revitalize.Framework.Objects } private bool inventoryManagerRequiresUpdate() { - if (this._inventory == null) return false; - else return this._inventory.requiresUpdate; + if (this.inventory == null) return false; + else return this.inventory.requiresUpdate; } private bool lightManagerRequiresUpdate() { @@ -483,17 +476,35 @@ namespace Revitalize.Framework.Objects private bool energyManagerRequiresUpdate() { - if (this._energyManager == null) return false; - else return this._energyManager.requiresUpdate; + if (this.EnergyManager == null) + { + //ModCore.log("Energy manager is NULL! " + this.name); + return false; + } + else + { + if (this.EnergyManager.requiresUpdate) + { + //ModCore.log("Energy manager requres an update: " + this.name); + } + return this.EnergyManager.requiresUpdate; + } + } + + private bool colorManagerRequiresUpdate() + { + if (this._colorManager == null) return false; + else return this._colorManager.requiresUpdate; } public void cleanAfterUpdate() { this.requiresUpdate = false; - this._inventory.requiresUpdate = false; + this.inventory.requiresUpdate = false; this._animationManager.requiresUpdate = false; this._lightManager.requiresUpdate = false; - this._energyManager.requiresUpdate = false; + this.EnergyManager.requiresUpdate = false; + this._colorManager.requiresUpdate = false; } /// diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 6ace0224..fd4c7e68 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -20,9 +20,9 @@ namespace Revitalize.Framework.Objects // -Inventories /// A custom object template. - public class CustomObject : PySObject,IEnergyInterface + public class CustomObject : PySObject, IEnergyInterface { - + [JsonIgnore] public virtual string text { get @@ -42,7 +42,7 @@ namespace Revitalize.Framework.Objects } } - + [JsonIgnore] public override string Name { @@ -83,7 +83,7 @@ namespace Revitalize.Framework.Objects } } } - + [JsonIgnore] public override string DisplayName { get @@ -107,7 +107,7 @@ namespace Revitalize.Framework.Objects } } - + [JsonIgnore] public string id { get @@ -131,11 +131,7 @@ namespace Revitalize.Framework.Objects { get { - if (this.info == null) - { - this.updateInfo(); - } - + this.updateInfo(); //ModCore.log("Location Name is: " + this.info.locationName); if (this._location == null) { @@ -174,30 +170,6 @@ namespace Revitalize.Framework.Objects } } - [JsonIgnore] - /// - /// Accesses the energy manager for all objects. - /// - public virtual EnergyManager EnergyManager - { - get - { - if (this.info == null) - { - this.updateInfo(); - return this.info.EnergyManager; - } - else - { - return this.info.EnergyManager; - } - } - set - { - this.info.EnergyManager = value; - } - } - /// The display texture for this object. [JsonIgnore] public Texture2D displayTexture => this.animationManager.getTexture(); @@ -330,13 +302,13 @@ namespace Revitalize.Framework.Objects MouseState mState = Mouse.GetState(); KeyboardState keyboardState = Game1.GetKeyboardState(); - if (mState.RightButton == ButtonState.Pressed && keyboardState.IsKeyDown(Keys.LeftShift)==false && keyboardState.IsKeyDown(Keys.RightShift)==false) + if (mState.RightButton == ButtonState.Pressed && keyboardState.IsKeyDown(Keys.LeftShift) == false && keyboardState.IsKeyDown(Keys.RightShift) == false) { //ModCore.log("Right clicked!"); return this.rightClicked(who); } - if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift)==true || keyboardState.IsKeyDown(Keys.RightShift)==true)) + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) == true || keyboardState.IsKeyDown(Keys.RightShift) == true)) return this.shiftRightClicked(who); return base.checkForAction(who, justCheckingForActivity); @@ -628,7 +600,7 @@ namespace Revitalize.Framework.Objects } /// What happens when the object is drawn when held by a player. - public virtual void drawFullyInMenu(SpriteBatch spriteBatch, Vector2 objectPosition,float Depth) + public virtual void drawFullyInMenu(SpriteBatch spriteBatch, Vector2 objectPosition, float Depth) { this.updateInfo(); if (this.animationManager == null) @@ -637,7 +609,7 @@ namespace Revitalize.Framework.Objects } if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.DrawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None,Depth); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.DrawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Depth); //base.drawWhenHeld(spriteBatch, objectPosition, f); } @@ -671,7 +643,7 @@ namespace Revitalize.Framework.Objects { if (ModCore.Configs.objectsConfig.showDyedColorName) { - return this.info.getDyedColorName() +" "+ this.info.name; + return this.info.getDyedColorName() + " " + this.info.name; } //Load in a file that has all object names referenced here or something. return this.info.name; @@ -769,16 +741,42 @@ namespace Revitalize.Framework.Objects public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { - if (this.info == null) - { - this.updateInfo(); - } - + this.updateInfo(); if (this.location == null) { this.location = environment; } base.updateWhenCurrentLocation(time, environment); } + + public virtual ref EnergyManager GetEnergyManager() + { + if (this.info == null) + { + this.updateInfo(); + } + + return ref this.info.EnergyManager; + } + + public virtual void SetEnergyManager(ref EnergyManager Manager) + { + this.info.EnergyManager = Manager; + } + + public virtual ref InventoryManager GetInventoryManager() + { + if (this.info == null) + { + this.updateInfo(); + return ref this.info.inventory; + } + return ref this.info.inventory; + } + + public virtual void SetInventoryManager(InventoryManager Manager) + { + this.info.inventory = Manager; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs index 796657fa..d55b89d0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs @@ -249,5 +249,15 @@ namespace Revitalize.Framework.Objects.Items.Tools { return this.UpgradeLevel + 1; } + + public ref EnergyManager GetEnergyManager() + { + return ref this.info.EnergyManager; + } + + public void SetEnergyManager(ref EnergyManager Manager) + { + this.info.EnergyManager = Manager; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs index 4399efcb..b2bead1e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -22,17 +22,6 @@ namespace Revitalize.Framework.Objects.Items.Tools private int hitsToBoulder; private Texture2D energyTexture; - [JsonIgnore] - public EnergyManager EnergyManager - { - get => this.info.EnergyManager; - set - { - this.info.EnergyManager = value; - this.info.requiresUpdate = true; - } - } - public MiningDrill() { @@ -75,7 +64,7 @@ namespace Revitalize.Framework.Objects.Items.Tools { 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); + spriteBatch.Draw(this.energyTexture, new Rectangle((int)location.X + 8, (int)location.Y + Game1.tileSize / 2, (int)((Game1.tileSize - 16) * this.GetEnergyManager().energyPercentRemaining), (int)16), new Rectangle(0, 0, 1, 1), EnergyUtilities.GetEnergyRemainingColor(this.GetEnergyManager()), 0f, Vector2.Zero, SpriteEffects.None, layerDepth); } public override bool beginUsing(GameLocation location, int x, int y, Farmer who) @@ -89,7 +78,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override void endUsing(GameLocation location, Farmer who) { - if (this.EnergyManager.hasEnoughEnergy(this.getEnergyConsumptionRate()) == false) + if (this.GetEnergyManager().hasEnoughEnergy(this.getEnergyConsumptionRate()) == false) { Game1.toolAnimationDone(who); who.canReleaseTool = false; @@ -148,7 +137,7 @@ namespace Revitalize.Framework.Objects.Items.Tools 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(this.getEnergyConsumptionRate()) == true) + if (this.GetEnergyManager().hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) { } else @@ -160,7 +149,7 @@ namespace Revitalize.Framework.Objects.Items.Tools power = who.toolPower; //who.Stamina -= (float)(2 * (power + 1)) - (float)who.MiningLevel * 0.1f; //Drain energy here; - this.EnergyManager.consumeEnergy(this.getEnergyConsumptionRate()); + this.GetEnergyManager().consumeEnergy(this.getEnergyConsumptionRate()); //Double check to prevent animation from happening with even no power @@ -358,9 +347,9 @@ namespace Revitalize.Framework.Objects.Items.Tools { StringBuilder b = new StringBuilder(); b.Append("Energy: "); - b.Append(this.EnergyManager.remainingEnergy); + b.Append(this.GetEnergyManager().remainingEnergy); b.Append("/"); - b.Append(this.EnergyManager.maxEnergy); + b.Append(this.GetEnergyManager().maxEnergy); b.Append(System.Environment.NewLine); b.Append(this.info.description); return b.ToString(); @@ -387,5 +376,15 @@ namespace Revitalize.Framework.Objects.Items.Tools { return this.UpgradeLevel + 1; } + + public ref EnergyManager GetEnergyManager() + { + return ref this.info.EnergyManager; + } + + public void SetEnergyManager(ref EnergyManager Manager) + { + this.info.EnergyManager = Manager; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs index 1a191b2a..6f077f42 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs @@ -66,6 +66,7 @@ namespace Revitalize.Framework.Objects.Machines public override bool minutesElapsed(int minutes, GameLocation environment) { + this.updateInfo(); if (this.updatesContainerObjectForProduction) { //ModCore.log("Update container object for production!"); @@ -73,22 +74,22 @@ namespace Revitalize.Framework.Objects.Machines int remaining = minutes; //ModCore.log("Minutes elapsed: " + remaining); List energySources = new List(); - if (this.ConsumesEnergy || this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + if (this.ConsumesEnergy || this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { //ModCore.log("This machine drains energy: " + this.info.name); energySources = this.EnergyGraphSearchSources(); //Only grab the network once. } this.drainEnergyFromNetwork(energySources); - foreach(Item I in this.InventoryManager.items) + foreach(Item I in this.GetInventoryManager().items) { if (I is null) continue; if (I is IEnergyInterface==false) continue; IEnergyInterface o = (IEnergyInterface)I; - if (o.EnergyManager.canReceieveEnergy) + if (o.GetEnergyManager().canReceieveEnergy) { - this.EnergyManager.transferEnergyToAnother(o.EnergyManager, Math.Min(this.EnergyManager.remainingEnergy, o.EnergyManager.capacityRemaining)); + this.GetEnergyManager().transferEnergyToAnother(o.GetEnergyManager(), Math.Min(this.GetEnergyManager().remainingEnergy, o.GetEnergyManager().capacityRemaining)); } - if (this.EnergyManager.hasEnergy == false) break; + if (this.GetEnergyManager().hasEnergy == false) break; } return false; diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs index dda7195f..34b34f28 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs @@ -80,7 +80,7 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public override void produceEnergy() { - if (this.EnergyManager.canReceieveEnergy) + if (this.GetEnergyManager().canReceieveEnergy) { int energy= this.energyRequiredPer10Minutes; if (WeatherUtilities.IsWetWeather()) @@ -96,7 +96,7 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration { if (this.location.IsOutdoors == false) return; } - this.EnergyManager.produceEnergy(energy); + this.GetEnergyManager().produceEnergy(energy); } } @@ -104,11 +104,6 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { this.updateInfo(); - if (this.info.ignoreBoundingBox == true) - { - x *= -1; - y *= -1; - } if (this.info == null) { diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs index d875a78f..535819a8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs @@ -64,10 +64,10 @@ namespace Revitalize.Framework.Objects.Machines public override bool minutesElapsed(int minutes, GameLocation environment) { + this.updateInfo(); if (this.updatesContainerObjectForProduction) { if (this.energyRequiredPer10Minutes != ModCore.Configs.machinesConfig.grinderEnergyConsumption) this.energyRequiredPer10Minutes = ModCore.Configs.machinesConfig.grinderEnergyConsumption; - ModCore.log("Update container object for production!"); //this.MinutesUntilReady -= minutes; int remaining = minutes; @@ -85,10 +85,10 @@ namespace Revitalize.Framework.Objects.Machines if (this.ConsumesEnergy) { this.drainEnergyFromNetwork(energySources); //Continually drain from the network. - if (this.EnergyManager.remainingEnergy < ModCore.Configs.machinesConfig.grinderEnergyConsumption) return false; + if (this.GetEnergyManager().remainingEnergy < ModCore.Configs.machinesConfig.grinderEnergyConsumption) return false; else { - this.EnergyManager.consumeEnergy(ModCore.Configs.machinesConfig.grinderEnergyConsumption); //Consume the required amount of energy necessary. + this.GetEnergyManager().consumeEnergy(ModCore.Configs.machinesConfig.grinderEnergyConsumption); //Consume the required amount of energy necessary. } } else @@ -98,7 +98,7 @@ namespace Revitalize.Framework.Objects.Machines remaining -= 10; this.containerObject.MinutesUntilReady -= 10; - if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull == false) + if (this.containerObject.MinutesUntilReady <= 0 && this.GetInventoryManager().IsFull == false) { this.produceItem(); this.consumeItemForGrinding(); @@ -206,7 +206,10 @@ namespace Revitalize.Framework.Objects.Machines try { - this.animationManager.tickAnimation(); + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } // Log.AsyncC("Tick animation"); } catch (Exception err) @@ -220,9 +223,9 @@ namespace Revitalize.Framework.Objects.Machines public override void produceItem() { - if (this.InventoryManager.hasItemsInBuffer) + if (this.GetInventoryManager().hasItemsInBuffer) { - this.InventoryManager.dumpBufferToItems(); + this.GetInventoryManager().dumpBufferToItems(); } } @@ -230,31 +233,31 @@ namespace Revitalize.Framework.Objects.Machines { Item itemToRemove = null; - foreach(Item I in this.InventoryManager.items) + foreach(Item I in this.GetInventoryManager().items) { if(I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.CopperOre, 1))){ - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("CopperSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("CopperSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.IronOre, 1))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("IronSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("IronSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.GoldOre, 1))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("GoldSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("GoldSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.IridiumOre, 1))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("IridiumSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("IridiumSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; @@ -262,35 +265,35 @@ namespace Revitalize.Framework.Objects.Machines if (I.canStackWith(ModCore.ObjectManager.resources.getOre("BauxiteOre"))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("BauxiteSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("BauxiteSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(ModCore.ObjectManager.resources.getOre("LeadOre"))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("LeadSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("LeadSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(ModCore.ObjectManager.resources.getOre("SilverOre"))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("SilverSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("SilverSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(ModCore.ObjectManager.resources.getOre("TinOre"))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("TinSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("TinSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; } if (I.canStackWith(ModCore.ObjectManager.resources.getOre("TitaniumOre"))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("TitaniumSand", 2)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("TitaniumSand", 2)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; @@ -298,7 +301,7 @@ namespace Revitalize.Framework.Objects.Machines if (I.canStackWith(new StardewValley.Object((int)Enums.SDVObject.Stone, 1))) { - this.InventoryManager.bufferItems.Add(ModCore.ObjectManager.resources.getResource("Sand", 1)); + this.GetInventoryManager().bufferItems.Add(ModCore.ObjectManager.resources.getResource("Sand", 1)); itemToRemove = I; this.containerObject.MinutesUntilReady = ModCore.Configs.machinesConfig.grinderTimeToGrind; break; @@ -313,7 +316,7 @@ namespace Revitalize.Framework.Objects.Machines } else if (itemToRemove.Stack == 1) { - this.InventoryManager.items.Remove(itemToRemove); + this.GetInventoryManager().items.Remove(itemToRemove); } return true; diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 552a7110..26025608 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -13,6 +13,7 @@ using Revitalize.Framework.Menus.Machines; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardustCore.Animations; using StardustCore.UIUtilities; using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; @@ -32,12 +33,29 @@ namespace Revitalize.Framework.Objects.Machines string pyTkData = ModCore.Serializer.ToJSONString(this.data); string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : ""; string container = this.containerObject != null ? this.containerObject.guid.ToString() : ""; - string resources = ModCore.Serializer.ToJSONString(this.producedResources); string energyRequired = this.energyRequiredPer10Minutes.ToString(); string timeToProduce = this.timeToProduce.ToString(); string updatesContainer = this.updatesContainerObjectForProduction.ToString(); - - return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + resources + "<" + energyRequired + "<" + timeToProduce + "<" + updatesContainer + "<" + this.craftingRecipeBook; + StringBuilder b = new StringBuilder(); + b.Append(info); + b.Append("<"); + b.Append(guidStr); + b.Append("<"); + b.Append(pyTkData); + b.Append("<"); + b.Append(offsetKey); + b.Append("<"); + b.Append(container); + b.Append("<"); + b.Append(energyRequired); + b.Append("<"); + b.Append(timeToProduce); + b.Append("<"); + b.Append(updatesContainer); + b.Append("<"); + b.Append(this.craftingRecipeBook); + //ModCore.log("Setting info: " + b.ToString()); + return b.ToString(); } set { @@ -48,16 +66,16 @@ namespace Revitalize.Framework.Objects.Machines string pyTKData = data[2]; string offsetVec = data[3]; string containerObject = data[4]; - string resourcesString = data[5]; - string energyRequired = data[6]; - string time = data[7]; - string updates = data[8]; - this.craftingRecipeBook = data[9]; + string energyRequired = data[5]; + string time = data[6]; + string updates = data[7]; + this.craftingRecipeBook = data[8]; this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); this.energyRequiredPer10Minutes = Convert.ToInt32(energyRequired); this.timeToProduce = Convert.ToInt32(time); this.updatesContainerObjectForProduction = Convert.ToBoolean(updates); + if (string.IsNullOrEmpty(offsetVec)) return; if (string.IsNullOrEmpty(containerObject)) return; this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); @@ -104,19 +122,26 @@ namespace Revitalize.Framework.Objects.Machines //ModCore.CustomObjects.Remove(oldGuid); } } - - if (string.IsNullOrEmpty(resourcesString) == false) - { - this.producedResources = ModCore.Serializer.DeserializeFromJSONString>(resourcesString); - } - else - { - if (this.producedResources == null) this.producedResources = new List(); - } } } - public List producedResources; + [JsonIgnore] + public List producedResources + { + get + { + return MachineUtilities.GetResourcesProducedByThisMachine(this.info.id); + } + set + { + if (MachineUtilities.ResourcesForMachines == null) MachineUtilities.InitializeResourceList(); + if (MachineUtilities.ResourcesForMachines.ContainsKey(this.info.id)) return; + MachineUtilities.ResourcesForMachines.Add(this.info.id, value); + + + Chest c = new Chest(); + } + } public int energyRequiredPer10Minutes; public int timeToProduce; public bool updatesContainerObjectForProduction; @@ -140,6 +165,7 @@ namespace Revitalize.Framework.Objects.Machines { get { + this.updateInfo(); if (ModCore.Configs.machinesConfig.doMachinesConsumeEnergy == false) { //ModCore.log("Machine config disables energy consumption."); @@ -150,12 +176,12 @@ namespace Revitalize.Framework.Objects.Machines //ModCore.log("Machine rquires 0 energy to run."); return false; } - if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes) + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Consumes) { //ModCore.log("Machine does consume energy."); return true; } - if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { return true; @@ -216,20 +242,17 @@ namespace Revitalize.Framework.Objects.Machines public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { - - base.updateWhenCurrentLocation(time, environment); + + this.animationManager.prepareForNextUpdateTick(); } public override bool minutesElapsed(int minutes, GameLocation environment) { - if (this.info == null) - { - this.updateInfo(); - } - ModCore.log(this.info.animationManager.currentAnimationName); + this.updateInfo(); + //ModCore.log(this.info.animationManager.currentAnimationName); if (this.updatesContainerObjectForProduction) { @@ -238,7 +261,7 @@ namespace Revitalize.Framework.Objects.Machines int remaining = minutes; //ModCore.log("Minutes elapsed: " + remaining); List energySources = new List(); - if (this.ConsumesEnergy || this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + if (this.ConsumesEnergy || this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { //ModCore.log("This machine drains energy: " + this.info.name); energySources = this.EnergyGraphSearchSources(); //Only grab the network once. @@ -246,17 +269,16 @@ namespace Revitalize.Framework.Objects.Machines if (this.ProducesItems) { - ModCore.log("This machine produces items: " + this.info.name); while (remaining > 0) { if (this.ConsumesEnergy) { this.drainEnergyFromNetwork(energySources); //Continually drain from the network. - if (this.EnergyManager.remainingEnergy < this.energyRequiredPer10Minutes) return false; + if (this.GetEnergyManager().remainingEnergy < this.energyRequiredPer10Minutes) return false; else { - this.EnergyManager.consumeEnergy(this.energyRequiredPer10Minutes); //Consume the required amount of energy necessary. + this.GetEnergyManager().consumeEnergy(this.energyRequiredPer10Minutes); //Consume the required amount of energy necessary. } } else @@ -266,14 +288,14 @@ namespace Revitalize.Framework.Objects.Machines remaining -= 10; this.containerObject.MinutesUntilReady -= 10; - if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull == false) + if (this.containerObject.MinutesUntilReady <= 0 && this.GetInventoryManager().IsFull == false) { this.produceItem(); this.containerObject.MinutesUntilReady = this.timeToProduce; } } } - if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces) + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) { while (remaining > 0) { @@ -286,9 +308,9 @@ namespace Revitalize.Framework.Objects.Machines { this.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); - if (this.InventoryManager.hasItemsInBuffer && this.MinutesUntilReady == 0) + if (this.GetInventoryManager().hasItemsInBuffer && this.MinutesUntilReady == 0) { - this.InventoryManager.dumpBufferToItems(); + this.GetInventoryManager().dumpBufferToItems(); } } @@ -298,7 +320,7 @@ namespace Revitalize.Framework.Objects.Machines else { - if (this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces) + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) { this.storeEnergyToNetwork(); } @@ -330,15 +352,15 @@ namespace Revitalize.Framework.Objects.Machines MachineSummaryMenu m = new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width / 2) - 400, 48, 800, 600, Color.White, this.containerObject, this.energyRequiredPer10Minutes); machineMenu.addInMenuTab("Summary", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), m, true); - if (this.InventoryManager.capacity > 0) + if (this.GetInventoryManager().capacity > 0) { - InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, this.InventoryManager.capacity, this.InventoryManager.displayRows, this.InventoryManager.displayColumns); + InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.GetInventoryManager().items, this.GetInventoryManager().capacity, this.GetInventoryManager().displayRows, this.GetInventoryManager().displayColumns); machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, false); } if (string.IsNullOrEmpty(this.craftingRecipeBook) == false) { - CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items, ref this.InventoryManager.items, this); + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.GetInventoryManager().items, ref this.GetInventoryManager().items, this); machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); } @@ -384,11 +406,6 @@ namespace Revitalize.Framework.Objects.Machines public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { this.updateInfo(); - if (this.info.ignoreBoundingBox == true) - { - x *= -1; - y *= -1; - } if (this.info == null) { @@ -428,7 +445,10 @@ namespace Revitalize.Framework.Objects.Machines try { - this.animationManager.tickAnimation(); + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } // Log.AsyncC("Tick animation"); } catch (Exception err) @@ -448,7 +468,7 @@ namespace Revitalize.Framework.Objects.Machines if (r.shouldDropResource()) { Item i = r.getItemDrops(); - this.InventoryManager.addItem(i); + this.GetInventoryManager().addItem(i); //ModCore.log("Produced an item!"); } } @@ -457,9 +477,9 @@ namespace Revitalize.Framework.Objects.Machines public virtual void produceEnergy() { - if (this.EnergyManager.canReceieveEnergy) + if (this.GetEnergyManager().canReceieveEnergy) { - this.EnergyManager.produceEnergy(this.energyRequiredPer10Minutes); + this.GetEnergyManager().produceEnergy(this.energyRequiredPer10Minutes); } } @@ -467,7 +487,10 @@ 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) + if (this.machineStatusBubbleBox == null) this.createStatusBubble(); + this.updateInfo(); + if (this.GetInventoryManager() == null) return; + if (this.GetInventoryManager().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)); @@ -480,6 +503,26 @@ namespace Revitalize.Framework.Objects.Machines } } + public override void updateInfo() + { + if (this.info == null || this.containerObject == null) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + //this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + this.containerObject.updateInfo(); + //ModCore.log("Force an update for machine: " + this.info.name); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs index c5d34565..b5c42139 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs @@ -33,6 +33,7 @@ namespace Revitalize.Framework.Objects.Machines public override bool minutesElapsed(int minutes, GameLocation environment) { + this.updateInfo(); return false; } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 933189b8..e25f0024 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -92,52 +92,6 @@ namespace Revitalize.Framework.Objects public Vector2 offsetKey; - [JsonIgnore] - public override EnergyManager EnergyManager - { - get - { - if (this.info == null || this.containerObject==null) - { - this.updateInfo(); - if (this.containerObject == null) return null; - return this.containerObject.info.EnergyManager; - } - else - { - return this.containerObject.info.EnergyManager; - } - } - set - { - this.containerObject.info.EnergyManager = value; - } - } - - /// - /// The inventory for the object. - /// - [JsonIgnore] - public virtual InventoryManager InventoryManager - { - get - { - if (this.info == null || this.containerObject == null) - { - this.updateInfo(); - if (this.containerObject == null) return null; - return this.containerObject.info.inventory; - } - else - { - return this.containerObject.info.inventory; - } - } - set - { - this.containerObject.info.inventory = value; - } - } public MultiTiledComponent() { } @@ -422,6 +376,7 @@ namespace Revitalize.Framework.Objects if (this.info == null || this.containerObject==null) { this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); return; } @@ -460,7 +415,7 @@ namespace Revitalize.Framework.Objects StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); if (obj is MultiTiledComponent) { - if ((obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Produces || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + if ((obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { customObjects.Add((MultiTiledComponent)obj); } @@ -498,7 +453,7 @@ namespace Revitalize.Framework.Objects StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); if (obj is MultiTiledComponent) { - if ((obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Consumes || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage) + if ((obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Consumes || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { customObjects.Add((MultiTiledComponent)obj); } @@ -519,15 +474,15 @@ namespace Revitalize.Framework.Objects /// protected virtual List getAppropriateEnergyNeighbors() { - if (this.EnergyManager.consumesEnergy) + if (this.GetEnergyManager().consumesEnergy) { return this.GetNeighboringOutputEnergySources(); } - else if (this.EnergyManager.producesEnergy) + else if (this.GetEnergyManager().producesEnergy) { return this.GetNeighboringInputEnergySources(); } - else if (this.EnergyManager.transfersEnergy) + else if (this.GetEnergyManager().transfersEnergy) { List objs = new List(); objs.AddRange(this.GetNeighboringInputEnergySources()); @@ -620,8 +575,8 @@ namespace Revitalize.Framework.Objects for(int i = 0; i < energySources.Count; i++) { - this.EnergyManager.transferEnergyFromAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); - if (this.EnergyManager.hasMaxEnergy) break; + this.GetEnergyManager().transferEnergyFromAnother(energySources[i].GetEnergyManager(), this.GetEnergyManager().capacityRemaining); + if (this.GetEnergyManager().hasMaxEnergy) break; } } @@ -631,8 +586,8 @@ namespace Revitalize.Framework.Objects for (int i = 0; i < energySources.Count; i++) { - this.EnergyManager.transferEnergyFromAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); - if (this.EnergyManager.hasMaxEnergy) break; + this.GetEnergyManager().transferEnergyFromAnother(energySources[i].GetEnergyManager(), this.GetEnergyManager().capacityRemaining); + if (this.GetEnergyManager().hasMaxEnergy) break; } } @@ -647,8 +602,8 @@ namespace Revitalize.Framework.Objects for (int i = 0; i < energySources.Count; i++) { - this.EnergyManager.transferEnergyToAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); - if (this.EnergyManager.hasEnergy==false) break; + this.GetEnergyManager().transferEnergyToAnother(energySources[i].GetEnergyManager(), this.GetEnergyManager().capacityRemaining); + if (this.GetEnergyManager().hasEnergy==false) break; } } @@ -659,8 +614,57 @@ namespace Revitalize.Framework.Objects for (int i = 0; i < energySources.Count; i++) { - this.EnergyManager.transferEnergyToAnother(energySources[i].EnergyManager, this.EnergyManager.capacityRemaining); - if (this.EnergyManager.hasEnergy==false) break; + this.GetEnergyManager().transferEnergyToAnother(energySources[i].GetEnergyManager(), this.GetEnergyManager().capacityRemaining); + if (this.GetEnergyManager().hasEnergy==false) break; + } + } + + public override ref EnergyManager GetEnergyManager() + { + if (this.info == null || this.containerObject == null) + { + this.updateInfo(); + if (this.containerObject == null) return ref this.info.EnergyManager; + return ref this.containerObject.info.EnergyManager; + } + return ref this.containerObject.info.EnergyManager; + } + + public override void SetEnergyManager(ref EnergyManager Manager) + { + this.info.EnergyManager = Manager; + } + + public override ref InventoryManager GetInventoryManager() + { + if (this.info == null || this.containerObject == null) + { + this.updateInfo(); + if (this.containerObject == null) + { + return ref this.info.inventory; + } + return ref this.containerObject.info.inventory; + } + return ref this.containerObject.info.inventory; + } + + public override void SetInventoryManager(InventoryManager Manager) + { + this.info.inventory = Manager; + this.containerObject.info.inventory = Manager; + } + + + public override bool requiresUpdate() + { + if (this.info.requiresSyncUpdate() || this.containerObject.info.requiresSyncUpdate()) + { + return true; + } + else + { + return false; } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index c4ca919b..b47c01f7 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -183,7 +183,7 @@ namespace Revitalize.Framework.Objects MultiTiledObject sandBox = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); Machine sandBox_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"),new Animation(0,0,16,16)), Color.White, false, new InventoryManager(36), null, null), new List() { - //new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) + new InformationFiles.ResourceInformation(this.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) }, 0, TimeUtilities.GetMinutesFromTime(0, 1, 0), true,"Workbench"); Machine sandBox_1_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Sandbox", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), typeof(Machine), Color.White, true), new BasicItemInformation("Sandbox", "Omegasis.Revitalize.Objects.Machines.Sandbox", "A sandbox which slowly produces sand. Unfortunately you can't sit in this one.", "Machine", Color.SteelBlue, -300, 0, false, 750, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Sandbox"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Sandbox"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(36), null, null), new List() diff --git a/GeneralMods/Revitalize/Framework/Utilities/MachineUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MachineUtilities.cs new file mode 100644 index 00000000..f22001a8 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/MachineUtilities.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Objects.InformationFiles; + +namespace Revitalize.Framework.Utilities +{ + public class MachineUtilities + { + + public static Dictionary> ResourcesForMachines; + + + public static List GetResourcesProducedByThisMachine(string ID) + { + + if (ResourcesForMachines == null) InitializeResourceList(); + + if (ResourcesForMachines.ContainsKey(ID)) + { + return ResourcesForMachines[ID]; + } + else if (ID.Equals("Omegasis.Revitalize.Objects.Machines.MiningDrillV1")) + { + return ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(); + } + + return new List(); + } + + public static void InitializeResourceList() + { + + ResourcesForMachines = new Dictionary>() + { + {"Omegasis.Revitalize.Objects.Machines.BatteryBin" ,new List(){ + new Objects.InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1,1,1,1,1,1,0,0,0,0) + } }, + {"Omegasis.Revitalize.Objects.Machines.Sandbox",new List(){ + new Objects.InformationFiles.ResourceInformation(ModCore.ObjectManager.resources.getResource("Sand",1),1,1,1,1,1,1,0,0,0,0) + } } + }; + } + + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index a43138bc..b75b5d4e 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -335,7 +335,7 @@ namespace Revitalize */ if (e.Button == SButton.U) { - CraftingMenuV1 craft = new CraftingMenuV1(100, 100, 600, 800, Color.White, Game1.player.Items); + CraftingMenuV1 craft = new CraftingMenuV1(100, 100, 600, 800, Color.White, Game1.player.Items.ToList()); craft.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); craft.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new List() { diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index a5dffd19..e096132a 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -183,6 +183,7 @@ + diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index 4c222d11..5d220c48 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -27,6 +27,8 @@ namespace StardustCore.Animations public bool requiresUpdate; public bool IsNull => this.defaultDrawFrame == null && this.objectTexture == null; + public bool hasRecievedUpdateTick; + /// /// Checks to see if there is an animation playing. /// @@ -107,6 +109,7 @@ namespace StardustCore.Animations this.getNextAnimationFrame(); this.currentAnimation.tickAnimationFrame(); //this.requiresUpdate = true; + this.hasRecievedUpdateTick = true; } catch (Exception err) { @@ -115,6 +118,16 @@ namespace StardustCore.Animations } } + public void prepareForNextUpdateTick() + { + this.hasRecievedUpdateTick = false; + } + + public bool canTickAnimation() + { + return this.hasRecievedUpdateTick == false; + } + /// Get the next animation frame in the list of animations. private void getNextAnimationFrame() { From 4eda84e57df2eca32b0a14f3a1635764f597d410 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 02:32:59 -0700 Subject: [PATCH 72/98] NO MORE MULTIPLAYER. This is my last stardew wish and I'll make what I can. --- .../CraftingTables/CraftingTableTile.cs | 16 ----- .../Framework/Objects/CustomObject.cs | 2 +- .../Framework/Objects/Machines/Grinder.cs | 60 +++++++++++------ .../Framework/Objects/Machines/Machine.cs | 65 ++++++++++++------- .../Framework/Objects/MultiTiledObject.cs | 2 +- .../Framework/Objects/ObjectManager.cs | 14 ++-- .../Utilities/Serialization/Serialization.cs | 8 +++ GeneralMods/Revitalize/manifest.json | 3 +- 8 files changed, 101 insertions(+), 69 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs b/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs index d917b346..37a64437 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CraftingTables/CraftingTableTile.cs @@ -186,22 +186,6 @@ namespace Revitalize.Framework.Objects.CraftingTables } - /// - ///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden. - /// - public void checkForSpecialUpSittingAnimation() - { - if (this.info.facingDirection == Enums.Direction.Up && Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject) - { - string animationKey = "Sitting_" + (int)Enums.Direction.Up; - if (this.animationManager.animations.ContainsKey(animationKey)) - { - this.animationManager.setAnimation(animationKey); - } - } - } - - /// What happens when the object is drawn at a tile location. public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index fd4c7e68..1ba2ede8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -741,7 +741,7 @@ namespace Revitalize.Framework.Objects public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { - this.updateInfo(); + //this.updateInfo(); if (this.location == null) { this.location = environment; diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs index 535819a8..705b7ba0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Grinder.cs @@ -117,6 +117,11 @@ namespace Revitalize.Framework.Objects.Machines //return base.minutesElapsed(minutes, environment); } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + public override bool rightClicked(Farmer who) { if (this.location == null) @@ -130,38 +135,51 @@ namespace Revitalize.Framework.Objects.Machines public override Item getOne() { - Grinder component = new Grinder(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, ModCore.Configs.machinesConfig.grinderEnergyConsumption, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.containerObject); + Grinder component = new Grinder(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, ModCore.Configs.machinesConfig.grinderEnergyConsumption, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; return component; } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { - //instead of using this.offsetkey.x use get additional save data function and store offset key there - Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; Grinder self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); - if (self == null) + if (ModCore.IsNullOrDefault(self)) return null; + try { - return null; + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); } - if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) - { - //Get new container - MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); - self.containerObject = obj; - obj.addComponent(offsetKey, self); - //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); - Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); - } - else - { - self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; - Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); - //Revitalize.ModCore.log("READD AN OBJECT!!!!"); - } + return self; + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; - return (ICustomObject)self; } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 26025608..91f110b5 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -20,6 +20,8 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Objects.Machines { + + // Every machine needs a recreate, a rebuild, a get additional save data,and a getOne function. public class Machine : MultiTiledComponent { @@ -369,38 +371,47 @@ namespace Revitalize.Framework.Objects.Machines public override Item getOne() { - Machine component = new Machine(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.containerObject); + Machine component = new Machine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; return component; } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { - //instead of using this.offsetkey.x use get additional save data function and store offset key there - Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; Machine self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); - if (self == null) + if (ModCore.IsNullOrDefault(self)) return null; + try { - return null; + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); } - if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) - { - //Get new container - MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); - self.containerObject = obj; - obj.addComponent(offsetKey, self); - //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); - Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); - } - else - { - self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; - Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); - //Revitalize.ModCore.log("READD AN OBJECT!!!!"); - } + return self; + } - return (ICustomObject)self; + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) @@ -505,6 +516,7 @@ namespace Revitalize.Framework.Objects.Machines public override void updateInfo() { + return; if (this.info == null || this.containerObject == null) { this.ItemInfo = this.text; @@ -517,12 +529,21 @@ namespace Revitalize.Framework.Objects.Machines //this.ItemInfo = this.text; this.text = this.ItemInfo; this.info.cleanAfterUpdate(); - this.containerObject.updateInfo(); + //this.containerObject.updateInfo(); //ModCore.log("Force an update for machine: " + this.info.name); MultiplayerUtilities.RequestUpdateSync(this.guid); } } + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 1bcf6898..0c0a7e3c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -451,7 +451,7 @@ namespace Revitalize.Framework.Objects { Dictionary saveData = base.getAdditionalSaveData(); saveData.Add("GUID", this.guid.ToString()); - //Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return saveData; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index b47c01f7..5d83e347 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -258,10 +258,10 @@ namespace Revitalize.Framework.Objects MultiTiledObject grinder= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes))); - Grinder grinder_0_0 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)),null,ModCore.Configs.machinesConfig.grinderEnergyConsumption,ModCore.Configs.machinesConfig.grinderTimeToGrind,true,""); - Grinder grinder_1_0 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); - Grinder grinder_0_1 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); - Grinder grinder_1_1 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); + Grinder grinder_0_0 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(Grinder), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)),null,ModCore.Configs.machinesConfig.grinderEnergyConsumption,ModCore.Configs.machinesConfig.grinderTimeToGrind,true,""); + Grinder grinder_1_0 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(Grinder), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); + Grinder grinder_0_1 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(Grinder), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); + Grinder grinder_1_1 = new Grinder(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Grinder", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), typeof(Grinder), Color.White, true), new BasicItemInformation("Grinder", "Omegasis.Revitalize.Objects.Machines.Grinder", "Grinds up ores and rocks.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Grinder"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Grinder"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), null, ModCore.Configs.machinesConfig.grinderEnergyConsumption, ModCore.Configs.machinesConfig.grinderTimeToGrind, false, ""); grinder.addComponent(new Vector2(0, 0), grinder_0_0); grinder.addComponent(new Vector2(1, 0), grinder_1_0); grinder.addComponent(new Vector2(0, 1), grinder_0_1); @@ -269,7 +269,7 @@ namespace Revitalize.Framework.Objects this.AddItem("Grinder", grinder); MultiTiledObject miningDrillMachine = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes))); - Machine miningDrillMachine_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16), new Dictionary>() { + Machine miningDrillMachine_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(Machine), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16), new Dictionary>() { {"Default",new List(){new Animation(0,0,16,16) } }, { "Mining",new List(){ new Animation(0,0,16,16,30), @@ -279,7 +279,7 @@ namespace Revitalize.Framework.Objects } } }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, true, ""); - Machine miningDrillMachine_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 16, 16, 16),new Dictionary>() { + Machine miningDrillMachine_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(Machine), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 16, 16, 16),new Dictionary>() { {"Default",new List(){new Animation(0,16,16,16) } }, { "Mining",new List(){ new Animation(0,16,16,16,30), @@ -287,7 +287,7 @@ namespace Revitalize.Framework.Objects new Animation(32,16,16,16,30), new Animation(48,16,16,16,30), } } - }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, false, ""); + }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, true, ""); miningDrillMachine.addComponent(new Vector2(0, 0), miningDrillMachine_0_0); miningDrillMachine.addComponent(new Vector2(0, 1), miningDrillMachine_0_1); miningDrillMachine_0_0.animationManager.setAnimation("Mining"); diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index b4341ed1..dd688853 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -134,6 +134,7 @@ namespace Revitalize.Framework.Utilities /// public void afterLoad() { + ModCore.log("WHAT"); this.deleteAllUnusedFiles(); //this.removeNullObjects(); this.restoreModObjects(); @@ -144,6 +145,7 @@ namespace Revitalize.Framework.Utilities /// public void restoreModObjects() { + ModCore.log("Restore all mod objects!"); //Replace all items in the world. List objsToRestore = new List(); foreach (var v in ModCore.ObjectGroups) @@ -162,6 +164,7 @@ namespace Revitalize.Framework.Utilities //Replace all held items or items in inventories. foreach (GameLocation loc in LocationUtilities.GetAllLocations()) { + ModCore.log("Looking at location: " + loc); foreach (StardewValley.Object c in loc.Objects.Values) { if (c is Chest) @@ -188,6 +191,11 @@ namespace Revitalize.Framework.Utilities (c as Chest).items.Add(I); } } + else if(c is Chest && c.Name != "Chest") + { + loc.objects[c.TileLocation] = (StardewValley.Object)this.GetItemFromChestName(c.Name); + ModCore.log("Found a custom item that is a chest!"); + } else if (c is CustomObject) { if ((c as CustomObject).info.inventory == null) continue; diff --git a/GeneralMods/Revitalize/manifest.json b/GeneralMods/Revitalize/manifest.json index 5c46a2a6..0b1254f8 100644 --- a/GeneralMods/Revitalize/manifest.json +++ b/GeneralMods/Revitalize/manifest.json @@ -8,6 +8,7 @@ "MinimumApiVersion": "2.10.1", "UpdateKeys": [], "Dependencies": [ - { "UniqueID": "Omegasis.StardustCore" } + { "UniqueID": "Omegasis.StardustCore" }, + { "UniqueID": "Platonymous.Toolkit" } ] } From caa7653b32e2b4db88bc3e5ca7dcbe3272685590 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 11:12:07 -0700 Subject: [PATCH 73/98] Finally added in the alloy furnace. I think all machines should serialize now. --- .../Objects/Machines/AlloyFurnace.png | Bin 0 -> 718 bytes .../Objects/Machines/MiningDrillMachine.png | Bin 829 -> 845 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 48 ++++ .../Framework/Crafting/VanillaRecipeBook.cs | 3 +- .../Menus/CraftingInformationPage.cs | 2 +- .../Objects/Machines/AlloyFurnace.cs | 262 ++++++++++++++++++ .../Objects/Machines/ChargingStation.cs | 14 + .../Machines/EnergyGeneration/SolarPanel.cs | 16 ++ .../Framework/Objects/Machines/Machine.cs | 6 +- .../Framework/Objects/Machines/Wire.cs | 14 + .../Objects/Machines/WireMultiTiledObject.cs | 4 + .../Framework/Objects/ObjectManager.cs | 35 +++ .../Utilities/Serialization/Serialization.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 4 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + 15 files changed, 404 insertions(+), 9 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/AlloyFurnace.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/AlloyFurnace.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/AlloyFurnace.png new file mode 100644 index 0000000000000000000000000000000000000000..0c8e5dfe548aaaf1a0d4cf7c04aba5fab6760a34 GIT binary patch literal 718 zcmV;<0x|uGP)Px%h)G02RA_gW=abO; zfJ&9_SxcfHP0Q-d`h7!m?(@}^kdf7cw3Dlff>lKc;v%%1cJk8qg)yb74#YZOT2_z8 zWpp4k(L8z56Tn6JBm{qfX<5BrCnp8~)G=T2rSFGg0C-xj{~k;xBtBMOu0Glc3dIVD-n{51AymM*=aDDKTEL*Gs>bH_3jn}qc#KA?of_|K z9bzzfTU>PxJ@I-D&9N5YqYDu6i8JuQeGb-{`vTuH z_yaOLsXrjY^BEZM6-d4ZqXb>q&3 zo5V#n{(y=F7lM$j+k)UisF*(x$RcevUGxXErASM#e$b+&Ndu8g7p5AlwvG!kkD2Mb z$)s;GLm+4MCUfsOxo7TsH)J?Ch`V=gDR$!4Ha0mYby@U%tbYVXB&TMmdC`!FmDMHc zeJ}KV#vqmgtPl-}sL9oiac=9MGoV`n722owW^vIp=E?j#iS2e9^h%!?;6wrA(imC4 zt)+GM9!Hl+%t7VQu>x52bsfM`K>G_RS3(h8yb%YLL+T#(LZ2AmL;+gR3ZTI&ed-y| zZ2?Af8}F4q)qj9~DS%bqu?{fKaI1JbQ@|~K(<#smffni^rk>VjurmeR)Hj_17b(Da zh&6p#jGQh20OE2PyP+fidsDzo{YzQ`EpgMACF{6cCTlyVaMPE?a6&@UmqlDIBOPt% zILzRcJ~uZzNm_45;gOu0Aq2nPS1?n5gmkolB} z)$|FdKV_}*-PRwP7O%dT5d8=Tczpc+7t@K``2AxAKjj2QP8V?GkD&4Gm=NrJ`HXwg zFv0;Ia`QitntvlOgwoar!lB~GA0gryiAOlVo926=PqqL6WF#Idt4oN6MB*L*oqHLH zH+A30VShw7xo+xnbF-7mgy_eoYKwfRwxSls*3;$~^8w&kyr#RpT;11QTjjf{ubTq7 z^=)#vj7wv>v9z|a$*r~5+H-@JkM(UOl}aHdUB|1}F9Cquvy<h($ delta 794 zcmV+#1Lge92E7K5Fn~=O;0(qx_{pP)WZ@!rc8x9WQ=8bD@D|O|KP0mSO7JUyZfqx#!xfFF?Bp5|$eUzBEcwXabVNJar2ht&R54)jH0&v2B8Z-kmxTQ}$1MC{m z!*0D>`qTgh#eV>+zGEGrzr)Syt=t0r(l@*X>=3A-9Ae68Z3HW~KtJ^jZ-I*#&>vz= zPX^B*3BT&|F@l~cIs$zUuYpy|mVE?1C_G&CGW za7&+CT$m-Tx83$4IhP^?zurqo)$b!6X<)4u!fr5$%74~d%y1`$WZP{o?%ckMnp`zp z0p+Kx+5CR%kIqLgKb?;H5b}HR@!KEFC$8i7j}m^$35=gEv|A>_NSN)?XZhase3XXhXB7RTsBINfP&UZtfTU?lJPe*;E__cIGQdC1tpkSxk zA}^qf)qg9ghJNMLbKKM?hoC|*!vUrB)pG<&>+Dqjr>;l#%{#I;r-Vt(sb1dLEJ~aSFv_(+_00bri=zokYeeH2lKQIvh08@Qh0IUW$b=!5u zc0PbuHo&S+3&0Tr3fv0NihkD)=te-nzyvt#09FDD1}4B^2e1-QFfaiQJAjpdf`JLJ zR~-NV;CUWWec$dh$MmK8K6suttug&;jKKf^aM^5DS+xuO8*Ie@tG-zP%mx_d^-cdT YqZ1Y5IQFW)WB>pF07*qoM6N<$f~#Y2@Bjb+ diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index d0e7b8b1..ca5c95af 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -477,6 +477,54 @@ namespace Revitalize.Framework.Crafting CraftingRecipesByGroup.Add("Anvil", AnvilRecipes); } + //~~~~~~~~~~~~~~~~~~~~~~~// + // Alloy Furnace Recipes // + //~~~~~~~~~~~~~~~~~~~~~~~// + CraftingRecipeBook AlloyFurnaceRecipes = new CraftingRecipeBook("AlloyFurnace"); + AlloyFurnaceRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); + + + AlloyFurnaceRecipes.addCraftingRecipe("BrassIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AluminumIngot"),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + },new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BrassIngot"), 1),null, TimeUtilities.GetMinutesFromTime(0, 3, 0)), true)); + + AlloyFurnaceRecipes.addCraftingRecipe("BronzeIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TinIngot"),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 4, 0)), true)); + + AlloyFurnaceRecipes.addCraftingRecipe("SteelIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,1),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 6, 0)), true)); + + AlloyFurnaceRecipes.addCraftingRecipe("ElectrumIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.GoldBar,1),1), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SilverIngot"),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 4, 0)), true)); + + if (CraftingRecipesByGroup.ContainsKey(AlloyFurnaceRecipes.craftingGroup)) + { + foreach (KeyValuePair recipe in AlloyFurnaceRecipes.craftingRecipes) + { + if (CraftingRecipesByGroup[AlloyFurnaceRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) + { + + } + else + { + CraftingRecipesByGroup[AlloyFurnaceRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. + } + } + } + else + { + CraftingRecipesByGroup.Add("AlloyFurnace", AlloyFurnaceRecipes); + } } #endregion diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs index 856ac7f2..22905a3c 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs @@ -168,8 +168,7 @@ namespace Revitalize.Framework.Crafting }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("Glass"),1), TimeUtilities.GetMinutesFromTime(0, 1, 0), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Sand", furnace_glass); - ///Sand recipes here.... - /// + ///Sand recipes here. VanillaRecipe furnace_bauxiteSand = new VanillaRecipe(new Dictionary() { {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 248d74f9..9c981377 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -114,7 +114,7 @@ namespace Revitalize.Framework.Menus } else { - this.machine.MinutesUntilReady = this.infoButton.recipe.timeToCraft; + this.machine.containerObject.MinutesUntilReady = this.infoButton.recipe.timeToCraft; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs new file mode 100644 index 00000000..c0156019 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs @@ -0,0 +1,262 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines +{ + public class AlloyFurnace:Machine + { + + public AlloyFurnace() { } + + public AlloyFurnace(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + + } + + public AlloyFurnace(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) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public AlloyFurnace(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) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + + this.animationManager.prepareForNextUpdateTick(); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + + this.updateInfo(); + //ModCore.log(this.info.animationManager.currentAnimationName); + + if (this.updatesContainerObjectForProduction) + { + //ModCore.log("Update container object for production!"); + //this.MinutesUntilReady -= minutes; + int remaining = minutes; + //ModCore.log("Minutes elapsed: " + remaining); + List energySources = new List(); + if (this.ConsumesEnergy || this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) + { + //ModCore.log("This machine drains energy: " + this.info.name); + energySources = this.EnergyGraphSearchSources(); //Only grab the network once. + } + if (this.containerObject.MinutesUntilReady > 0) + { + this.containerObject.MinutesUntilReady = Math.Max(0, this.containerObject.MinutesUntilReady - minutes); + + if (this.GetInventoryManager().hasItemsInBuffer && this.containerObject.MinutesUntilReady == 0) + { + this.GetInventoryManager().dumpBufferToItems(); + } + + this.animationManager.playAnimation("Working"); + } + else + { + this.animationManager.playDefaultAnimation(); + } + + return false; + } + else + { + + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) + { + this.storeEnergyToNetwork(); + } + + return false; + } + + //return base.minutesElapsed(minutes, environment); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + + this.createMachineMenu(); + return true; + } + + public override Item getOne() + { + AlloyFurnace component = new AlloyFurnace(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + AlloyFurnace self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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 + { + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void updateInfo() + { + return; + if (this.info == null || this.containerObject == null) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + //this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + //this.containerObject.updateInfo(); + //ModCore.log("Force an update for machine: " + this.info.name); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs index 6f077f42..9c48e6e1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs @@ -137,6 +137,20 @@ namespace Revitalize.Framework.Objects.Machines return (ICustomObject)self; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { this.updateInfo(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs index 34b34f28..09a08ca7 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs @@ -78,6 +78,22 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration return (ICustomObject)self; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + + public override void produceEnergy() { if (this.GetEnergyManager().canReceieveEnergy) diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 91f110b5..001e3163 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -306,9 +306,9 @@ namespace Revitalize.Framework.Objects.Machines this.storeEnergyToNetwork(); } } - if (this.MinutesUntilReady > 0) + if (this.containerObject.MinutesUntilReady > 0) { - this.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); + this.containerObject.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); if (this.GetInventoryManager().hasItemsInBuffer && this.MinutesUntilReady == 0) { @@ -362,7 +362,7 @@ namespace Revitalize.Framework.Objects.Machines if (string.IsNullOrEmpty(this.craftingRecipeBook) == false) { - CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.GetInventoryManager().items, ref this.GetInventoryManager().items, this); + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.GetInventoryManager().items, ref this.GetInventoryManager().bufferItems, this); machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs index b5c42139..3cc3ed59 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs @@ -87,6 +87,20 @@ namespace Revitalize.Framework.Objects.Machines return (ICustomObject)self; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { this.updateInfo(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs index 2905a779..f3b4503c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs @@ -97,6 +97,10 @@ namespace Revitalize.Framework.Objects.Machines return saveData; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 5d83e347..a0a591d8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -296,6 +296,41 @@ namespace Revitalize.Framework.Objects miningDrillMachine_0_1.animationManager.playAnimation("Mining"); this.AddItem("MiningDrillMachineV1",miningDrillMachine); + MultiTiledObject alloyFurnace = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.AlloyFurnace", TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Alloy Furnace", "Omegasis.Revitalize.Objects.Machines.AlloyFurnace", "Smelts bars into ingots. Works twice as fast as a traditional furnace.", "Machine", Color.SteelBlue, -300, 0, false, 250, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(6, 3, 6), null,null)); + AlloyFurnace alloyFurnace_0_0 = new AlloyFurnace(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.AlloyFurnace", TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), typeof(AlloyFurnace), Color.White, true), new BasicItemInformation("Alloy Furnace", "Omegasis.Revitalize.Objects.Machines.AlloyFurnace", "Smelts bars into ingots. Works twice as fast as a traditional furnace.", "Machine", Color.SteelBlue, -300, 0, false, 250, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new Animation(0, 0, 16, 16), new Dictionary>() + { + {"Default",new List() + { + new Animation(0,0,16,16) + } + }, + {"Working",new List() + { + new Animation(0,32,16,16,30), + new Animation(16,32,16,16,30) + } + } + + },"Default"), Color.White, true, new InventoryManager(6, 3, 6), null, null), null, 0, 0, true, "AlloyFurnace"); + AlloyFurnace alloyFurnace_0_1 = new AlloyFurnace(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.AlloyFurnace", TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), typeof(Machine), Color.White, true), new BasicItemInformation("Alloy Furnace", "Omegasis.Revitalize.Objects.Machines.AlloyFurnace", "Smelts bars into ingots. Works twice as fast as a traditional furnace.", "Machine", Color.SteelBlue, -300, 0, false, 250, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new Animation(0, 16, 16, 16), new Dictionary>() + { + {"Default",new List() + { + new Animation(0,16,16,16) + } + }, + {"Working",new List() + { + new Animation(0,48,16,16,30), + new Animation(16,48,16,16,30) + } + } + + }, "Default"), Color.White, false, new InventoryManager(6, 3, 6), null, null), null, 0, 0, false, "AlloyFurnace"); + alloyFurnace.addComponent(new Vector2(0, 0), alloyFurnace_0_0); + alloyFurnace.addComponent(new Vector2(0, 1), alloyFurnace_0_1); + this.AddItem("AlloyFurnace", alloyFurnace); + } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index dd688853..01b0effb 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -145,7 +145,7 @@ namespace Revitalize.Framework.Utilities /// public void restoreModObjects() { - ModCore.log("Restore all mod objects!"); + //ModCore.log("Restore all mod objects!"); //Replace all items in the world. List objsToRestore = new List(); foreach (var v in ModCore.ObjectGroups) @@ -164,7 +164,7 @@ namespace Revitalize.Framework.Utilities //Replace all held items or items in inventories. foreach (GameLocation loc in LocationUtilities.GetAllLocations()) { - ModCore.log("Looking at location: " + loc); + //ModCore.log("Looking at location: " + loc); foreach (StardewValley.Object c in loc.Objects.Values) { if (c is Chest) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b75b5d4e..ec8c98f2 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -574,7 +574,9 @@ namespace Revitalize new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), ModCore.ObjectManager.GetTool("MiningDrillV1"), ModCore.ObjectManager.GetTool("ChainsawV1"), - ModCore.ObjectManager.GetItem("MiningDrillMachineV1") + ModCore.ObjectManager.GetItem("MiningDrillMachineV1"), + ModCore.ObjectManager.GetItem("AlloyFurnace"), + new StardewValley.Object((int)Enums.SDVObject.IronBar,100), }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e096132a..2fa41e63 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -162,6 +162,7 @@ + From 68bfaa38c932b3c5d555f02d423b10277e881d68 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 11:49:25 -0700 Subject: [PATCH 74/98] Fixed tools serialization. Also made modded tools able to be trashed. --- .../Objects/Items/Tools/AxeExtended.cs | 61 ++++++++++++------- .../Framework/Objects/Items/Tools/Chainsaw.cs | 51 +++++++++++++--- .../Objects/Items/Tools/HoeExtended.cs | 61 ++++++++++++------- .../Objects/Items/Tools/MiningDrill.cs | 23 ++++++- .../Objects/Items/Tools/PickaxeExtended.cs | 56 ++++++++++++----- .../Items/Tools/WateringCanExtended.cs | 61 ++++++++++++------- 6 files changed, 221 insertions(+), 92 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs index ec68f1a9..fdc621a2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs @@ -10,12 +10,13 @@ using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardewValley.Tools; using StardustCore.UIUtilities; namespace Revitalize.Framework.Objects.Items.Tools { - public class AxeExtended: StardewValley.Tools.Axe, ISaveElement, IItemInfo + public class AxeExtended: StardewValley.Tools.Axe, ISaveElement, IItemInfo,ICustomObject { public BasicItemInformation info; public Texture2DExtended workingTexture; @@ -194,15 +195,6 @@ namespace Revitalize.Framework.Objects.Items.Tools //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); } - public Dictionary getAdditionalSaveData() - { - Dictionary serializedInfo = new Dictionary(); - serializedInfo.Add("id", this.ItemInfo); - serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); - return serializedInfo; - } - public override bool beginUsing(GameLocation location, int x, int y, Farmer who) { this.updateInfo(); @@ -247,17 +239,6 @@ namespace Revitalize.Framework.Objects.Items.Tools return new AxeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); } - public virtual object getReplacement() - { - return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel }; - } - - public virtual void rebuild(Dictionary additionalSaveData, object replacement) - { - this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel; - } - /// /// Updates the info on the item. @@ -301,5 +282,43 @@ namespace Revitalize.Framework.Objects.Items.Tools return false; } } + public virtual ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + AxeExtended p = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + return p; + } + public virtual Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + serializedInfo.Add("GUID", this.guid.ToString()); + serializedInfo.Add("Level", this.UpgradeLevel.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public virtual object getReplacement() + { + Chest c = new Chest(true); + c.playerChoiceColor.Value = Color.Magenta; + c.TileLocation = new Vector2(0, 0); + return c; + } + + public virtual void rebuild(Dictionary additionalSaveData, object replacement) + { + //ModCore.log("REBULD THE PICKAXE!!!!!!!"); + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]); + //this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + + } + + public override bool canBeTrashed() + { + return base.canBeTrashed(); + } + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs index d55b89d0..effaf242 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs @@ -7,9 +7,11 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Netcode; using Newtonsoft.Json; +using PyTK.CustomElementHandler; using Revitalize.Framework.Energy; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardewValley.Tools; using StardustCore.UIUtilities; using xTile.ObjectModel; @@ -234,16 +236,6 @@ namespace Revitalize.Framework.Objects.Items.Tools return new Chainsaw(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); } - public override object getReplacement() - { - return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel }; - } - - public override void rebuild(Dictionary additionalSaveData, object replacement) - { - this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel; - } private int getEnergyConsumptionRate() { @@ -259,5 +251,44 @@ namespace Revitalize.Framework.Objects.Items.Tools { this.info.EnergyManager = Manager; } + + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Chainsaw p = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + return p; + } + public override Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + serializedInfo.Add("GUID", this.guid.ToString()); + serializedInfo.Add("Level", this.UpgradeLevel.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public override object getReplacement() + { + Chest c = new Chest(true); + c.playerChoiceColor.Value = Color.Magenta; + c.TileLocation = new Vector2(0, 0); + return c; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + //ModCore.log("REBULD THE PICKAXE!!!!!!!"); + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]); + //this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + + } + + public override bool canBeTrashed() + { + return base.canBeTrashed(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs index c1137f4f..3320b97e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs @@ -10,12 +10,13 @@ using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardewValley.Tools; using StardustCore.UIUtilities; namespace Revitalize.Framework.Objects.Items.Tools { - public class HoeExtended: StardewValley.Tools.Hoe, ISaveElement, IItemInfo + public class HoeExtended: StardewValley.Tools.Hoe, ISaveElement, IItemInfo,ICustomObject { public BasicItemInformation info; public Texture2DExtended workingTexture; @@ -194,15 +195,6 @@ namespace Revitalize.Framework.Objects.Items.Tools //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); } - public Dictionary getAdditionalSaveData() - { - Dictionary serializedInfo = new Dictionary(); - serializedInfo.Add("id", this.ItemInfo); - serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); - return serializedInfo; - } - public override bool beginUsing(GameLocation location, int x, int y, Farmer who) { this.updateInfo(); @@ -247,17 +239,6 @@ namespace Revitalize.Framework.Objects.Items.Tools return new HoeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy()); } - public object getReplacement() - { - return new StardewValley.Tools.Hoe { UpgradeLevel = this.UpgradeLevel }; - } - - public void rebuild(Dictionary additionalSaveData, object replacement) - { - this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - this.upgradeLevel.Value = (replacement as Hoe).UpgradeLevel; - } - /// /// Updates the info on the item. @@ -301,5 +282,43 @@ namespace Revitalize.Framework.Objects.Items.Tools return false; } } + + + public virtual ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + HoeExtended p = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + return p; + } + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + serializedInfo.Add("GUID", this.guid.ToString()); + serializedInfo.Add("Level", this.UpgradeLevel.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public virtual object getReplacement() + { + Chest c = new Chest(true); + c.playerChoiceColor.Value = Color.Magenta; + c.TileLocation = new Vector2(0, 0); + return c; + } + + public virtual void rebuild(Dictionary additionalSaveData, object replacement) + { + //ModCore.log("REBULD THE PICKAXE!!!!!!!"); + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]); + //this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + + } + public override bool canBeTrashed() + { + return base.canBeTrashed(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs index b2bead1e..9da0a860 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -7,9 +7,11 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Netcode; using Newtonsoft.Json; +using PyTK.CustomElementHandler; using Revitalize.Framework.Energy; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardewValley.Tools; using StardustCore.UIUtilities; @@ -362,13 +364,25 @@ namespace Revitalize.Framework.Objects.Items.Tools public override object getReplacement() { - return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel }; + Chest c = new Chest(true); + c.playerChoiceColor.Value = Color.Magenta; + c.TileLocation = new Vector2(0, 0); + return c; } public override void rebuild(Dictionary additionalSaveData, object replacement) { + //ModCore.log("REBULD THE PICKAXE!!!!!!!"); this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]); + //this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + MiningDrill p = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + return p; } @@ -386,5 +400,10 @@ namespace Revitalize.Framework.Objects.Items.Tools { this.info.EnergyManager = Manager; } + + public override bool canBeTrashed() + { + return base.canBeTrashed(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs index ce5e53d6..791c8a6a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs @@ -11,12 +11,13 @@ using Revitalize.Framework.Hacks; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardewValley.Tools; using StardustCore.UIUtilities; namespace Revitalize.Framework.Objects.Items.Tools { - public class PickaxeExtended:StardewValley.Tools.Pickaxe, ISaveElement,IItemInfo + public class PickaxeExtended:StardewValley.Tools.Pickaxe, ISaveElement,IItemInfo, ICustomObject { public BasicItemInformation info; public Texture2DExtended workingTexture; @@ -195,14 +196,6 @@ namespace Revitalize.Framework.Objects.Items.Tools //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); } - public Dictionary getAdditionalSaveData() - { - Dictionary serializedInfo = new Dictionary(); - serializedInfo.Add("id", this.ItemInfo); - serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); - return serializedInfo; - } public override bool beginUsing(GameLocation location, int x, int y, Farmer who) { @@ -248,15 +241,11 @@ namespace Revitalize.Framework.Objects.Items.Tools return new PickaxeExtended(this.info.Copy(), this.UpgradeLevel,this.workingTexture.Copy()); } - public virtual object getReplacement() - { - return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel }; - } - public virtual void rebuild(Dictionary additionalSaveData, object replacement) + + public override bool canBeTrashed() { - this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + return true; } @@ -302,5 +291,40 @@ namespace Revitalize.Framework.Objects.Items.Tools return false; } } + + public virtual ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + PickaxeExtended p = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + return p; + } + + + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + serializedInfo.Add("GUID", this.guid.ToString()); + serializedInfo.Add("Level", this.UpgradeLevel.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public virtual object getReplacement() + { + Chest c = new Chest(true); + c.playerChoiceColor.Value = Color.Magenta; + c.TileLocation = new Vector2(0, 0); + return c; + } + + public virtual void rebuild(Dictionary additionalSaveData, object replacement) + { + //ModCore.log("REBULD THE PICKAXE!!!!!!!"); + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]); + //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 c9f2534f..b573b220 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs @@ -10,12 +10,13 @@ using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.Interfaces; using Revitalize.Framework.Utilities; using StardewValley; +using StardewValley.Objects; using StardewValley.Tools; using StardustCore.UIUtilities; namespace Revitalize.Framework.Objects.Items.Tools { - public class WateringCanExtended:StardewValley.Tools.WateringCan, ISaveElement, IItemInfo + public class WateringCanExtended:StardewValley.Tools.WateringCan, ISaveElement, IItemInfo, ICustomObject { public BasicItemInformation info; public Texture2DExtended workingTexture; @@ -195,15 +196,6 @@ namespace Revitalize.Framework.Objects.Items.Tools //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); } - public Dictionary getAdditionalSaveData() - { - Dictionary serializedInfo = new Dictionary(); - serializedInfo.Add("id", this.ItemInfo); - serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); - return serializedInfo; - } - public override bool beginUsing(GameLocation location, int x, int y, Farmer who) { this.updateInfo(); @@ -248,18 +240,6 @@ namespace Revitalize.Framework.Objects.Items.Tools return new WateringCanExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy(),this.waterCanMax); } - public object getReplacement() - { - return new StardewValley.Tools.WateringCan { UpgradeLevel = this.UpgradeLevel, waterCanMax=this.waterCanMax }; - } - - public void rebuild(Dictionary additionalSaveData, object replacement) - { - this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); - this.upgradeLevel.Value = (replacement as WateringCan).UpgradeLevel; - } - - /// /// Updates the info on the item. /// @@ -302,5 +282,42 @@ namespace Revitalize.Framework.Objects.Items.Tools return false; } } + + public virtual ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + WateringCanExtended p = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + return p; + } + public Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("id", this.ItemInfo); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + serializedInfo.Add("GUID", this.guid.ToString()); + serializedInfo.Add("Level", this.UpgradeLevel.ToString()); + Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return serializedInfo; + } + + public virtual object getReplacement() + { + Chest c = new Chest(true); + c.playerChoiceColor.Value = Color.Magenta; + c.TileLocation = new Vector2(0, 0); + return c; + } + + public virtual void rebuild(Dictionary additionalSaveData, object replacement) + { + //ModCore.log("REBULD THE PICKAXE!!!!!!!"); + this.info = ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]); + //this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; + + } + public override bool canBeTrashed() + { + return base.canBeTrashed(); + } } } From 95593e93edd7bdeaff790c74be3731a83efb31b9 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 15:27:15 -0700 Subject: [PATCH 75/98] Created liquid manager. Will test later. --- .../Revitalize/Framework/Enums/Enums.cs | 9 + .../Framework/Utilities/LiquidManager.cs | 321 ++++++++++++++++++ .../Framework/Utilities/LocationUtilities.cs | 7 + GeneralMods/Revitalize/Revitalize.csproj | 1 + 4 files changed, 338 insertions(+) create mode 100644 GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index 81814f93..80b4c76d 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -35,6 +35,15 @@ namespace Revitalize.Framework Storage } + public enum LiquidInteractionType + { + None, + Produces, + Consumes, + Transfers, + Storage + } + /// /// References Stardew Valley Object id's for easier coding. /// diff --git a/GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs b/GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs new file mode 100644 index 00000000..290ba787 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs @@ -0,0 +1,321 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Utilities +{ + public class Liquid + { + public string name; + public Color liquidColor; + public int amount; + public int capacity; + + public string liquidDisplayString + { + get + { + StringBuilder b = new StringBuilder(); + b.Append(this.amount); + b.Append("/"); + b.Append(this.capacity); + return b.ToString(); + } + } + + public int capacityRemaining + { + get + { + return this.capacity - this.amount; + } + } + + /// + /// Returns the energy remaining as a percent value. + /// + public double liquidPercentRemaining + { + get + { + return (double)this.amount / (double)this.capacity; + } + } + + public bool IsEmpty + { + get + { + return this.amount == 0; + } + } + + public bool IsFull + { + get + { + return this.amount == this.capacity; + } + } + + + public Liquid() + { + + } + + public Liquid(string Name, Color liquidColor, int Capacity) + { + this.name = Name; + this.liquidColor = liquidColor; + this.capacity = Capacity; + } + + public Liquid(string Name, Color liquidColor, int Amount, int Capacity) + { + this.name = Name; + this.liquidColor = liquidColor; + this.capacity = Capacity; + this.amount = Amount; + } + + public void produceLiquid(int amount) + { + this.amount = Math.Min(this.capacity, this.amount + amount); + } + + public void consumeLiquid(int amount) + { + this.amount = Math.Max(0, this.amount - amount); + } + + + /// + /// Checks to see if this energy source has enough energy remaining. + /// + /// + /// + public bool hasEnoughLiquid(int Required) + { + return this.amount >= Required; + } + + public Liquid Copy() + { + return new Liquid(this.name, this.liquidColor, 0, this.capacity); + } + } + + public class LiquidManager + { + + + + public bool requiresUpdate; + /// + /// How does this energy manager interface energy systems. + /// + public Enums.LiquidInteractionType liquidInteractionType; + + /// + /// Checks to see if this energy manager consumes energy. + /// + public bool consumesLiquid + { + get + { + return this.liquidInteractionType == Enums.LiquidInteractionType.Consumes; + } + } + /// + /// Checks to see if this energy manager produces energy. + /// + public bool producesLiquid + { + get + { + return this.liquidInteractionType == Enums.LiquidInteractionType.Produces; + } + } + + /// + /// Checks to see if this energy manager transfers energy. + /// + public bool transfersLiquid + { + get + { + return this.liquidInteractionType == Enums.LiquidInteractionType.Transfers; + } + } + + public int MaxPossibleAmountOfLiquids; + public Dictionary liquids; + public List acceptedLiquid; + + public LiquidManager() + { + + } + + public LiquidManager(Enums.LiquidInteractionType LiquidType) : this(1, LiquidType) + { + } + + public LiquidManager(int NumberOfPossibleFluids, Enums.LiquidInteractionType liquidInteractionType) + { + this.liquidInteractionType = liquidInteractionType; + this.MaxPossibleAmountOfLiquids = NumberOfPossibleFluids; + this.liquids = new Dictionary(); + } + + + public void consumeLiquid(int amount, string LiquidName) + { + + this.GetLiquid(LiquidName, out Liquid selfLiquid); + if (selfLiquid == null) return; + + selfLiquid.consumeLiquid(amount); + this.requiresUpdate = true; + if (selfLiquid.IsEmpty) + { + this.liquids.Remove(selfLiquid.name); + } + } + + public void produceLiquid(int amount, string LiquidName,Liquid L) + { + this.GetLiquid(LiquidName, out Liquid selfLiquid); + if (selfLiquid == null) + { + this.AddLiquid(L); + this.GetLiquid(LiquidName, out Liquid selfLiquid2); + selfLiquid2.produceLiquid(amount); + this.requiresUpdate = true; + return; + } + + selfLiquid.produceLiquid(amount); + this.requiresUpdate = true; + } + + public void AddLiquid(Liquid M) + { + if (this.liquids.ContainsKey(M.name)) + { + this.liquids[M.name].produceLiquid(M.amount); + this.requiresUpdate = true; + } + else + { + if (this.canReceieveThisLiquid(M)) + { + this.liquids.Add(M.name, M); + } + } + } + + public void GetLiquid(string Name, out Liquid Liquid) + { + Liquid = new Liquid(); + if (this.liquids.ContainsKey(Name)) + { + this.liquids.TryGetValue(Name, out Liquid); + } + } + + public void transferLiquidFromAnother(LiquidManager other, string LiquidName, int amount) + { + other.GetLiquid(LiquidName, out Liquid OtherLiquid); + if (OtherLiquid == null) return; + if (this.canReceieveThisLiquid(OtherLiquid)) + { + int actualAmount = Math.Min(amount, OtherLiquid.amount); + + this.GetLiquid(LiquidName, out Liquid SelfLiquid); + + int selfCapacity = SelfLiquid!=null? SelfLiquid.capacityRemaining:OtherLiquid.amount; + this.produceLiquid(actualAmount, OtherLiquid.name,OtherLiquid.Copy()); + other.consumeLiquid(Math.Min(actualAmount, selfCapacity),OtherLiquid.name); + } + else + { + return; + } + } + + public void transferLiquidToAnother(LiquidManager other, string LiquidName, int amount) + { + this.GetLiquid(LiquidName, out Liquid SelfLiquid); + if (SelfLiquid == null) return; + if (other.canReceieveThisLiquid(SelfLiquid)) + { + int actualAmount = Math.Min(amount, SelfLiquid.amount); + + this.GetLiquid(LiquidName, out Liquid OtherLiquid); + int selfCapacity =OtherLiquid != null ? OtherLiquid.capacityRemaining : SelfLiquid.amount; + + other.produceLiquid(Math.Min(actualAmount, selfCapacity), SelfLiquid.name,SelfLiquid.Copy()); + this.consumeLiquid(Math.Min(actualAmount, selfCapacity),SelfLiquid.name); + } + else + { + return; + } + } + + public LiquidManager Copy() + { + return new LiquidManager(this.MaxPossibleAmountOfLiquids, this.liquidInteractionType); + } + + public bool canReceieveThisLiquid(Liquid M) + { + if (M == null) return false; + if (this.liquids.Count < this.MaxPossibleAmountOfLiquids) return true; + if (this.liquids.Values.ToList().FindAll(L => L.name == M.name).Count > 0) return true; + if (this.acceptedLiquid.FindAll(L => L.name == M.name).Count > 0) return true; + + return false; + } + + public bool hasLiquid(string Name) + { + if (this.liquids.ContainsKey(Name)) + { + return true; + } + else return false; + } + + public bool doesLiquidHaveVolume(string Name) + { + if (this.liquids.ContainsKey(Name)) + { + if (this.liquids[Name].amount > 0) return true; + return false; + } + else return false; + } + + public bool doesLiquidHaveEnough(string LiquidName,int Amount) + { + this.GetLiquid(LiquidName, out Liquid selfLiquid); + if (selfLiquid == null) return false; + if (selfLiquid.amount >= Amount) return true; + else return false; + } + + public bool canThisLiquidReceiveMoreVolume(string LiquidName, int Amount) + { + this.GetLiquid(LiquidName, out Liquid selfLiquid); + if (selfLiquid == null) return false; + if (selfLiquid.IsFull) return false; + else return true; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs index 6d485cc5..4d040e34 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs @@ -140,5 +140,12 @@ namespace Revitalize.Framework.Utilities } return locations; } + + public static bool IsThereWaterAtThisTile(GameLocation location, int X, int Y) + { + if ( location.doesTileHaveProperty((int)X, (int)Y, "Water", "Back") == null) + return false; + return true; + } } } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 2fa41e63..fed97860 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -183,6 +183,7 @@ + From d8b144eac976cf056015eb49387dbcc7722ea49b Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 16:58:56 -0700 Subject: [PATCH 76/98] Rewrote the liquid manager to be way more managable. Will implement later. --- .../Framework/Managers/LiquidManagerV2.cs | 475 ++++++++++++++++++ .../Framework/Utilities/LiquidManager.cs | 321 ------------ GeneralMods/Revitalize/Revitalize.csproj | 2 +- 3 files changed, 476 insertions(+), 322 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs delete mode 100644 GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs diff --git a/GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs new file mode 100644 index 00000000..3c6468b6 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs @@ -0,0 +1,475 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Managers +{ + /// + /// A liquid used for various mod purposes. + /// + public class Liquid + { + /// + /// The name of the liquid. + /// + public string name; + /// + /// The color for the liquid. + /// + public Color color; + + /// + /// Constructor. + /// + public Liquid() + { + + } + + /// + /// Constructor. + /// + /// + /// + public Liquid(string Name, Color LiquidColor) + { + this.name = Name; + this.color = LiquidColor; + } + + /// + /// Liquid comparison check to see if two liquids are the same. + /// + /// + /// + public bool isLiquidHomogenous(Liquid Other) + { + if (this.name.Equals(Other.name)) return true; + return false; + } + + /// + /// Copys over the liquid. + /// + /// + public Liquid Copy() + { + return new Liquid(this.name, this.color); + } + } + + public class MachineLiquidTank + { + /// + /// The liquid inside of the tank. + /// + public Liquid liquid; + /// + /// How much liquid is inside the tank currently. + /// + public int amount; + /// + /// How much liquid the tank can hold. + /// + public int capacity; + + /// + /// The remaining capacity on the tank. + /// + + public int remainingCapacity + { + get + { + return this.capacity - this.amount; + } + } + + /// + /// Checks to see if this tank is full. + /// + public bool IsFull + { + get + { + return this.amount == this.capacity; + } + } + + /// + /// Checks if there is fluid inside the tank. + /// + public bool IsEmpty + { + get + { + return this.amount == 0; + } + } + /// + /// Constructor. + /// + public MachineLiquidTank() + { + + } + + /// + /// Constructor. + /// + /// + public MachineLiquidTank(int Capacity) + { + this.capacity = Capacity; + this.amount = 0; + this.liquid = null; + } + + /// + /// Constructor. + /// + /// + /// + /// + public MachineLiquidTank(int Capacity, int Amount, Liquid Liquid) + { + this.capacity = Capacity; + this.amount = Amount; + this.liquid = Liquid; + } + + /// + /// Checks to see if this tank can recieve this liquid. + /// + /// + /// + public bool CanRecieveThisLiquid(Liquid L) + { + if (this.IsFull) return false; + if (this.liquid == null) return true; + if (this.liquid.isLiquidHomogenous(L)) return true; + if (this.IsEmpty) return true; + else return false; + } + + /// + /// Takes in liquid into this tank. + /// + /// + /// + public void intakeLiquid(Liquid L, int Amount) + { + if (this.CanRecieveThisLiquid(L)) + { + if (this.liquid == null) this.liquid = L.Copy(); + else + { + int intakeAmount=Math.Min(this.remainingCapacity, Amount); + this.amount = this.amount + intakeAmount; + } + } + else return; + } + /// + /// Consumes, aka reduces the internal liquid on this tank by the amount given or the amount remaining in the tank. + /// + /// + public void consumeLiquid(int Amount) + { + if (this.IsEmpty) return; + if (this.liquid == null) return; + int consumeAmount = Math.Min(this.amount, Amount); + this.amount = this.amount - consumeAmount; + if (this.amount <= 0) this.liquid = null; + } + + /// + /// Checks to see if this tank has enough + /// + /// + /// + /// + public bool DoesThisTankHaveEnoughLiquid(Liquid L, int Amount) + { + if (this.GetAmountOfLiquidInThisTank(L) >= Amount) return true; + return false; + } + + /// + /// Drains the tank completly + /// + public void emptyTank() + { + this.liquid = null; + this.amount = 0; + } + + /// + /// Gets the amount of liquid in this tank for the given liquid. + /// + /// + /// Returns 0 if the tank doesn't contain liquid of the same type. Otherwise returns the amount stored in the tank. + public int GetAmountOfLiquidInThisTank(Liquid L) + { + if (this.liquid == null) return 0; + if (this.liquid.isLiquidHomogenous(L)) return this.amount; + return 0; + } + + /// + /// Gets the amount of liquid this take can take in in acordance with the parameter liquid. + /// + /// + /// + public int GetAmountOfLiquidThisTankCanReceieve(Liquid L) + { + if (this.liquid == null) return this.capacity; + if (this.liquid.isLiquidHomogenous(L)) return this.remainingCapacity; + return 0; + } + + /// + /// Checks to see if this tank contains this liquid at all. + /// + /// + /// + public bool DoesTankContainThisLiquid(Liquid L) + { + if (this.liquid == null) return false; + if (this.liquid.isLiquidHomogenous(L)) return true; + return false; + } + + } + public class LiquidManagerV2 + { + public MachineLiquidTank inputTank1; + public MachineLiquidTank inputTank2; + public MachineLiquidTank outputTank; + + public bool needsUpdate; + + /// + /// Does this machine allow the same fluid in both tanks? + /// + public bool allowDoubleInput; + + public LiquidManagerV2() + { + this.inputTank1 = new MachineLiquidTank(0); + this.inputTank2 = new MachineLiquidTank(0); + this.outputTank = new MachineLiquidTank(0); + this.needsUpdate = false; + } + + /// + /// Constructor. + /// + /// + /// + /// Can both input tanks store the same liquid? + public LiquidManagerV2(int Capacity, bool OnlyOutput, bool AllowDoubleInput=false) + { + if (OnlyOutput) + { + this.outputTank = new MachineLiquidTank(Capacity); + this.inputTank1 = new MachineLiquidTank(0); + this.inputTank2 = new MachineLiquidTank(0); + + } + else + { + this.outputTank = new MachineLiquidTank(Capacity); + this.inputTank1 = new MachineLiquidTank(Capacity); + this.inputTank2 = new MachineLiquidTank(Capacity); + } + this.allowDoubleInput = AllowDoubleInput; + this.needsUpdate = false; + } + + /// + /// Produces a given amount of liquid and puts it into the output tank for this liquid manager. + /// + /// + /// + public void produceLiquid(Liquid L, int Amount) + { + if (this.outputTank.CanRecieveThisLiquid(L)) + { + this.outputTank.intakeLiquid(L, Amount); + this.needsUpdate = true; + } + } + + /// + /// Intakes liquid into the input takes on this liquid manager. + /// + /// + /// + public void intakeLiquid(Liquid L, int Amount) + { + int remainingAmount = Amount; + if (this.allowDoubleInput) + { + if (this.inputTank1.CanRecieveThisLiquid(L) && remainingAmount>0) + { + int allowedAmount = this.inputTank1.remainingCapacity; + this.inputTank1.intakeLiquid(L, remainingAmount); + remainingAmount -= allowedAmount; + } + if (this.inputTank2.CanRecieveThisLiquid(L)&& remainingAmount>0) + { + int allowedAmount = this.inputTank2.remainingCapacity; + this.inputTank2.intakeLiquid(L, remainingAmount); + remainingAmount -= allowedAmount; + } + this.needsUpdate = true; + } + else + { + + if (this.inputTank1.CanRecieveThisLiquid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisLiquid(L)==false) + { + int allowedAmount = this.inputTank1.remainingCapacity; + this.inputTank1.intakeLiquid(L, remainingAmount); + remainingAmount -= allowedAmount; + this.needsUpdate = true; + return; + } + if (this.inputTank2.CanRecieveThisLiquid(L) && remainingAmount > 0 && this.inputTank1.DoesTankContainThisLiquid(L) == false) + { + int allowedAmount = this.inputTank2.remainingCapacity; + this.inputTank2.intakeLiquid(L, remainingAmount); + remainingAmount -= allowedAmount; + this.needsUpdate = true; + return; + } + } + + } + + /// + /// Consumes the liquid in the input tanks. Mainly used for machine processing but shouldn't be drained outwards. + /// + /// + /// + public void consumeLiquid(Liquid L, int Amount) + { + if (this.doTheInputTanksHaveEnoughLiquid(L, Amount) == false) return; + + int requiredAmount = Amount; + int tank1Amount = this.inputTank1.GetAmountOfLiquidInThisTank(L); + int tank2Amount= this.inputTank2.GetAmountOfLiquidInThisTank(L); + if (tank1Amount > 0 && requiredAmount>0) + { + this.inputTank1.consumeLiquid(requiredAmount); + requiredAmount -= tank1Amount; + this.needsUpdate = true; + + } + if(tank2Amount>0 && requiredAmount > 0) + { + this.inputTank2.consumeLiquid(requiredAmount); + requiredAmount -= tank2Amount; + this.needsUpdate = true; + } + //Consumes liquid from both tanks if double input is enabled. Otherwise it only drains from the appropriate tank. + } + + public void drainOutputTank(int Amount) + { + this.outputTank.consumeLiquid(Amount); + if (this.outputTank.IsEmpty) this.outputTank.liquid = null; + this.needsUpdate = true; + } + + /// + /// Checks to see if the input tanks have enough liquid combined to process the request. + /// + /// + /// + /// + public bool doTheInputTanksHaveEnoughLiquid(Liquid L, int Amount) + { + int tankTotals = this.inputTank1.GetAmountOfLiquidInThisTank(L) + this.inputTank2.GetAmountOfLiquidInThisTank(L); + if (tankTotals >= Amount) return true; + else return false; + } + + /// + /// Gets the total amount of liquid that the input tanks can recieve + /// + /// + /// + public int getMaxAmountOfLiquidIntakePossible(Liquid L) + { + + if (this.allowDoubleInput) + { + int amount = 0; + amount += this.inputTank1.GetAmountOfLiquidThisTankCanReceieve(L); + amount += this.inputTank2.GetAmountOfLiquidThisTankCanReceieve(L); + } + else + { + if(this.inputTank1.CanRecieveThisLiquid(L) && this.inputTank2.DoesTankContainThisLiquid(L) == false) + { + return this.inputTank1.GetAmountOfLiquidThisTankCanReceieve(L); + } + if (this.inputTank1.CanRecieveThisLiquid(L) && this.inputTank2.DoesTankContainThisLiquid(L) == false) + { + return this.inputTank2.GetAmountOfLiquidThisTankCanReceieve(L); + } + } + return 0; + } + + /// + /// Checks to see if the input tanks on this liquid manager have the capacity to take in this liquid at all. + /// + /// + /// + public bool canRecieveThisLiquid(Liquid L) + { + if (L == null) return false; + if (this.allowDoubleInput) + { + if (this.inputTank1.CanRecieveThisLiquid(L) || this.inputTank2.CanRecieveThisLiquid(L)) + { + return true; + } + } + else + { + if (this.inputTank1.CanRecieveThisLiquid(L) && this.inputTank2.DoesTankContainThisLiquid(L) == false) + { + return false; + } + if (this.inputTank2.CanRecieveThisLiquid(L) && this.inputTank1.DoesTankContainThisLiquid(L) == false) + { + return true; + } + } + return false; + + } + + /// + /// Takes the fluid in this output tank and tries to transfer it to another liquid manager who has an tank available. + /// + /// + public void outputLiquidToOtherSources(LiquidManagerV2 Other) + { + if (this.outputTank.liquid == null) return; + if (Other.canRecieveThisLiquid(this.outputTank.liquid)) + { + int actualAmount = Math.Min(this.outputTank.amount, Other.getMaxAmountOfLiquidIntakePossible(this.outputTank.liquid)); + Other.intakeLiquid(this.outputTank.liquid,actualAmount); + this.drainOutputTank(actualAmount); + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs b/GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs deleted file mode 100644 index 290ba787..00000000 --- a/GeneralMods/Revitalize/Framework/Utilities/LiquidManager.cs +++ /dev/null @@ -1,321 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; - -namespace Revitalize.Framework.Utilities -{ - public class Liquid - { - public string name; - public Color liquidColor; - public int amount; - public int capacity; - - public string liquidDisplayString - { - get - { - StringBuilder b = new StringBuilder(); - b.Append(this.amount); - b.Append("/"); - b.Append(this.capacity); - return b.ToString(); - } - } - - public int capacityRemaining - { - get - { - return this.capacity - this.amount; - } - } - - /// - /// Returns the energy remaining as a percent value. - /// - public double liquidPercentRemaining - { - get - { - return (double)this.amount / (double)this.capacity; - } - } - - public bool IsEmpty - { - get - { - return this.amount == 0; - } - } - - public bool IsFull - { - get - { - return this.amount == this.capacity; - } - } - - - public Liquid() - { - - } - - public Liquid(string Name, Color liquidColor, int Capacity) - { - this.name = Name; - this.liquidColor = liquidColor; - this.capacity = Capacity; - } - - public Liquid(string Name, Color liquidColor, int Amount, int Capacity) - { - this.name = Name; - this.liquidColor = liquidColor; - this.capacity = Capacity; - this.amount = Amount; - } - - public void produceLiquid(int amount) - { - this.amount = Math.Min(this.capacity, this.amount + amount); - } - - public void consumeLiquid(int amount) - { - this.amount = Math.Max(0, this.amount - amount); - } - - - /// - /// Checks to see if this energy source has enough energy remaining. - /// - /// - /// - public bool hasEnoughLiquid(int Required) - { - return this.amount >= Required; - } - - public Liquid Copy() - { - return new Liquid(this.name, this.liquidColor, 0, this.capacity); - } - } - - public class LiquidManager - { - - - - public bool requiresUpdate; - /// - /// How does this energy manager interface energy systems. - /// - public Enums.LiquidInteractionType liquidInteractionType; - - /// - /// Checks to see if this energy manager consumes energy. - /// - public bool consumesLiquid - { - get - { - return this.liquidInteractionType == Enums.LiquidInteractionType.Consumes; - } - } - /// - /// Checks to see if this energy manager produces energy. - /// - public bool producesLiquid - { - get - { - return this.liquidInteractionType == Enums.LiquidInteractionType.Produces; - } - } - - /// - /// Checks to see if this energy manager transfers energy. - /// - public bool transfersLiquid - { - get - { - return this.liquidInteractionType == Enums.LiquidInteractionType.Transfers; - } - } - - public int MaxPossibleAmountOfLiquids; - public Dictionary liquids; - public List acceptedLiquid; - - public LiquidManager() - { - - } - - public LiquidManager(Enums.LiquidInteractionType LiquidType) : this(1, LiquidType) - { - } - - public LiquidManager(int NumberOfPossibleFluids, Enums.LiquidInteractionType liquidInteractionType) - { - this.liquidInteractionType = liquidInteractionType; - this.MaxPossibleAmountOfLiquids = NumberOfPossibleFluids; - this.liquids = new Dictionary(); - } - - - public void consumeLiquid(int amount, string LiquidName) - { - - this.GetLiquid(LiquidName, out Liquid selfLiquid); - if (selfLiquid == null) return; - - selfLiquid.consumeLiquid(amount); - this.requiresUpdate = true; - if (selfLiquid.IsEmpty) - { - this.liquids.Remove(selfLiquid.name); - } - } - - public void produceLiquid(int amount, string LiquidName,Liquid L) - { - this.GetLiquid(LiquidName, out Liquid selfLiquid); - if (selfLiquid == null) - { - this.AddLiquid(L); - this.GetLiquid(LiquidName, out Liquid selfLiquid2); - selfLiquid2.produceLiquid(amount); - this.requiresUpdate = true; - return; - } - - selfLiquid.produceLiquid(amount); - this.requiresUpdate = true; - } - - public void AddLiquid(Liquid M) - { - if (this.liquids.ContainsKey(M.name)) - { - this.liquids[M.name].produceLiquid(M.amount); - this.requiresUpdate = true; - } - else - { - if (this.canReceieveThisLiquid(M)) - { - this.liquids.Add(M.name, M); - } - } - } - - public void GetLiquid(string Name, out Liquid Liquid) - { - Liquid = new Liquid(); - if (this.liquids.ContainsKey(Name)) - { - this.liquids.TryGetValue(Name, out Liquid); - } - } - - public void transferLiquidFromAnother(LiquidManager other, string LiquidName, int amount) - { - other.GetLiquid(LiquidName, out Liquid OtherLiquid); - if (OtherLiquid == null) return; - if (this.canReceieveThisLiquid(OtherLiquid)) - { - int actualAmount = Math.Min(amount, OtherLiquid.amount); - - this.GetLiquid(LiquidName, out Liquid SelfLiquid); - - int selfCapacity = SelfLiquid!=null? SelfLiquid.capacityRemaining:OtherLiquid.amount; - this.produceLiquid(actualAmount, OtherLiquid.name,OtherLiquid.Copy()); - other.consumeLiquid(Math.Min(actualAmount, selfCapacity),OtherLiquid.name); - } - else - { - return; - } - } - - public void transferLiquidToAnother(LiquidManager other, string LiquidName, int amount) - { - this.GetLiquid(LiquidName, out Liquid SelfLiquid); - if (SelfLiquid == null) return; - if (other.canReceieveThisLiquid(SelfLiquid)) - { - int actualAmount = Math.Min(amount, SelfLiquid.amount); - - this.GetLiquid(LiquidName, out Liquid OtherLiquid); - int selfCapacity =OtherLiquid != null ? OtherLiquid.capacityRemaining : SelfLiquid.amount; - - other.produceLiquid(Math.Min(actualAmount, selfCapacity), SelfLiquid.name,SelfLiquid.Copy()); - this.consumeLiquid(Math.Min(actualAmount, selfCapacity),SelfLiquid.name); - } - else - { - return; - } - } - - public LiquidManager Copy() - { - return new LiquidManager(this.MaxPossibleAmountOfLiquids, this.liquidInteractionType); - } - - public bool canReceieveThisLiquid(Liquid M) - { - if (M == null) return false; - if (this.liquids.Count < this.MaxPossibleAmountOfLiquids) return true; - if (this.liquids.Values.ToList().FindAll(L => L.name == M.name).Count > 0) return true; - if (this.acceptedLiquid.FindAll(L => L.name == M.name).Count > 0) return true; - - return false; - } - - public bool hasLiquid(string Name) - { - if (this.liquids.ContainsKey(Name)) - { - return true; - } - else return false; - } - - public bool doesLiquidHaveVolume(string Name) - { - if (this.liquids.ContainsKey(Name)) - { - if (this.liquids[Name].amount > 0) return true; - return false; - } - else return false; - } - - public bool doesLiquidHaveEnough(string LiquidName,int Amount) - { - this.GetLiquid(LiquidName, out Liquid selfLiquid); - if (selfLiquid == null) return false; - if (selfLiquid.amount >= Amount) return true; - else return false; - } - - public bool canThisLiquidReceiveMoreVolume(string LiquidName, int Amount) - { - this.GetLiquid(LiquidName, out Liquid selfLiquid); - if (selfLiquid == null) return false; - if (selfLiquid.IsFull) return false; - else return true; - } - - } -} diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index fed97860..5064cbbf 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -88,6 +88,7 @@ + @@ -183,7 +184,6 @@ - From a33a39a7851393ea90b17c13b425a36e1a4cc66d Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 23 Sep 2019 17:33:28 -0700 Subject: [PATCH 77/98] Renamed liquid manager to fluid manager for correctness. --- .../{LiquidManagerV2.cs => FluidManagerV2.cs} | 228 +++++++++--------- .../Framework/Objects/BasicItemInformation.cs | 9 +- 2 files changed, 121 insertions(+), 116 deletions(-) rename GeneralMods/Revitalize/Framework/Managers/{LiquidManagerV2.cs => FluidManagerV2.cs} (52%) diff --git a/GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs similarity index 52% rename from GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs rename to GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs index 3c6468b6..e7c0d16f 100644 --- a/GeneralMods/Revitalize/Framework/Managers/LiquidManagerV2.cs +++ b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs @@ -8,23 +8,23 @@ using Microsoft.Xna.Framework; namespace Revitalize.Framework.Managers { /// - /// A liquid used for various mod purposes. + /// A Fluid used for various mod purposes. /// - public class Liquid + public class Fluid { /// - /// The name of the liquid. + /// The name of the Fluid. /// public string name; /// - /// The color for the liquid. + /// The color for the Fluid. /// public Color color; /// /// Constructor. /// - public Liquid() + public Fluid() { } @@ -33,46 +33,46 @@ namespace Revitalize.Framework.Managers /// Constructor. /// /// - /// - public Liquid(string Name, Color LiquidColor) + /// + public Fluid(string Name, Color FluidColor) { this.name = Name; - this.color = LiquidColor; + this.color = FluidColor; } /// - /// Liquid comparison check to see if two liquids are the same. + /// Fluid comparison check to see if two Fluids are the same. /// /// /// - public bool isLiquidHomogenous(Liquid Other) + public bool isFluidHomogenous(Fluid Other) { if (this.name.Equals(Other.name)) return true; return false; } /// - /// Copys over the liquid. + /// Copys over the Fluid. /// /// - public Liquid Copy() + public Fluid Copy() { - return new Liquid(this.name, this.color); + return new Fluid(this.name, this.color); } } - public class MachineLiquidTank + public class MachineFluidTank { /// - /// The liquid inside of the tank. + /// The Fluid inside of the tank. /// - public Liquid liquid; + public Fluid fluid; /// - /// How much liquid is inside the tank currently. + /// How much Fluid is inside the tank currently. /// public int amount; /// - /// How much liquid the tank can hold. + /// How much Fluid the tank can hold. /// public int capacity; @@ -112,7 +112,7 @@ namespace Revitalize.Framework.Managers /// /// Constructor. /// - public MachineLiquidTank() + public MachineFluidTank() { } @@ -121,11 +121,11 @@ namespace Revitalize.Framework.Managers /// Constructor. /// /// - public MachineLiquidTank(int Capacity) + public MachineFluidTank(int Capacity) { this.capacity = Capacity; this.amount = 0; - this.liquid = null; + this.fluid = null; } /// @@ -133,38 +133,38 @@ namespace Revitalize.Framework.Managers /// /// /// - /// - public MachineLiquidTank(int Capacity, int Amount, Liquid Liquid) + /// + public MachineFluidTank(int Capacity, int Amount, Fluid Fluid) { this.capacity = Capacity; this.amount = Amount; - this.liquid = Liquid; + this.fluid = Fluid; } /// - /// Checks to see if this tank can recieve this liquid. + /// Checks to see if this tank can recieve this Fluid. /// /// /// - public bool CanRecieveThisLiquid(Liquid L) + public bool CanRecieveThisFluid(Fluid L) { if (this.IsFull) return false; - if (this.liquid == null) return true; - if (this.liquid.isLiquidHomogenous(L)) return true; + if (this.fluid == null) return true; + if (this.fluid.isFluidHomogenous(L)) return true; if (this.IsEmpty) return true; else return false; } /// - /// Takes in liquid into this tank. + /// Takes in Fluid into this tank. /// /// /// - public void intakeLiquid(Liquid L, int Amount) + public void intakeFluid(Fluid L, int Amount) { - if (this.CanRecieveThisLiquid(L)) + if (this.CanRecieveThisFluid(L)) { - if (this.liquid == null) this.liquid = L.Copy(); + if (this.fluid == null) this.fluid = L.Copy(); else { int intakeAmount=Math.Min(this.remainingCapacity, Amount); @@ -174,16 +174,16 @@ namespace Revitalize.Framework.Managers else return; } /// - /// Consumes, aka reduces the internal liquid on this tank by the amount given or the amount remaining in the tank. + /// Consumes, aka reduces the internal Fluid on this tank by the amount given or the amount remaining in the tank. /// /// - public void consumeLiquid(int Amount) + public void consumeFluid(int Amount) { if (this.IsEmpty) return; - if (this.liquid == null) return; + if (this.fluid == null) return; int consumeAmount = Math.Min(this.amount, Amount); this.amount = this.amount - consumeAmount; - if (this.amount <= 0) this.liquid = null; + if (this.amount <= 0) this.fluid = null; } /// @@ -192,9 +192,9 @@ namespace Revitalize.Framework.Managers /// /// /// - public bool DoesThisTankHaveEnoughLiquid(Liquid L, int Amount) + public bool DoesThisTankHaveEnoughFluid(Fluid L, int Amount) { - if (this.GetAmountOfLiquidInThisTank(L) >= Amount) return true; + if (this.GetAmountOfFluidInThisTank(L) >= Amount) return true; return false; } @@ -203,52 +203,52 @@ namespace Revitalize.Framework.Managers /// public void emptyTank() { - this.liquid = null; + this.fluid = null; this.amount = 0; } /// - /// Gets the amount of liquid in this tank for the given liquid. + /// Gets the amount of Fluid in this tank for the given Fluid. /// /// - /// Returns 0 if the tank doesn't contain liquid of the same type. Otherwise returns the amount stored in the tank. - public int GetAmountOfLiquidInThisTank(Liquid L) + /// Returns 0 if the tank doesn't contain Fluid of the same type. Otherwise returns the amount stored in the tank. + public int GetAmountOfFluidInThisTank(Fluid L) { - if (this.liquid == null) return 0; - if (this.liquid.isLiquidHomogenous(L)) return this.amount; + if (this.fluid == null) return 0; + if (this.fluid.isFluidHomogenous(L)) return this.amount; return 0; } /// - /// Gets the amount of liquid this take can take in in acordance with the parameter liquid. + /// Gets the amount of Fluid this take can take in in acordance with the parameter Fluid. /// /// /// - public int GetAmountOfLiquidThisTankCanReceieve(Liquid L) + public int GetAmountOfFluidThisTankCanReceieve(Fluid L) { - if (this.liquid == null) return this.capacity; - if (this.liquid.isLiquidHomogenous(L)) return this.remainingCapacity; + if (this.fluid == null) return this.capacity; + if (this.fluid.isFluidHomogenous(L)) return this.remainingCapacity; return 0; } /// - /// Checks to see if this tank contains this liquid at all. + /// Checks to see if this tank contains this Fluid at all. /// /// /// - public bool DoesTankContainThisLiquid(Liquid L) + public bool DoesTankContainThisFluid(Fluid L) { - if (this.liquid == null) return false; - if (this.liquid.isLiquidHomogenous(L)) return true; + if (this.fluid == null) return false; + if (this.fluid.isFluidHomogenous(L)) return true; return false; } } - public class LiquidManagerV2 + public class FluidManagerV2 { - public MachineLiquidTank inputTank1; - public MachineLiquidTank inputTank2; - public MachineLiquidTank outputTank; + public MachineFluidTank inputTank1; + public MachineFluidTank inputTank2; + public MachineFluidTank outputTank; public bool needsUpdate; @@ -257,11 +257,11 @@ namespace Revitalize.Framework.Managers /// public bool allowDoubleInput; - public LiquidManagerV2() + public FluidManagerV2() { - this.inputTank1 = new MachineLiquidTank(0); - this.inputTank2 = new MachineLiquidTank(0); - this.outputTank = new MachineLiquidTank(0); + this.inputTank1 = new MachineFluidTank(0); + this.inputTank2 = new MachineFluidTank(0); + this.outputTank = new MachineFluidTank(0); this.needsUpdate = false; } @@ -270,60 +270,60 @@ namespace Revitalize.Framework.Managers /// /// /// - /// Can both input tanks store the same liquid? - public LiquidManagerV2(int Capacity, bool OnlyOutput, bool AllowDoubleInput=false) + /// Can both input tanks store the same Fluid? + public FluidManagerV2(int Capacity, bool OnlyOutput, bool AllowDoubleInput=false) { if (OnlyOutput) { - this.outputTank = new MachineLiquidTank(Capacity); - this.inputTank1 = new MachineLiquidTank(0); - this.inputTank2 = new MachineLiquidTank(0); + this.outputTank = new MachineFluidTank(Capacity); + this.inputTank1 = new MachineFluidTank(0); + this.inputTank2 = new MachineFluidTank(0); } else { - this.outputTank = new MachineLiquidTank(Capacity); - this.inputTank1 = new MachineLiquidTank(Capacity); - this.inputTank2 = new MachineLiquidTank(Capacity); + this.outputTank = new MachineFluidTank(Capacity); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); } this.allowDoubleInput = AllowDoubleInput; this.needsUpdate = false; } /// - /// Produces a given amount of liquid and puts it into the output tank for this liquid manager. + /// Produces a given amount of Fluid and puts it into the output tank for this Fluid manager. /// /// /// - public void produceLiquid(Liquid L, int Amount) + public void produceFluid(Fluid L, int Amount) { - if (this.outputTank.CanRecieveThisLiquid(L)) + if (this.outputTank.CanRecieveThisFluid(L)) { - this.outputTank.intakeLiquid(L, Amount); + this.outputTank.intakeFluid(L, Amount); this.needsUpdate = true; } } /// - /// Intakes liquid into the input takes on this liquid manager. + /// Intakes Fluid into the input takes on this Fluid manager. /// /// /// - public void intakeLiquid(Liquid L, int Amount) + public void intakeFluid(Fluid L, int Amount) { int remainingAmount = Amount; if (this.allowDoubleInput) { - if (this.inputTank1.CanRecieveThisLiquid(L) && remainingAmount>0) + if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount>0) { int allowedAmount = this.inputTank1.remainingCapacity; - this.inputTank1.intakeLiquid(L, remainingAmount); + this.inputTank1.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; } - if (this.inputTank2.CanRecieveThisLiquid(L)&& remainingAmount>0) + if (this.inputTank2.CanRecieveThisFluid(L)&& remainingAmount>0) { int allowedAmount = this.inputTank2.remainingCapacity; - this.inputTank2.intakeLiquid(L, remainingAmount); + this.inputTank2.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; } this.needsUpdate = true; @@ -331,18 +331,18 @@ namespace Revitalize.Framework.Managers else { - if (this.inputTank1.CanRecieveThisLiquid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisLiquid(L)==false) + if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisFluid(L)==false) { int allowedAmount = this.inputTank1.remainingCapacity; - this.inputTank1.intakeLiquid(L, remainingAmount); + this.inputTank1.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; this.needsUpdate = true; return; } - if (this.inputTank2.CanRecieveThisLiquid(L) && remainingAmount > 0 && this.inputTank1.DoesTankContainThisLiquid(L) == false) + if (this.inputTank2.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank1.DoesTankContainThisFluid(L) == false) { int allowedAmount = this.inputTank2.remainingCapacity; - this.inputTank2.intakeLiquid(L, remainingAmount); + this.inputTank2.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; this.needsUpdate = true; return; @@ -352,103 +352,103 @@ namespace Revitalize.Framework.Managers } /// - /// Consumes the liquid in the input tanks. Mainly used for machine processing but shouldn't be drained outwards. + /// Consumes the Fluid in the input tanks. Mainly used for machine processing but shouldn't be drained outwards. /// /// /// - public void consumeLiquid(Liquid L, int Amount) + public void consumeFluid(Fluid L, int Amount) { - if (this.doTheInputTanksHaveEnoughLiquid(L, Amount) == false) return; + if (this.doTheInputTanksHaveEnoughFluid(L, Amount) == false) return; int requiredAmount = Amount; - int tank1Amount = this.inputTank1.GetAmountOfLiquidInThisTank(L); - int tank2Amount= this.inputTank2.GetAmountOfLiquidInThisTank(L); + int tank1Amount = this.inputTank1.GetAmountOfFluidInThisTank(L); + int tank2Amount= this.inputTank2.GetAmountOfFluidInThisTank(L); if (tank1Amount > 0 && requiredAmount>0) { - this.inputTank1.consumeLiquid(requiredAmount); + this.inputTank1.consumeFluid(requiredAmount); requiredAmount -= tank1Amount; this.needsUpdate = true; } if(tank2Amount>0 && requiredAmount > 0) { - this.inputTank2.consumeLiquid(requiredAmount); + this.inputTank2.consumeFluid(requiredAmount); requiredAmount -= tank2Amount; this.needsUpdate = true; } - //Consumes liquid from both tanks if double input is enabled. Otherwise it only drains from the appropriate tank. + //Consumes Fluid from both tanks if double input is enabled. Otherwise it only drains from the appropriate tank. } public void drainOutputTank(int Amount) { - this.outputTank.consumeLiquid(Amount); - if (this.outputTank.IsEmpty) this.outputTank.liquid = null; + this.outputTank.consumeFluid(Amount); + if (this.outputTank.IsEmpty) this.outputTank.fluid = null; this.needsUpdate = true; } /// - /// Checks to see if the input tanks have enough liquid combined to process the request. + /// Checks to see if the input tanks have enough Fluid combined to process the request. /// /// /// /// - public bool doTheInputTanksHaveEnoughLiquid(Liquid L, int Amount) + public bool doTheInputTanksHaveEnoughFluid(Fluid L, int Amount) { - int tankTotals = this.inputTank1.GetAmountOfLiquidInThisTank(L) + this.inputTank2.GetAmountOfLiquidInThisTank(L); + int tankTotals = this.inputTank1.GetAmountOfFluidInThisTank(L) + this.inputTank2.GetAmountOfFluidInThisTank(L); if (tankTotals >= Amount) return true; else return false; } /// - /// Gets the total amount of liquid that the input tanks can recieve + /// Gets the total amount of Fluid that the input tanks can recieve /// /// /// - public int getMaxAmountOfLiquidIntakePossible(Liquid L) + public int getMaxAmountOfFluidIntakePossible(Fluid L) { if (this.allowDoubleInput) { int amount = 0; - amount += this.inputTank1.GetAmountOfLiquidThisTankCanReceieve(L); - amount += this.inputTank2.GetAmountOfLiquidThisTankCanReceieve(L); + amount += this.inputTank1.GetAmountOfFluidThisTankCanReceieve(L); + amount += this.inputTank2.GetAmountOfFluidThisTankCanReceieve(L); } else { - if(this.inputTank1.CanRecieveThisLiquid(L) && this.inputTank2.DoesTankContainThisLiquid(L) == false) + if(this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false) { - return this.inputTank1.GetAmountOfLiquidThisTankCanReceieve(L); + return this.inputTank1.GetAmountOfFluidThisTankCanReceieve(L); } - if (this.inputTank1.CanRecieveThisLiquid(L) && this.inputTank2.DoesTankContainThisLiquid(L) == false) + if (this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false) { - return this.inputTank2.GetAmountOfLiquidThisTankCanReceieve(L); + return this.inputTank2.GetAmountOfFluidThisTankCanReceieve(L); } } return 0; } /// - /// Checks to see if the input tanks on this liquid manager have the capacity to take in this liquid at all. + /// Checks to see if the input tanks on this Fluid manager have the capacity to take in this Fluid at all. /// /// /// - public bool canRecieveThisLiquid(Liquid L) + public bool canRecieveThisFluid(Fluid L) { if (L == null) return false; if (this.allowDoubleInput) { - if (this.inputTank1.CanRecieveThisLiquid(L) || this.inputTank2.CanRecieveThisLiquid(L)) + if (this.inputTank1.CanRecieveThisFluid(L) || this.inputTank2.CanRecieveThisFluid(L)) { return true; } } else { - if (this.inputTank1.CanRecieveThisLiquid(L) && this.inputTank2.DoesTankContainThisLiquid(L) == false) + if (this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false) { return false; } - if (this.inputTank2.CanRecieveThisLiquid(L) && this.inputTank1.DoesTankContainThisLiquid(L) == false) + if (this.inputTank2.CanRecieveThisFluid(L) && this.inputTank1.DoesTankContainThisFluid(L) == false) { return true; } @@ -458,16 +458,16 @@ namespace Revitalize.Framework.Managers } /// - /// Takes the fluid in this output tank and tries to transfer it to another liquid manager who has an tank available. + /// Takes the fluid in this output tank and tries to transfer it to another Fluid manager who has an tank available. /// /// - public void outputLiquidToOtherSources(LiquidManagerV2 Other) + public void outputFluidToOtherSources(FluidManagerV2 Other) { - if (this.outputTank.liquid == null) return; - if (Other.canRecieveThisLiquid(this.outputTank.liquid)) + if (this.outputTank.fluid == null) return; + if (Other.canRecieveThisFluid(this.outputTank.fluid)) { - int actualAmount = Math.Min(this.outputTank.amount, Other.getMaxAmountOfLiquidIntakePossible(this.outputTank.liquid)); - Other.intakeLiquid(this.outputTank.liquid,actualAmount); + int actualAmount = Math.Min(this.outputTank.amount, Other.getMaxAmountOfFluidIntakePossible(this.outputTank.fluid)); + Other.intakeFluid(this.outputTank.fluid,actualAmount); this.drainOutputTank(actualAmount); } } diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 3f3609ae..8ab2f8c3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -352,7 +352,7 @@ namespace Revitalize.Framework.Objects } - public ColorManager _colorManager; + private ColorManager _colorManager; public ColorManager ColorManager { @@ -367,6 +367,9 @@ namespace Revitalize.Framework.Objects } } + public LiquidManagerV2 fluidManager; + + [JsonIgnore] public bool requiresUpdate; public BasicItemInformation() @@ -392,9 +395,10 @@ namespace Revitalize.Framework.Objects this.EnergyManager = new Energy.EnergyManager(); this._alwaysDrawAbovePlayer = false; this.ColorManager = new ColorManager(Enums.DyeBlendMode.Blend, 0.5f); + this.fluidManager = new LiquidManagerV2(); } - public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null, ColorManager ColorManager=null) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null, ColorManager ColorManager=null,LiquidManagerV2 LiquidManager=null) { this.name = name; this.id = id; @@ -429,6 +433,7 @@ namespace Revitalize.Framework.Objects this.DyedColor = DyedColor ?? new NamedColor("", new Color(0, 0, 0, 0)); this.ColorManager = ColorManager ?? new ColorManager(Enums.DyeBlendMode.Blend, 0.5f); + this.fluidManager = LiquidManager ?? new LiquidManagerV2(); } /// From 0a676166f56d1451e800f161ef1e6e1673f61221 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 23 Sep 2019 18:13:45 -0700 Subject: [PATCH 78/98] implemented code to search out fluids in the network. --- .../Revitalize/Framework/Enums/Enums.cs | 5 +- .../Framework/Managers/FluidManagerV2.cs | 57 +++++-- .../Framework/Objects/BasicItemInformation.cs | 18 +- .../Framework/Objects/CustomObject.cs | 11 ++ .../Framework/Objects/MultiTiledComponent.cs | 155 ++++++++++++++++++ 5 files changed, 226 insertions(+), 20 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Enums/Enums.cs b/GeneralMods/Revitalize/Framework/Enums/Enums.cs index 80b4c76d..21e67fb0 100644 --- a/GeneralMods/Revitalize/Framework/Enums/Enums.cs +++ b/GeneralMods/Revitalize/Framework/Enums/Enums.cs @@ -35,11 +35,10 @@ namespace Revitalize.Framework Storage } - public enum LiquidInteractionType + public enum FluidInteractionType { None, - Produces, - Consumes, + Machine, Transfers, Storage } diff --git a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs index e7c0d16f..9158f1af 100644 --- a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs +++ b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs @@ -250,19 +250,36 @@ namespace Revitalize.Framework.Managers public MachineFluidTank inputTank2; public MachineFluidTank outputTank; - public bool needsUpdate; + public bool requiresUpdate; /// /// Does this machine allow the same fluid in both tanks? /// public bool allowDoubleInput; + public bool onlyOutput; + /// + /// The capacity for the fluid tanks. + /// + public int tankCapacity; + + public Enums.FluidInteractionType fluidInteractionType; + + public bool InteractsWithFluids + { + get + { + return this.fluidInteractionType != Enums.FluidInteractionType.None; + } + } + public FluidManagerV2() { this.inputTank1 = new MachineFluidTank(0); this.inputTank2 = new MachineFluidTank(0); this.outputTank = new MachineFluidTank(0); - this.needsUpdate = false; + this.requiresUpdate = false; + this.fluidInteractionType = Enums.FluidInteractionType.None; } /// @@ -271,7 +288,7 @@ namespace Revitalize.Framework.Managers /// /// /// Can both input tanks store the same Fluid? - public FluidManagerV2(int Capacity, bool OnlyOutput, bool AllowDoubleInput=false) + public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput=false) { if (OnlyOutput) { @@ -286,8 +303,10 @@ namespace Revitalize.Framework.Managers this.inputTank1 = new MachineFluidTank(Capacity); this.inputTank2 = new MachineFluidTank(Capacity); } + this.onlyOutput = OnlyOutput; this.allowDoubleInput = AllowDoubleInput; - this.needsUpdate = false; + this.requiresUpdate = false; + this.fluidInteractionType = LiquidInteractionType; } /// @@ -300,7 +319,7 @@ namespace Revitalize.Framework.Managers if (this.outputTank.CanRecieveThisFluid(L)) { this.outputTank.intakeFluid(L, Amount); - this.needsUpdate = true; + this.requiresUpdate = true; } } @@ -326,7 +345,7 @@ namespace Revitalize.Framework.Managers this.inputTank2.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; } - this.needsUpdate = true; + this.requiresUpdate = true; } else { @@ -336,7 +355,7 @@ namespace Revitalize.Framework.Managers int allowedAmount = this.inputTank1.remainingCapacity; this.inputTank1.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; - this.needsUpdate = true; + this.requiresUpdate = true; return; } if (this.inputTank2.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank1.DoesTankContainThisFluid(L) == false) @@ -344,7 +363,7 @@ namespace Revitalize.Framework.Managers int allowedAmount = this.inputTank2.remainingCapacity; this.inputTank2.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; - this.needsUpdate = true; + this.requiresUpdate = true; return; } } @@ -367,14 +386,14 @@ namespace Revitalize.Framework.Managers { this.inputTank1.consumeFluid(requiredAmount); requiredAmount -= tank1Amount; - this.needsUpdate = true; + this.requiresUpdate = true; } if(tank2Amount>0 && requiredAmount > 0) { this.inputTank2.consumeFluid(requiredAmount); requiredAmount -= tank2Amount; - this.needsUpdate = true; + this.requiresUpdate = true; } //Consumes Fluid from both tanks if double input is enabled. Otherwise it only drains from the appropriate tank. } @@ -383,7 +402,7 @@ namespace Revitalize.Framework.Managers { this.outputTank.consumeFluid(Amount); if (this.outputTank.IsEmpty) this.outputTank.fluid = null; - this.needsUpdate = true; + this.requiresUpdate = true; } /// @@ -471,5 +490,21 @@ namespace Revitalize.Framework.Managers this.drainOutputTank(actualAmount); } } + + /// + /// Checks to see if this output tank has the corresponding fluid and if the amount is greater than 0. + /// + /// + /// + public bool doesThisOutputTankContainThisFluid(Fluid F) + { + if (this.outputTank.GetAmountOfFluidInThisTank(F) > 0) return true; + else return false; + } + + public FluidManagerV2 Copy() + { + return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput,this.fluidInteractionType,this.allowDoubleInput); + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 8ab2f8c3..08e5f5b5 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -367,7 +367,7 @@ namespace Revitalize.Framework.Objects } } - public LiquidManagerV2 fluidManager; + public FluidManagerV2 fluidManager; [JsonIgnore] @@ -395,10 +395,10 @@ namespace Revitalize.Framework.Objects this.EnergyManager = new Energy.EnergyManager(); this._alwaysDrawAbovePlayer = false; this.ColorManager = new ColorManager(Enums.DyeBlendMode.Blend, 0.5f); - this.fluidManager = new LiquidManagerV2(); + this.fluidManager = new FluidManagerV2(); } - public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null, ColorManager ColorManager=null,LiquidManagerV2 LiquidManager=null) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights,Energy.EnergyManager EnergyManager=null,bool AlwaysDrawAbovePlayer=false,NamedColor DyedColor=null, ColorManager ColorManager=null,FluidManagerV2 FluidManager=null) { this.name = name; this.id = id; @@ -433,7 +433,7 @@ namespace Revitalize.Framework.Objects this.DyedColor = DyedColor ?? new NamedColor("", new Color(0, 0, 0, 0)); this.ColorManager = ColorManager ?? new ColorManager(Enums.DyeBlendMode.Blend, 0.5f); - this.fluidManager = LiquidManager ?? new LiquidManagerV2(); + this.fluidManager = FluidManager ?? new FluidManagerV2(); } /// @@ -451,12 +451,12 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy()); } public bool requiresSyncUpdate() { - return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate() || this.energyManagerRequiresUpdate() || this.colorManagerRequiresUpdate(); + return this.requiresUpdate || this.animationManagerRequiresUpdate() || this.inventoryManagerRequiresUpdate() || this.lightManagerRequiresUpdate() || this.energyManagerRequiresUpdate() || this.colorManagerRequiresUpdate() || this.fluidManagerRequiresUpdate(); } public void forceUpdate() @@ -502,6 +502,12 @@ namespace Revitalize.Framework.Objects else return this._colorManager.requiresUpdate; } + private bool fluidManagerRequiresUpdate() + { + if (this.fluidManager == null) return false; + else return this.fluidManager.requiresUpdate; + } + public void cleanAfterUpdate() { this.requiresUpdate = false; diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 1ba2ede8..75e48276 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -11,6 +11,7 @@ using StardewValley.Objects; using Revitalize.Framework.Utilities; using Revitalize.Framework.Energy; using Revitalize.Framework.Illuminate; +using Revitalize.Framework.Managers; namespace Revitalize.Framework.Objects { @@ -778,5 +779,15 @@ namespace Revitalize.Framework.Objects { this.info.inventory = Manager; } + + public virtual ref FluidManagerV2 GetFluidManager() + { + return ref this.info.fluidManager; + } + + public virtual void SetFluidManager(FluidManagerV2 FluidManager) + { + this.info.fluidManager = FluidManager; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index e25f0024..d98e1afe 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Energy; +using Revitalize.Framework.Managers; using Revitalize.Framework.Utilities; using StardewValley; using StardewValley.Objects; @@ -656,6 +657,160 @@ namespace Revitalize.Framework.Objects } + public override ref FluidManagerV2 GetFluidManager() + { + if (this.info == null || this.containerObject == null) + { + this.updateInfo(); + if (this.containerObject == null) return ref this.info.fluidManager; + return ref this.containerObject.info.fluidManager; + } + return ref this.containerObject.info.fluidManager; + } + + public override void SetFluidManager(FluidManagerV2 FluidManager) + { + this.info.fluidManager = FluidManager; + } + + + /// + /// Gets corresponding neighbor objects that can interact with fluid. + /// + /// + protected virtual List GetNeighboringFluidManagers() + { + Vector2 tileLocation = this.TileLocation; + List customObjects = new List(); + if (this.location != null) + { + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i == j || i == (-j)) continue; + + Vector2 neighborTile = tileLocation + new Vector2(i, j); + if (this.location.isObjectAtTile((int)neighborTile.X, (int)neighborTile.Y)) + { + StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); + if (obj is MultiTiledComponent) + { + if ((obj as MultiTiledComponent).GetFluidManager().InteractsWithFluids) + { + customObjects.Add((MultiTiledComponent)obj); + } + } + else continue; + } + } + } + } + return customObjects; + } + + /// + /// Searches a network of fluid managers to see if any of these fluid managers have an output tank with the corresponding fluid. + /// + /// + /// + protected virtual List FluidGraphSearchForFluidFromOutputTanks(Fluid L) + { + List fluidSources = new List(); + List searchedComponents = new List(); + List entitiesToSearch = new List(); + entitiesToSearch.AddRange(this.GetNeighboringFluidManagers()); + searchedComponents.Add(this); + while (entitiesToSearch.Count > 0) + { + MultiTiledComponent searchComponent = entitiesToSearch[0]; + entitiesToSearch.Remove(searchComponent); + if (searchedComponents.Contains(searchComponent)) + { + continue; + } + else + { + searchedComponents.Add(searchComponent); + entitiesToSearch.AddRange(searchComponent.GetNeighboringFluidManagers()); + + if (searchComponent.containerObject.info.fluidManager.doesThisOutputTankContainThisFluid(L)) + { + fluidSources.Add(searchComponent.containerObject); + } + } + + } + return fluidSources; + } + + protected virtual List FluidGraphSearchInputTanksThatCanAcceptThisFluid(Fluid L) + { + List fluidSources = new List(); + List searchedComponents = new List(); + List entitiesToSearch = new List(); + entitiesToSearch.AddRange(this.GetNeighboringFluidManagers()); + searchedComponents.Add(this); + while (entitiesToSearch.Count > 0) + { + MultiTiledComponent searchComponent = entitiesToSearch[0]; + entitiesToSearch.Remove(searchComponent); + if (searchedComponents.Contains(searchComponent)) + { + continue; + } + else + { + searchedComponents.Add(searchComponent); + entitiesToSearch.AddRange(searchComponent.GetNeighboringFluidManagers()); + + if (searchComponent.containerObject.info.fluidManager.canRecieveThisFluid(L)) + { + fluidSources.Add(searchComponent.containerObject); + } + } + + } + return fluidSources; + } + + /// + /// Searches for output tanks that have the corresponding fluid and tries to drain from them. + /// + /// + public void pullFluidFromNetworkOutputs(Fluid L) + { + List energySources = this.FluidGraphSearchForFluidFromOutputTanks(L); + + int index = 0; + + for (int i = 0; i < energySources.Count; i++) + { + FluidManagerV2 other = energySources[i].GetFluidManager(); + other.outputFluidToOtherSources(this.GetFluidManager()); + if (this.GetFluidManager().canRecieveThisFluid(L)==false) break; //Since we already check for valid tanks this will basically check again to see if the tanks are full. + } + } + + /// + /// Searches for output tanks that have the corresponding fluid and tries to drain from them. + /// + /// + /// + public void pullFluidFromNetworkOutputs(List FluidSources,Fluid L) + { + List energySources = FluidSources; + + int index = 0; + + for (int i = 0; i < energySources.Count; i++) + { + FluidManagerV2 other = energySources[i].GetFluidManager(); + other.outputFluidToOtherSources(this.GetFluidManager()); + if (this.GetFluidManager().canRecieveThisFluid(L) == false) break; //Since we already check for valid tanks this will basically check again to see if the tanks are full. + } + } + public override bool requiresUpdate() { if (this.info.requiresSyncUpdate() || this.containerObject.info.requiresSyncUpdate()) From 43eb60e9b9445abb92293d2454b2b499b8f4609e Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 24 Sep 2019 15:18:57 -0700 Subject: [PATCH 79/98] Added in fluids to resource manager. Got fluid pump able to be placed in water, added in infinite reach for placing custom objects. --- .../Menus/EnergyMenu/DropletColored.png | Bin 0 -> 180 bytes .../Menus/EnergyMenu/DropletOutline.png | Bin 0 -> 127 bytes .../Graphics/Objects/Machines/WaterPump.png | Bin 0 -> 317 bytes .../Framework/Managers/FluidManagerV2.cs | 47 ++-- .../Menus/Machines/MachineSummaryMenu.cs | 39 ++- .../Framework/Objects/Machines/WaterPump.cs | 242 ++++++++++++++++++ .../Framework/Objects/MultiTiledComponent.cs | 17 +- .../Framework/Objects/MultiTiledObject.cs | 8 +- .../Framework/Objects/ObjectManager.cs | 7 + .../Framework/Objects/ResourceManager.cs | 25 ++ .../Revitalize/Framework/Player/PlayerInfo.cs | 1 + .../Framework/Utilities/PlayerUtilities.cs | 2 +- GeneralMods/Revitalize/ModCore.cs | 26 +- GeneralMods/Revitalize/Revitalize.csproj | 15 +- 14 files changed, 400 insertions(+), 29 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/DropletColored.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/DropletOutline.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/WaterPump.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/WaterPump.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/DropletColored.png b/GeneralMods/Revitalize/Content/Graphics/Menus/EnergyMenu/DropletColored.png new file mode 100644 index 0000000000000000000000000000000000000000..0d11814a5987769c5adcdf450938ae5b4922cc40 GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|@;qG}Lo9l) zPVyEypupkm%>V4+$ArSgeew?GbNx2A?(qzGz@KDN!f7t85H``@rd!{-}^dp zA{;mOKx=WZb%T;IWaZOATZHQ z(7O1!{^6FB{+-4LTv}%~PMkPVF!Ig+|NkQncWCI}iJ8!5+|X&{V4EnWtY^6)_%3wSH}4*Y#to&HWZjG(Btu(vM9WUNJDp%#OM~{r91xz#w4o MboFyt=akR{0KGken*aa+ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs index 9158f1af..ffec6dc4 100644 --- a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs +++ b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs @@ -79,7 +79,7 @@ namespace Revitalize.Framework.Managers /// /// The remaining capacity on the tank. /// - + public int remainingCapacity { get @@ -109,6 +109,21 @@ namespace Revitalize.Framework.Managers return this.amount == 0; } } + + public string getFluidDisplayString() + { + StringBuilder b = new StringBuilder(); + if (this.fluid != null) + { + b.Append(this.fluid.name); + b.Append(": "); + } + b.Append(this.amount); + b.Append("/"); + b.Append(this.capacity); + return b.ToString(); + } + /// /// Constructor. /// @@ -165,11 +180,9 @@ namespace Revitalize.Framework.Managers if (this.CanRecieveThisFluid(L)) { if (this.fluid == null) this.fluid = L.Copy(); - else - { - int intakeAmount=Math.Min(this.remainingCapacity, Amount); - this.amount = this.amount + intakeAmount; - } + int intakeAmount = Math.Min(this.remainingCapacity, Amount); + this.amount = this.amount + intakeAmount; + } else return; } @@ -288,7 +301,7 @@ namespace Revitalize.Framework.Managers /// /// /// Can both input tanks store the same Fluid? - public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput=false) + public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput = false) { if (OnlyOutput) { @@ -333,13 +346,13 @@ namespace Revitalize.Framework.Managers int remainingAmount = Amount; if (this.allowDoubleInput) { - if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount>0) + if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0) { int allowedAmount = this.inputTank1.remainingCapacity; this.inputTank1.intakeFluid(L, remainingAmount); remainingAmount -= allowedAmount; } - if (this.inputTank2.CanRecieveThisFluid(L)&& remainingAmount>0) + if (this.inputTank2.CanRecieveThisFluid(L) && remainingAmount > 0) { int allowedAmount = this.inputTank2.remainingCapacity; this.inputTank2.intakeFluid(L, remainingAmount); @@ -350,7 +363,7 @@ namespace Revitalize.Framework.Managers else { - if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisFluid(L)==false) + if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisFluid(L) == false) { int allowedAmount = this.inputTank1.remainingCapacity; this.inputTank1.intakeFluid(L, remainingAmount); @@ -381,15 +394,15 @@ namespace Revitalize.Framework.Managers int requiredAmount = Amount; int tank1Amount = this.inputTank1.GetAmountOfFluidInThisTank(L); - int tank2Amount= this.inputTank2.GetAmountOfFluidInThisTank(L); - if (tank1Amount > 0 && requiredAmount>0) + int tank2Amount = this.inputTank2.GetAmountOfFluidInThisTank(L); + if (tank1Amount > 0 && requiredAmount > 0) { this.inputTank1.consumeFluid(requiredAmount); requiredAmount -= tank1Amount; this.requiresUpdate = true; } - if(tank2Amount>0 && requiredAmount > 0) + if (tank2Amount > 0 && requiredAmount > 0) { this.inputTank2.consumeFluid(requiredAmount); requiredAmount -= tank2Amount; @@ -434,7 +447,7 @@ namespace Revitalize.Framework.Managers } else { - if(this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false) + if (this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false) { return this.inputTank1.GetAmountOfFluidThisTankCanReceieve(L); } @@ -473,7 +486,7 @@ namespace Revitalize.Framework.Managers } } return false; - + } /// @@ -486,7 +499,7 @@ namespace Revitalize.Framework.Managers if (Other.canRecieveThisFluid(this.outputTank.fluid)) { int actualAmount = Math.Min(this.outputTank.amount, Other.getMaxAmountOfFluidIntakePossible(this.outputTank.fluid)); - Other.intakeFluid(this.outputTank.fluid,actualAmount); + Other.intakeFluid(this.outputTank.fluid, actualAmount); this.drainOutputTank(actualAmount); } } @@ -504,7 +517,7 @@ namespace Revitalize.Framework.Managers public FluidManagerV2 Copy() { - return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput,this.fluidInteractionType,this.allowDoubleInput); + return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput, this.fluidInteractionType, this.allowDoubleInput); } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index d812cff6..79f7a64d 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -51,6 +51,12 @@ namespace Revitalize.Framework.Menus.Machines private AnimatedButton storageButton; private Vector2 storageRemainingDisplayLocation; + + private AnimatedButton inputFluidTank1Button; + private AnimatedButton inputFluidTank2Button; + private AnimatedButton outputFluidTankButton; + private Vector2 fluidDisplayLocation; + private int requiredEnergyPer10Min; private EnergyManager energy @@ -89,6 +95,7 @@ namespace Revitalize.Framework.Menus.Machines this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f)); this.energyRequiredDisplayLocation = this.timeDisplayLocation + new Vector2(0, 64); this.storageRemainingDisplayLocation = this.energyRequiredDisplayLocation + new Vector2(0, 64); + this.fluidDisplayLocation = this.storageRemainingDisplayLocation + new Vector2(0, 64); this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4); this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); @@ -99,6 +106,12 @@ namespace Revitalize.Framework.Menus.Machines this.energyRequiredButton=new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Energy Required", this.energyRequiredDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "LightningBolt"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); this.storageButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Storage Remaining", this.storageRemainingDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Chest"), new StardustCore.Animations.Animation(0, 0, 16, 32)), Color.White), new Rectangle(0, 0, 16, 32), 1f); + + this.inputFluidTank1Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 1 fluid:", this.fluidDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu",this.objectSource.info.fluidManager.inputTank1.fluid!=null? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank1.fluid!=null ? this.objectSource.info.fluidManager.inputTank1.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + this.inputFluidTank2Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 2 fluid:", this.fluidDisplayLocation+new Vector2(0,64), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.inputTank2.fluid!=null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank2.fluid!=null ? this.objectSource.info.fluidManager.inputTank2.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + ModCore.log(this.objectSource.info.fluidManager.outputTank.fluid != null ? "Color of fluid:" + this.objectSource.info.fluidManager.outputTank.fluid.color.ToString() : "Color is null!"); + this.outputFluidTankButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Output fluid:", this.fluidDisplayLocation+new Vector2(0,128), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.outputTank.fluid!=null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.outputTank.fluid!=null ? this.objectSource.info.fluidManager.outputTank.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + this.requiredEnergyPer10Min = RequiredEnergyPer10Min; } @@ -160,20 +173,38 @@ namespace Revitalize.Framework.Menus.Machines { this.batteryBackground.draw(b, 1f, 1f); this.energyMeterColorSwap(); - b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale)+ (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f,1f), SpriteEffects.None, 0.2f); + b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale) + (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f, 1f), SpriteEffects.None, 0.2f); this.battergyEnergyGuage.draw(b, 1f, 1f); this.energyRequiredButton.draw(b); - b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min+" E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black); + b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min + " E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black); } if (this.objectSource.info.inventory.HasInventory) { this.storageButton.draw(b); - b.DrawString(Game1.smallFont, "Storage remaining: "+ (this.objectSource.info.inventory.capacity-this.objectSource.info.inventory.ItemCount)+"/"+this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black); + b.DrawString(Game1.smallFont, "Storage remaining: " + (this.objectSource.info.inventory.capacity - this.objectSource.info.inventory.ItemCount) + "/" + this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black); } - + if (this.objectSource.info.fluidManager.InteractsWithFluids) + { + if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + { + this.inputFluidTank1Button.draw(b); + b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 0f), Color.Black); + } + if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + { + this.inputFluidTank2Button.draw(b); + b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 64f), Color.Black); + } + if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + { + //ModCore.log("Color:" + this.objectSource.GetFluidManager().outputTank.fluid.color); + this.outputFluidTankButton.draw(b); + b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 128f), Color.Black); + } + } this.objectSource.drawFullyInMenu(b, new Vector2((int)(this.xPositionOnScreen + (this.width / 2) - (this.itemDisplayOffset.X / 2)), (int)(this.yPositionOnScreen + 128f)), .24f); Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/WaterPump.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/WaterPump.cs new file mode 100644 index 00000000..5118dbd4 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/WaterPump.cs @@ -0,0 +1,242 @@ +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 PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines +{ + public class WaterPump: Machine + { + + public WaterPump() { } + + public WaterPump(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + + } + + public WaterPump(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) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public WaterPump(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) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + + this.animationManager.prepareForNextUpdateTick(); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + + this.updateInfo(); + //ModCore.log(this.info.animationManager.currentAnimationName); + + if (this.updatesContainerObjectForProduction) + { + //ModCore.log("Update container object for production!"); + //this.MinutesUntilReady -= minutes; + int remaining = minutes; + //ModCore.log("Minutes elapsed: " + remaining); + while (remaining > 0) + { + if (LocationUtilities.IsThereWaterAtThisTile(environment, (int)this.TileLocation.X, (int)this.TileLocation.Y)) + { + this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Water"), 100); + } + remaining -= 10; + } + + return false; + } + return false; + + //return base.minutesElapsed(minutes, environment); + } + + public override bool canBePlacedInWater() + { + return true; + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + this.createMachineMenu(); + return true; + } + + public override Item getOne() + { + WaterPump component = new WaterPump(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + WaterPump self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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 + { + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void updateInfo() + { + return; + if (this.info == null || this.containerObject == null) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + //this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + //this.containerObject.updateInfo(); + //ModCore.log("Force an update for machine: " + this.info.name); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index d98e1afe..cc210ffd 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -122,10 +122,24 @@ namespace Revitalize.Framework.Objects return base.checkForAction(who, justCheckingForActivity); } + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + return base.canBePlacedHere(l, tile); + } + + + public override bool clicked(Farmer who) { //ModCore.log("Clicked a multiTiledComponent!"); - this.containerObject.pickUp(who); + if (ModCore.playerInfo.justPlacedACustomObject == true) return false; + if (PlayerUtilities.CanPlayerInventoryReceiveThisItem(this.containerObject)) { + this.containerObject.pickUp(who); + } + else + { + return false; + } return true; //return base.clicked(who); } @@ -180,6 +194,7 @@ namespace Revitalize.Framework.Objects location.objects.Add(this.TileLocation, this); + if(this.getBoundingBox(this.TileLocation).Width==0&& this.getBoundingBox(this.TileLocation).Height == 0) { this.boundingBox.Value = new Rectangle(this.boundingBox.X, this.boundingBox.Y, Game1.tileSize, Game1.tileSize); diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 0c0a7e3c..dfb69b9e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -257,8 +257,8 @@ namespace Revitalize.Framework.Objects //Revitalize.ModCore.log(new Vector2(x + ((int)pair.Key.X), y + ((int)pair.Key.Y))); if ((pair.Value as MultiTiledComponent).info.ignoreBoundingBox) { - x *= -1; - y *= -1; + //x *= -1; + //y *= -1; } (pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f); //break; @@ -283,10 +283,10 @@ namespace Revitalize.Framework.Objects { if ((pair.Value as MultiTiledComponent).info.lightManager != null) { - ModCore.log("Let there be light."); + //ModCore.log("Let there be light."); if ((pair.Value as MultiTiledComponent).info.lightManager.lightsOn == true) { - ModCore.log("Got a light???"); + //ModCore.log("Got a light???"); } } (pair.Value as MultiTiledComponent).removeFromLocation(who.currentLocation, pair.Key); diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index a0a591d8..c8fe7ba3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -331,6 +331,13 @@ namespace Revitalize.Framework.Objects alloyFurnace.addComponent(new Vector2(0, 1), alloyFurnace_0_1); this.AddItem("AlloyFurnace", alloyFurnace); + + MultiTiledObject waterPumpV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false))); + WaterPump waterPumpV1_0_0 = new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + WaterPump waterPumpV1_0_1= new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, ""); + waterPumpV1.addComponent(new Vector2(0, 0), waterPumpV1_0_0); + waterPumpV1.addComponent(new Vector2(0, 1), waterPumpV1_0_1); + this.AddItem("WaterPumpV1", waterPumpV1); } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 9df39c04..3547061a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using Microsoft.Xna.Framework; using Revitalize.Framework.Factories.Objects.Resources; +using Revitalize.Framework.Managers; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Objects.Items.Resources; using Revitalize.Framework.Objects.Resources.OreVeins; @@ -33,6 +34,7 @@ namespace Revitalize.Framework.Objects public Dictionary resources; public Dictionary miningDrillResources; + public Dictionary fluids; /// /// A list of all visited floors on the current visit to the mines. @@ -51,6 +53,7 @@ namespace Revitalize.Framework.Objects this.visitedFloors = new List(); this.resources = new Dictionary(); this.miningDrillResources = new Dictionary(); + this.fluids = new Dictionary(); } @@ -62,8 +65,13 @@ namespace Revitalize.Framework.Objects this.serializeOreVeins(); this.loadOreVeins(); this.loadInMiningDrillLootTable(); + this.loadInFluidDictionary(); } + private void loadInFluidDictionary() + { + this.fluids.Add("Water", new Fluid("Water", Color.Blue)); + } private void loadInMiningDrillLootTable() { this.miningDrillResources.Add("Bauxite", new ResourceInformation(this.getResource("Bauxite"), ModCore.Configs.miningDrillConfig.amountOfBauxiteToMine.min, ModCore.Configs.miningDrillConfig.amountOfBauxiteToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.bauxiteMineChance, 0, 0, 0, 0)); @@ -380,6 +388,23 @@ namespace Revitalize.Framework.Objects } } + /// + /// Gets a fluid from the fluid dictionary. + /// + /// + /// + public Fluid getFluid(string name) + { + if (this.fluids.ContainsKey(name)) + { + return this.fluids[name].Copy(); + } + else + { + return null; + } + } + /// /// Get a resource from the resource maanger. /// diff --git a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs index 275e6355..49a46b24 100644 --- a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs +++ b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs @@ -6,6 +6,7 @@ namespace Revitalize.Framework.Player { public SittingInfo sittingInfo; public MagicManager magicManager; + public bool justPlacedACustomObject; public PlayerInfo() { diff --git a/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs index d27be79e..95f6a807 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/PlayerUtilities.cs @@ -24,7 +24,7 @@ namespace Revitalize.Framework.Utilities for(int i = 0; i < Game1.player.Items.Count; i++) { if (I == Game1.player.Items[i]) return true; - if (I == null) return true; + if (Game1.player.Items[i] == null) return true; if (I.canStackWith(Game1.player.Items[i])) return true; } return false; diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index ec8c98f2..a2e494a8 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -275,7 +275,7 @@ namespace Revitalize ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage; ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.ResetNormalToolsColorOnLeftClick; - + ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed1; ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory; @@ -285,6 +285,28 @@ namespace Revitalize CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary(); } + private void Input_ButtonPressed1(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) + { + if(e.Button== SButton.MouseLeft) + { + if (Game1.player != null) + { + if (Game1.activeClickableMenu != null || Game1.eventUp || Game1.currentMinigame != null) return; + if(Game1.player.ActiveObject is CustomObject) + { + if((Game1.player.ActiveObject as CustomObject).canBePlacedHere(Game1.player.currentLocation, Game1.currentCursorTile)) + { + CustomObject o =(CustomObject) Game1.player.ActiveObject; + o.placementAction(Game1.currentLocation,(int) Game1.currentCursorTile.X*Game1.tileSize,(int)Game1.currentCursorTile.Y*Game1.tileSize, Game1.player); + //o.performObjectDropInAction(Game1.player.ActiveObject, true, Game1.player); + Game1.player.reduceActiveItemByOne(); + playerInfo.justPlacedACustomObject = true; + } + } + } + } + } + /// @@ -526,6 +548,7 @@ namespace Revitalize private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e) { + if (playerInfo.justPlacedACustomObject == true) playerInfo.justPlacedACustomObject = false; DarkerNight.SetDarkerColor(); playerInfo.update(); } @@ -577,6 +600,7 @@ namespace Revitalize ModCore.ObjectManager.GetItem("MiningDrillMachineV1"), ModCore.ObjectManager.GetItem("AlloyFurnace"), new StardewValley.Object((int)Enums.SDVObject.IronBar,100), + ModCore.ObjectManager.GetItem("WaterPumpV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 5064cbbf..dc1561e3 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -88,7 +88,7 @@ - + @@ -168,6 +168,7 @@ + @@ -415,6 +416,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -475,6 +482,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -499,6 +509,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From ecfc59575166bd94886e9106c71b40d4c1d02804 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 24 Sep 2019 17:31:33 -0700 Subject: [PATCH 80/98] Fixed fluid manager not transporting fluids. Added in steam boiler, water, and steam. --- .../Graphics/Objects/Machines/SteamBoiler.png | Bin 0 -> 1279 bytes .../Framework/Managers/FluidManagerV2.cs | 2 +- .../Machines/EnergyGeneration/SteamBoiler.cs | 295 ++++++++++++++++++ .../Framework/Objects/Machines/Machine.cs | 4 - .../Framework/Objects/MultiTiledComponent.cs | 7 + .../Framework/Objects/ObjectManager.cs | 80 ++++- .../Framework/Objects/ResourceManager.cs | 14 + GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + 9 files changed, 401 insertions(+), 8 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamBoiler.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamBoiler.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamBoiler.png new file mode 100644 index 0000000000000000000000000000000000000000..57fb38afd34c8b653d4886638966bbdaa20b3fdf GIT binary patch literal 1279 zcmVPx(xk*GpRA_#h%wKZUgqy@U4<(lHX8)w|6^mzW~;44*+nP4Y6)}xXgyEEZw8~0FZou z@EqMsK3x9@Q0N>n#b+lyuUl;IcCfKI0r61TsO+44&O63CeReWL7(}H?FvV}E;Jgvu ziOXyVr`>_&ILOnqR92Sk%w;yjH#?p2g#ZOPVUk~`0({MrEXNTHt=k^*G)4M860Xaw z#M`kPN4TG->BI?6rug-q*Dc(ZFTm)5JWYifl#T1e*F4#fW7uu^=y~13G@tc=cm0TU zFS#&p)MDyCZ%oLyX09CiV4e>3(_W)D;1_0#F2uBBfG<_S{ zD1p7^vck&{wJx2@FKUwC001jpV}*FQoR#MlB_Fb-lSw`s1?1$DoW}U}yS;JtJefWD z&}n1SLl{J8`s0kQ8wE`9SrR-t=(C5Y>z&;IOd=cEC;^~PMyB|sQD9XfhfMQX1@J@0 zqN=0NrUkCwRP0!l`Zp%j)L~NPMYg!1H;0qz3s_Em4^MzW#ZTUj7n)MQ<_;p~s8q;Or zuRr^|5|Dhi*0w9Og52$LXQVZ5 zrEAEY5v+7gTSngLVJ~&PC1#Q@d>y8plcsMAPE0dC>%I=Iift48hFn;6zKABnPI-9K zB{mcM+Ox-xiuz$LOd90zlMGOoou%zv{Ra(d8;tx>b&UrO;;d53SLN@2-w}?gYxD5y0C2Ts3A-oq1Jj0~Y0|xL zavHPvpO^pU*GM?(u2tpNUhF?9{`vPmmWcQRLfA3-1<}jruemIj~^8Tr_8BaOUn+;nxM#F-ahYyNj{qg zJbk{$hLEc*3-!aivhgY+n>3XD{Nr!JJirv6RRCY`Hl<>jJM*z(cY_~ pS ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + + } + + public SteamBoiler(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) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public SteamBoiler(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) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + + this.animationManager.prepareForNextUpdateTick(); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + this.updateInfo(); + + if (this.containerObject.MinutesUntilReady > 0) + { + this.animationManager.playAnimation("Working"); + } + else + { + this.animationManager.playDefaultAnimation(); + } + this.pullFluidFromNetworkOutputs(ModCore.ObjectManager.resources.getFluid("Water")); + + if (this.updatesContainerObjectForProduction) + { + int remaining = minutes; + if (this.containerObject.MinutesUntilReady <= 0) + { + this.searchInventoryForBurnableObjects(); + } + while (remaining > 0 && this.containerObject.MinutesUntilReady > 0) + { + remaining -= 10; + this.processFluidLogic(); + if (this.containerObject.MinutesUntilReady <= 0) + { + this.searchInventoryForBurnableObjects(); + } + } + return false; + } + else + { + + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) + { + this.storeEnergyToNetwork(); + } + + return false; + } + + //return base.minutesElapsed(minutes, environment); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + this.createMachineMenu(); + return true; + } + + + public override Item getOne() + { + SteamBoiler component = new SteamBoiler(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + SteamBoiler self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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 + { + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void produceEnergy() + { + /* + if (this.GetEnergyManager().canReceieveEnergy) + { + this.GetEnergyManager().produceEnergy(this.energyRequiredPer10Minutes); + this.containerObject.MinutesUntilReady -= 10; + } + */ + } + + public virtual void processFluidLogic() + { + if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid("Water"), 200)) + { + this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid("Water"), 200); + this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), 100); + this.MinutesUntilReady -= 10; + } + } + + public override void updateInfo() + { + return; + if (this.info == null || this.containerObject == null) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + //this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + //this.containerObject.updateInfo(); + //ModCore.log("Force an update for machine: " + this.info.name); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + protected virtual void searchInventoryForBurnableObjects() + { + Item removed = null; + foreach (Item I in this.GetInventoryManager().items) + { + if (ModCore.ObjectManager.resources.burnableObjects.ContainsKey(I.Name)) + { + this.containerObject.MinutesUntilReady = ModCore.ObjectManager.resources.burnableObjects[I.Name]; + removed = I; + break; + } + } + if (removed == null) return; + if (removed.Stack == 1) this.GetInventoryManager().items.Remove(removed); + else removed.Stack -= 1; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 001e3163..0c381a04 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -127,7 +127,6 @@ namespace Revitalize.Framework.Objects.Machines } } - [JsonIgnore] public List producedResources { get @@ -139,9 +138,6 @@ namespace Revitalize.Framework.Objects.Machines if (MachineUtilities.ResourcesForMachines == null) MachineUtilities.InitializeResourceList(); if (MachineUtilities.ResourcesForMachines.ContainsKey(this.info.id)) return; MachineUtilities.ResourcesForMachines.Add(this.info.id, value); - - - Chest c = new Chest(); } } public int energyRequiredPer10Minutes; diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index cc210ffd..bba52826 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -711,9 +711,15 @@ namespace Revitalize.Framework.Objects StardewValley.Object obj = this.location.getObjectAtTile((int)neighborTile.X, (int)neighborTile.Y); if (obj is MultiTiledComponent) { + if ((obj as MultiTiledComponent).GetFluidManager().InteractsWithFluids) { customObjects.Add((MultiTiledComponent)obj); + //ModCore.log("Found a neighboring fluid manager"); + } + else + { + ModCore.log("Found a neighboring object but it isn't a valid fluid manager."); } } else continue; @@ -752,6 +758,7 @@ namespace Revitalize.Framework.Objects if (searchComponent.containerObject.info.fluidManager.doesThisOutputTankContainThisFluid(L)) { fluidSources.Add(searchComponent.containerObject); + //ModCore.log("Found a tank that contains this fluid!"); } } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index c8fe7ba3..38d4d164 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -333,11 +333,87 @@ namespace Revitalize.Framework.Objects MultiTiledObject waterPumpV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false))); - WaterPump waterPumpV1_0_0 = new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); - WaterPump waterPumpV1_0_1= new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, ""); + WaterPump waterPumpV1_0_0 = new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(WaterPump), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + WaterPump waterPumpV1_0_1= new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(WaterPump), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, ""); waterPumpV1.addComponent(new Vector2(0, 0), waterPumpV1_0_0); waterPumpV1.addComponent(new Vector2(0, 1), waterPumpV1_0_1); this.AddItem("WaterPumpV1", waterPumpV1); + + MultiTiledObject steamBoilerV1= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false))); + SteamBoiler steamBoilerV1_0_0 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16),new Dictionary>() + { + {"Default",new List(){ + new Animation(0,0,16,16) + } }, + {"Working",new List(){ + new Animation(32,0,16,16) + } }, + + },"Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, ""); + + SteamBoiler steamBoilerV1_1_0 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 0, 16, 16), new Dictionary>() + { + {"Default",new List(){ + new Animation(16,0,16,16) + } }, + {"Working",new List(){ + new Animation(48,0,16,16) + } }, + + }, "Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + + SteamBoiler steamBoilerV1_0_1 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 16, 16, 16), new Dictionary>() + { + {"Default",new List(){ + new Animation(0,16,16,16) + } }, + {"Working",new List(){ + new Animation(32,16,16,16) + } }, + + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + + SteamBoiler steamBoilerV1_1_1 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 16, 16, 16), new Dictionary>() + { + {"Default",new List(){ + new Animation(16,16,16,16) + } }, + {"Working",new List(){ + new Animation(48,16,16,16) + } }, + + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + + SteamBoiler steamBoilerV1_0_2 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 32, 16, 16), new Dictionary>() + { + {"Default",new List(){ + new Animation(0,32,16,16) + } }, + {"Working",new List(){ + new Animation(32,32,16,16) + } }, + + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + + SteamBoiler steamBoilerV1_1_2 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 32, 16, 16), new Dictionary>() + { + {"Default",new List(){ + new Animation(16,32,16,16) + } }, + {"Working",new List(){ + new Animation(48,32,16,16) + } }, + + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + + steamBoilerV1.addComponent(new Vector2(0, 0), steamBoilerV1_0_0); + steamBoilerV1.addComponent(new Vector2(1, 0), steamBoilerV1_1_0); + steamBoilerV1.addComponent(new Vector2(0, 1), steamBoilerV1_0_1); + steamBoilerV1.addComponent(new Vector2(1, 1), steamBoilerV1_1_1); + steamBoilerV1.addComponent(new Vector2(0, 2), steamBoilerV1_0_2); + steamBoilerV1.addComponent(new Vector2(1, 2), steamBoilerV1_1_2); + + this.AddItem("SteamBoilerV1", steamBoilerV1); } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 3547061a..7a6f511a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -36,6 +36,11 @@ namespace Revitalize.Framework.Objects public Dictionary miningDrillResources; public Dictionary fluids; + /// + /// A dictionary containing the names of all objects that can be burned with their burn times for a value. + /// + public Dictionary burnableObjects; + /// /// A list of all visited floors on the current visit to the mines. /// @@ -54,6 +59,7 @@ namespace Revitalize.Framework.Objects this.resources = new Dictionary(); this.miningDrillResources = new Dictionary(); this.fluids = new Dictionary(); + this.burnableObjects = new Dictionary(); } @@ -66,11 +72,19 @@ namespace Revitalize.Framework.Objects this.loadOreVeins(); this.loadInMiningDrillLootTable(); this.loadInFluidDictionary(); + this.loadInBurnableObjects(); } private void loadInFluidDictionary() { this.fluids.Add("Water", new Fluid("Water", Color.Blue)); + this.fluids.Add("Steam", new Fluid("Steam", Color.White)); + } + + private void loadInBurnableObjects() + { + this.burnableObjects.Add("Coal", TimeUtilities.GetMinutesFromTime(0, 1, 0)); + this.burnableObjects.Add("Wood", TimeUtilities.GetMinutesFromTime(0, 0, 10)); } private void loadInMiningDrillLootTable() { diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index a2e494a8..1ce659d4 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -600,7 +600,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("MiningDrillMachineV1"), ModCore.ObjectManager.GetItem("AlloyFurnace"), new StardewValley.Object((int)Enums.SDVObject.IronBar,100), - ModCore.ObjectManager.GetItem("WaterPumpV1") + ModCore.ObjectManager.GetItem("WaterPumpV1"), + ModCore.ObjectManager.GetItem("SteamBoilerV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index dc1561e3..d2846b29 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -166,6 +166,7 @@ + @@ -509,6 +510,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 32e1c9d3ac058f7673bc0d241561da5ca6e672ad Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:02:58 -0700 Subject: [PATCH 81/98] Added in pipes and added some optimization checks to searching out energy and fluid networks. --- .../Objects/Machines/Pipes/IronPipe.png | Bin 0 -> 231 bytes .../Machines/EnergyGeneration/SteamBoiler.cs | 2 +- .../Framework/Objects/Machines/Pipe.cs | 160 ++++++++++++++++ .../Objects/Machines/PipeMultiTiledObject.cs | 181 ++++++++++++++++++ .../Framework/Objects/Machines/Wire.cs | 4 +- .../Framework/Objects/MultiTiledComponent.cs | 5 +- .../Framework/Objects/ObjectManager.cs | 9 +- GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 5 + 9 files changed, 362 insertions(+), 7 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Pipes/IronPipe.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/Pipe.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/PipeMultiTiledObject.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Pipes/IronPipe.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Pipes/IronPipe.png new file mode 100644 index 0000000000000000000000000000000000000000..44d9bfdf3202462b17bdb6fc288572ab2de6b776 GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|7J9lkhFJ6_ zryO9caryec+r!(a!~2uLo|=EH56@nH&J!IMpW+gJyyY}Qih|zB=HR{sj6p? + /// Creates the necessary components to display the machine menu properly. + /// + + public override Item getOne() + { + Pipe component = new Pipe(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.containerObject); + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + Pipe self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + PipeMultiTiledObject obj = (PipeMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + //this.determineWireOrientation(); + 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); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override bool canBePlacedInWater() + { + return true; + } + + private void determinePipeOrientation() + { + //TODO: Make this so that the correct wire orientation is used if I want to get fancy with pipes and their graphics. + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/PipeMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/PipeMultiTiledObject.cs new file mode 100644 index 00000000..f71bde6c --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/PipeMultiTiledObject.cs @@ -0,0 +1,181 @@ +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 PyTK.CustomElementHandler; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines +{ + public class PipeMultiTiledObject:MultiTiledObject + { + public PipeMultiTiledObject() : base() + { + + } + + public PipeMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info) + : base(PyTKData, info) + { + + } + + public PipeMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation) + : base(PyTKData, info, TileLocation) + { + + } + + public PipeMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) + : base(PyTKData, info, TileLocation, ObjectsList) + { + + + } + + public override Item getOne() + { + Dictionary objs = new Dictionary(); + foreach (var pair in this.objects) + { + objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne()); + } + return new PipeMultiTiledObject(this.data, this.info.Copy(), this.TileLocation, objs); + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + PipeMultiTiledObject obj = (PipeMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (obj == null) + { + return null; + } + + Dictionary guids = new Dictionary(); + + foreach (KeyValuePair pair in obj.childrenGuids) + { + guids.Add(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in guids) + { + obj.childrenGuids.Remove(pair.Key); + MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString()); + component.InitNetFields(); + obj.removeComponent(pair.Key); + obj.addComponent(pair.Key, component); + + + } + obj.InitNetFields(); + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) + { + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj); + return obj; + } + else + { + return Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]]; + } + + + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + //saveData.Add("GUID", this.guid.ToString()); + //Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + return saveData; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as MultiTiledComponent).draw(spriteBatch, x + ((int)pair.Key.X), y + ((int)pair.Key.Y), alpha); + } + } + + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + { + pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile + (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); + } + + //base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + { + //ModCore.log(location + (pair.Key * 16) + new Vector2(32, 32)); + pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16) + new Vector2(32, 32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) + Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); + //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + this.updateInfo(); + foreach (KeyValuePair pair in this.objects) + pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f); + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override bool canStackWith(Item other) + { + if (other is PipeMultiTiledObject) + { + return (other as PipeMultiTiledObject).info.id == this.info.id && (other as PipeMultiTiledObject).info.DyedColor == this.info.DyedColor; + } + else return false; + } + + public override int maximumStackSize() + { + return 999; + } + + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + this.updateInfo(); + PipeMultiTiledObject m = (PipeMultiTiledObject)this.getOne(); + + foreach (KeyValuePair pair in m.objects) + { + /* + if ((pair.Value as CustomObject).info.ignoreBoundingBox) + { + pair.Value.placementAction(location, -1 * (x + (int)pair.Key.X * Game1.tileSize), -1 * (y + (int)pair.Key.Y * Game1.tileSize), who); + } + else + { + pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + }*/ + (pair.Value as MultiTiledComponent).placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + //ModCore.log(pair.Value.TileLocation); + } + m.location = location; + return true; + //return base.placementAction(location, x, y, who); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs index 3cc3ed59..217337c5 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs @@ -71,11 +71,11 @@ namespace Revitalize.Framework.Objects.Machines if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) { //Get new container - MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + WireMultiTiledObject obj = (WireMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); self.containerObject = obj; obj.addComponent(offsetKey, self); //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); - Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (WireMultiTiledObject)obj); } else { diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index bba52826..095c0b76 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -433,6 +433,7 @@ namespace Revitalize.Framework.Objects { if ((obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { + if ((obj as MultiTiledComponent).containerObject == this.containerObject) continue; customObjects.Add((MultiTiledComponent)obj); } } @@ -471,6 +472,7 @@ namespace Revitalize.Framework.Objects { if ((obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Consumes || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Transfers || (obj as MultiTiledComponent).GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) { + if ((obj as MultiTiledComponent).containerObject == this.containerObject) continue; customObjects.Add((MultiTiledComponent)obj); } } @@ -714,12 +716,13 @@ namespace Revitalize.Framework.Objects if ((obj as MultiTiledComponent).GetFluidManager().InteractsWithFluids) { + if ((obj as MultiTiledComponent).containerObject == this.containerObject) continue; customObjects.Add((MultiTiledComponent)obj); //ModCore.log("Found a neighboring fluid manager"); } else { - ModCore.log("Found a neighboring object but it isn't a valid fluid manager."); + //ModCore.log("Found a neighboring object but it isn't a valid fluid manager."); } } else continue; diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 38d4d164..1370a412 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -168,7 +168,7 @@ namespace Revitalize.Framework.Objects private void loadInMachines() { - this.loadInWires(); + this.loadInConnectionComponents(); @@ -416,12 +416,17 @@ namespace Revitalize.Framework.Objects this.AddItem("SteamBoilerV1", steamBoilerV1); } - private void loadInWires() + private void loadInConnectionComponents() { WireMultiTiledObject copperWire = new WireMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers), false)); Wire copperWire_0_0 = new Wire(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.CopperWire", TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), typeof(Wire), Color.White, true), new BasicItemInformation("Copper Wire", "Omegasis.Revitalize.Objects.Machines.Wire.CopperWire", "Wire made from copper bars. Transfers energy between sources.", "Machine", Color.SteelBlue, -300, 0, false, 15, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "CopperWire"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "CopperWire"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(100, Enums.EnergyInteractionType.Transfers),false)); copperWire.addComponent(new Vector2(0, 0), copperWire_0_0); this.AddItem("CopperWire", copperWire); + + PipeMultiTiledObject ironPipe = new PipeMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.IronPipe", TextureManager.GetTexture(ModCore.Manifest, "Machines", "IronPipe"), typeof(Pipe), Color.White, true), new BasicItemInformation("Iron Pipe", "Omegasis.Revitalize.Objects.Machines.Wire.Pipe", "Pipes made from iron. Transfers fluids between machines.", "Machine", Color.SteelBlue, -300, 0, false, 25, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "IronPipe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "IronPipe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, null, false,null,null,new Managers.FluidManagerV2(0,false, Enums.FluidInteractionType.Transfers,false))); + Pipe ironPipe_0_0 = new Pipe(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.Wires.IronPipe", TextureManager.GetTexture(ModCore.Manifest, "Machines", "IronPipe"), typeof(Pipe), Color.White, true), new BasicItemInformation("Iron Pipe", "Omegasis.Revitalize.Objects.Machines.Wire.Pipe", "Pipes made from iron. Transfers fluids between machines.", "Machine", Color.SteelBlue, -300, 0, false, 25, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "IronPipe"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "IronPipe"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, null, false, null, null, new Managers.FluidManagerV2(0, false, Enums.FluidInteractionType.Transfers, false))); + ironPipe.addComponent(new Vector2(0, 0), ironPipe_0_0); + this.AddItem("IronPipe", ironPipe); } private void loadInTools() diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 1ce659d4..6b0a98aa 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -601,7 +601,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("AlloyFurnace"), new StardewValley.Object((int)Enums.SDVObject.IronBar,100), ModCore.ObjectManager.GetItem("WaterPumpV1"), - ModCore.ObjectManager.GetItem("SteamBoilerV1") + ModCore.ObjectManager.GetItem("SteamBoilerV1"), + ModCore.ObjectManager.GetItem("IronPipe",10) }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index d2846b29..9f73a218 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -169,6 +169,8 @@ + + @@ -501,6 +503,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From b41da3b9de30cc90a1c2b9f33ee0d0b6917a5fce Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:05:35 -0700 Subject: [PATCH 82/98] Made it so that custom mod tools could be trashed. --- .../Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs | 2 +- .../Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs | 2 +- .../Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs | 2 +- .../Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs | 2 +- .../Framework/Objects/Items/Tools/PickaxeExtended.cs | 5 +++++ .../Framework/Objects/Items/Tools/WateringCanExtended.cs | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs index fdc621a2..4485fd4c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/AxeExtended.cs @@ -317,7 +317,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override bool canBeTrashed() { - return base.canBeTrashed(); + return true; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs index effaf242..6743defa 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/Chainsaw.cs @@ -288,7 +288,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override bool canBeTrashed() { - return base.canBeTrashed(); + return true; } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs index 3320b97e..e5fea117 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/HoeExtended.cs @@ -318,7 +318,7 @@ namespace Revitalize.Framework.Objects.Items.Tools } public override bool canBeTrashed() { - return base.canBeTrashed(); + return true; } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs index 9da0a860..f516f6cd 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/MiningDrill.cs @@ -403,7 +403,7 @@ namespace Revitalize.Framework.Objects.Items.Tools public override bool canBeTrashed() { - return base.canBeTrashed(); + return true; } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs index 791c8a6a..41ad57bc 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs @@ -326,5 +326,10 @@ namespace Revitalize.Framework.Objects.Items.Tools //this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel; } + + public override bool canBeTrashed() + { + return true; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs index b573b220..7a79e452 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/WateringCanExtended.cs @@ -317,7 +317,7 @@ namespace Revitalize.Framework.Objects.Items.Tools } public override bool canBeTrashed() { - return base.canBeTrashed(); + return true; } } } From 486529f2503bbcd83d7caf80bd215f6b5bc3d732 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:15:08 -0700 Subject: [PATCH 83/98] Added in alloy furnace and iron pipe recipes to crafting tables. --- .../Framework/Crafting/CraftingRecipeBook.cs | 22 ++++++++++++++----- .../Objects/Items/Tools/PickaxeExtended.cs | 5 +---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index ca5c95af..7c62dbab 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -154,7 +154,7 @@ namespace Revitalize.Framework.Crafting if (pair.Value.hasUnlocked) { menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab); - ModCore.log("Add in a crafting recipe to the menu!"); + //ModCore.log("Add in a crafting recipe to the menu!"); } else { @@ -181,7 +181,7 @@ namespace Revitalize.Framework.Crafting if (pair.Value.hasUnlocked) { menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab); - ModCore.log("Add in a crafting recipe to the menu!"); + //ModCore.log("Add in a crafting recipe to the menu!"); } else { @@ -208,7 +208,7 @@ namespace Revitalize.Framework.Crafting if (pair.Value.hasUnlocked) { menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab); - ModCore.log("Add in a crafting recipe to the menu!"); + //ModCore.log("Add in a crafting recipe to the menu!"); } else { @@ -271,7 +271,7 @@ namespace Revitalize.Framework.Crafting { if (recipe.Value.recipe.ingredients[i].item is MultiTiledObject) { - ModCore.log("Found a multi tiled object as an output!"); + //ModCore.log("Found a multi tiled object as an output!"); //ModCore.log("Found a multi tiled object!"); Type t = recipe.Value.recipe.ingredients[i].item.GetType(); string id = (recipe.Value.recipe.ingredients[i].item as MultiTiledObject).info.id; @@ -282,13 +282,13 @@ namespace Revitalize.Framework.Crafting { if (recipe.Value.recipe.outputs[i].item is MultiTiledObject) { - ModCore.log("Found a multi tiled object as an output!"); + //ModCore.log("Found a multi tiled object as an output!"); //ModCore.log("Found a multi tiled object!"); Type t = recipe.Value.recipe.outputs[i].item.GetType(); string id = (recipe.Value.recipe.outputs[i].item as MultiTiledObject).info.id; recipe.Value.recipe.outputs[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t); - ModCore.log("Components are: "+(recipe.Value.recipe.outputs[i].item as MultiTiledObject).objects.Count); + //ModCore.log("Components are: "+(recipe.Value.recipe.outputs[i].item as MultiTiledObject).objects.Count); } } } @@ -338,6 +338,11 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"),2),null,0),true)); + WorkbenchRecipes.addCraftingRecipe("Alloy Furnace", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Clay,20),10), + new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 10) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AlloyFurnace"), 1), null, 0), true)); if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { @@ -458,6 +463,11 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),5) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TrashCan"), 1)),true)); + AnvilRecipes.addCraftingRecipe("Iron Pipe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,2),2) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("IronPipe"), 1)), true)); + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs index 41ad57bc..50caa67a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Items/Tools/PickaxeExtended.cs @@ -327,9 +327,6 @@ namespace Revitalize.Framework.Objects.Items.Tools } - public override bool canBeTrashed() - { - return true; - } + } } From 822ef651f53bc58c0f5981dafed94c95463317df Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:17:53 -0700 Subject: [PATCH 84/98] Added in recipe for the sandbox. --- .../Revitalize/Framework/Crafting/CraftingRecipeBook.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index 7c62dbab..6b46b258 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -344,6 +344,12 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AlloyFurnace"), 1), null, 0), true)); + WorkbenchRecipes.addCraftingRecipe("Sand Box", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), + new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 25) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SandBox"), 1), null, 0), true)); + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) From 57665d5e8c0e89d7c33306d09de9a3db8658390f Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:27:40 -0700 Subject: [PATCH 85/98] Added in recipe for solar panel tier 1 and solar array tier 1. --- .../Framework/Crafting/CraftingRecipeBook.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index 6b46b258..edf617d8 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -474,6 +474,26 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,2),2) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("IronPipe"), 1)), true)); + AnvilRecipes.addCraftingRecipe("Solar Panel", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),4), + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarPanelTier1"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Solar Array", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,45),45), + new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),20), + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarArrayTier1"), 1)), true)); + + ///Alt solar array crafting recipe. + AnvilRecipes.addCraftingRecipe("Solar Array Alt. Recipe", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),45), + new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),4), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarPanelTier1"), 4) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarArrayTier1"), 1)), true)); + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) From 54e560f4a2e6a7b7ef5431cf0856960f793f2d05 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:41:35 -0700 Subject: [PATCH 86/98] Added in recipes for battery bin and lighthouse. --- .../Framework/Crafting/CraftingRecipeBook.cs | 15 ++++++++++++++ .../Framework/Objects/ObjectManager.cs | 20 +++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index edf617d8..d0e7a7aa 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -350,6 +350,12 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 25) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SandBox"), 1), null, 0), true)); + WorkbenchRecipes.addCraftingRecipe("Battery Bin", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"),10) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BatteryBin"), 1), null, 0), true)); + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) @@ -494,6 +500,15 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarPanelTier1"), 4) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarArrayTier1"), 1)), true)); + AnvilRecipes.addCraftingRecipe("LightHouse", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),45), + new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),5), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,10), 10) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Lighthouse"), 1)), true)); + + + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 1370a412..98091012 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -102,6 +102,8 @@ namespace Revitalize.Framework.Objects this.ItemsByName = new Dictionary(); this.Tools = new Dictionary(); + + //Load in furniture again! } /// @@ -119,14 +121,14 @@ namespace Revitalize.Framework.Objects private void loadInAestheticsObjects() { LampMultiTiledObject lighthouse = new LampMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(), Color.White, false, null, null)); - LampTileComponent lighthouse_0_0 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 0, 16, 16)), Color.White, true, null, new Illuminate.LightManager(),null,true)); - LampTileComponent lighthouse_1_0 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 0, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); - LampTileComponent lighthouse_0_1 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 16, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); - LampTileComponent lighthouse_1_1 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 16, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); - LampTileComponent lighthouse_0_2 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 32, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, false)); - LampTileComponent lighthouse_1_2 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 32, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, false)); - LampTileComponent lighthouse_0_3 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 48, 16, 16)), Color.White, false, null, new Illuminate.LightManager())); - LampTileComponent lighthouse_1_3 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 48, 16, 16)), Color.White, false, null, new Illuminate.LightManager())); + LampTileComponent lighthouse_0_0 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 0, 16, 16)), Color.White, true, null, new Illuminate.LightManager(),null,true)); + LampTileComponent lighthouse_1_0 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 0, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); + LampTileComponent lighthouse_0_1 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 16, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); + LampTileComponent lighthouse_1_1 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 16, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, true)); + LampTileComponent lighthouse_0_2 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 32, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, false)); + LampTileComponent lighthouse_1_2 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 32, 16, 16)), Color.White, true, null, new Illuminate.LightManager(), null, false)); + LampTileComponent lighthouse_0_3 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(0, 48, 16, 16)), Color.White, false, null, new Illuminate.LightManager())); + LampTileComponent lighthouse_1_3 = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), typeof(LampTileComponent), Color.White, true), new BasicItemInformation("LightHouse", "Omegasis.Revitalize.Objects.Furniture.Misc.Lighthouse", "A minuture lighthouse that provides a decent amount of light.", "Furniture", Color.Brown, -300, 0, false, 2500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Lighthouse"), new Animation(16, 48, 16, 16)), Color.White, false, null, new Illuminate.LightManager())); lighthouse_0_0.lightManager.addLight(new Vector2(16, 16), LightManager.CreateLightSource(10f, Color.White), lighthouse_0_0); lighthouse.addComponent(new Vector2(0,-3),lighthouse_0_0); lighthouse.addComponent(new Vector2(1, -3), lighthouse_1_0); @@ -170,8 +172,6 @@ namespace Revitalize.Framework.Objects { this.loadInConnectionComponents(); - - MultiTiledObject trashCan = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(), Color.White, true, new InventoryManager(36), null, null)); TrashCanTile trash1 = new TrashCanTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(TrashCanTile), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "TrashCan"), new Animation(0, 0, 16, 16)), Color.White, true, new InventoryManager(36), null, null)); TrashCanTile trash2 = new TrashCanTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Misc.TrashCan", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), typeof(TrashCanTile), Color.White, true), new BasicItemInformation("Trash Can", "Omegasis.Revitalize.Furniture.Misc.TrashCan", "A trash can where you can throw away unnecessary objects. It empties out at the beginning of each new day.", "Machine", Color.SteelBlue, -300, 0, false, 650, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "TrashCan"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "TrashCan"), new Animation(0, 16, 16, 16)), Color.White, false, new InventoryManager(36), null, null)); From 90523d61da5d50a1c39deff9fca653ebdfd8f051 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:48:57 -0700 Subject: [PATCH 87/98] Added in the recipes for the capacitor and the charging station. --- .../Framework/Crafting/CraftingRecipeBook.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index d0e7a7aa..4424562a 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -356,6 +356,20 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"),10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BatteryBin"), 1), null, 0), true)); + WorkbenchRecipes.addCraftingRecipe("Capacitor", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,50),50), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,10),10) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1), null, 0), true)); + + WorkbenchRecipes.addCraftingRecipe("Charging Station", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"), 20), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ChargingStation"), 1), null, 0), true)); + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) From 9dfe8a3783c612e3cf73254cf26c827d91e522e9 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 15:56:32 -0700 Subject: [PATCH 88/98] Added in the recipe for the grinder. --- .../Framework/Crafting/CraftingRecipeBook.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index 4424562a..7cbf20eb 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -516,12 +516,20 @@ namespace Revitalize.Framework.Crafting AnvilRecipes.addCraftingRecipe("LightHouse", new UnlockableCraftingRecipe("Default", new Recipe(new List() { - new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),45), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),5), new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),5), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,10), 10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Lighthouse"), 1)), true)); + AnvilRecipes.addCraftingRecipe("Grinder", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),30), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,10), 10), + new CraftingRecipeComponent(new StardewValley.Objects.Chest(true),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Grinder"), 1)), true));; + if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { From 1acfc40639be4d39be269ab0e2ebc25050baaf23 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 16:03:54 -0700 Subject: [PATCH 89/98] Added in recipes for chainsaw and mining drill. --- .../Framework/Crafting/CraftingRecipeBook.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index 7cbf20eb..ebead5d9 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -528,7 +528,21 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),30), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,10), 10), new CraftingRecipeComponent(new StardewValley.Objects.Chest(true),1) - }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Grinder"), 1)), true));; + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Grinder"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Mining Drill V1", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot",10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BrassIngot",10),10), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("MiningDrillV1"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Chainsaw V1", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot",10),10), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot",10),10), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("ChainsawV1"), 1)), true)); if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) From 720ac67216d63075c50d2e109cedf5c4cef76d34 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 16:09:23 -0700 Subject: [PATCH 90/98] Added in recipe for fluid pump and steam boiler. --- .../Framework/Crafting/CraftingRecipeBook.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index ebead5d9..c0e2728c 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -509,7 +509,7 @@ namespace Revitalize.Framework.Crafting ///Alt solar array crafting recipe. AnvilRecipes.addCraftingRecipe("Solar Array Alt. Recipe", new UnlockableCraftingRecipe("Default", new Recipe(new List() { - new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),45), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),5), new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),4), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarPanelTier1"), 4) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarArrayTier1"), 1)), true)); @@ -544,6 +544,17 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("ChainsawV1"), 1)), true)); + AnvilRecipes.addCraftingRecipe("Water Pump V1", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,15),15) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("WaterPumpV1"), 1)), true)); + + AnvilRecipes.addCraftingRecipe("Steam Boiler V1", new UnlockableCraftingRecipe("Default", new Recipe(new List() + { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,25),25), + new CraftingRecipeComponent(new StardewValley.Objects.Chest(true),1) + + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteamBoilerV1"), 1)), true)); if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { From 09c32bf96fabf50c2b666d10d36f88fc45a1c505 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 25 Sep 2019 16:12:42 -0700 Subject: [PATCH 91/98] Added in config options for how much water the steam boiler requires per 10 min and how much steam it produces per operation. --- .../Revitalize/Framework/Configs/GlobalMachineConfig.cs | 5 +++++ .../Objects/Machines/EnergyGeneration/SteamBoiler.cs | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs index b0b799bc..8e1bf4bc 100644 --- a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs @@ -22,6 +22,9 @@ namespace Revitalize.Framework.Configs public int miningDrillEnergyConsumption; public int miningDrillTimeToMine; + public int steamBoilerV1_requiredWaterPerOperation; + public int steamBoilerV1_producedSteamPerOperation; + public GlobalMachineConfig() { this.doMachinesConsumeEnergy = true; @@ -33,6 +36,8 @@ namespace Revitalize.Framework.Configs this.grinderTimeToGrind = 30; this.miningDrillEnergyConsumption = 50; this.miningDrillTimeToMine = 60; + this.steamBoilerV1_requiredWaterPerOperation = 200; + this.steamBoilerV1_producedSteamPerOperation = 100; } public static GlobalMachineConfig InitializeConfig() diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs index 3798a5d5..c9ce4bfa 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs @@ -237,10 +237,10 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public virtual void processFluidLogic() { - if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid("Water"), 200)) + if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid("Water"), ModCore.Configs.machinesConfig.steamBoilerV1_requiredWaterPerOperation)) { - this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid("Water"), 200); - this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), 100); + this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid("Water"), ModCore.Configs.machinesConfig.steamBoilerV1_requiredWaterPerOperation); + this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamBoilerV1_producedSteamPerOperation); this.containerObject.MinutesUntilReady -= 10; } } From 6c7f0e80991dd3efae70b94bde5f84b6018a425f Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 3 Oct 2019 23:42:16 -0700 Subject: [PATCH 92/98] Added in steam engine. Updated fluid graph search from output tanks for better optimization. --- .../Graphics/Objects/Machines/Capacitor.png | Bin 338 -> 335 bytes .../Graphics/Objects/Machines/SteamEngine.png | Bin 0 -> 648 bytes .../Framework/Configs/GlobalMachineConfig.cs | 5 + .../Framework/Managers/FluidManagerV2.cs | 25 ++ .../Menus/Machines/MachineSummaryMenu.cs | 2 +- .../Machines/EnergyGeneration/SteamEngine.cs | 294 ++++++++++++++++++ .../Framework/Objects/Machines/Machine.cs | 43 ++- .../Framework/Objects/MultiTiledComponent.cs | 41 ++- .../Framework/Objects/ObjectManager.cs | 7 + GeneralMods/Revitalize/ModCore.cs | 3 +- GeneralMods/Revitalize/Revitalize.csproj | 4 + 11 files changed, 407 insertions(+), 17 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamEngine.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png index 2662d05b74d1feaadd9f9f8092fff2ea7f6fec83..db85e09e6d4f3ccf453be0305cce296a29e0ea5c 100644 GIT binary patch delta 295 zcmV+?0oeZ10?z`FF@Fh3L_t(Ijm3|#N&`U{gue}e5LCitK_ny=ia}D@2=@$E`WC*B zzDR1DG*_k45MmI);}B&N_K=8NaaI?0?{*VAr`ciunfd33|Ar_@6h(K9*TwB$jpNx; z05nbW&Gjh&`uoRg?6g}YEylB@XjBEJITn5Eb%k32uFa;|rGIPss>Y&E?|6U=Bxa0K$sS+rS*UP@QiZ=zPP&)8|gJ z37v230D$~_L|01AdPCILI{@SJemzW%Q@d wRGJXX#st7k;Um`OYk>W;i>szK8+8}(14Q&`ppJPsEdT%j07*qoM6N<$f{ki}A^-pY diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamEngine.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamEngine.png new file mode 100644 index 0000000000000000000000000000000000000000..72ae0383697339c6a121cca1436fa566cc981be1 GIT binary patch literal 648 zcmV;30(bq1P)Px%LP|sdcv!OK!w9hRK)>eu^0%27k)n>p=f!X3ES8xezP1m7|@HWSdqLPV^+L=uw4PY@Px;Q z?2@VP)LE&ZRly3qn(cdSi`Q>5mbtD50A!cU*}x3>wF2czsVgrYjfi2Vn?p_q`ev)v zDhA%T+XJ*K5RXPgDxH-K21bVlwep690(pf}9)^LCiKikH42q?_xYhj2X061e+eful z;lacEc)jf04`3p`zVD=z(fNxPO^3;?uF1sIcMrYB~o|JnjTK62a;7s~~<>vhO2 z_ci%t@s{{Fa+RCcE=vG+6ZbkA)v^i4WEaJ90RaEhIaAz0x9t9Lw}<3v1$d_ko7caq zf$jQE-&iLusV2<3z)G;EfpTt{GVn<^)-B$H1no;D9*qc^?LBV?sdRS#E&v$uU$|lG iOFh2suZKF}LGcfJmE>^{mCs=S0000 /// Checks to see if the input tanks on this Fluid manager have the capacity to take in this Fluid at all. /// diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 79f7a64d..3950c517 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -75,7 +75,7 @@ namespace Revitalize.Framework.Menus.Machines { get { - return this.energy.maxEnergy != 0 || ModCore.Configs.machinesConfig.doMachinesConsumeEnergy==false; + return this.energy.maxEnergy != 0 && ModCore.Configs.machinesConfig.doMachinesConsumeEnergy==true; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs new file mode 100644 index 00000000..26d0d1ab --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs @@ -0,0 +1,294 @@ +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 PyTK.CustomElementHandler; +using Revitalize.Framework.Managers; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines.EnergyGeneration +{ + public class SteamEngine:Machine + { + + public SteamEngine() { } + + public SteamEngine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "",Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation=0) : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; + } + + public SteamEngine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info, TileLocation) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; + } + + public SteamEngine(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, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info, TileLocation) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + + this.animationManager.prepareForNextUpdateTick(); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + this.updateInfo(); + + /* + if (this.containerObject.MinutesUntilReady > 0) + { + this.animationManager.playAnimation("Working"); + } + else + { + this.animationManager.playDefaultAnimation(); + } + */ + this.pullFluidFromNetworkOutputs(ModCore.ObjectManager.resources.getFluid("Steam")); + + if (this.updatesContainerObjectForProduction) + { + int remaining = minutes; + while (remaining > 0) + { + if (this.GetEnergyManager().canReceieveEnergy == false) return false; + remaining -= 10; + int fluidAmount = this.GetFluidManager().getAmountOfFluidInInputTanks(this.requiredFluidForOperation); + if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid(this.requiredFluidForOperation.name), this.amountOfFluidRequiredForOperation)) + { + this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid(this.requiredFluidForOperation.name), this.amountOfFluidRequiredForOperation); + //this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamBoilerV1_producedSteamPerOperation); + this.produceEnergy(); + this.storeEnergyToNetwork(); + } + else if(fluidAmount>0) + { + //Try to always consume fluid if possible. + double ratio = (double)fluidAmount / (double)ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation; + int liquidToConsume = fluidAmount; + this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid(this.requiredFluidForOperation.name), liquidToConsume); + this.produceEnergy(ratio); + this.storeEnergyToNetwork(); + } + } + return false; + } + else + { + + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) + { + this.storeEnergyToNetwork(); + } + + return false; + } + + //return base.minutesElapsed(minutes, environment); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + this.createMachineMenu(); + return true; + } + + + public override Item getOne() + { + SteamEngine component = new SteamEngine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook,this.requiredFluidForOperation,this.amountOfFluidRequiredForOperation); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + SteamEngine self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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 + { + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void produceEnergy() + { + + if (this.GetEnergyManager().canReceieveEnergy) + { + this.GetEnergyManager().produceEnergy(this.energyRequiredPer10Minutes); + } + + } + + public virtual void processFluidLogic() + { + return; + if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid("Water"), ModCore.Configs.machinesConfig.steamBoilerV1_requiredWaterPerOperation)) + { + this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid("Water"), ModCore.Configs.machinesConfig.steamBoilerV1_requiredWaterPerOperation); + this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamBoilerV1_producedSteamPerOperation); + this.containerObject.MinutesUntilReady -= 10; + } + } + + public override void updateInfo() + { + return; + if (this.info == null || this.containerObject == null) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + //this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + //this.containerObject.updateInfo(); + //ModCore.log("Force an update for machine: " + this.info.name); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 0c381a04..31c849ba 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Crafting; +using Revitalize.Framework.Managers; using Revitalize.Framework.Menus; using Revitalize.Framework.Menus.Machines; using Revitalize.Framework.Objects.InformationFiles; @@ -38,6 +39,8 @@ namespace Revitalize.Framework.Objects.Machines string energyRequired = this.energyRequiredPer10Minutes.ToString(); string timeToProduce = this.timeToProduce.ToString(); string updatesContainer = this.updatesContainerObjectForProduction.ToString(); + string fluidString = this.requiredFluidForOperation != null ? ModCore.Serializer.ToJSONString(this.amountOfFluidRequiredForOperation) : ""; + string fluidAmountString = this.amountOfFluidRequiredForOperation.ToString(); StringBuilder b = new StringBuilder(); b.Append(info); b.Append("<"); @@ -56,6 +59,10 @@ namespace Revitalize.Framework.Objects.Machines b.Append(updatesContainer); b.Append("<"); b.Append(this.craftingRecipeBook); + b.Append("<"); + b.Append(fluidString); + b.Append("<"); + b.Append(fluidAmountString); //ModCore.log("Setting info: " + b.ToString()); return b.ToString(); } @@ -72,12 +79,18 @@ namespace Revitalize.Framework.Objects.Machines string time = data[6]; string updates = data[7]; this.craftingRecipeBook = data[8]; + string fluid = data[9]; + string fluidAmount = data[10]; this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation)); this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData); this.energyRequiredPer10Minutes = Convert.ToInt32(energyRequired); this.timeToProduce = Convert.ToInt32(time); this.updatesContainerObjectForProduction = Convert.ToBoolean(updates); - + if (string.IsNullOrEmpty(fluid) == false) + { + this.requiredFluidForOperation = ModCore.Serializer.DeserializeFromJSONString(fluid); + } + this.amountOfFluidRequiredForOperation= Convert.ToInt32(fluidAmount); if (string.IsNullOrEmpty(offsetVec)) return; if (string.IsNullOrEmpty(containerObject)) return; this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec); @@ -158,6 +171,9 @@ namespace Revitalize.Framework.Objects.Machines } } + public Fluid requiredFluidForOperation; + public int amountOfFluidRequiredForOperation; + [JsonIgnore] public bool ConsumesEnergy { @@ -191,7 +207,7 @@ namespace Revitalize.Framework.Objects.Machines public Machine() { } - public Machine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info) + public Machine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation =0) : base(PyTKData, info) { this.producedResources = ProducedResources ?? new List(); this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; @@ -200,10 +216,11 @@ namespace Revitalize.Framework.Objects.Machines this.MinutesUntilReady = TimeToProduce; this.craftingRecipeBook = CraftingBook; this.createStatusBubble(); - + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; } - 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) + 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, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation =0) : base(PyTKData, info, TileLocation) { this.containerObject = obj; this.producedResources = ProducedResources ?? new List(); @@ -213,9 +230,11 @@ namespace Revitalize.Framework.Objects.Machines this.MinutesUntilReady = TimeToProduce; this.craftingRecipeBook = CraftingBook; this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; } - 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) + 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, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation =0) : base(PyTKData, info, TileLocation) { this.offsetKey = offsetKey; this.containerObject = obj; @@ -226,6 +245,8 @@ namespace Revitalize.Framework.Objects.Machines this.MinutesUntilReady = TimeToProduce; this.craftingRecipeBook = CraftingBook; this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; } protected virtual void createStatusBubble() @@ -367,7 +388,7 @@ namespace Revitalize.Framework.Objects.Machines public override Item getOne() { - Machine component = new Machine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + Machine component = new Machine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook,this.requiredFluidForOperation,this.amountOfFluidRequiredForOperation); component.containerObject = this.containerObject; component.offsetKey = this.offsetKey; return component; @@ -491,6 +512,16 @@ namespace Revitalize.Framework.Objects.Machines } + public virtual void produceEnergy(double ratio) + { + + if (this.GetEnergyManager().canReceieveEnergy) + { + this.GetEnergyManager().produceEnergy((int)(this.energyRequiredPer10Minutes * ratio)); + } + + } + protected virtual void drawStatusBubble(SpriteBatch b, int x, int y, float Alpha) { if (this.updatesContainerObjectForProduction == false) return; diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 095c0b76..2db112c2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -741,22 +742,44 @@ namespace Revitalize.Framework.Objects protected virtual List FluidGraphSearchForFluidFromOutputTanks(Fluid L) { List fluidSources = new List(); - List searchedComponents = new List(); - List entitiesToSearch = new List(); - entitiesToSearch.AddRange(this.GetNeighboringFluidManagers()); - searchedComponents.Add(this); + HashSet searchedComponents = new HashSet(); + Queue entitiesToSearch = new Queue(); + HashSet searchedObjects = new HashSet(); + foreach(MultiTiledComponent tile in this.GetNeighboringFluidManagers()) + { + entitiesToSearch.Enqueue(tile); + } + //entitiesToSearch.AddRange(this.GetNeighboringFluidManagers()); + searchedComponents.Add(this.guid); while (entitiesToSearch.Count > 0) { - MultiTiledComponent searchComponent = entitiesToSearch[0]; - entitiesToSearch.Remove(searchComponent); - if (searchedComponents.Contains(searchComponent)) + MultiTiledComponent searchComponent = entitiesToSearch.Dequeue(); + //entitiesToSearch.Remove(searchComponent); + if (searchedComponents.Contains(searchComponent.guid)) { continue; } + /* + else if (searchedObjects.Contains(searchComponent.containerObject)) + { + continue; + } + */ else { - searchedComponents.Add(searchComponent); - entitiesToSearch.AddRange(searchComponent.GetNeighboringFluidManagers()); + searchedComponents.Add(searchComponent.guid); + searchedObjects.Add(searchComponent.containerObject.guid); + + List neighbors = searchComponent.GetNeighboringFluidManagers(); + + foreach(MultiTiledComponent tile in neighbors) + { + if (searchedObjects.Contains(tile.containerObject.guid) || searchedComponents.Contains(tile.guid)) continue; + else + { + entitiesToSearch.Enqueue(tile); + } + } if (searchComponent.containerObject.info.fluidManager.doesThisOutputTankContainThisFluid(L)) { diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 98091012..b623a78f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -414,6 +414,13 @@ namespace Revitalize.Framework.Objects steamBoilerV1.addComponent(new Vector2(1, 2), steamBoilerV1_1_2); this.AddItem("SteamBoilerV1", steamBoilerV1); + + MultiTiledObject steamEngineV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false))); + SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + steamEngineV1.addComponent(new Vector2(0, 0), steamEngineV1_0_0); + steamEngineV1.addComponent(new Vector2(1, 0), steamEngineV1_1_0); + this.AddItem("SteamEngineV1", steamEngineV1); } private void loadInConnectionComponents() diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 6b0a98aa..ecd11d81 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -602,7 +602,8 @@ namespace Revitalize new StardewValley.Object((int)Enums.SDVObject.IronBar,100), ModCore.ObjectManager.GetItem("WaterPumpV1"), ModCore.ObjectManager.GetItem("SteamBoilerV1"), - ModCore.ObjectManager.GetItem("IronPipe",10) + ModCore.ObjectManager.GetItem("IronPipe",100), + ModCore.ObjectManager.GetItem("SteamEngineV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 9f73a218..aaf21f71 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -167,6 +167,7 @@ + @@ -518,6 +519,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 53428ae96276981d3ea5f3c7b6241b52975a0536 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 5 Oct 2019 18:57:03 -0700 Subject: [PATCH 93/98] Fixed random space infront of non dyed object names when config enables dyed object names. --- GeneralMods/Revitalize/Framework/Objects/CustomObject.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 75e48276..d3919fe1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -644,6 +644,7 @@ namespace Revitalize.Framework.Objects { if (ModCore.Configs.objectsConfig.showDyedColorName) { + if (string.IsNullOrEmpty(this.info.getDyedColorName())) return this.info.name; return this.info.getDyedColorName() + " " + this.info.name; } //Load in a file that has all object names referenced here or something. From 5604f46a7467530776a4dd7e9d5add763b820215 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 8 Oct 2019 11:23:21 -0700 Subject: [PATCH 94/98] Updated the crafting menu to have an extra display box for all of the ingredients. --- .../Revitalize/Framework/Menus/CraftingInformationPage.cs | 6 +++--- GeneralMods/Revitalize/Framework/Objects/CustomObject.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 9c981377..5ad31b26 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -18,7 +18,6 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { /// - /// Need to display a craft button. /// Also need to make the crafting menu scroll better. /// public class CraftingInformationPage:IClickableMenuExtended @@ -66,7 +65,7 @@ namespace Revitalize.Framework.Menus this.requiredItems = new Dictionary(); for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) { - ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); + ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64+this.width, this.yPositionOnScreen+(i*64)+128), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount); } this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f); @@ -84,7 +83,7 @@ namespace Revitalize.Framework.Menus this.requiredItems = new Dictionary(); for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) { - ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); + ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64+this.width, this.yPositionOnScreen+(i*64)+128), new Rectangle(0, 0, 64, 64), 2f, true, Color.White); this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount); } this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2 - 96, this.getCraftingButtonHeight()), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"), new StardustCore.Animations.Animation(0, 0, 48, 16)), Color.White), new Rectangle(0, 0, 48, 16), 4f); @@ -166,6 +165,7 @@ namespace Revitalize.Framework.Menus public override void draw(SpriteBatch b) { this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + this.drawDialogueBoxBackground(this.xPositionOnScreen+this.width, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); this.infoButton.draw(b,this.itemDisplayLocation); b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName,new Vector2(this.xPositionOnScreen+ (this.width/2),this.itemDisplayLocation.Y)+ this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index d3919fe1..ecce4bb7 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -656,7 +656,7 @@ namespace Revitalize.Framework.Objects if (this.info == null) { this.ItemInfo = this.text; - ModCore.log("Updated item info!"); + //ModCore.log("Updated item info!"); return; } From 70518a1d38561a817c943566668536d1dcde6567 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 8 Oct 2019 11:44:43 -0700 Subject: [PATCH 95/98] Updated machine summary menu to hide fluid tanks with no relevance to that machine. --- .../Framework/Managers/FluidManagerV2.cs | 49 +++++++++++++++++-- .../Menus/Machines/MachineSummaryMenu.cs | 34 ++++++++++++- .../Framework/Objects/ObjectManager.cs | 20 ++++---- 3 files changed, 86 insertions(+), 17 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs index 47b587f5..d0908e37 100644 --- a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs +++ b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs @@ -271,6 +271,9 @@ namespace Revitalize.Framework.Managers public bool allowDoubleInput; public bool onlyOutput; + + private bool onlyInput; + private int numberOfInputTanks; /// /// The capacity for the fluid tanks. /// @@ -301,7 +304,7 @@ namespace Revitalize.Framework.Managers /// /// /// Can both input tanks store the same Fluid? - public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput = false) + public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput = false,bool OnlyInput=false, int NumberOfInputTanks=2) { if (OnlyOutput) { @@ -310,18 +313,49 @@ namespace Revitalize.Framework.Managers this.inputTank2 = new MachineFluidTank(0); } + else if (OnlyInput) + { + if (this.allowDoubleInput) + { + this.outputTank = new MachineFluidTank(0); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); + } + if (NumberOfInputTanks >= 2) + { + this.outputTank = new MachineFluidTank(0); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); + } + else if (NumberOfInputTanks == 1) + { + this.outputTank = new MachineFluidTank(0); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(0); + } + } else { this.outputTank = new MachineFluidTank(Capacity); - this.inputTank1 = new MachineFluidTank(Capacity); - this.inputTank2 = new MachineFluidTank(Capacity); + if (NumberOfInputTanks == 1) + { + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(0); + } + else if(NumberOfInputTanks >=2) + { + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); + } } this.onlyOutput = OnlyOutput; this.allowDoubleInput = AllowDoubleInput; this.requiresUpdate = false; this.fluidInteractionType = LiquidInteractionType; - } + this.onlyInput = OnlyInput; + this.numberOfInputTanks = NumberOfInputTanks; + } /// /// Produces a given amount of Fluid and puts it into the output tank for this Fluid manager. /// @@ -460,6 +494,11 @@ namespace Revitalize.Framework.Managers return 0; } + /// + /// Gets the amount of fluid that are in the input tanks. + /// + /// The type of fluid to check to the input tanks. + /// The total amount of fluid of the same type of fluid passed in. public int getAmountOfFluidInInputTanks(Fluid L) { if (this.allowDoubleInput) @@ -542,7 +581,7 @@ namespace Revitalize.Framework.Managers public FluidManagerV2 Copy() { - return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput, this.fluidInteractionType, this.allowDoubleInput); + return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput, this.fluidInteractionType, this.allowDoubleInput,this.onlyInput,this.numberOfInputTanks); } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 3950c517..5cf591d6 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -134,9 +134,39 @@ namespace Revitalize.Framework.Menus.Machines hovered = true; } - if (hovered == false) + if (this.objectSource.info.fluidManager.InteractsWithFluids) { - this.hoverText = ""; + if (this.inputFluidTank1Button.containsPoint(x, y)) + { + if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + { + this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(); + hovered = true; + } + } + + if (this.inputFluidTank2Button.containsPoint(x, y)) + { + if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + { + this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(); + hovered = true; + } + } + + if (this.outputFluidTankButton.containsPoint(x, y)) + { + if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + { + this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(); + hovered = true; + } + } + + if (hovered == false) + { + this.hoverText = ""; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index b623a78f..6658452e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -339,7 +339,7 @@ namespace Revitalize.Framework.Objects waterPumpV1.addComponent(new Vector2(0, 1), waterPumpV1_0_1); this.AddItem("WaterPumpV1", waterPumpV1); - MultiTiledObject steamBoilerV1= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false))); + MultiTiledObject steamBoilerV1= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false,false,1))); SteamBoiler steamBoilerV1_0_0 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16),new Dictionary>() { {"Default",new List(){ @@ -349,7 +349,7 @@ namespace Revitalize.Framework.Objects new Animation(32,0,16,16) } }, - },"Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, ""); + },"Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, true, ""); SteamBoiler steamBoilerV1_1_0 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 0, 16, 16), new Dictionary>() { @@ -360,7 +360,7 @@ namespace Revitalize.Framework.Objects new Animation(48,0,16,16) } }, - }, "Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_0_1 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 16, 16, 16), new Dictionary>() { @@ -371,7 +371,7 @@ namespace Revitalize.Framework.Objects new Animation(32,16,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_1_1 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 16, 16, 16), new Dictionary>() { @@ -382,7 +382,7 @@ namespace Revitalize.Framework.Objects new Animation(48,16,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_0_2 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 32, 16, 16), new Dictionary>() { @@ -393,7 +393,7 @@ namespace Revitalize.Framework.Objects new Animation(32,32,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_1_2 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 32, 16, 16), new Dictionary>() { @@ -404,7 +404,7 @@ namespace Revitalize.Framework.Objects new Animation(48,32,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); steamBoilerV1.addComponent(new Vector2(0, 0), steamBoilerV1_0_0); steamBoilerV1.addComponent(new Vector2(1, 0), steamBoilerV1_1_0); @@ -415,9 +415,9 @@ namespace Revitalize.Framework.Objects this.AddItem("SteamBoilerV1", steamBoilerV1); - MultiTiledObject steamEngineV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false))); - SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); - SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + MultiTiledObject steamEngineV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false,true,1))); + SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); steamEngineV1.addComponent(new Vector2(0, 0), steamEngineV1_0_0); steamEngineV1.addComponent(new Vector2(1, 0), steamEngineV1_1_0); this.AddItem("SteamEngineV1", steamEngineV1); From 106b7a94741e8d5f6b66218ecd4f8a174ccc8142 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 8 Oct 2019 13:01:58 -0700 Subject: [PATCH 96/98] Added in windmills. Also fixed machine summary menu crashing when fluid manager doesn't set fluid tanks on initialization. --- .../Objects/Machines/ClothWindmill.png | Bin 0 -> 490 bytes .../Graphics/Objects/Machines/Windmill.png | Bin 0 -> 430 bytes .../Framework/Configs/GlobalMachineConfig.cs | 7 + .../Framework/Managers/FluidManagerV2.cs | 7 +- .../Menus/Machines/MachineSummaryMenu.cs | 28 +- .../Machines/EnergyGeneration/Windmill.cs | 272 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 64 ++++- .../Framework/Utilities/WeatherUtilities.cs | 5 + GeneralMods/Revitalize/ModCore.cs | 7 +- GeneralMods/Revitalize/Revitalize.csproj | 7 + 10 files changed, 380 insertions(+), 17 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ClothWindmill.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Windmill.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ClothWindmill.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ClothWindmill.png new file mode 100644 index 0000000000000000000000000000000000000000..14a1a3f73769681eeaaf7f1f6969787ba0694105 GIT binary patch literal 490 zcmVPx$q)9|UR9J=WR=rNcFc3bYEES^ah8WT@Qb5C~;F25@_}FSZ+KS@KDhV&8rDZ@U5xi1{=}{k>Q#!RaKNavLE=hw4_V z1eneCVE6;(di!0&H(^6Z|^|Ye|--aLrACp_2UyR(~Ir;ar0ux zLxwd%0k;~NO)@+`J2e7&czTX5e=OfQh7{>&Xc*WRF??qRjty@G^Z<5648Lzd--5mc zeGC4*1#AUolMDgAOQ?TzKZJew&g*2qVm3mr;=X*N1+z(p^gjTHpKOo|q6^=dfn)TY g!U>?uar+Jb3r@pgiNe1azW@LL07*qoM6N<$f;e%|q5uE@ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Windmill.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Windmill.png new file mode 100644 index 0000000000000000000000000000000000000000..6166dda5b805ed8c81ffad615d147782249ba240 GIT binary patch literal 430 zcmV;f0a5;mP)Px$Xh}ptR9J=WRzXU{FceK?Rt_U>WN^`yP!PHi#)YToE%X4M!vi?C@D#IfU^c>l z;Hsa6mh(Ejx0zr3HHHdFtI`@0)W_v_6rL+{LD2q64h5)h^iQvgY?WehXfD=*D$A{ZK_VoPf zO)g93;&ZGwyUZ$qOmcCxf^h_LjoZ%oXdDXQtNHxc!Z-ri&28s=H12FQx#42>Kvfoc zxtRCQP1~uLw|9$YIDnGp=V!fYSBv@()djBPNJJ=xx?m;)L}=R1h&OGgmW%nQbHK+j z1n}BcWua;1Bp{~$3DFMxCFBC41=L^PlLUnDy#hj3FqIDvqGKYJAeA7MAeA7M06I{W zg;wg 0) + { + this.inputFluidTank1Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 1 fluid:", this.fluidDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.inputTank1.fluid != null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank1.fluid != null ? this.objectSource.info.fluidManager.inputTank1.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + if (this.objectSource.GetFluidManager().inputTank2.capacity > 0) + { + this.inputFluidTank2Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 2 fluid:", this.fluidDisplayLocation + new Vector2(0, 64), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.inputTank2.fluid != null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank2.fluid != null ? this.objectSource.info.fluidManager.inputTank2.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + //ModCore.log(this.objectSource.info.fluidManager.outputTank.fluid != null ? "Color of fluid:" + this.objectSource.info.fluidManager.outputTank.fluid.color.ToString() : "Color is null!"); + if (this.objectSource.GetFluidManager().outputTank.capacity > 0) + { + this.outputFluidTankButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Output fluid:", this.fluidDisplayLocation + new Vector2(0, 128), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.outputTank.fluid != null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.outputTank.fluid != null ? this.objectSource.info.fluidManager.outputTank.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + } this.requiredEnergyPer10Min = RequiredEnergyPer10Min; } @@ -162,11 +170,11 @@ namespace Revitalize.Framework.Menus.Machines hovered = true; } } + } - if (hovered == false) - { - this.hoverText = ""; - } + if (hovered == false) + { + this.hoverText = ""; } } @@ -180,7 +188,7 @@ namespace Revitalize.Framework.Menus.Machines else if (this.energy.producesEnergy) { - return "Produces " + EnergyAmount + " per 10 minutes."; + return "Produces " + EnergyAmount + " energy per 10 minutes."; } else return ""; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs new file mode 100644 index 00000000..1a1cbd6a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs @@ -0,0 +1,272 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Managers; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardustCore.Animations; + +namespace Revitalize.Framework.Objects.Machines.EnergyGeneration +{ + public class Windmill:Machine + { + + public Windmill() { } + + public Windmill(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info) + { + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; + } + + public Windmill(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info, TileLocation) + { + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; + } + + public Windmill(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, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info, TileLocation) + { + this.offsetKey = offsetKey; + this.containerObject = obj; + this.producedResources = ProducedResources ?? new List(); + this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes; + this.timeToProduce = TimeToProduce; + this.updatesContainerObjectForProduction = UpdatesContainer; + this.MinutesUntilReady = TimeToProduce; + this.craftingRecipeBook = CraftingBook; + this.createStatusBubble(); + this.requiredFluidForOperation = FluidRequiredForOperation; + this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation; + } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + base.updateWhenCurrentLocation(time, environment); + + this.animationManager.prepareForNextUpdateTick(); + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + + this.updateInfo(); + //ModCore.log(this.info.animationManager.currentAnimationName); + this.info.animationManager.playAnimation("Working"); + if (this.updatesContainerObjectForProduction) + { + int remaining = minutes; + + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) + { + while (remaining > 0) + { + remaining -= 10; + this.produceEnergy(); + this.storeEnergyToNetwork(); + } + } + + return false; + } + else + { + + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) + { + this.storeEnergyToNetwork(); + } + + return false; + } + + //return base.minutesElapsed(minutes, environment); + } + + public override bool rightClicked(Farmer who) + { + if (this.location == null) + this.location = Game1.player.currentLocation; + if (Game1.menuUp || Game1.currentMinigame != null) return false; + + //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + this.createMachineMenu(); + return true; + } + + + public override Item getOne() + { + Windmill component = new Windmill(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.requiredFluidForOperation, this.amountOfFluidRequiredForOperation); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + Windmill self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (ModCore.IsNullOrDefault(self)) return null; + try + { + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + self.containerObject.removeComponent(offsetKey); + self.containerObject.addComponent(offsetKey, self); + } + } + catch (Exception err) + { + ModCore.log(err); + } + + return self; + } + + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + this.updateInfo(); + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(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 * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + 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 + { + if (this.animationManager.canTickAnimation()) + { + this.animationManager.tickAnimation(); + } + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + public override void produceEnergy() + { + if (this.location != null) + { + if (this.location.IsOutdoors == false) return; + } + if (this.GetEnergyManager().canReceieveEnergy) + { + if (WeatherUtilities.IsWeatherGoodForWindmills()) + { + this.GetEnergyManager().produceEnergy((int)(this.energyRequiredPer10Minutes*ModCore.Configs.machinesConfig.windmill_windyDayPowerMultiplier)); + } + else + { + this.GetEnergyManager().produceEnergy(this.energyRequiredPer10Minutes); + } + } + + } + + public override void updateInfo() + { + if (this.info == null || this.containerObject == null) + { + this.ItemInfo = this.text; + //ModCore.log("Updated item info!"); + return; + } + + if (this.requiresUpdate()) + { + //this.ItemInfo = this.text; + this.text = this.ItemInfo; + this.info.cleanAfterUpdate(); + //this.containerObject.updateInfo(); + //ModCore.log("Force an update for machine: " + this.info.name); + MultiplayerUtilities.RequestUpdateSync(this.guid); + } + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 6658452e..f6ee11db 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -416,11 +416,71 @@ namespace Revitalize.Framework.Objects this.AddItem("SteamBoilerV1", steamBoilerV1); MultiTiledObject steamEngineV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false,true,1))); - SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); - SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(SteamEngine), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(SteamEngine), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); steamEngineV1.addComponent(new Vector2(0, 0), steamEngineV1_0_0); steamEngineV1.addComponent(new Vector2(1, 0), steamEngineV1_1_0); this.AddItem("SteamEngineV1", steamEngineV1); + + + MultiTiledObject windMillV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV1", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Windmill"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null)); + Windmill windMillV1_0_0 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV1", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Windmill"), new Animation(0, 0, 16, 16),new Dictionary>() { + + {"Default",new List() + { + new Animation(0,0,16,16) + } }, + {"Working",new List() + { + new Animation(0,0,16,16,20), + new Animation(16,0,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV1_basePowerProduction, 0, true, "", null, 0); + Windmill windMillV1_0_1 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV1", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Windmill"), new Animation(0, 0, 16, 16), new Dictionary>() { + + {"Default",new List() + { + new Animation(0,16,16,16) + } }, + {"Working",new List() + { + new Animation(0,16,16,16,20), + new Animation(16,16,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV1_basePowerProduction, 0, false, "", null, 0); + windMillV1.addComponent(new Vector2(0, 0), windMillV1_0_0); + windMillV1.addComponent(new Vector2(0, 1), windMillV1_0_1); + this.AddItem("WindmillV1", windMillV1); + + + MultiTiledObject windMillV2 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV2", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Improved Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV2", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 700, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null)); + Windmill windMillV2_0_0 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV2", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), typeof(Windmill), Color.White, true), new BasicItemInformation("Improved Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV2", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 700, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new Animation(0, 0, 16, 16), new Dictionary>() { + + {"Default",new List() + { + new Animation(0,0,16,16) + } }, + {"Working",new List() + { + new Animation(0,0,16,16,20), + new Animation(16,0,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV2_basePowerProduction, 0, true, "", null, 0); + Windmill windMillV2_0_1 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV2", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), typeof(Windmill), Color.White, true), new BasicItemInformation("Improved Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV2", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 700, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new Animation(0, 0, 16, 16), new Dictionary>() { + + {"Default",new List() + { + new Animation(0,16,16,16) + } }, + {"Working",new List() + { + new Animation(0,16,16,16,20), + new Animation(16,16,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV2_basePowerProduction, 0, false, "", null, 0); + windMillV2.addComponent(new Vector2(0, 0), windMillV2_0_0); + windMillV2.addComponent(new Vector2(0, 1), windMillV2_0_1); + this.AddItem("WindmillV2", windMillV2); } private void loadInConnectionComponents() diff --git a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs index 55aef69c..61389693 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs @@ -67,5 +67,10 @@ namespace Revitalize.Framework.Utilities return IsItRaining() || IsItSnowing() || IsStorm(); } + public static bool IsWeatherGoodForWindmills() + { + return IsWindyDay() || IsStorm(); + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index ecd11d81..b47bed7f 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -588,14 +588,11 @@ namespace Revitalize ModCore.ObjectManager.GetItem("SolarPanelTier1",1), ModCore.ObjectManager.GetItem("SolarArrayTier1",1), new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false), - ModCore.ObjectManager.GetItem("Lighthouse",1), ModCore.ObjectManager.GetItem("CopperWire",10), batteryBin, ModCore.ObjectManager.GetItem("Capacitor",1), ModCore.ObjectManager.GetItem("ChargingStation",1), - ModCore.ObjectManager.GetItem("Grinder",1), new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), - ModCore.ObjectManager.GetTool("MiningDrillV1"), ModCore.ObjectManager.GetTool("ChainsawV1"), ModCore.ObjectManager.GetItem("MiningDrillMachineV1"), ModCore.ObjectManager.GetItem("AlloyFurnace"), @@ -603,7 +600,9 @@ namespace Revitalize ModCore.ObjectManager.GetItem("WaterPumpV1"), ModCore.ObjectManager.GetItem("SteamBoilerV1"), ModCore.ObjectManager.GetItem("IronPipe",100), - ModCore.ObjectManager.GetItem("SteamEngineV1") + ModCore.ObjectManager.GetItem("SteamEngineV1"), + ModCore.ObjectManager.GetItem("WindmillV1"), + ModCore.ObjectManager.GetItem("WindmillV2") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index aaf21f71..b9ab7842 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -168,6 +168,7 @@ + @@ -498,6 +499,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -525,6 +529,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 89ef844ab3b1e9e25e6065b58bc1c7eeef72ece8 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 9 Oct 2019 00:18:45 -0700 Subject: [PATCH 97/98] Fixed crafting not working for player inventory. Fixed machine summary menu crashing when displaying empty tanks. Fixed animaation managers not copying over correctly. --- .../Menus/CraftingMenu/GoldButton.png | Bin 0 -> 244 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 34 ++++++++++++---- .../Revitalize/Framework/Crafting/Recipe.cs | 22 +++++++--- .../Revitalize/Framework/Crafting/StatCost.cs | 8 ++-- .../Objects/Furniture/FurnitureFactory.cs | 3 ++ .../Framework/Managers/ColorManager.cs | 5 +++ .../Menus/CraftingInformationPage.cs | 38 +++++++++++++++--- .../Framework/Menus/CraftingMenuV1.cs | 3 +- .../Menus/Machines/MachineSummaryMenu.cs | 35 ++++++++++------ .../Framework/Objects/BasicItemInformation.cs | 2 +- .../Framework/Objects/CustomObject.cs | 4 +- .../Objects/Furniture/ChairTileComponent.cs | 4 +- .../Machines/EnergyGeneration/SteamBoiler.cs | 4 +- .../Machines/EnergyGeneration/SteamEngine.cs | 4 +- .../Machines/EnergyGeneration/Windmill.cs | 4 +- .../Framework/Objects/ObjectManager.cs | 2 + .../Framework/Utilities/InventoryManager.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 3 -- GeneralMods/Revitalize/Revitalize.csproj | 3 ++ .../Animations/AnimationManager.cs | 34 ++++++++++++++-- .../ComponentsV2/Buttons/AnimatedButton.cs | 2 +- 21 files changed, 161 insertions(+), 57 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/GoldButton.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/GoldButton.png b/GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/GoldButton.png new file mode 100644 index 0000000000000000000000000000000000000000..bf04da0ceed3c249b88676151f7e493236993824 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_J-(hFJ7o zov@Mjkb!`!JjZ(n-?v>|heA(@BuZ+9t1k&im5fPg5|LDJ-q6f_X@P=zx~o_7j&tST z@9)q5QTp~-Z+hyz>_yofliw}Sopa7mn{Tb>J*@*`4U?ZP5O$iqErh{O;@zf#&wCk4 zFWp|<@J{=i?-BE#9=}*mx$e8qRdDEWkpFcDDer!R-v@jJR~ZRKeJ(T)S;}{jac%() { //Inputs here new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)), true)); - - WorkbenchRecipes.addCraftingRecipe("Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), @@ -332,36 +332,30 @@ namespace Revitalize.Framework.Crafting { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), }, new CraftingRecipeComponent(new StardewValley.Tools.WateringCan() { UpgradeLevel = 0 }, 1)), true)); - WorkbenchRecipes.addCraftingRecipe("Copper Wire", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"),2),null,0),true)); - WorkbenchRecipes.addCraftingRecipe("Alloy Furnace", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Clay,20),10), new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AlloyFurnace"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Sand Box", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 25) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SandBox"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Battery Bin", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"),10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BatteryBin"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Capacitor", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,50),50), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,10),10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Charging Station", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), @@ -370,8 +364,21 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ChargingStation"), 1), null, 0), true)); + WorkbenchRecipes.addCraftingRecipe("Oak Chair", new UnlockableCraftingRecipe("Furniture", new Recipe(new List(),new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Oak Chair"),1),new StatCost(0,0,100,0),0), true)); + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { + foreach(KeyValuePair pair in WorkbenchRecipes.craftingMenuTabs) + { + if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key)) + { + + } + else + { + CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value); + } + } foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) { if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) @@ -558,6 +565,17 @@ namespace Revitalize.Framework.Crafting if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { + foreach (KeyValuePair pair in AnvilRecipes.craftingMenuTabs) + { + if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key)) + { + + } + else + { + CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value); + } + } foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) { if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index af8db6e5..4e636f29 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -58,7 +58,7 @@ namespace Revitalize.Framework.Crafting { output }; - this.statCost = StatCost ?? new StatCost(); + this.statCost = StatCost; this.timeToCraft = TimeToCraft; } @@ -68,7 +68,7 @@ namespace Revitalize.Framework.Crafting this.outputs = outputs; this.outputName = OutputName; this.outputDescription = OutputDescription; - this.statCost = StatCost ?? new StatCost(); + this.statCost = StatCost; this.timeToCraft = TimeToCraft; } @@ -87,6 +87,7 @@ namespace Revitalize.Framework.Crafting /// Checks if an inventory contains all items. public bool InventoryContainsAllIngredient(IList items) { + if (this.ingredients.Count == 0) return true; foreach (CraftingRecipeComponent pair in this.ingredients) if (!this.InventoryContainsIngredient(items, pair)) return false; return true; @@ -176,7 +177,7 @@ namespace Revitalize.Framework.Crafting /// Checks to see if the invventory is the player's public void craft(ref IList from, ref IList to, bool dropToGround = false, bool isPlayerInventory = false) { - InventoryManager manager = new InventoryManager(to); + InventoryManager manager = new InventoryManager(to,Game1.player.MaxItems); if (manager.ItemCount + this.outputs.Count >= manager.capacity) { if (isPlayerInventory) @@ -198,7 +199,11 @@ namespace Revitalize.Framework.Crafting Game1.player.Items = playerItems; //Set the items to be post consumption. foreach (Item I in outPutItems) - Game1.player.addItemToInventory(I); //Add all items produced. + { + Item copy = I.getOne(); + copy.Stack = I.Stack; + Game1.player.addItemToInventory(copy); //Add all items produced. + } this.statCost.payCost(); } @@ -209,7 +214,14 @@ namespace Revitalize.Framework.Crafting public bool CanCraft(IList items) { - return this.InventoryContainsAllIngredient(items); + if (this.statCost == null) + { + return this.InventoryContainsAllIngredient(items); + } + else + { + return this.InventoryContainsAllIngredient(items) && this.statCost.canSafelyAffordCost(); + } } } } diff --git a/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs b/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs index 4ab07ed6..8711b04c 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs @@ -9,10 +9,10 @@ namespace Revitalize.Framework.Crafting { public class StatCost { - int health; - int stamina; - int magic; - int gold; + public int health; + public int stamina; + public int magic; + public int gold; public StatCost(int Stamina = 0, int Health = 0, int Gold = 0, int Magic = 0){ this.stamina = Stamina; diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs index 48dcb19e..d756cea4 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs @@ -325,6 +325,7 @@ namespace Revitalize.Framework.Factories.Objects foreach (var v in chairObjects) { ModCore.ObjectManager.chairs.Add(v.Value.info.id, v.Value); + ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value); } } } @@ -406,6 +407,7 @@ namespace Revitalize.Framework.Factories.Objects foreach (var v in chairObjects) { ModCore.ObjectManager.tables.Add(v.Value.info.id, v.Value); + ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value); } } } @@ -488,6 +490,7 @@ namespace Revitalize.Framework.Factories.Objects foreach (var v in chairObjects) { ModCore.ObjectManager.furnitureStorage.Add(v.Value.info.id, v.Value); + ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value); } } } diff --git a/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs b/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs index e13265b4..e5de6a95 100644 --- a/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs +++ b/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs @@ -98,5 +98,10 @@ namespace Revitalize.Framework.Managers return self; } + + public ColorManager Copy() + { + return new ColorManager(this._blendInfluence, this._colorMixMode); + } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 5ad31b26..7f4901a7 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -34,6 +34,7 @@ namespace Revitalize.Framework.Menus private Dictionary requiredItems; public AnimatedButton craftingButton; + public AnimatedButton goldButton; public bool isPlayerInventory; @@ -70,6 +71,14 @@ namespace Revitalize.Framework.Menus } this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f); this.outputInventory = this.inventory; + + if (this.infoButton.recipe.statCost != null) + { + if (this.infoButton.recipe.statCost.gold > 0) + { + this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + } } public CraftingInformationPage(int x, int y, int width, int height, Color BackgroundColor, CraftingRecipeButton ItemToDisplay, ref IList Inventory,ref IList OutputInventory ,bool IsPlayerInventory, Machine Machine) : base(x, y, width, height, false) @@ -92,6 +101,13 @@ namespace Revitalize.Framework.Menus { this.outputInventory = this.inventory; } + if (this.infoButton.recipe.statCost != null) + { + if (this.infoButton.recipe.statCost.gold > 0) + { + this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + } this.outputInventory = OutputInventory; this.machine = Machine; } @@ -104,7 +120,15 @@ namespace Revitalize.Framework.Menus { Game1.soundBank.PlayCue("coin"); - this.infoButton.craftItem(this.inventory, this.outputInventory); + if (this.isPlayerInventory) + { + this.infoButton.craftItem(); + } + else + { + this.infoButton.craftItem(this.inventory, this.outputInventory); + + } if (this.machine != null) { if (this.infoButton.recipe.timeToCraft == 0) @@ -177,9 +201,13 @@ namespace Revitalize.Framework.Menus button.Key.draw(b); b.DrawString(Game1.smallFont, button.Key.item.DisplayName+ " x "+button.Value.ToString(), button.Key.Position + new Vector2(64, 16), this.getNameColor(button.Key.item, button.Value)); } + if (this.goldButton != null) + { + this.goldButton.draw(b); + b.DrawString(Game1.smallFont, this.infoButton.recipe.statCost.gold+" G", this.goldButton.Position +new Vector2(0,32),Color.Black); + } this.craftingButton.draw(b, this.getCraftableColor().A); - this.drawMouse(b); } @@ -264,11 +292,9 @@ namespace Revitalize.Framework.Menus /// Gets the height position for where to draw a required ingredient. /// /// - private Vector2 getIngredientHeightOffset() + private Vector2 getMoneyRequiredOffset() { - string parsedDescription = Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width); - Vector2 offset=Game1.smallFont.MeasureString(parsedDescription); - return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count)); + return new Vector2(this.xPositionOnScreen+64+this.width,this.yPositionOnScreen+128); } private float getCraftingButtonHeight() diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 0b43795a..390e3c29 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -263,7 +263,8 @@ namespace Revitalize.Framework.Menus } else { - Vector2 newPos = new Vector2(100 + (48), this.yPositionOnScreen + (24 * 4) * (count + 1)); + Vector2 newPos = new Vector2(100 + (48), (this.yPositionOnScreen+24) + ((24 * 4) * (count + 1))); + ModCore.log("newPos: " + newPos.ToString()); Button.Position = newPos; this.CraftingTabs.Add(name, Button); this.craftingItemsToDisplay.Add(name, new List()); diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index ea6edb15..1f5893e6 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -144,30 +144,40 @@ namespace Revitalize.Framework.Menus.Machines if (this.objectSource.info.fluidManager.InteractsWithFluids) { - if (this.inputFluidTank1Button.containsPoint(x, y)) + if (this.inputFluidTank1Button != null) { - if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + if (this.inputFluidTank1Button.containsPoint(x, y)) { - this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(); - hovered = true; + if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + { + this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(); + hovered = true; + } } } - if (this.inputFluidTank2Button.containsPoint(x, y)) + if (this.inputFluidTank2Button != null) { - if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + if (this.inputFluidTank2Button.containsPoint(x, y)) { - this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(); - hovered = true; + if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + { + this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(); + hovered = true; + } } + } - if (this.outputFluidTankButton.containsPoint(x, y)) + if (this.outputFluidTankButton != null) { - if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + if (this.outputFluidTankButton.containsPoint(x, y)) { - this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(); - hovered = true; + if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + { + this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(); + hovered = true; + } } } } @@ -187,7 +197,6 @@ namespace Revitalize.Framework.Menus.Machines } else if (this.energy.producesEnergy) { - return "Produces " + EnergyAmount + " energy per 10 minutes."; } else return ""; diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 08e5f5b5..8de795e3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -451,7 +451,7 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy()); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager.Copy(), this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy()); } public bool requiresSyncUpdate() diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index ecce4bb7..60a4f39b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -440,7 +440,8 @@ namespace Revitalize.Framework.Objects if (this.info.animationManager.animations.ContainsKey(this.generateRotationalAnimationKey())) { - this.info.animationManager.setAnimation(this.generateRotationalAnimationKey()); + this.info.animationManager.enabled = true; + this.info.animationManager.playAnimation(this.generateRotationalAnimationKey()); } else { @@ -451,6 +452,7 @@ namespace Revitalize.Framework.Objects public string generateRotationalAnimationKey() { + if (string.IsNullOrEmpty(this.info.animationManager.currentAnimationName)) return this.generateDefaultRotationalAnimationKey(); return (this.info.animationManager.currentAnimationName.Split('_')[0]) + "_" + (int)this.info.facingDirection; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index 93e2581e..217cb95b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -180,8 +180,8 @@ namespace Revitalize.Framework.Objects.Furniture public override Item getOne() { ChairTileComponent component = new ChairTileComponent(this.data,this.info.Copy(), (ChairInformation)this.furnitureInfo); - component.containerObject = this.containerObject; - component.offsetKey = this.offsetKey; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs index c9ce4bfa..4e4ca65a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs @@ -124,8 +124,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public override Item getOne() { SteamBoiler component = new SteamBoiler(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); - component.containerObject = this.containerObject; - component.offsetKey = this.offsetKey; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs index 26d0d1ab..1c553686 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs @@ -140,8 +140,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public override Item getOne() { SteamEngine component = new SteamEngine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook,this.requiredFluidForOperation,this.amountOfFluidRequiredForOperation); - component.containerObject = this.containerObject; - component.offsetKey = this.offsetKey; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs index 1a1cbd6a..e9c2fb62 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs @@ -121,8 +121,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public override Item getOne() { Windmill component = new Windmill(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.requiredFluidForOperation, this.amountOfFluidRequiredForOperation); - component.containerObject = this.containerObject; - component.offsetKey = this.offsetKey; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index f6ee11db..08072839 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Revitalize.Framework.Factories.Objects; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Objects.CraftingTables; using Revitalize.Framework.Objects.Extras; @@ -116,6 +117,7 @@ namespace Revitalize.Framework.Objects this.loadInMachines(); this.loadInTools(); this.loadInAestheticsObjects(); + FurnitureFactory.LoadFurnitureFiles(); } private void loadInAestheticsObjects() diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index f8c9e128..5e2dc2d5 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -64,9 +64,9 @@ namespace Revitalize.Framework.Utilities this.displayColumns = DisplayColumns; } - public InventoryManager(IList items, int DisplayRows = 6, int DisplayColumns = 6) + public InventoryManager(IList items, int Capacity= int.MaxValue, int DisplayRows = 6, int DisplayColumns = 6) { - this.capacity = int.MaxValue; + this.capacity = Capacity; this.setMaxLimit(int.MaxValue); this.items = items; this.bufferItems = new List(); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b47bed7f..922c5a9a 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -490,9 +490,6 @@ namespace Revitalize ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Rugs.RugTest", rug); - - FurnitureFactory.LoadFurnitureFiles(); - SeasideScramble sscGame = new SeasideScramble(); ArcadeCabinetTile ssc1 = new ArcadeCabinetTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), typeof(ArcadeCabinetTile), Color.White), new BasicItemInformation("Seaside Scramble Arcade Game", "Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", "A arcade to play Seaside Scramble!", "Arcades", Color.LimeGreen, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary>() { diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b9ab7842..bc7a392e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -412,6 +412,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index 5d220c48..5a37d561 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -29,6 +29,8 @@ namespace StardustCore.Animations public bool hasRecievedUpdateTick; + public string startingAnimationName; + /// /// Checks to see if there is an animation playing. /// @@ -57,6 +59,7 @@ namespace StardustCore.Animations this.currentAnimation = this.defaultDrawFrame; this.currentAnimationName = ""; this.animationDataString = ""; + this.startingAnimationName = ""; } public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, string animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true) @@ -68,6 +71,7 @@ namespace StardustCore.Animations this.animationDataString = animationString; this.animations = parseAnimationsFromXNB(animationString); + this.startingAnimationName = startingAnimationKey; if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) this.setAnimation(startingAnimationKey, startingAnimationFrame); else @@ -85,12 +89,29 @@ namespace StardustCore.Animations this.enabled = EnabledByDefault; this.animations = animationString; - if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + this.startingAnimationName = startingAnimationKey; + if (this.animations != null) { - this.setAnimation(startingAnimationKey, startingAnimationFrame); - this.playAnimation(startingAnimationKey, true, startingAnimationFrame); - } + if (string.IsNullOrEmpty(startingAnimationKey) == false) + { + if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + { + this.setAnimation(startingAnimationKey, startingAnimationFrame); + this.playAnimation(startingAnimationKey, true, startingAnimationFrame); + } + else + { + this.currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + } + } + else + { + this.currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + } + } else { this.currentAnimation = this.defaultDrawFrame; @@ -485,5 +506,10 @@ namespace StardustCore.Animations { return this.objectTexture.getTexture(); } + + public AnimationManager Copy() + { + return new AnimationManager(this.objectTexture, this.defaultDrawFrame, this.animations, this.startingAnimationName, 0, this.enabled); + } } } diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs index a86159c7..ffd68198 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs @@ -17,7 +17,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// /// The default bounds for the button. /// - private Rectangle defaultBounds; + public Rectangle defaultBounds; /// /// The actual bounds for the button which takes scale into acount. /// From 20acb522ef23f4e8d6bbc767d7ec1814b93c1301 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 27 Nov 2019 15:10:55 -0800 Subject: [PATCH 98/98] Updated pathos api package to 3.0 and started updating mods to SMAPI 3.0. Fixed AdvancedSaveBackup and AutoSpeed so far. --- .../AdvancedSaveBackup.csproj | 2 +- GeneralMods/AdvancedSaveBackup/manifest.json | 4 +-- GeneralMods/AutoSpeed/AutoSpeed.cs | 30 +++++++++++++++- GeneralMods/AutoSpeed/AutoSpeed.csproj | 4 ++- .../AutoSpeed/Framework/AutoSpeedAPI.cs | 34 +++++++++++++++++++ .../AutoSpeed/Framework/IAutoSpeedApi.cs | 22 ++++++++++++ GeneralMods/AutoSpeed/manifest.json | 4 +-- .../BillboardAnywhere.csproj | 2 +- .../BuildEndurance/BuildEndurance.csproj | 2 +- GeneralMods/BuildHealth/BuildHealth.csproj | 2 +- .../BuyBackCollectables.csproj | 2 +- .../CustomNPCFramework.csproj | 2 +- .../DailyQuestAnywhere.csproj | 2 +- .../Fall28SnowDay/Fall28SnowDay.csproj | 2 +- .../FarmersMarketStall.csproj | 2 +- .../HappyBirthday/HappyBirthday.csproj | 2 +- GeneralMods/MapEvents/EventSystem.csproj | 2 +- .../MapExampleRF1/MapExampleRF1.csproj | 7 ++-- GeneralMods/MapExampleRF1/packages.config | 2 +- GeneralMods/MoreRain/MoreRain.csproj | 2 +- .../MuseumRearranger/MuseumRearranger.csproj | 2 +- GeneralMods/NightOwl/NightOwl.csproj | 2 +- GeneralMods/NoMorePets/NoMorePets.csproj | 2 +- GeneralMods/Revitalize/Revitalize.csproj | 2 +- GeneralMods/SaveAnywhere/SaveAnywhere.csproj | 2 +- .../SimpleSoundManager.csproj | 2 +- .../StardewSymphonyRemastered.csproj | 2 +- GeneralMods/StardustCore/StardustCore.csproj | 2 +- .../SundropMapEvents/SundropMapEvents.csproj | 2 +- GeneralMods/TimeFreeze/TimeFreeze.csproj | 2 +- .../Vocalization/Vocalization.csproj | 2 +- 31 files changed, 118 insertions(+), 35 deletions(-) create mode 100644 GeneralMods/AutoSpeed/Framework/AutoSpeedAPI.cs create mode 100644 GeneralMods/AutoSpeed/Framework/IAutoSpeedApi.cs diff --git a/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj b/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj index 46bf2a7a..56a8f844 100644 --- a/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj +++ b/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/AdvancedSaveBackup/manifest.json b/GeneralMods/AdvancedSaveBackup/manifest.json index 559192a8..ca57093f 100644 --- a/GeneralMods/AdvancedSaveBackup/manifest.json +++ b/GeneralMods/AdvancedSaveBackup/manifest.json @@ -1,10 +1,10 @@ { "Name": "Advanced Save Backup", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.7.1", "Description": "Backs up your save files when loading SMAPI and every in game night when saving.", "UniqueID": "Omegasis.AdvancedSaveBackup", "EntryDll": "AdvancedSaveBackup.dll", - "MinimumApiVersion": "2.10.1", + "MinimumApiVersion": "3.0.0", "UpdateKeys": [ "Nexus:435" ] } diff --git a/GeneralMods/AutoSpeed/AutoSpeed.cs b/GeneralMods/AutoSpeed/AutoSpeed.cs index d4859a35..85e3d3ef 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.cs +++ b/GeneralMods/AutoSpeed/AutoSpeed.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.Linq; using Omegasis.AutoSpeed.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; @@ -8,12 +10,24 @@ namespace Omegasis.AutoSpeed /// The mod entry point. public class AutoSpeed : Mod { + /********* + **Static Fields + *********/ + /// + /// All of the speed that is added together for auto speed. This is used for mod authors to hook in their speed boosts before auto speed applies the default speed boost. + /// + public Dictionary combinedAddedSpeed; + /********* ** Fields *********/ /// The mod configuration. private ModConfig Config; + /// + /// A static reference to expose public fields. + /// + public static AutoSpeed Instance; /********* ** Public methods @@ -24,6 +38,17 @@ namespace Omegasis.AutoSpeed { helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; this.Config = helper.ReadConfig(); + this.combinedAddedSpeed = new Dictionary(); + Instance = this; + } + + /// + /// Returns a copy of the mods' api. + /// + /// + public override object GetApi() + { + return new AutoSpeedAPI(); } @@ -36,7 +61,10 @@ namespace Omegasis.AutoSpeed private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (Context.IsPlayerFree) - Game1.player.addedSpeed = this.Config.Speed; + { + int addedSpeed = this.combinedAddedSpeed.Values.Sum(); + Game1.player.addedSpeed = this.Config.Speed+addedSpeed; + } } } } diff --git a/GeneralMods/AutoSpeed/AutoSpeed.csproj b/GeneralMods/AutoSpeed/AutoSpeed.csproj index 50269de6..46dda84d 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.csproj +++ b/GeneralMods/AutoSpeed/AutoSpeed.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + @@ -77,6 +77,8 @@ Properties\GlobalAssemblyInfo.cs + + diff --git a/GeneralMods/AutoSpeed/Framework/AutoSpeedAPI.cs b/GeneralMods/AutoSpeed/Framework/AutoSpeedAPI.cs new file mode 100644 index 00000000..020fc43b --- /dev/null +++ b/GeneralMods/AutoSpeed/Framework/AutoSpeedAPI.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Omegasis.AutoSpeed.Framework +{ + /// + /// API for auto speed to hook into the Game1.player.addedSpeed function. + /// + public class AutoSpeedAPI + { + + /// + /// Allows adding a speed for Auto Speed to take acount for when calculating Game1.player.addedSpeed; Will fail if a unique key has already been added. + /// + /// + /// + public void addSpeedBoost(string ID, int Amount) + { + AutoSpeed.Instance.combinedAddedSpeed.Add(ID, Amount); + } + /// + /// Removes an added speed boost by passing in the unique key. + /// + /// + /// + public void remvoveSpeedBoost(string ID, int Amount) + { + AutoSpeed.Instance.combinedAddedSpeed.Remove(ID); + } + } +} diff --git a/GeneralMods/AutoSpeed/Framework/IAutoSpeedApi.cs b/GeneralMods/AutoSpeed/Framework/IAutoSpeedApi.cs new file mode 100644 index 00000000..6edeaff4 --- /dev/null +++ b/GeneralMods/AutoSpeed/Framework/IAutoSpeedApi.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Omegasis.AutoSpeed.Framework +{ + /// + /// Interface used to interface AutoSpeed's API class. + /// + public interface IAutoSpeedAPI + { + void addSpeedBoost(string ID, int Amount); + /// + /// Removes an added speed boost by passing in the unique key. + /// + /// + /// + void remvoveSpeedBoost(string ID, int Amount); + } +} diff --git a/GeneralMods/AutoSpeed/manifest.json b/GeneralMods/AutoSpeed/manifest.json index b5c3f9e3..ac3c625b 100644 --- a/GeneralMods/AutoSpeed/manifest.json +++ b/GeneralMods/AutoSpeed/manifest.json @@ -1,10 +1,10 @@ { "Name": "Auto Speed", "Author": "Alpha_Omegasis", - "Version": "1.8.0", + "Version": "1.9.0", "Description": "Got to go fast!", "UniqueID": "Omegasis.AutoSpeed", "EntryDll": "AutoSpeed.dll", - "MinimumApiVersion": "2.10.1", + "MinimumApiVersion": "3.0.0", "UpdateKeys": [ "Nexus:443" ] } diff --git a/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj b/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj index d98ba599..36bff343 100644 --- a/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj +++ b/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/BuildEndurance/BuildEndurance.csproj b/GeneralMods/BuildEndurance/BuildEndurance.csproj index 83e9f2df..ea68b11c 100644 --- a/GeneralMods/BuildEndurance/BuildEndurance.csproj +++ b/GeneralMods/BuildEndurance/BuildEndurance.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/BuildHealth/BuildHealth.csproj b/GeneralMods/BuildHealth/BuildHealth.csproj index f1846f3b..2121f301 100644 --- a/GeneralMods/BuildHealth/BuildHealth.csproj +++ b/GeneralMods/BuildHealth/BuildHealth.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj b/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj index dcba9f4e..d1de638c 100644 --- a/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj +++ b/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index a6467cf3..6abb32e1 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -68,7 +68,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj index 13cf5c50..5e0d840b 100644 --- a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj +++ b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj b/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj index 23b5bc04..9ba5c5f8 100644 --- a/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj +++ b/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj index d77edb4c..3c073956 100644 --- a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj +++ b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/HappyBirthday/HappyBirthday.csproj b/GeneralMods/HappyBirthday/HappyBirthday.csproj index 6f54c1d7..4730af0c 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.csproj +++ b/GeneralMods/HappyBirthday/HappyBirthday.csproj @@ -70,7 +70,7 @@ - + diff --git a/GeneralMods/MapEvents/EventSystem.csproj b/GeneralMods/MapEvents/EventSystem.csproj index 227d5cbf..9a6a2791 100644 --- a/GeneralMods/MapEvents/EventSystem.csproj +++ b/GeneralMods/MapEvents/EventSystem.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/MapExampleRF1/MapExampleRF1.csproj b/GeneralMods/MapExampleRF1/MapExampleRF1.csproj index 5c9a3a80..efb94200 100644 --- a/GeneralMods/MapExampleRF1/MapExampleRF1.csproj +++ b/GeneralMods/MapExampleRF1/MapExampleRF1.csproj @@ -50,15 +50,12 @@ - - - - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/GeneralMods/MapExampleRF1/packages.config b/GeneralMods/MapExampleRF1/packages.config index 84563214..b24c9890 100644 --- a/GeneralMods/MapExampleRF1/packages.config +++ b/GeneralMods/MapExampleRF1/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/GeneralMods/MoreRain/MoreRain.csproj b/GeneralMods/MoreRain/MoreRain.csproj index 1517a05e..1e95e354 100644 --- a/GeneralMods/MoreRain/MoreRain.csproj +++ b/GeneralMods/MoreRain/MoreRain.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/MuseumRearranger/MuseumRearranger.csproj b/GeneralMods/MuseumRearranger/MuseumRearranger.csproj index 7f1ced70..b5736d52 100644 --- a/GeneralMods/MuseumRearranger/MuseumRearranger.csproj +++ b/GeneralMods/MuseumRearranger/MuseumRearranger.csproj @@ -68,7 +68,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/NightOwl/NightOwl.csproj b/GeneralMods/NightOwl/NightOwl.csproj index 7c0f46b8..05d47fe6 100644 --- a/GeneralMods/NightOwl/NightOwl.csproj +++ b/GeneralMods/NightOwl/NightOwl.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/NoMorePets/NoMorePets.csproj b/GeneralMods/NoMorePets/NoMorePets.csproj index d6478fbb..cffd18df 100644 --- a/GeneralMods/NoMorePets/NoMorePets.csproj +++ b/GeneralMods/NoMorePets/NoMorePets.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index bc7a392e..86c29d0d 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -34,7 +34,7 @@ 12.0.1 - + diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.csproj b/GeneralMods/SaveAnywhere/SaveAnywhere.csproj index 2fb9a4ca..9e2f201d 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.csproj +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj b/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj index 4e840a0a..f7060a80 100644 --- a/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj +++ b/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj index 6ae1d2b7..08c2e6e7 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj @@ -68,7 +68,7 @@ - + diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 84ef868f..fc202b8a 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -69,7 +69,7 @@ - + diff --git a/GeneralMods/SundropMapEvents/SundropMapEvents.csproj b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj index fecf165e..46ffd780 100644 --- a/GeneralMods/SundropMapEvents/SundropMapEvents.csproj +++ b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj @@ -67,7 +67,7 @@ - + diff --git a/GeneralMods/TimeFreeze/TimeFreeze.csproj b/GeneralMods/TimeFreeze/TimeFreeze.csproj index b91c66e6..091ef460 100644 --- a/GeneralMods/TimeFreeze/TimeFreeze.csproj +++ b/GeneralMods/TimeFreeze/TimeFreeze.csproj @@ -66,7 +66,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj index ce9bb04a..62287599 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj @@ -30,7 +30,7 @@ 4 - +