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:
parent
5446f8095d
commit
e1a2a0da47
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,9 @@ namespace StardustCore
|
|||
SerializationManager.initializeDefaultSuportedTypes();
|
||||
TextureManagers = new Dictionary<string, 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);
|
||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||
|
||||
|
@ -169,6 +171,7 @@ namespace StardustCore
|
|||
|
||||
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
|
||||
|
||||
/*
|
||||
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")));
|
||||
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -21,16 +21,36 @@ namespace StardustCore.NetCode.Graphics
|
|||
|
||||
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,13 +83,37 @@ 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);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -89,5 +134,10 @@ namespace StardustCore.NetCode.Graphics
|
|||
animationData.Write(writer);
|
||||
|
||||
}
|
||||
|
||||
public override void Set(AnimationManager newValue)
|
||||
{
|
||||
this.value = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ namespace StardustCore.NetCode.Objects
|
|||
|
||||
public NetMultiTileComponent(MultiTileComponent obj): base(obj)
|
||||
{
|
||||
|
||||
Set(obj);
|
||||
}
|
||||
|
||||
public NetInt InventoryMaxSize { get; private set; }
|
||||
|
|
|
@ -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.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<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)
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log(v.Value.name);
|
||||
netList.Add(v);
|
||||
}
|
||||
netList.Write(writer);
|
||||
|
|
|
@ -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);
|
||||
|
@ -702,12 +711,13 @@ 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
|
|||
/// <param name="alpha"></param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -166,7 +166,8 @@ namespace StardustCore.Objects
|
|||
|
||||
}
|
||||
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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -222,6 +231,7 @@ namespace StardustCore.Objects
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public override Color getCategoryColor()
|
||||
{
|
||||
return this.categoryColor;
|
||||
|
|
|
@ -99,8 +99,6 @@
|
|||
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
|
||||
<Compile Include="NetCode\ModdedClient.cs" />
|
||||
<Compile Include="NetCode\ModdedGameServer.cs" />
|
||||
<Compile Include="NetCode\NetAnimation.cs" />
|
||||
<Compile Include="NetCode\NetAnimationManager.cs" />
|
||||
<Compile Include="NetCode\NetBufferReadStream.cs" />
|
||||
<Compile Include="NetCode\NetBufferWriteStream.cs" />
|
||||
<Compile Include="NetCode\NetKeyValuePair.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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue