Exemplo n.º 1
0
    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);
        }
    }
Exemplo n.º 2
0
    private void AddedEntities()
    {
        EntityArray entities = addedSyncEntities.entities;
        ComponentDataArray <NetworkSync> networkSyncs = addedSyncEntities.networkSyncComponents;

        for (int i = 0; i < entities.Length; i++)
        {
            int       instanceId = networkSyncs[i].instanceId;
            SyncState component  = new SyncState()
            {
                actorId   = networkManager.LocalPlayerID,
                networkId = networkManager.GetNetworkId(),
            };
            Entity entity = entities[i];
            PostUpdateCommands.AddComponent(entity, component);
            PostUpdateCommands.AddComponent(entity, new NetworktOwner());

            NetworkEntity networkEntityData = new NetworkEntity {
                InstanceId = networkSyncs[i].instanceId,

                Id = new EntityId {
                    ActorId   = component.actorId,
                    NetworkId = component.networkId,
                }
            };

            for (int j = 0; j < AddComponentDataOnEntityAddedMethods.Count; j++)
            {
                if (AddComponentDataOnEntityAddedMethods[j].Invoke(this, ref entity, out NetworkComponent componentData))
                {
                    networkEntityData.Components.Add(componentData);
                }
            }

            ownNetworkSendMessageUtility.AddEntity(networkEntityData);
            AllNetworkSendMessageUtility.AddEntity(networkEntityData);
        }
    }