diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs index dbc1520e..566295b2 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs @@ -13,7 +13,7 @@ namespace Revitalize.Framework.Graphics.Animations public string currentAnimationName; public int currentAnimationListIndex; public List currentAnimationList = new List(); - private Texture2DExtended objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. + public Texture2DExtended objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. public Animation defaultDrawFrame; public Animation currentAnimation; public bool enabled; diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 6ec9252d..6744d6cb 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -49,7 +49,7 @@ namespace Revitalize.Framework.Objects this.canBeSetIndoors = false; this.canBeSetOutdoors = false; - this.animationManager = null; + this.animationManager = new AnimationManager(); this.drawPosition = Vector2.Zero; this.drawColor = Color.White; this.inventory = new InventoryManager(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs index 5681ab7c..2a4b5c1a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs @@ -31,7 +31,7 @@ namespace Revitalize.Framework.Objects.Furniture } - public ChairMultiTiledObject(BasicItemInformation Info,Vector2 TilePosition,Dictionary Objects) : base(Info, TilePosition, Objects) { + public ChairMultiTiledObject(BasicItemInformation Info,Vector2 TilePosition,Dictionary Objects) : base(Info, TilePosition, Objects) { } @@ -42,11 +42,11 @@ namespace Revitalize.Framework.Objects.Furniture public override void rotate() { Revitalize.ModCore.log("Rotate!"); - foreach(KeyValuePair pair in this.objects) + foreach(KeyValuePair pair in this.objects) { (pair.Value as ChairTileComponent).rotate(); } - foreach (KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) { (pair.Value as ChairTileComponent).checkForSpecialUpSittingAnimation(); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index fa39aaac..11fb9914 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -69,7 +69,7 @@ namespace Revitalize.Framework.Objects.Furniture if (this.CanSitHere) { Revitalize.ModCore.playerInfo.sittingInfo.sit(this.containerObject, this.TileLocation*Game1.tileSize); - foreach(KeyValuePair pair in this.containerObject.objects) + foreach(KeyValuePair pair in this.containerObject.objects) { (pair.Value as ChairTileComponent).checkForSpecialUpSittingAnimation(); } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index a5f366c8..d76326bc 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -203,6 +203,8 @@ 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) { + Revitalize.ModCore.log("DRAW THE THING!!!"); + 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)); diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index d15f4fe0..1bdfc0f1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -5,13 +5,12 @@ using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using PyTK.CustomElementHandler; using StardewValley; -using StardewValley.Objects; namespace Revitalize.Framework.Objects { public class MultiTiledObject : CustomObject { - public Dictionary objects; + public Dictionary objects; [JsonIgnore] public Dictionary offSets; @@ -36,7 +35,7 @@ namespace Revitalize.Framework.Objects public MultiTiledObject() { - this.objects = new Dictionary(); + this.objects = new Dictionary(); this.offSets = new Dictionary(); this.guid = Guid.NewGuid(); } @@ -44,7 +43,7 @@ namespace Revitalize.Framework.Objects public MultiTiledObject(BasicItemInformation info) : base(info) { - this.objects = new Dictionary(); + this.objects = new Dictionary(); this.offSets = new Dictionary(); this.guid = Guid.NewGuid(); } @@ -52,20 +51,20 @@ namespace Revitalize.Framework.Objects public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation) : base(info, TileLocation) { - this.objects = new Dictionary(); + this.objects = new Dictionary(); this.offSets = new Dictionary(); this.guid = Guid.NewGuid(); } - public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) + public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) : base(info, TileLocation) { - this.objects = new Dictionary(); + this.objects = new Dictionary(); this.offSets = new Dictionary(); foreach (var v in ObjectsList) { - MultiTiledComponent component = (MultiTiledComponent)v.Value.getOne(); - this.addComponent(v.Key, component); + MultiTiledComponent component =(MultiTiledComponent) v.Value.getOne(); + this.addComponent(v.Key, (component as MultiTiledComponent)); } this.guid = Guid.NewGuid(); @@ -76,12 +75,12 @@ namespace Revitalize.Framework.Objects if (this.objects.ContainsKey(key)) return false; - this.objects.Add(key, obj); - this.offSets.Add(obj, key); + this.objects.Add(key, (obj as MultiTiledComponent)); + this.offSets.Add((obj as MultiTiledComponent), key); if (key.X > this.width) this.width = (int)key.X; if (key.Y > this.height) this.height = (int)key.Y; - obj.containerObject = this; - obj.offsetKey = key; + (obj as MultiTiledComponent).containerObject = this; + (obj as MultiTiledComponent).offsetKey = key; return true; } @@ -96,13 +95,13 @@ namespace Revitalize.Framework.Objects public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { - foreach (KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) pair.Value.draw(spriteBatch, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, alpha); } public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { - foreach (KeyValuePair pair in this.objects) + 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); @@ -110,14 +109,14 @@ namespace Revitalize.Framework.Objects public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { - foreach (KeyValuePair pair in this.objects) + 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); } public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) { - foreach (KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f); //base.drawWhenHeld(spriteBatch, objectPosition, f); } @@ -130,7 +129,7 @@ namespace Revitalize.Framework.Objects bool canPickUp = this.removeAndAddToPlayersInventory(); if (canPickUp) { - foreach (KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) (pair.Value as MultiTiledComponent).removeFromLocation((pair.Value as MultiTiledComponent).location, pair.Key); this.location = null; } @@ -151,10 +150,10 @@ namespace Revitalize.Framework.Objects public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { - foreach (KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) { pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); - ModCore.log(pair.Value.TileLocation); + //ModCore.log(pair.Value.TileLocation); } this.location = location; return true; @@ -163,7 +162,7 @@ namespace Revitalize.Framework.Objects public override bool canBePlacedHere(GameLocation l, Vector2 tile) { - foreach (KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) { if (!pair.Value.canBePlacedHere(l, tile + pair.Key)) return false; @@ -230,7 +229,7 @@ namespace Revitalize.Framework.Objects public void setAllAnimationsToDefault() { - foreach(KeyValuePair pair in this.objects) + foreach(KeyValuePair pair in this.objects) { string animationKey = (pair.Value as MultiTiledComponent) .generateDefaultRotationalAnimationKey(); if ((pair.Value as MultiTiledComponent).animationManager.animations.ContainsKey(animationKey)) @@ -239,5 +238,15 @@ namespace Revitalize.Framework.Objects } } } + public override bool canStackWith(Item other) + { + return false; + } + + public override int maximumStackSize() + { + return 1; + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 1400539d..3fc3d586 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -20,6 +20,7 @@ using StardewValley.Objects; namespace Revitalize { // TODO: + //Need to find a way to recreate objects again. //Make guid object list to keep track of container objects on rebuild. Container objects have guid, on getAdditionalSaveData, store it. On rebuild keep a list, get a reference to container object, clear those objects, and reset them as we are rebuilting multiTiledComponents. // // -Multiple Lights On Object @@ -282,12 +283,28 @@ namespace Revitalize - var hello=Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, (obj as MultiTiledObject).guid + ".json")); + MultiTiledObject hello=Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, (obj as MultiTiledObject).guid + ".json")); //(hello as MultiTiledObject).info.drawColor = Color.Blue; customObjects["Omegasis.BigTiledTest"].info.drawColor = hello.info.drawColor; - Game1.player.addItemToInventory(hello); + if (hello == null) log("WTF"); + else + { + log("AHHHH" + hello.name); + } + hello.info.drawColor = Color.Blue; + + foreach(KeyValuePair pair in hello.objects){ + pair.Value.containerObject = hello; + } + + Game1.player.items.Add(hello); + + Game1.activeClickableMenu = new StardewValley.Menus.ItemGrabMenu(new List() + { + hello + }); }