public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { //Debug.Log(BitTools.BitDisplay.BytesToString(stream.Data)); //Debug.Log("MessageCode.EntityUpdate.Deserialize"); //read the entity header int prefabId = SerializerUtils.ReadInt(stream, 0, Core.net.maxPrefabs); int networkId = SerializerUtils.ReadInt(stream, 0, Core.net.maxNetworkIds); int owner = SerializerUtils.ReadInt(stream, 0, Core.net.maxPlayers); int controller = SerializerUtils.ReadInt(stream, 0, Core.net.maxPlayers); //pass it down to the Behaviour to process further Core.net.GetPrefabNetworkGameObject(prefabId).Deserialize(stream, prefabId, networkId, owner, controller); //what happens if we get here and we CAN"T find the entity? It's already been destroyed locally? //we won't know the state, and we won't know how much data to read. //and we can't just throw away the packet.. because it might have important data AFTER this message //so we need a way to know the message size even if the entity doesn't exisit. //we could send the message size but that's another 8 bits at least.. and that would kind of be a waste. //hmmmmm //cause use the prefabs template peek because it could have a different size (delta compressed) //HMMMMM //can we use a static deserialize (on the prefab template) //that will read anything conditional? I guess //Debug.Log("Deserialize: " + prefabId + " : " + networkId + " : " + owner + " : " + controller); //process is called the next level down (prefab's behaviour's deserialize) //Core.net.MessageProcessors[msgCode](sender, prefabId, networkId, owner, controller); }
// public static void Serialize(ulong receiver, ByteStream stream, params object[] args) { int arg0 = (int)args[0]; //the connectionIndex of the player who sent you this message (the host) int arg1 = (int)args[1]; //the connectionIndex of you assigned by the host SerializerUtils.WriteInt(stream, arg0, 0, 255); SerializerUtils.WriteInt(stream, arg1, 0, 255); }
public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { int arg0 = SerializerUtils.ReadInt(stream, 0, 255); int arg1 = SerializerUtils.ReadInt(stream, 0, 255); //no need for a null check, can't have a deserializer without a processor. //I mean, you can, but it wouldn't do anything with the data you just received Core.net.MessageProcessors[msgCode](sender, arg0, arg1); }
public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { //Remember to call Core.Net.MessageProcessors[msgCode](sender, args...) here! //Core.net.MessageProcessors[msgCode](sender, arg0, arg1, arg2, arg3, arg4, arg5); int zone = SerializerUtils.ReadInt(stream, 0, Core.net.maxZones); float x = SerializerUtils.ReadFloat(stream, Core.net.minWorldPos.x, Core.net.maxWorldPos.x, Core.net.worldPosPrecision); float y = SerializerUtils.ReadFloat(stream, Core.net.minWorldPos.y, Core.net.maxWorldPos.y, Core.net.worldPosPrecision); float z = SerializerUtils.ReadFloat(stream, Core.net.minWorldPos.z, Core.net.maxWorldPos.z, Core.net.worldPosPrecision); Core.net.MessageProcessors[msgCode](sender, zone, x, y, z); }
public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { int prefabId = SerializerUtils.ReadInt(stream, 0, Core.net.maxPrefabs); int networkId = SerializerUtils.ReadInt(stream, 0, Core.net.maxNetworkIds); int owner = SerializerUtils.ReadInt(stream, 0, Core.net.maxPlayers); int controller = SerializerUtils.ReadInt(stream, 0, Core.net.maxPlayers); //no need for a null check, can't have a deserializer without a processor. //I mean, you can, but it wouldn't do anything with the data you just received Core.net.MessageProcessors[msgCode](sender, prefabId, networkId, owner, controller); }
public static void Serialize(ulong receiver, ByteStream stream, params object[] args) { int zone = (int)args[0]; float x = (float)args[1]; float y = (float)args[2]; float z = (float)args[3]; SerializerUtils.WriteInt(stream, zone, 0, Core.net.maxZones); SerializerUtils.WriteFloat(stream, x, Core.net.minWorldPos.x, Core.net.maxWorldPos.x, Core.net.worldPosPrecision); SerializerUtils.WriteFloat(stream, y, Core.net.minWorldPos.y, Core.net.maxWorldPos.y, Core.net.worldPosPrecision); SerializerUtils.WriteFloat(stream, z, Core.net.minWorldPos.z, Core.net.maxWorldPos.z, Core.net.worldPosPrecision); }
// public static void Serialize(ulong receiver, ByteStream stream, params object[] args) { int prefabId = (int)args[0]; int networkId = (int)args[1]; int owner = (int)args[2]; int controller = (int)args[3]; //Debug.Log("NetworkID :: " + networkId); SerializerUtils.WriteInt(stream, prefabId, 0, Core.net.maxPrefabs); SerializerUtils.WriteInt(stream, networkId, 0, Core.net.maxNetworkIds); SerializerUtils.WriteInt(stream, owner, 0, Core.net.maxPlayers); SerializerUtils.WriteInt(stream, controller, 0, Core.net.maxPlayers); }
public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { //Debug.Log(BitTools.BitDisplay.BytesToString(stream.Data)); //Debug.Log("MessageCode.EntityUpdate.Deserialize"); //read the entity header int prefabId = SerializerUtils.ReadInt(stream, 0, Core.net.maxPrefabs); int networkId = SerializerUtils.ReadInt(stream, 0, Core.net.maxNetworkIds); int owner = SerializerUtils.ReadInt(stream, 0, Core.net.maxPlayers); int controller = SerializerUtils.ReadInt(stream, 0, Core.net.maxPlayers); //pass it down to the Behaviour to process further //Core.net.GetPrefabNetworkGameObject(prefabId).Deserialize(stream, prefabId, networkId, owner, controller); //Core.net.ProcessEntityMessage(prefabId, networkId, owner, controller); Core.net.MessageProcessors[msgCode](sender, prefabId, networkId, owner, controller); }
// public static void Serialize(ulong receiver, ByteStream stream, params object[] args) { //Debug.Log("Serialize: " + args[0] + " : " + args[1] + " : " + args[2] + " : " + args[3]); //Debug.Log("Serialize: " + args[0]); int prefabId = (int)args[0]; int networkId = (int)args[1]; int owner = (int)args[2]; int controller = (int)args[3]; //Debug.Log("NetworkID :: " + networkId); SerializerUtils.WriteInt(stream, prefabId, 0, Core.net.maxPrefabs); SerializerUtils.WriteInt(stream, networkId, 0, Core.net.maxNetworkIds); SerializerUtils.WriteInt(stream, owner, 0, Core.net.maxPlayers); SerializerUtils.WriteInt(stream, controller, 0, Core.net.maxPlayers); //Debug.Log(BitTools.BitDisplay.BytesToString(stream.Data)); }
public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { //Remember to call Core.Net.MessageProcessors[msgCode](sender, args...) here! //Core.net.MessageProcessors[msgCode](sender, arg0, arg1, arg2, arg3, arg4, arg5); }
public static void Serialize(ulong receiver, ByteStream stream, params object[] args) { }
public static void Deserialize(ulong sender, int msgCode, ByteStream stream) { Core.net.MessageProcessors[msgCode](sender, msgCode); }