private void Entities() { EntityArray entities = addedSyncEntities.entities; ComponentDataArray <NetworkSync> networkSyncs = addedSyncEntities.networkSyncComponents; ComponentDataArray <NetworkSyncState> networkSyncStates = addedSyncEntities.networkSyncStateComponents; for (int i = 0; i < entities.Length; i++) { int instanceId = networkSyncs[i].instanceId; Entity entity = entities[i]; NetworkEntityData networkEntityData = new NetworkEntityData { InstanceId = networkSyncs[i].instanceId, NetworkSyncEntity = new NetworkSyncEntity { ActorId = networkSyncStates[i].actorId, NetworkId = networkSyncStates[i].networkId, } }; for (int j = 0; j < GetComponentDataMethods.Count; j++) { if (GetComponentDataMethods[j].Invoke(this, ref entity, out ComponentDataContainer componentData)) { networkEntityData.ComponentData.Add(componentData); } } networkSendMessageUtility.AddEntity(networkEntityData); } }
public void SendNetworkEntityData(NetworkEntityData networkEntityData, bool server = false) { if (enabled) { //Encapsulate in message if (!server) { SendMessage(new NetworkEntityDataMessage(networkEntityData), sendTCP: false); } else { SendMessage(new ServerNetworkEntityDataMessage(networkEntityData), sendTCP: false); } } }
private void AddedEntities() { EntityArray entities = addedSyncEntities.entities; ComponentDataArray <NetworkSync> networkSyncs = addedSyncEntities.networkSyncComponents; for (int i = 0; i < entities.Length; i++) { NetworkSync networkSync = networkSyncs[i]; int instanceId = networkSync.instanceId; NetworkSyncState component = new NetworkSyncState() { actorId = networkManager.LocalPlayerID, networkId = networkManager.GetNetworkId(), }; Entity entity = entities[i]; PostUpdateCommands.AddComponent(entity, component); if (NetworkUtility.CanAssignAuthority(networkManager, networkSync.authority)) { PostUpdateCommands.AddComponent(entity, new NetworktAuthority()); } NetworkEntityData networkEntityData = new NetworkEntityData { InstanceId = networkSync.instanceId, NetworkSyncEntity = new NetworkSyncEntity { ActorId = component.actorId, NetworkId = component.networkId, } }; for (int j = 0; j < AddComponentDataOnEntityAddedMethods.Count; j++) { if (AddComponentDataOnEntityAddedMethods[j].Invoke(this, ref entity, out ComponentDataContainer componentData)) { networkEntityData.ComponentData.Add(componentData); } } ownNetworkSendMessageUtility.AddEntity(networkEntityData); AllNetworkSendMessageUtility.AddEntity(networkEntityData); } }
public ServerNetworkEntityDataMessage(NetworkEntityData networkEntityData) { this.networkEntityData = networkEntityData; }
public void AddEntity(NetworkEntityData networkEntityData) { DataContainer.AddedNetworkSyncEntities.Add(networkEntityData); }
public static void LoadNetworkContent() { NetworkEntityData.LoadSerialization(); }