From 50dcdf0eb68cab2579dc178f439af077658cda82 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sat, 7 Sep 2019 19:04:24 -0700 Subject: [PATCH] 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