Implemented some of the itemcomponent read/write methods, made submarines server serializable
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using FarseerPhysics;
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Common;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Lidgren.Network;
|
||||
@@ -28,7 +29,7 @@ namespace Barotrauma
|
||||
HideInMenus = 2
|
||||
}
|
||||
|
||||
class Submarine : Entity
|
||||
class Submarine : Entity, IServerSerializable
|
||||
{
|
||||
|
||||
public static string SavePath = "Submarines";
|
||||
@@ -122,6 +123,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private ushort netStateID;
|
||||
public ushort NetStateID
|
||||
{
|
||||
get
|
||||
{
|
||||
return netStateID;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Submarine> Loaded
|
||||
{
|
||||
get { return loaded; }
|
||||
@@ -951,6 +961,21 @@ namespace Barotrauma
|
||||
|
||||
DockedTo.Clear();
|
||||
}
|
||||
|
||||
public void ServerWrite(NetOutgoingMessage msg)
|
||||
{
|
||||
msg.Write(subBody.Position.X);
|
||||
msg.Write(subBody.Position.Y);
|
||||
|
||||
msg.Write(Velocity.X);
|
||||
msg.Write(Velocity.Y);
|
||||
}
|
||||
|
||||
public void ClientRead(NetIncomingMessage msg)
|
||||
{
|
||||
subBody.TargetPosition = new Vector2(msg.ReadSingle(), msg.ReadSingle());
|
||||
subBody.Velocity = new Vector2(msg.ReadSingle(), msg.ReadSingle());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ namespace Barotrauma
|
||||
|
||||
private Vector2? targetPosition;
|
||||
|
||||
//private float mass = 10000.0f;
|
||||
|
||||
public Rectangle Borders
|
||||
{
|
||||
get;
|
||||
|
||||
Reference in New Issue
Block a user