Core objects work aside from net animation manager. Also need to figure out how to load in when custom objects are present.

This commit is contained in:
Joshua Navarro 2018-12-15 11:49:56 -08:00
parent 5446f8095d
commit e1a2a0da47
15 changed files with 165 additions and 229 deletions

View File

@ -32,7 +32,8 @@ namespace StardustCore.Animations
public Animation() public Animation()
{ {
this.sourceRectangle = new Rectangle(); this.sourceRectangle = new Rectangle(0,0,16,16);
this.frameCountUntilNextAnimation = -1;
this.frameDuration = -1; this.frameDuration = -1;
} }
@ -43,6 +44,7 @@ namespace StardustCore.Animations
public Animation(Rectangle SourceRectangle) public Animation(Rectangle SourceRectangle)
{ {
sourceRectangle = SourceRectangle; sourceRectangle = SourceRectangle;
this.frameCountUntilNextAnimation = -1;
frameDuration = -1; frameDuration = -1;
} }

View File

@ -69,7 +69,9 @@ namespace StardustCore
SerializationManager.initializeDefaultSuportedTypes(); SerializationManager.initializeDefaultSuportedTypes();
TextureManagers = new Dictionary<string, TextureManager>(); TextureManagers = new Dictionary<string, TextureManager>();
TextureManager = new TextureManager(); 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); TextureManagers.Add(ModManifest.UniqueID, TextureManager);
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
@ -169,6 +171,7 @@ namespace StardustCore
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
/*
List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>(); List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>();
MultiTileComponent tile1 = new MultiTileComponent(0,"Tileobj1","A basic tile obj",new Texture2DExtended(ModCore.ModHelper,ModCore.Manifest ,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); 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); 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) private void SaveEvents_AfterSave(object sender, EventArgs e)

View File

@ -22,17 +22,20 @@ namespace StardustCore.NetCode.Graphics
} }
public NetAnimation(Animations.Animation animation) : base(animation) public NetAnimation(Animations.Animation animation) : base(animation)
{ {
this.Set(animation);
} }
public override void Set(Animation newValue) public override void Set(Animation newValue)
{ {
throw new NotImplementedException(); this.value = newValue;
} }
protected override void ReadDelta(BinaryReader reader, NetVersion version) protected override void ReadDelta(BinaryReader reader, NetVersion version)
{ {
sourceRect = new NetRectangle(); 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); sourceRect.Read(reader, version);
Value.sourceRectangle = sourceRect.Value; Value.sourceRectangle = sourceRect.Value;
@ -42,11 +45,13 @@ namespace StardustCore.NetCode.Graphics
frameDurationUntilNextAnimation = new NetInt(); frameDurationUntilNextAnimation = new NetInt();
frameDurationUntilNextAnimation.Read(reader, version); frameDurationUntilNextAnimation.Read(reader, version);
Value.frameDuration = frameDuration.Value; Value.frameCountUntilNextAnimation = frameDurationUntilNextAnimation.Value;
} }
protected override void WriteDelta(BinaryWriter writer) protected override void WriteDelta(BinaryWriter writer)
{ {
sourceRect = new NetRectangle(Value.sourceRectangle); sourceRect = new NetRectangle(Value.sourceRectangle);
sourceRect.Write(writer); sourceRect.Write(writer);

View File

@ -11,7 +11,7 @@ using StardustCore.Animations;
namespace StardustCore.NetCode.Graphics namespace StardustCore.NetCode.Graphics
{ {
public class NetAnimationManager : Netcode.NetField<Animations.AnimationManager,NetAnimationManager> public class NetAnimationManager : Netcode.NetField<Animations.AnimationManager, NetAnimationManager>
{ {
public NetAnimationManager() 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) public NetString currentAnimationName;
{ public NetInt currentAnimationListIndex;
throw new NotImplementedException(); public NetTexture2DExtended objectTexture;
} public NetAnimation defaultDrawFrame;
public NetBool enabled;
public NetString animationDataString;
protected override void ReadDelta(BinaryReader reader, NetVersion version) 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(); NetString currentAnimationName = new NetString();
currentAnimationName.Read(reader, version); currentAnimationName.Read(reader, version);
@ -63,14 +83,38 @@ namespace StardustCore.NetCode.Graphics
} }
else else
{ {
Value.currentAnimation = defaultAnimation.Value; Value.currentAnimation = defaultDrawFrame.Value;
} }
} }
protected override void WriteDelta(BinaryWriter writer) 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); NetInt currentAnimationListIndex = new NetInt(Value.currentAnimationListIndex);
@ -79,6 +123,7 @@ namespace StardustCore.NetCode.Graphics
NetTexture2DExtended texture = new NetTexture2DExtended(Value.getExtendedTexture()); NetTexture2DExtended texture = new NetTexture2DExtended(Value.getExtendedTexture());
texture.Write(writer); texture.Write(writer);
//do read/write null values here!!!
NetAnimation defaultDrawFrame = new NetAnimation(Value.defaultDrawFrame); NetAnimation defaultDrawFrame = new NetAnimation(Value.defaultDrawFrame);
defaultDrawFrame.Write(writer); defaultDrawFrame.Write(writer);
@ -89,5 +134,10 @@ namespace StardustCore.NetCode.Graphics
animationData.Write(writer); animationData.Write(writer);
} }
public override void Set(AnimationManager newValue)
{
this.value = newValue;
}
} }
} }

View File

@ -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<Animations.Animation, NetAnimation>
{
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);
}
}
}

View File

@ -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<Animations.AnimationManager,NetAnimationManager>
{
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;
}
}
}

View File

@ -24,6 +24,7 @@ namespace StardustCore.NetCode
public NetTexture2DExtended(Texture2DExtended value) : base(value) public NetTexture2DExtended(Texture2DExtended value) : base(value)
{ {
this.Set(value);
} }
public void ReadData(BinaryReader reader, NetVersion version) public void ReadData(BinaryReader reader, NetVersion version)
@ -55,10 +56,15 @@ namespace StardustCore.NetCode
//Texture2D texture = new Texture2D(Game1.graphics.GraphicsDevice,width,height); //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); 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; this.Value = texture;
} }

View File

@ -74,6 +74,7 @@ namespace StardustCore.NetCode
{ {
texture = new NetTexture2DExtended(); texture = new NetTexture2DExtended();
texture.Read(reader, version); texture.Read(reader, version);
Value.setExtendedTexture(texture.Value); Value.setExtendedTexture(texture.Value);
which = new NetInt(); which = new NetInt();
@ -100,9 +101,12 @@ namespace StardustCore.NetCode
drawPosition.Read(reader, version); drawPosition.Read(reader, version);
Value.drawPosition = drawPosition.Value; Value.drawPosition = drawPosition.Value;
/*
animationManager = new NetAnimationManager(); animationManager = new NetAnimationManager();
animationManager.Read(reader, version); animationManager.Read(reader, version);
Value.animationManager = animationManager.Value; Value.animationManager = animationManager.Value;
*/
} }
protected override void WriteDelta(BinaryWriter writer) protected override void WriteDelta(BinaryWriter writer)
@ -128,10 +132,14 @@ namespace StardustCore.NetCode
drawPosition = new NetVector2(Value.drawPosition); drawPosition = new NetVector2(Value.drawPosition);
drawPosition.Write(writer); drawPosition.Write(writer);
/*
if (Value.animationManager == null)
{
throw new Exception("WTF, why is the animation manager null???????????");
}
animationManager = new NetAnimationManager(Value.animationManager); animationManager = new NetAnimationManager(Value.animationManager);
animationManager.Write(writer); animationManager.Write(writer);
*/
} }
} }
} }

