From 4469fbd9b353e543f6d5fb1d437853142e6f431b Mon Sep 17 00:00:00 2001 From: Date: Wed, 13 Jun 2018 02:36:52 -0700 Subject: [PATCH] Made multi tile objects that can be used in the future for things like machines and more furniture. Bigger things here we come. Need to edit sme click functionality however. --- .../AdditionalCropsFramework/PlanterBox.cs | 3 - .../Content/Graphics/MultiTest/Test1.png | Bin 0 -> 191 bytes .../Content/Graphics/MultiTest/Test2.png | Bin 0 -> 171 bytes .../Content/Graphics/MultiTest/Test3.png | Bin 0 -> 193 bytes GeneralMods/StardustCore/ModCore.cs | 32 ++- .../StardustCore/Objects/CoreObject.cs | 193 +++--------------- .../Objects/MultiTileComponent.cs | 130 ++++++++++++ .../StardustCore/Objects/MultiTileObject.cs | 185 +++++++++++++++++ .../StardustCore/Objects/Tools/ExtendedAxe.cs | 2 +- .../StardustCore/Objects/Tools/ExtendedHoe.cs | 2 +- .../Objects/Tools/ExtendedPickaxe.cs | 2 +- .../Objects/Tools/ExtendedWateringCan.cs | 2 +- GeneralMods/StardustCore/StardustCore.csproj | 11 + GeneralMods/StardustCore/Utilities.cs | 11 +- 14 files changed, 386 insertions(+), 187 deletions(-) create mode 100644 GeneralMods/StardustCore/Content/Graphics/MultiTest/Test1.png create mode 100644 GeneralMods/StardustCore/Content/Graphics/MultiTest/Test2.png create mode 100644 GeneralMods/StardustCore/Content/Graphics/MultiTest/Test3.png create mode 100644 GeneralMods/StardustCore/Objects/MultiTileComponent.cs create mode 100644 GeneralMods/StardustCore/Objects/MultiTileObject.cs diff --git a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs index 99293655..96dc57b1 100644 --- a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs +++ b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs @@ -501,9 +501,6 @@ namespace AdditionalCropsFramework this.locationsName = ""; return true; } - - - return false; } diff --git a/GeneralMods/StardustCore/Content/Graphics/MultiTest/Test1.png b/GeneralMods/StardustCore/Content/Graphics/MultiTest/Test1.png new file mode 100644 index 0000000000000000000000000000000000000000..cb95df9b2e7c4e06781356e557f6db76f296ef31 GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk-Ziu65Q978Ppryk$P$zUMBZ1{fvm*xB2SgvGjx3~RzCD0#LT=By}Z;C1rt33 zJtM=93Yk-ZiljYV978PplXraGKTpMERigwLzcBf;o}D51WrTe3!z+S7WelFKelF{r G5}E*&8!z7g literal 0 HcmV?d00001 diff --git a/GeneralMods/StardustCore/Content/Graphics/MultiTest/Test3.png b/GeneralMods/StardustCore/Content/Graphics/MultiTest/Test3.png new file mode 100644 index 0000000000000000000000000000000000000000..2a2e2b7c89f48ee1e02c95dc7406fd2ac1cba500 GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk-ZiVQtn978Ppryf`2V^H8>F#Nav`~8R7J0@KDGUukf-OneJ{ZWYfY5EQt WlLe9%GVB0qX7F_Nb6Mw<&;$U> objs = new List>(); + MultiTileComponent tile1 = new MultiTileComponent(new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test1.png")), 0, Vector2.Zero, 0)); + MultiTileComponent tile2 = new MultiTileComponent(new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png")), 0, Vector2.Zero, 0)); + MultiTileComponent tile3 = new MultiTileComponent(new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")), 0, Vector2.Zero, 0)); - ExtendedHoe hoe = new ExtendedHoe(new BasicToolInfo("My First Hoe", 7, "An hoe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"))); - Game1.player.addItemToInventory(hoe); + objs.Add(new KeyValuePair(new Vector2(0, 0), tile1)); + objs.Add(new KeyValuePair(new Vector2(1, 0), tile2)); + objs.Add(new KeyValuePair(new Vector2(2, 0), tile3)); - ExtendedPickaxe pick = new ExtendedPickaxe(new BasicToolInfo("My First pickaxe", 7, "An pickaxe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"))); - Game1.player.addItemToInventory(pick); - - ExtendedWateringCan water = new ExtendedWateringCan(new BasicToolInfo("My First Can", 7, "An can so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")),10,3); - Game1.player.addItemToInventory(water); - - - - ExtendedWateringCan.Serialize(water); - ExtendedAxe.Serialize(axe); - ExtendedPickaxe.Serialize(pick); - ExtendedHoe.Serialize(hoe); + MultiTileObject collection= new MultiTileObject("MultiTest", "Trying to get multi object testing working", Vector2.Zero, new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")), objs, StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Purple), "MultiTest"); + Game1.player.addItemToInventory(collection); } private void SaveEvents_AfterSave(object sender, EventArgs e) diff --git a/GeneralMods/StardustCore/Objects/CoreObject.cs b/GeneralMods/StardustCore/Objects/CoreObject.cs index e77eff49..1c407066 100644 --- a/GeneralMods/StardustCore/Objects/CoreObject.cs +++ b/GeneralMods/StardustCore/Objects/CoreObject.cs @@ -31,7 +31,7 @@ namespace StardustCore public int sourceIndexOffset; - protected Vector2 drawPosition; + public Vector2 drawPosition; public Rectangle sourceRect; @@ -136,19 +136,13 @@ namespace StardustCore this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.getTexture().Width, which * 16 / TextureSheet.getTexture().Width * 16, 1, 1); if (array[2].Equals("-1")) { - this.sourceRect = this.getDefaultSourceRectForType(which, this.Decoration_type); + this.sourceRect = new Rectangle(0, 0, 16, 16); this.defaultSourceRect = this.sourceRect; } else { - this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[] - { - ' ' - })[0]); - this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[] - { - ' ' - })[1]); + this.defaultSourceRect.Width = 16; + this.defaultSourceRect.Height = 16; this.sourceRect = new Rectangle(which * 16 % TextureSheet.getTexture().Width, which * 16 / TextureSheet.getTexture().Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); this.defaultSourceRect = this.sourceRect; } @@ -168,7 +162,7 @@ namespace StardustCore { ' ' })[1]); - this.boundingBox.Value = new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + this.boundingBox.Value = new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); this.defaultBoundingBox = this.boundingBox.Value; } this.updateDrawPosition(); @@ -190,7 +184,7 @@ namespace StardustCore /// The x tile location to "place". /// The y tile location to "place". /// If true then the Serialization manager will keep track of this object. - public void fakePlacementAction(GameLocation location, int tileX, int tileY,bool trackSerialization=true) + public virtual void fakePlacementAction(GameLocation location, int tileX, int tileY,bool trackSerialization=true) { this.thisLocation = location; this.TileLocation = new Vector2(tileX, tileY); @@ -605,7 +599,14 @@ namespace StardustCore environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); this.lightGlowAdded = false; } - this.spillInventoryEverywhere(); + try + { + this.spillInventoryEverywhere(); + } + catch(Exception err) + { + + } base.performRemoveAction(tileLocation, environment); } @@ -979,163 +980,37 @@ namespace StardustCore public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) { + + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); - if (location is FarmHouse) + this.TileLocation = new Vector2((float)point.X, (float)point.Y); + + this.boundingBox.Value = new Rectangle(x, y, Game1.tileSize, Game1.tileSize); + + using (List.Enumerator enumerator3 = location.getFarmers().GetEnumerator()) { - Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); - List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); - this.TileLocation = new Vector2((float)point.X, (float)point.Y); - bool flag = false; - if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.ParentSheetIndex == 1293) + while (enumerator3.MoveNext()) { - int num = (this.ParentSheetIndex == 1293) ? 3 : 0; - bool flag2 = false; - foreach (Rectangle current in walls) - { - if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) - { - flag2 = true; - break; - } - } - if (!flag2) - { - Game1.showRedMessage("Must be placed on wall"); - return false; - } - flag = true; - } - for (int i = point.X; i < point.X + this.getTilesWide(); i++) - { - for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) - { - if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) - { - Game1.showRedMessage("Furniture can't be placed here"); - return false; - } - if (!flag && Utility.pointInRectangles(walls, i, j)) - { - Game1.showRedMessage("Can't place on wall"); - return false; - } - if (location.getTileIndexAt(i, j, "Buildings") != -1) - { - return false; - } - } - } - this.boundingBox.Value = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); - foreach (var c in location.objects.Pairs) - { - StardewValley.Object ehh = c.Value; - if (((ehh.GetType()).ToString()).Contains("Spawner")) - { - CoreObject current2 = (CoreObject)ehh; - if (current2.Decoration_type == 11 && current2.heldObject.Value == null && current2.getBoundingBox(current2.TileLocation).Intersects(this.boundingBox.Value)) - { - current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); - bool result = true; - return result; - } - } - } - foreach (StardewValley.Farmer current3 in location.getFarmers()) - { - if (current3.GetBoundingBox().Intersects(this.boundingBox.Value)) + if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox.Value)) { Game1.showRedMessage("Can't place on top of a person."); bool result = false; return result; } } - this.updateDrawPosition(); - // Log.AsyncO(this.boundingBox); - // Log.AsyncO(x); - // Log.AsyncY(y); - for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) - { - base.placementAction(location, x + 1, y, who); - } - for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) - { - base.placementAction(location, x, y + 1, who); - } - return true; - } - else - { - Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); - // List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); - this.TileLocation = new Vector2((float)point.X, (float)point.Y); - if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.ParentSheetIndex == 1293) - { - int num = (this.ParentSheetIndex == 1293) ? 3 : 0; - bool flag2 = false; - /* - foreach (Rectangle current in walls) - { - if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) - { - flag2 = true; - break; - } - } - */ - if (!flag2) - { - Game1.showRedMessage("Must be placed on wall"); - return false; - } - } - for (int i = point.X; i < point.X + this.getTilesWide(); i++) - { - for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) - { - if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) - { - Game1.showRedMessage("Furniture can't be placed here"); - return false; - } - /* - if (!flag && Utility.pointInRectangles(walls, i, j)) - { - Game1.showRedMessage("Can't place on wall"); - return false; - } - */ - if (location.getTileIndexAt(i, j, "Buildings") != -1) - { - return false; - } - } - } - this.boundingBox.Value = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); - /* - foreach (Furniture current2 in (location as FarmHouse).furniture) - { - if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) - { - current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); - bool result = true; - return result; - } - } - */ - foreach (StardewValley.Farmer current3 in location.getFarmers()) - { - if (current3.GetBoundingBox().Intersects(this.boundingBox.Value)) - { - Game1.showRedMessage("Can't place on top of a person."); - bool result = false; - return result; - } - } - this.updateDrawPosition(); - this.thisLocation = Game1.player.currentLocation; - return base.placementAction(location, x * Game1.tileSize, y * Game1.tileSize, who); } + this.updateDrawPosition(); + + bool f = Utilities.placementAction(this, location, x, y, StardustCore.ModCore.SerializationManager,who); + this.thisLocation = Game1.player.currentLocation; + return f; + // Game1.showRedMessage("Can only be placed in House"); + // return false; + + + + } public override bool isPlaceable() diff --git a/GeneralMods/StardustCore/Objects/MultiTileComponent.cs b/GeneralMods/StardustCore/Objects/MultiTileComponent.cs new file mode 100644 index 00000000..420a0a32 --- /dev/null +++ b/GeneralMods/StardustCore/Objects/MultiTileComponent.cs @@ -0,0 +1,130 @@ +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 StardewValley; + +namespace StardustCore.Objects +{ + public class MultiTileComponent : CoreObject + { + public MultiTileObject containerObject; + public CoreObject objectPart; + + public MultiTileComponent(CoreObject part) + { + this.objectPart = part; + this.name = this.objectPart.name; + this.defaultBoundingBox = new Rectangle(0, 0, 16, 16); + this.boundingBox.Value = new Rectangle((int)0 * Game1.tileSize, (int)0* Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); + } + + public override bool clicked(Farmer who) + { + containerObject.RemoveAllObjects(); + return true; + } + + public override Item getOne() + { + var obj= new MultiTileComponent((CoreObject)objectPart.getOne()); + obj.containerObject = this.containerObject; + return obj; + } + + public override bool RightClicked(Farmer who) + { + return this.objectPart.RightClicked(who); + } + + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + + this.TileLocation = new Vector2((float)point.X, (float)point.Y); + this.boundingBox.Value = new Rectangle((int)TileLocation.X * Game1.tileSize, (int)TileLocation.Y * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); + using (List.Enumerator enumerator3 = location.getFarmers().GetEnumerator()) + { + while (enumerator3.MoveNext()) + { + if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox.Value)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + } + this.updateDrawPosition(); + + bool f = Utilities.placementAction(this, location, x, y,StardustCore.ModCore.SerializationManager ,who); + this.thisLocation = Game1.player.currentLocation; + return f; + // Game1.showRedMessage("Can only be placed in House"); + // return false; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + // Game1.showRedMessage("Why3?"); + try + { + this.heldObject.Value.performRemoveAction(this.TileLocation, this.thisLocation); + this.heldObject.Value = null; + } + catch(Exception err) + { + + } + StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this); + this.thisLocation.objects.Remove(this.TileLocation); + this.thisLocation = null; + this.locationsName = ""; + base.performRemoveAction(tileLocation, environment); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (x == -1) + { + spriteBatch.Draw(this.objectPart.TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.objectPart.drawPosition), new Rectangle?(this.objectPart.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.objectPart.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.objectPart.Decoration_type == 12) ? 0f : ((float)(this.objectPart.boundingBox.Bottom - 8) / 10000f)); + } + else + { + //The actual planter box being drawn. + if (animationManager == null) + { + spriteBatch.Draw(this.objectPart.TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.objectPart.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.objectPart.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + this.animationManager.draw(spriteBatch, this.objectPart.animationManager.objectTexture.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.objectPart.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.objectPart.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + 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/StardustCore/Objects/MultiTileObject.cs b/GeneralMods/StardustCore/Objects/MultiTileObject.cs new file mode 100644 index 00000000..00efae1f --- /dev/null +++ b/GeneralMods/StardustCore/Objects/MultiTileObject.cs @@ -0,0 +1,185 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewValley; +using StardustCore.UIUtilities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardustCore.Objects +{ + public class MultiTileObject : CoreObject + { + public List> objects; + public Color categoryColor; + public String categoryName; + + public MultiTileObject(String Name, String Description,Vector2 tile, Texture2DExtended texture, List> Objects, Color CategoryColor, String CategoryName) :base(texture,0,tile,0) + { + this.objects = Objects; + this.TextureSheet = texture; + this.texturePath = texture.path; + this.categoryColor = CategoryColor; + this.categoryName = CategoryName; + this.name = Name; + this.displayName = Name; + this.description = Description; + + foreach(var v in this.objects) + { + v.Value.containerObject = this; + } + + InitializeBasics(0, tile); + } + + public MultiTileObject(String Name, String Description, Vector2 tile, Animations.AnimationManager animationManager, List> Objects, Color CategoryColor, String CategoryName) + { + this.animationManager = animationManager; + this.objects = Objects; + this.TextureSheet =animationManager.objectTexture; + this.texturePath = animationManager.objectTexture.path; + this.name = Name; + this.displayName = Name; + this.description = Description; + InitializeBasics(0, tile); + } + + public void RemoveAllObjects() + { + if (Game1.player.isInventoryFull() == false){ + foreach (var v in this.objects) + { + v.Value.performRemoveAction(v.Value.TileLocation, v.Value.objectPart.thisLocation); + } + Game1.player.addItemToInventory(this); + } + return; + } + + public override Type getCustomType() + { + return this.GetType(); + } + + public override string GetSerializationName() + { + return typeof(MultiTileObject).ToString(); + } + + public override void InitializeBasics(int InvMaxSize, Vector2 tile) + { + base.InitializeBasics(InvMaxSize, tile); + } + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + foreach(var pair in this.objects) + { + pair.Value.placementAction(location, x+(int)(pair.Key.X*Game1.tileSize), y+ (int)(pair.Key.Y * Game1.tileSize), who); + } + return true; + } + + public override bool clicked(Farmer who) + { + foreach (var pair in this.objects) + { + pair.Value.clicked(who); + } + return true; + } + + public override bool RightClicked(Farmer who) + { + foreach (var pair in this.objects) + { + pair.Value.RightClicked(who); + } + return true; + } + + /// + /// Need to fix this for sure!!! + /// + /// + public override Item getOne() + { + List> items = new List>(); + foreach (var pair in this.objects) + { + items.Add(new KeyValuePair(pair.Key, (pair.Value.getOne()) as MultiTileComponent)); + } + if (this.animationManager != null) + { + return new MultiTileObject(this.name, this.description, this.TileLocation, this.animationManager, items, this.categoryColor, this.categoryName); + //throw new NotImplementedException(); + } + else + { + return new MultiTileObject(this.name, this.description, this.TileLocation, this.TextureSheet, items, this.categoryColor, this.categoryName); + } + return null; + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) + { + + foreach(var v in this.objects) + { + if (v.Value.objectPart.thisLocation != null) + { + v.Value.draw(spriteBatch, (int)v.Value.position.X, (int)v.Value.position.Y, alpha); + } + } + + //base.draw(spriteBatch, x, y, alpha); + } + + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + foreach (var v in this.objects) + { + //v.Value.draw(spriteBatch, (int)v.Value.position.X, (int)v.Value.position.Y, layerDepth, alpha); + } + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) + { + if (animationManager == null) + { + spriteBatch.Draw(this.TextureSheet.getTexture(), objectPosition, new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + } + else + { + spriteBatch.Draw(animationManager.objectTexture.getTexture(), objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + } + + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadows) + { + if (animationManager == null) spriteBatch.Draw(this.TextureSheet.getTexture(), location,this.defaultSourceRect, Color.White * transparency, 0f, new Vector2(0,0), scaleSize, SpriteEffects.None, layerDepth); + else + { + spriteBatch.Draw(animationManager.objectTexture.getTexture(), location, animationManager.currentAnimation.sourceRectangle, Color.White * transparency, 0f, new Vector2(0,0), scaleSize, SpriteEffects.None, layerDepth); + //this.modularCrop.drawInMenu(spriteBatch, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), Color.White, 0f,true); + if (Game1.player.CurrentItem != this) animationManager.tickAnimation(); + } + } + + public override Color getCategoryColor() + { + return this.categoryColor; + } + + public override string getCategoryName() + { + return this.name; + } + + + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs index a271dfa6..43fec26c 100644 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs @@ -43,7 +43,7 @@ namespace StardustCore.Objects.Tools StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedAxe).Name); this.displayName = "Hello"; this.description = (dataBase as Serialization_ExtendedAxe).Description; - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); + this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedAxe).TextureInformation.Name); //new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); this.UpgradeLevel = (dataBase as Serialization_ExtendedAxe).UpgradeLevel; } diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs index ebbcc04a..393f3daf 100644 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs @@ -43,7 +43,7 @@ namespace StardustCore.Objects.Tools StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedHoe).Name); this.displayName = "Hello"; this.description = (dataBase as Serialization_ExtendedHoe).Description; - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); + this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedHoe).TextureInformation.Name); this.UpgradeLevel = (dataBase as Serialization_ExtendedHoe).UpgradeLevel; } diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs index 74bc63a6..0f67e793 100644 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs @@ -43,7 +43,7 @@ namespace StardustCore.Objects.Tools StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedPickaxe).Name); this.displayName = "Hello"; this.description = (dataBase as Serialization_ExtendedPickaxe).Description; - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); + this.texture = this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedPickaxe).TextureInformation.Name); this.UpgradeLevel = (dataBase as Serialization_ExtendedPickaxe).UpgradeLevel; } diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs index 345ec345..84fbd868 100644 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs @@ -46,7 +46,7 @@ namespace StardustCore.Objects.Tools StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedWateringCan).Name); this.displayName = "Hello"; this.description = (dataBase as Serialization_ExtendedWateringCan).Description; - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); + this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedWateringCan).TextureInformation.Name); this.UpgradeLevel = (dataBase as Serialization_ExtendedWateringCan).UpgradeLevel; this.waterCanMax= (dataBase as Serialization_ExtendedWateringCan).MaxCapacity; this.WaterLeft= (dataBase as Serialization_ExtendedWateringCan).WaterLeft; diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index eddcade2..7e5f69b9 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -89,6 +89,8 @@ + + @@ -422,6 +424,15 @@ + + Always + + + Always + + + Always + PreserveNewest diff --git a/GeneralMods/StardustCore/Utilities.cs b/GeneralMods/StardustCore/Utilities.cs index 7d7ae9bb..21b389d0 100644 --- a/GeneralMods/StardustCore/Utilities.cs +++ b/GeneralMods/StardustCore/Utilities.cs @@ -116,6 +116,10 @@ namespace StardustCore // cObj.health = 10; if (who != null) { + if (cObj == null) + { + StardustCore.ModCore.ModMonitor.Log("WHY IS MY COMPONENT NULL???"); + } cObj.owner.Value = who.UniqueMultiplayerID; } else @@ -267,7 +271,7 @@ namespace StardustCore } if (!cObj.performDropDownAction(who)) { - CoreObject @object = (CoreObject)cObj.getOne(); + CoreObject @object = cObj; @object.shakeTimer = 50; @object.TileLocation = vector; @object.performDropDownAction(who); @@ -303,9 +307,8 @@ namespace StardustCore } } - - + public static bool addItemToInventoryAndCleanTrackedList(CoreObject I,Serialization.SerializationManager s) { if (Game1.player.isInventoryFull() == false) @@ -463,6 +466,8 @@ namespace StardustCore } + + /// /// Checks whether or not the net inventory list is full of items. ///