internal void ProcessReplication(BitStream bs) { bool success; int typeID; success = bs.ReadCompressed(out typeID); Debug.Assert(success, "Failed to read replication type ID"); Debug.Assert(typeID < m_idToType.Count, "Invalid replication type ID"); Type type = m_idToType[typeID]; long tmpLong; success = bs.Read(out tmpLong); Debug.Assert(success, "Failed to read entityID"); ulong entityID = (ulong)tmpLong; object obj = Activator.CreateInstance(type); // should init here MySyncedClass sync = GetSyncedClass(obj); sync.entityId = entityID; sync.Deserialize(bs); m_registered.Add(entityID, sync); var handle = OnEntityCreated; if (handle != null) { handle(obj, entityID); } }
internal void ProcessReplicationCreate(BitStream bs) { bool success; int typeID; success = bs.ReadCompressed(out typeID); Debug.Assert(success, "Failed to read replication type ID"); Debug.Assert(typeID < m_idToType.Count, "Invalid replication type ID"); Type type = m_idToType[typeID]; uint networkID; success = bs.ReadCompressed(out networkID); Debug.Assert(success, "Failed to read networkID"); object obj = Activator.CreateInstance(type); MySyncedClass sync = GetSyncedClass(obj); sync.TypeID = typeID; sync.Deserialize(bs); // TODO:SK should init here AddNetworkedObject(networkID, obj, sync); var handle = OnEntityCreated; if (handle != null) { handle(obj); } }
internal void ProcessSync(BitStream bs) { uint networkID; bool success = bs.ReadCompressed(out networkID); Debug.Assert(success, "Failed to read networkID"); MySyncedClass mySyncedObject = GetNetworkedSync(networkID); if (mySyncedObject != null) { mySyncedObject.Deserialize(bs); } }
internal void ProcessSync(BitStream bs) { long tmpLong; bool success = bs.Read(out tmpLong); Debug.Assert(success, "Failed to read entityID"); ulong entityID = (ulong)tmpLong; MySyncedClass mySyncedObject = GetEntitySyncFields(entityID); if (mySyncedObject != null) { mySyncedObject.Deserialize(bs); } }