View File

@ -27,7 +27,7 @@ namespace StardustCore.NetCode.Objects
public NetMultiTileComponent(MultiTileComponent obj): base(obj) public NetMultiTileComponent(MultiTileComponent obj): base(obj)
{ {
Set(obj);
} }
public NetInt InventoryMaxSize { get; private set; } public NetInt InventoryMaxSize { get; private set; }

View File

@ -35,7 +35,17 @@ namespace StardustCore.NetCode.Objects
NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>> netList = new NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>>(); NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>> netList = new NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>>();
netList.Read(reader, version); 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(); Value.objects = netList.ToList();
//this.value.objects=netList.ToArray().ToList();
NetColor col = new NetColor(); NetColor col = new NetColor();
col.Read(reader, version); col.Read(reader, version);
@ -52,8 +62,11 @@ namespace StardustCore.NetCode.Objects
obj.Write(writer); obj.Write(writer);
NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>> netList = new NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>>(); NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>> netList = new NetList<KeyValuePair<Vector2, MultiTileComponent>, NetKeyValuePair<Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent>>();
if (Value.objects == null) throw new Exception("Trying to write null object list!");
foreach (var v in Value.objects) foreach (var v in Value.objects)
{ {
StardustCore.ModCore.ModMonitor.Log(v.Value.name);
netList.Add(v); netList.Add(v);
} }
netList.Write(writer); netList.Write(writer);

