From 1a6ee664b75aac72b7ca20237ce2c8f5f5806bb2 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Mon, 5 Aug 2019 23:10:56 -0700 Subject: [PATCH] Added in storage furniture! --- .../Furniture/Storage/Oak Cabinet.png | Bin 0 -> 491 bytes .../Objects/Furniture/FurnitureFactory.cs | 86 ++++++++ .../Objects/Extras/ArcadeCabinetOBJ.cs | 2 - .../Objects/Furniture/StorageFurnitureOBJ.cs | 146 +++++++++++++ .../Objects/Furniture/StorageFurnitureTile.cs | 206 ++++++++++++++++++ .../Framework/Utilities/InventoryManager.cs | 3 +- .../Serialization/Converters/ItemCoverter.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 1 + GeneralMods/Revitalize/Revitalize.csproj | 5 + 9 files changed, 449 insertions(+), 4 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Furniture/Storage/Oak Cabinet.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Furniture/Storage/Oak Cabinet.png b/GeneralMods/Revitalize/Content/Graphics/Furniture/Storage/Oak Cabinet.png new file mode 100644 index 0000000000000000000000000000000000000000..6b7dd0c5e24585f93af1942f23c491b23023f880 GIT binary patch literal 491 zcmVk0;Pj%#|g$j zn!?b$E%v>;cW3*K0RJ7@$E$PfQ-BTt18&)Fd+8HTRGGv1QCF_$F}lMEy+p!tK*@$Kb{8wR1p2{MqhfM_ow z2rVTK04`(kLu1OT9Eh1Pk+MA%PZY_j!3BuH*`^FpVk-kR;j&{t6CgTJ&4r;$FPiMq zQl6Si&;C@wGXb8nLzLJ6s)uV-WyTx0+g+*>aEwI4NocHb7cZ6_RE0hG!xK< zrxc)iQn%t=bqCtajXEB$fY^kp`Z=?cW!Q!%HnP$z=n_F_K?5-L2cuaZ0v3mjrU96; z1%EJ_vGS0#z~ZoZzeOO0-??-aP(%5|yA~3^bAY~r`K9q+{Yer0@|gO?!Yl|aAVkUV h7nlM+A39-q^Ba&O$%YZNq-p>F002ovPDHLkV1my`*6jcQ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs index c3eb13f7..b756664e 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs @@ -27,12 +27,14 @@ namespace Revitalize.Framework.Factories.Objects public static string ChairFolder = Path.Combine("Data", "Furniture", "Chairs"); public static string TablesFolder = Path.Combine("Data", "Furniture", "Tables"); public static string LampsFolder = Path.Combine("Data", "Furniture", "Lamps"); + public static string StorageFolder = Path.Combine("Data", "Furniture", "Storage"); public static void LoadFurnitureFiles() { LoadChairFiles(); LoadTableFiles(); LoadLampFiles(); + LoadFurnitureStorageFiles(); } private static void LoadChairFiles() @@ -52,6 +54,13 @@ namespace Revitalize.Framework.Factories.Objects SerializeLamps(); DeserializeLamps(); } + + private static void LoadFurnitureStorageFiles() + { + SerializeFurnitureStorageFiles(); + DeserializeFurnitureStorageFiles(); + } + /// /// Serialize a lamp to a .json file for easier creation of like objects. /// @@ -364,6 +373,83 @@ namespace Revitalize.Framework.Factories.Objects } + private static void SerializeFurnitureStorageFiles() + { + StorageFurnitureTile upperLeft = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); + StorageFurnitureTile upperRight = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(16, 0, 16, 16)), Color.White, false, null, null)); + StorageFurnitureTile bottomLeft = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(0, 16, 16, 16)), Color.White, false, null, null)); + StorageFurnitureTile bottomRight = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(16, 16, 16, 16)), Color.White, false, null, null)); + + + StorageFurnitureOBJ obj = new StorageFurnitureOBJ(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(9), null)); + + FactoryInfo uL = new FactoryInfo(upperLeft); + FactoryInfo uR = new FactoryInfo(upperRight); + FactoryInfo bL = new FactoryInfo(bottomLeft); + FactoryInfo bR = new FactoryInfo(bottomRight); + FactoryInfo cabinet = new FactoryInfo(obj); + //TableMultiTiledObject obj = new TableMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableMultiTiledObject), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple oak table to place things on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(), Color.White, false, null, null)); + + //TableFactoryInfo uL = new TableFactoryInfo(upperLeft); + //TableFactoryInfo uR = new TableFactoryInfo(upperRight); + //TableFactoryInfo cL = new TableFactoryInfo(centerLeft); + //TableFactoryInfo cR = new TableFactoryInfo(centerRight); + //TableFactoryInfo bR = new TableFactoryInfo(bottomRight); + + + + ModCore.Serializer.SerializeContentFile("OakCabinet_0_0", uL, Path.Combine(StorageFolder, "OakCabinet")); + ModCore.Serializer.SerializeContentFile("OakCabinet_1_0", uR, Path.Combine(StorageFolder, "OakCabinet")); + ModCore.Serializer.SerializeContentFile("OakCabinet_0_1", bL, Path.Combine(StorageFolder, "OakCabinet")); + ModCore.Serializer.SerializeContentFile("OakCabinet_1_1", bR, Path.Combine(StorageFolder, "OakCabinet")); + ModCore.Serializer.SerializeContentFile("OakCabinet", cabinet, Path.Combine(StorageFolder, "OakCabinet")); + + } + + private static void DeserializeFurnitureStorageFiles() + { + if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", StorageFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", StorageFolder)); + + string[] directories = Directory.GetDirectories(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", StorageFolder)); + foreach (string directory in directories) + { + + string[] files = Directory.GetFiles(directory); + + Dictionary chairObjects = new Dictionary(); + + //Deserialize container. + foreach (string file in files) + { + if ((Path.GetFileName(file)).Contains("_") == true) continue; + else + { + FactoryInfo factoryInfo = ModCore.Serializer.DeserializeContentFile(file); + chairObjects.Add(Path.GetFileNameWithoutExtension(file), new StorageFurnitureOBJ(factoryInfo.PyTkData, factoryInfo.info)); + } + } + //Deseralize components + foreach (string file in files) + { + if ((Path.GetFileName(file)).Contains("_") == false) continue; + else + { + + string[] splits = Path.GetFileNameWithoutExtension(file).Split('_'); + string name = splits[0]; + Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2])); + FactoryInfo info = ModCore.Serializer.DeserializeContentFile(file); + chairObjects[name].addComponent(offset, new StorageFurnitureTile(info.PyTkData, info.info)); + } + } + foreach (var v in chairObjects) + { + ModCore.customObjects.Add(v.Value.info.id, v.Value); + } + } + } + + public static ChairMultiTiledObject GetChair(string name) { return (ChairMultiTiledObject)ModCore.GetObjectFromPool(name); diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs index cd318be6..4792a01f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs @@ -140,8 +140,6 @@ namespace Revitalize.Framework.Objects.Extras } this.location = null; } - else - Game1.showRedMessage("NOOOOOOOO"); } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs new file mode 100644 index 00000000..78126f49 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.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 PyTK.CustomElementHandler; +using StardewValley; + +namespace Revitalize.Framework.Objects.Furniture +{ + public class StorageFurnitureOBJ:MultiTiledObject + { + public StorageFurnitureOBJ() : base() + { + + } + + public StorageFurnitureOBJ(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData, Info) + { + + } + + public StorageFurnitureOBJ(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData, Info, TilePosition) + { + + } + + public StorageFurnitureOBJ(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(PyTKData, Info, TilePosition, Objects) + { + + + } + + public override void rotate() + { + base.rotate(); + } + + public override Item getOne() + { + Dictionary objs = new Dictionary(); + foreach (var pair in this.objects) + { + objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne()); + } + + + return new StorageFurnitureOBJ(this.data, this.info, this.TileLocation, objs); + } + + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + StorageFurnitureOBJ obj = (StorageFurnitureOBJ)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); + //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); + StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString()); + component.InitNetFields(); + + 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 bool canBePlacedHere(GameLocation l, Vector2 tile) + { + return base.canBePlacedHere(l, tile); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + foreach (KeyValuePair pair in this.objects) + { + if (!this.isPlaceable()) + return; + int x = Game1.getOldMouseX() + Game1.viewport.X + (int)((pair.Value as MultiTiledComponent).offsetKey.X * Game1.tileSize); + int y = Game1.getOldMouseY() + Game1.viewport.Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y * Game1.tileSize); + if ((double)Game1.mouseCursorTransparency == 0.0) + { + x = ((int)Game1.player.GetGrabTile().X + (int)((pair.Value as MultiTiledComponent).offsetKey.X)) * 64; + y = ((int)Game1.player.GetGrabTile().Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y)) * 64; + } + if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0) + { + Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f); + translatedVector2 += (pair.Value as MultiTiledComponent).offsetKey; + x = (int)translatedVector2.X * 64; + y = (int)translatedVector2.Y * 64; + } + bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x / Game1.tileSize, y / Game1.tileSize)); + spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f); + + + (pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f); + //break; + //this.draw(spriteBatch, x / 64, y / 64, 0.5f); + } + } + + public override void pickUp() + { + + bool canPickUp = this.removeAndAddToPlayersInventory(); + if (canPickUp) + { + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as StorageFurnitureTile).removeFromLocation((pair.Value as StorageFurnitureTile).location, pair.Key); + } + this.location = null; + } + + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs new file mode 100644 index 00000000..70be154a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs @@ -0,0 +1,206 @@ +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.Serialization; +using StardewValley; + +namespace Revitalize.Framework.Objects.Furniture +{ + public class StorageFurnitureTile:FurnitureTileComponent + { + + public StorageFurnitureTile() : base() + { + + } + + public StorageFurnitureTile(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData, Info) + { + } + + public StorageFurnitureTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation) : base(PyTKData, Info, TileLocation) + { + + } + + + 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) + { + if (this.containerObject.info.inventory.ItemCount > 0) return false; + return base.clicked(who); + } + + public override bool rightClicked(Farmer who) + { + 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); + } + return false; + } + + + public override bool shiftRightClicked(Farmer who) + { + return base.shiftRightClicked(who); + } + + + public override Item getOne() + { + StorageFurnitureTile component = new StorageFurnitureTile(this.data, this.info); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + 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"])); + StorageFurnitureTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + StorageFurnitureOBJ obj = (StorageFurnitureOBJ)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"], 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(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + + 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); + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index 1265d65d..980f2c9e 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using StardewValley; namespace Revitalize.Framework.Utilities @@ -19,7 +20,7 @@ namespace Revitalize.Framework.Utilities public List items; /// Checks if the inventory is full or not. - public bool IsFull => this.ItemCount >= this.capacity; + 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; diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs index b32a093f..1ae10e1d 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs @@ -78,12 +78,14 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters type = asm.GetType(t); + //Check if the type exists in the SDV assembly. If not then try to load it from revitalize. if (type == null) { asm = typeof(Revitalize.ModCore).Assembly; type = asm.GetType(t); } + //If the type doesn't exist from revitalize look through ALL loded assemblies and try to load it. if (type == null) { foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) @@ -96,7 +98,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters if (type == null) { - throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can;t deserialize this thing!: " + t); + 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. diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 27cdb10c..992845b6 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -331,6 +331,7 @@ namespace Revitalize Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble")); + Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Storage.OakCabinet")); /* StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe(); Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 85395509..9ab71dfe 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -115,6 +115,8 @@ + + @@ -166,6 +168,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest