From e1a2a0da47765ff40d5b0a25e6980fcb18a76a49 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Sat, 15 Dec 2018 11:49:56 -0800 Subject: [PATCH] Core objects work aside from net animation manager. Also need to figure out how to load in when custom objects are present. --- .../StardustCore/Animations/Animation.cs | 4 +- GeneralMods/StardustCore/ModCore.cs | 21 +-- .../NetCode/Graphics/NetAnimation.cs | 11 +- .../NetCode/Graphics/NetAnimationManager.cs | 74 ++++++++-- .../StardustCore/NetCode/NetAnimation.cs | 64 --------- .../NetCode/NetAnimationManager.cs | 126 ------------------ .../NetCode/NetTexure2DExtended.cs | 8 +- .../NetCode/Objects/NetCoreObject.cs | 12 +- .../NetCode/Objects/NetMultiTileComponent.cs | 2 +- .../NetCode/Objects/NetMultiTileObject.cs | 13 ++ .../StardustCore/Objects/CoreObject.cs | 35 ++++- .../Objects/MultiTileComponent.cs | 11 +- .../StardustCore/Objects/MultiTileObject.cs | 10 ++ GeneralMods/StardustCore/StardustCore.csproj | 2 - .../UIUtilities/TextureManager.cs | 1 + 15 files changed, 165 insertions(+), 229 deletions(-) delete mode 100644 GeneralMods/StardustCore/NetCode/NetAnimation.cs delete mode 100644 GeneralMods/StardustCore/NetCode/NetAnimationManager.cs diff --git a/GeneralMods/StardustCore/Animations/Animation.cs b/GeneralMods/StardustCore/Animations/Animation.cs index a7d5fadc..e9193ec5 100644 --- a/GeneralMods/StardustCore/Animations/Animation.cs +++ b/GeneralMods/StardustCore/Animations/Animation.cs @@ -32,7 +32,8 @@ namespace StardustCore.Animations public Animation() { - this.sourceRectangle = new Rectangle(); + this.sourceRectangle = new Rectangle(0,0,16,16); + this.frameCountUntilNextAnimation = -1; this.frameDuration = -1; } @@ -43,6 +44,7 @@ namespace StardustCore.Animations public Animation(Rectangle SourceRectangle) { sourceRectangle = SourceRectangle; + this.frameCountUntilNextAnimation = -1; frameDuration = -1; } diff --git a/GeneralMods/StardustCore/ModCore.cs b/GeneralMods/StardustCore/ModCore.cs index 780cfb99..7f567191 100644 --- a/GeneralMods/StardustCore/ModCore.cs +++ b/GeneralMods/StardustCore/ModCore.cs @@ -69,7 +69,9 @@ namespace StardustCore SerializationManager.initializeDefaultSuportedTypes(); TextureManagers = new Dictionary(); TextureManager = new TextureManager(); - TextureManager.addTexture("Test1.png", new Texture2DExtended(ModCore.ModHelper, Manifest,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); + TextureManager.addTexture("Test1", new Texture2DExtended(ModCore.ModHelper, Manifest,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); + TextureManager.addTexture("Test2", new Texture2DExtended(ModCore.ModHelper, Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png"))); + TextureManager.addTexture("Test3", new Texture2DExtended(ModCore.ModHelper, Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png"))); TextureManagers.Add(ModManifest.UniqueID, TextureManager); StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; @@ -169,6 +171,7 @@ namespace StardustCore SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); + /* List> objs = new List>(); MultiTileComponent tile1 = new MultiTileComponent(0,"Tileobj1","A basic tile obj",new Texture2DExtended(ModCore.ModHelper,ModCore.Manifest ,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); @@ -182,15 +185,17 @@ namespace StardustCore Game1.player.addItemToInventory(collection); - /* - CoreObject tile1 = new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test1.png")),3, Vector2.Zero,9); - - tile1.description = "Hello"; - tile1.Name = "test"; - tile1.displayName = "test"; - Game1.player.addItemToInventory(tile1); */ + + CoreObject testTile = new CoreObject(new Texture2DExtended(ModCore.ModHelper,ModCore.Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")),3, Vector2.Zero,9); + + testTile.description = "Hello"; + testTile.Name = "test"; + testTile.displayName = "test"; + Game1.player.addItemToInventory(testTile); + + } private void SaveEvents_AfterSave(object sender, EventArgs e) diff --git a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs b/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs index da2d0c0c..52eb687f 100644 --- a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs +++ b/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs @@ -22,17 +22,20 @@ namespace StardustCore.NetCode.Graphics } public NetAnimation(Animations.Animation animation) : base(animation) { - + this.Set(animation); } public override void Set(Animation newValue) { - throw new NotImplementedException(); + this.value = newValue; } protected override void ReadDelta(BinaryReader reader, NetVersion version) { sourceRect = new NetRectangle(); + if (sourceRect == null) throw new Exception("WTF??? Why is netfield null"); + if (reader == null) throw new Exception("reader null"); + if (value == null) this.Set(new Animation()); sourceRect.Read(reader, version); Value.sourceRectangle = sourceRect.Value; @@ -42,11 +45,13 @@ namespace StardustCore.NetCode.Graphics frameDurationUntilNextAnimation = new NetInt(); frameDurationUntilNextAnimation.Read(reader, version); - Value.frameDuration = frameDuration.Value; + Value.frameCountUntilNextAnimation = frameDurationUntilNextAnimation.Value; } protected override void WriteDelta(BinaryWriter writer) { + + sourceRect = new NetRectangle(Value.sourceRectangle); sourceRect.Write(writer); diff --git a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs b/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs index 864a2823..964fa446 100644 --- a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs +++ b/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs @@ -11,7 +11,7 @@ using StardustCore.Animations; namespace StardustCore.NetCode.Graphics { - public class NetAnimationManager : Netcode.NetField + public class NetAnimationManager : Netcode.NetField { public NetAnimationManager() @@ -19,18 +19,38 @@ namespace StardustCore.NetCode.Graphics } - public NetAnimationManager(Animations.AnimationManager manager): base(manager) + public NetAnimationManager(Animations.AnimationManager manager) : base(manager) { - + this.Set(manager); } - public override void Set(AnimationManager newValue) - { - throw new NotImplementedException(); - } + public NetString currentAnimationName; + public NetInt currentAnimationListIndex; + public NetTexture2DExtended objectTexture; + public NetAnimation defaultDrawFrame; + public NetBool enabled; + public NetString animationDataString; protected override void ReadDelta(BinaryReader reader, NetVersion version) { + //Checks to see if the current animation is nothing, aka null. + NetBool isNull = new NetBool(); + isNull.Read(reader, version); + bool valueIsNull = isNull.Value; + if (isNull) + { + NetTexture2DExtended nullTexture = new NetTexture2DExtended(); + nullTexture.Read(reader, version); + + NetAnimation nullAnimation = new NetAnimation(); + nullAnimation.Read(reader, version); + + Value.setExtendedTexture(nullTexture.Value); + Value.defaultDrawFrame = nullAnimation.Value; + return; + } + + NetString currentAnimationName = new NetString(); currentAnimationName.Read(reader, version); @@ -63,15 +83,39 @@ namespace StardustCore.NetCode.Graphics } else { - Value.currentAnimation = defaultAnimation.Value; + Value.currentAnimation = defaultDrawFrame.Value; } } protected override void WriteDelta(BinaryWriter writer) { - NetString currentAnimationName = new NetString(Value.currentAnimationName); - currentAnimationName.Write(writer); - + + + if (String.IsNullOrEmpty(Value.currentAnimationName)) + { + NetBool isNull = new NetBool(true); + writer.Write(isNull); + + + + NetTexture2DExtended defaultTexture = new NetTexture2DExtended(Value.getExtendedTexture()); + defaultTexture.Write(writer); + + //do read/write null values here!!! + if (Value == null) throw new Exception("DONT WRITE A NULL VALUE!!!!"); + NetAnimation drawFrame = new NetAnimation(Value.defaultDrawFrame); + drawFrame.Write(writer); + return; + //throw new Exception("Null string value for currentAnimationName!"); + } + else + { + NetBool isNull = new NetBool(false); + writer.Write(isNull); + } + NetString curentAnimationName = new NetString(!String.IsNullOrEmpty(Value.currentAnimationName) ? Value.currentAnimationName : ""); + currentAnimationName.Write(writer); + NetInt currentAnimationListIndex = new NetInt(Value.currentAnimationListIndex); currentAnimationListIndex.Write(writer); @@ -79,6 +123,7 @@ namespace StardustCore.NetCode.Graphics NetTexture2DExtended texture = new NetTexture2DExtended(Value.getExtendedTexture()); texture.Write(writer); + //do read/write null values here!!! NetAnimation defaultDrawFrame = new NetAnimation(Value.defaultDrawFrame); defaultDrawFrame.Write(writer); @@ -87,7 +132,12 @@ namespace StardustCore.NetCode.Graphics NetString animationData = new NetString(Value.animationDataString); animationData.Write(writer); - + + } + + public override void Set(AnimationManager newValue) + { + this.value = newValue; } } } diff --git a/GeneralMods/StardustCore/NetCode/NetAnimation.cs b/GeneralMods/StardustCore/NetCode/NetAnimation.cs deleted file mode 100644 index 319fb2ba..00000000 --- a/GeneralMods/StardustCore/NetCode/NetAnimation.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Netcode; -using StardustCore.Animations; - -namespace StardustCore.NetCode -{ - public class NetAnimation : Netcode.NetField - { - - public NetRectangle sourceRect; - public NetInt frameDuration; - public NetInt frameDurationUntilNextAnimation; - - public NetAnimation() - { - - } - public NetAnimation(Animations.Animation animation) : base(animation) - { - - } - - public override void Set(Animation newValue) - { - this.value = newValue; - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - sourceRect = new NetRectangle(); - sourceRect.Read(reader, version); - Value.sourceRectangle = sourceRect.Value; - - frameDuration = new NetInt(); - frameDuration.Read(reader, version); - Value.frameDuration = frameDuration.Value; - - frameDurationUntilNextAnimation = new NetInt(); - frameDurationUntilNextAnimation.Read(reader, version); - Value.frameDuration = frameDuration.Value; - } - - protected override void WriteDelta(BinaryWriter writer) - { - if (Value == null) return; - if (value.sourceRectangle == null) return; - - - sourceRect = new NetRectangle(Value.sourceRectangle); - sourceRect.Write(writer); - - frameDuration = new NetInt(Value.frameDuration); - frameDuration.Write(writer); - - frameDurationUntilNextAnimation = new NetInt(Value.frameCountUntilNextAnimation); - frameDurationUntilNextAnimation.Write(writer); - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetAnimationManager.cs b/GeneralMods/StardustCore/NetCode/NetAnimationManager.cs deleted file mode 100644 index 68abfd62..00000000 --- a/GeneralMods/StardustCore/NetCode/NetAnimationManager.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Netcode; -using StardewValley; -using StardewValley.Network; -using StardustCore.Animations; - -namespace StardustCore.NetCode -{ - public class NetAnimationManager : Netcode.NetField - { - - public NetAnimationManager() - { - - } - - public NetAnimationManager(Animations.AnimationManager manager): base(manager) - { - this.Set(manager); - } - - public NetString currentAnimationName; - public NetInt currentAnimationListIndex; - public NetTexture2DExtended objectTexture; - public NetAnimation defaultDrawFrame; - public NetBool enabled; - public NetString animationDataString; - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - //Checks to see if the current animation is nothing, aka null. - NetBool isNull = new NetBool(); - isNull.Read(reader, version); - bool valueIsNull = isNull.Value; - if (isNull) return; - - - - NetString currentAnimationName = new NetString(); - currentAnimationName.Read(reader, version); - - NetInt currentIndex = new NetInt(); - currentIndex.Read(reader, version); - - NetTexture2DExtended text = new NetTexture2DExtended(); - text.Read(reader, version); - - NetAnimation defaultAnimation = new NetAnimation(); - defaultAnimation.Read(reader, version); - - NetBool enabled = new NetBool(); - enabled.Read(reader, version); - - NetString data = new NetString(); - data.Read(reader, version); - - Value.setExtendedTexture(text.Value); - Value.defaultDrawFrame = defaultAnimation.Value; - Value.enabled = enabled.Value; - //Try and prevent unnecessary parsing. - if (Value.animations == null && !String.IsNullOrEmpty(Value.animationDataString)) - { - Value.animations = Animations.AnimationManager.parseAnimationsFromXNB(data.Value); - } - if (!String.IsNullOrEmpty(data.Value)) - { - Value.setAnimation(currentAnimationName.Value, currentIndex.Value); - } - else - { - Value.currentAnimation = defaultDrawFrame.Value; - } - } - - protected override void WriteDelta(BinaryWriter writer) - { - if (Value == null) - { - throw new Exception("NULL ANIMATION MANAGER VALUE!!!"); - } - - if (String.IsNullOrEmpty(Value.currentAnimationName)) - { - NetBool isNull = new NetBool(true); - writer.Write(isNull); - return; - //throw new Exception("Null string value for currentAnimationName!"); - } - else - { - NetBool isNull = new NetBool(false); - writer.Write(isNull); - } - NetString curentAnimationName = new NetString(!String.IsNullOrEmpty(Value.currentAnimationName) ? Value.currentAnimationName : ""); - currentAnimationName.Write(writer); - - - NetInt currentAnimationListIndex = new NetInt(Value.currentAnimationListIndex); - currentAnimationListIndex.Write(writer); - - NetTexture2DExtended texture = new NetTexture2DExtended(Value.getExtendedTexture()); - texture.Write(writer); - - //do read/write null values here!!! - NetAnimation defaultDrawFrame = new NetAnimation(Value.defaultDrawFrame); - defaultDrawFrame.Write(writer); - - NetBool enabled = new NetBool(Value.enabled); - enabled.Write(writer); - - NetString animationData = new NetString(Value.animationDataString); - animationData.Write(writer); - - } - - public override void Set(AnimationManager newValue) - { - this.value = newValue; - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs b/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs index a70a204f..25cbcbeb 100644 --- a/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs +++ b/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs @@ -24,6 +24,7 @@ namespace StardustCore.NetCode public NetTexture2DExtended(Texture2DExtended value) : base(value) { + this.Set(value); } public void ReadData(BinaryReader reader, NetVersion version) @@ -55,10 +56,15 @@ namespace StardustCore.NetCode //Texture2D texture = new Texture2D(Game1.graphics.GraphicsDevice,width,height); - if (String.IsNullOrEmpty(iD.Value) || String.IsNullOrEmpty(name.Value)) return; + if (String.IsNullOrEmpty(iD.Value) || String.IsNullOrEmpty(name.Value)) + { + ModCore.ModMonitor.Log("FOR SOME REASON THE TEXTURE INFO IS NULL????"); + return; + } Texture2DExtended texture = ModCore.TextureManagers[iD.Value].getTexture(name.Value); + if (texture == null) throw new Exception("FOR SOME REASON NULL IS BEING READ???"); this.Value = texture; } diff --git a/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs b/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs index 1a4d9273..624ea0fa 100644 --- a/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs +++ b/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs @@ -74,6 +74,7 @@ namespace StardustCore.NetCode { texture = new NetTexture2DExtended(); texture.Read(reader, version); + Value.setExtendedTexture(texture.Value); which = new NetInt(); @@ -100,9 +101,12 @@ namespace StardustCore.NetCode drawPosition.Read(reader, version); Value.drawPosition = drawPosition.Value; + /* animationManager = new NetAnimationManager(); animationManager.Read(reader, version); Value.animationManager = animationManager.Value; + */ + } protected override void WriteDelta(BinaryWriter writer) @@ -128,10 +132,14 @@ namespace StardustCore.NetCode drawPosition = new NetVector2(Value.drawPosition); drawPosition.Write(writer); - + /* + if (Value.animationManager == null) + { + throw new Exception("WTF, why is the animation manager null???????????"); + } animationManager = new NetAnimationManager(Value.animationManager); animationManager.Write(writer); - + */ } } } \ No newline at end of file diff --git a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs b/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs index 11dbfe7a..62bfed63 100644 --- a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs +++ b/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs @@ -27,7 +27,7 @@ namespace StardustCore.NetCode.Objects public NetMultiTileComponent(MultiTileComponent obj): base(obj) { - + Set(obj); } public NetInt InventoryMaxSize { get; private set; } diff --git a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs b/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs index 3136d8bb..0653a03e 100644 --- a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs +++ b/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs @@ -35,7 +35,17 @@ namespace StardustCore.NetCode.Objects NetList, NetKeyValuePair> netList = new NetList, NetKeyValuePair>(); netList.Read(reader, version); + if (netList.ToList() == null) throw new Exception("WTF WHY IS NETLIST NULL?!?!?!?!"); + + foreach(var v in netList.ToList()) + { + StardustCore.ModCore.ModMonitor.Log(v.Value.name, StardewModdingAPI.LogLevel.Alert); + } + Value.objects = netList.ToList(); + //this.value.objects=netList.ToArray().ToList(); + + NetColor col = new NetColor(); col.Read(reader, version); @@ -52,8 +62,11 @@ namespace StardustCore.NetCode.Objects obj.Write(writer); NetList, NetKeyValuePair> netList = new NetList, NetKeyValuePair>(); + + if (Value.objects == null) throw new Exception("Trying to write null object list!"); foreach (var v in Value.objects) { + StardustCore.ModCore.ModMonitor.Log(v.Value.name); netList.Add(v); } netList.Write(writer); diff --git a/GeneralMods/StardustCore/Objects/CoreObject.cs b/GeneralMods/StardustCore/Objects/CoreObject.cs index fe141896..2a843133 100644 --- a/GeneralMods/StardustCore/Objects/CoreObject.cs +++ b/GeneralMods/StardustCore/Objects/CoreObject.cs @@ -201,6 +201,8 @@ namespace StardustCore this.thisLocation = null; this.textureName = this.TextureSheet.Name; + + this.animationManager = new AnimationManager(this.TextureSheet, new Animation(this.sourceRect), false); } public override string getDescription() @@ -275,6 +277,13 @@ namespace StardustCore return this.clicked(who); } + public override bool clicked(Farmer who) + { + performRemoveAction(this.TileLocation, this.thisLocation); + who.addItemToInventory(this); + return true; + } + public virtual bool RightClicked(StardewValley.Farmer who) { // StardewModdingAPI.Log.AsyncC(lightColor); @@ -701,13 +710,14 @@ 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); + + StardustCore.ModCore.ModMonitor.Log("X Value:" + x); + Point point = new Point(x, y); - this.TileLocation = new Vector2((float)point.X, (float)point.Y); + this.TileLocation = new Vector2((float)point.X/Game1.tileSize, (float)point.Y/Game1.tileSize); - this.boundingBox.Value = new Rectangle(x, y, Game1.tileSize, Game1.tileSize); + this.boundingBox.Value = new Rectangle((int)tileLocation.X, (int)tileLocation.Y, Game1.tileSize, Game1.tileSize); foreach (Farmer farmer in Game1.getAllFarmers()) { @@ -1006,6 +1016,10 @@ namespace StardustCore /// public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { + if (TextureSheet == null) + { + ModCore.ModMonitor.Log("WTF? Why is texture sheet null???"); + } if (x == -1) { spriteBatch.Draw(TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); @@ -1026,6 +1040,13 @@ namespace StardustCore } } + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + this.draw(spriteBatch, xNonTile, yNonTile, alpha); + } + + + public virtual void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) { spriteBatch.Draw(TextureSheet.getTexture(), location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); @@ -1279,6 +1300,12 @@ namespace StardustCore obj.TextureSheet = ModCore.TextureManager.getTexture(obj.textureName); return obj; } + + public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) + { + //Do nothing. + this.updateDrawPosition(); + } } } diff --git a/GeneralMods/StardustCore/Objects/MultiTileComponent.cs b/GeneralMods/StardustCore/Objects/MultiTileComponent.cs index bf3610cb..dfe76e57 100644 --- a/GeneralMods/StardustCore/Objects/MultiTileComponent.cs +++ b/GeneralMods/StardustCore/Objects/MultiTileComponent.cs @@ -34,7 +34,7 @@ namespace StardustCore.Objects this.boundingBox.Value = new Rectangle((int)0 * Game1.tileSize, (int)0* Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); - //this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); + this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); this.InitializeBasics(0, Vector2.Zero); } @@ -56,7 +56,7 @@ namespace StardustCore.Objects this.animationManager = new Animations.AnimationManager(texture, new Animations.Animation(this.defaultSourceRect), false); - //this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); + this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); this.InitializeBasics(0, Vector2.Zero); } @@ -77,7 +77,7 @@ namespace StardustCore.Objects this.serializationName = this.GetType().ToString(); this.ParentSheetIndex = which; - //this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); + this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); this.InitializeBasics(0,Vector2.Zero); } @@ -163,10 +163,11 @@ namespace StardustCore.Objects } catch(Exception err) { - + } StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this); - this.thisLocation.objects.Remove(this.TileLocation); + this.thisLocation.removeObject(this.tileLocation, false); + //this.thisLocation.objects.Remove(this.TileLocation); this.thisLocation = null; this.locationsName = ""; base.performRemoveAction(tileLocation, environment); diff --git a/GeneralMods/StardustCore/Objects/MultiTileObject.cs b/GeneralMods/StardustCore/Objects/MultiTileObject.cs index 67a2b806..045b8413 100644 --- a/GeneralMods/StardustCore/Objects/MultiTileObject.cs +++ b/GeneralMods/StardustCore/Objects/MultiTileObject.cs @@ -97,6 +97,7 @@ namespace StardustCore.Objects { 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; @@ -179,15 +180,23 @@ namespace StardustCore.Objects { if (animationManager == null) { + if (this.objects == null) return; + if (this.sourceRect == null) throw new Exception("Source rect null???"); foreach (var v in this.objects) { + + if (v.Value.getExtendedTexture() == null) throw new Exception("Extended texture is null!"); + if (v.Value.getExtendedTexture().getTexture() == null) throw new Exception("Texture is null!"); spriteBatch.Draw(v.Value.getExtendedTexture().getTexture(), objectPosition + new Vector2(v.Key.X * Game1.tileSize, v.Key.Y * Game1.tileSize), this.sourceRect, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); } } else { + foreach (var v in this.objects) { + if(v.Value.getExtendedTexture() == null) throw new Exception("Extended texture is null!"); + if (v.Value.getExtendedTexture().getTexture() == null) throw new Exception("Texture is null!"); spriteBatch.Draw(v.Value.animationManager.getTexture(), objectPosition + new Vector2(v.Key.X * Game1.tileSize, v.Key.Y * Game1.tileSize), this.sourceRect, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); } } @@ -221,6 +230,7 @@ namespace StardustCore.Objects } } } + public override Color getCategoryColor() { diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 09216db5..7c591de9 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -99,8 +99,6 @@ - - diff --git a/GeneralMods/StardustCore/UIUtilities/TextureManager.cs b/GeneralMods/StardustCore/UIUtilities/TextureManager.cs index 33071a4d..4fc34d65 100644 --- a/GeneralMods/StardustCore/UIUtilities/TextureManager.cs +++ b/GeneralMods/StardustCore/UIUtilities/TextureManager.cs @@ -31,6 +31,7 @@ namespace StardustCore.UIUtilities { if (v.Key == name) return v.Value.Copy(); } + throw new Exception("Error, texture name not found!!!"); return null; }