Server sends ServerEntityEvents to clients, NetEntityEvents can contain an object array which will be passed to the serializable entity (now only used for ItemComponent indices)

This commit is contained in:
Regalis
2016-11-13 13:56:48 +02:00
parent c314b37029
commit 498c72c64a
24 changed files with 133 additions and 43 deletions

View File

@@ -12,11 +12,20 @@ namespace Barotrauma.Networking
public readonly Entity Entity;
public readonly UInt32 ID;
//arbitrary extra data that will be passed to the Write method of the serializable entity
//(the index of an itemcomponent for example)
protected object[] Data;
protected NetEntityEvent(INetSerializable entity, UInt32 id)
{
this.ID = id;
this.Entity = entity as Entity;
}
public void SetData(object[] data)
{
this.Data = data;
}
}
class ServerEntityEvent : NetEntityEvent
@@ -31,7 +40,7 @@ namespace Barotrauma.Networking
public void Write(NetBuffer msg, Client recipient)
{
serializable.ServerWrite(msg, recipient);
serializable.ServerWrite(msg, recipient, Data);
}
}
@@ -47,7 +56,7 @@ namespace Barotrauma.Networking
public void Write(NetBuffer msg)
{
serializable.ClientWrite(msg);
serializable.ClientWrite(msg, Data);
}
}