private static void OnEntityUpdate(NetworkMessage message) { uint id = message.ReadUInt(); string path = message.ReadString(); Vector3 pos = message.ReadVector3(); Quaternion rot = message.ReadQuaternion(); NetworkEntity ent = EntityManager.Find(id); if (ent == null) { Debug.LogWarning("Server received OnEntityUpdate for an invalid entity, ID: " + id); return; } ent.OnReceiveEntityUpdate(pos, rot); NetworkMessage msg = new NetworkMessage(NetworkMessageType.Entity_UpdateTransform); msg.Write(1); msg.Write(id); msg.Write(ent.gridCell.Index); msg.Write(path); msg.Write(pos); msg.Write(rot); NetworkManager.Instance.SendToCell(ent.gridCell, msg, ent.clientID); }
private static void OnEntityUpdate(NetworkMessage message) { uint id = message.ReadUInt(); uint cellID = message.ReadUInt(); string path = message.ReadString(); Vector3 pos = message.ReadVector3(); Quaternion rot = message.ReadQuaternion(); NetworkEntity ent = EntityManager.Find(id); bool justCreated = false; if (ent == null) { ent = CreateEntity(id, cellID, path, false); justCreated = true; } ent.cellID = cellID; if (ent.locallyControlled) { return; } ent.OnReceiveEntityUpdate(pos, rot, !justCreated); message.reader.Close(); message.stream.Close(); }