View File

@ -201,6 +201,8 @@ namespace StardustCore
this.thisLocation = null; this.thisLocation = null;
this.textureName = this.TextureSheet.Name; this.textureName = this.TextureSheet.Name;
this.animationManager = new AnimationManager(this.TextureSheet, new Animation(this.sourceRect), false);
} }
public override string getDescription() public override string getDescription()
@ -275,6 +277,13 @@ namespace StardustCore
return this.clicked(who); 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) public virtual bool RightClicked(StardewValley.Farmer who)
{ {
// StardewModdingAPI.Log.AsyncC(lightColor); // StardewModdingAPI.Log.AsyncC(lightColor);
@ -702,12 +711,13 @@ namespace StardustCore
public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) 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()) foreach (Farmer farmer in Game1.getAllFarmers())
{ {
@ -1006,6 +1016,10 @@ namespace StardustCore
/// <param name="alpha"></param> /// <param name="alpha"></param>
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) 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) 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); 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) 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); 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); obj.TextureSheet = ModCore.TextureManager.getTexture(obj.textureName);
return obj; return obj;
} }
public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
{
//Do nothing.
this.updateDrawPosition();
}
} }
} }

View File

@ -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.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); 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.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); this.InitializeBasics(0, Vector2.Zero);
} }
@ -77,7 +77,7 @@ namespace StardustCore.Objects
this.serializationName = this.GetType().ToString(); this.serializationName = this.GetType().ToString();
this.ParentSheetIndex = which; this.ParentSheetIndex = which;
//this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture()));
this.InitializeBasics(0,Vector2.Zero); this.InitializeBasics(0,Vector2.Zero);
} }
@ -166,7 +166,8 @@ namespace StardustCore.Objects
} }
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this); 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.thisLocation = null;
this.locationsName = ""; this.locationsName = "";
base.performRemoveAction(tileLocation, environment); base.performRemoveAction(tileLocation, environment);

View File

@ -97,6 +97,7 @@ namespace StardustCore.Objects
{ {
foreach (var pair in this.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); pair.Value.placementAction(location, x + (int)(pair.Key.X * Game1.tileSize), y + (int)(pair.Key.Y * Game1.tileSize), who);
} }
return true; return true;
@ -179,15 +180,23 @@ namespace StardustCore.Objects
{ {
if (animationManager == null) if (animationManager == null)
{ {
if (this.objects == null) return;
if (this.sourceRect == null) throw new Exception("Source rect null???");
foreach (var v in this.objects) 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)); 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 else
{ {
foreach (var v in this.objects) 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)); 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));
} }
} }
@ -222,6 +231,7 @@ namespace StardustCore.Objects
} }
} }
public override Color getCategoryColor() public override Color getCategoryColor()
{ {
return this.categoryColor; return this.categoryColor;

View File

@ -99,8 +99,6 @@
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" /> <Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
<Compile Include="NetCode\ModdedClient.cs" /> <Compile Include="NetCode\ModdedClient.cs" />
<Compile Include="NetCode\ModdedGameServer.cs" /> <Compile Include="NetCode\ModdedGameServer.cs" />
<Compile Include="NetCode\NetAnimation.cs" />
<Compile Include="NetCode\NetAnimationManager.cs" />
<Compile Include="NetCode\NetBufferReadStream.cs" /> <Compile Include="NetCode\NetBufferReadStream.cs" />
<Compile Include="NetCode\NetBufferWriteStream.cs" /> <Compile Include="NetCode\NetBufferWriteStream.cs" />
<Compile Include="NetCode\NetKeyValuePair.cs" /> <Compile Include="NetCode\NetKeyValuePair.cs" />

View File

@ -31,6 +31,7 @@ namespace StardustCore.UIUtilities
{ {
if (v.Key == name) return v.Value.Copy(); if (v.Key == name) return v.Value.Copy();
} }
throw new Exception("Error, texture name not found!!!");
return null; return null;
} }