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

@@ -41,6 +41,8 @@ namespace Barotrauma.Networking
public UInt32 LastSentEntityEventID;
private ClientEntityEventManager entityEventManager;
public byte ID
{
get { return myID; }
@@ -86,6 +88,8 @@ namespace Barotrauma.Networking
Hull.EditWater = false;
name = newName;
entityEventManager = new ClientEntityEventManager(this);
characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
characterInfo.Job = null;
@@ -706,6 +710,7 @@ namespace Barotrauma.Networking
{
case ServerNetObject.SYNC_IDS:
lastSentChatMsgID = inc.ReadUInt32();
LastSentEntityEventID = inc.ReadUInt32();
break;
case ServerNetObject.ENTITY_POSITION:
UInt16 id = inc.ReadUInt16();
@@ -724,6 +729,9 @@ namespace Barotrauma.Networking
inc.ReadPadBits();
break;
case ServerNetObject.ENTITY_STATE:
entityEventManager.Read(inc, sendingTime);
break;
case ServerNetObject.CHAT_MESSAGE:
ChatMessage.ClientRead(inc);
break;
@@ -769,6 +777,7 @@ namespace Barotrauma.Networking
outmsg.Write(GameMain.NetLobbyScreen.LastUpdateID);
outmsg.Write(ChatMessage.LastID);
outmsg.Write(Entity.Spawner.NetStateID);
outmsg.Write(entityEventManager.LastReceivedEntityEventID);
ChatMessage removeMsg;
while ((removeMsg = chatMsgQueue.Find(cMsg => cMsg.NetStateID <= lastSentChatMsgID)) != null)