Implemented some of the itemcomponent read/write methods, made submarines server serializable

This commit is contained in:
Regalis
2016-09-02 17:59:08 +03:00
parent e0b6642767
commit cf77a59c97
10 changed files with 323 additions and 13 deletions
+27 -2
View File
@@ -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());
}
}
}
-2
View File
@@ -37,8 +37,6 @@ namespace Barotrauma
private Vector2? targetPosition;
//private float mass = 10000.0f;
public Rectangle Borders
{
get;