示例#1
0
    void Entities()
    {
        EntityArray entities = added.entities;
        ComponentDataArray <NetworkSync> networkSyncs      = added.syncs;
        ComponentDataArray <SyncState>   networkSyncStates = added.states;

        for (int i = 0; i < entities.Length; i++)
        {
            int instanceId = networkSyncs[i].instanceId;

            Entity        entity            = entities[i];
            NetworkEntity networkEntityData = new NetworkEntity {
                InstanceId = networkSyncs[i].instanceId,

                Id = new EntityId {
                    ActorId   = networkSyncStates[i].actorId,
                    NetworkId = networkSyncStates[i].networkId,
                }
            };

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

            networkSendMessageUtility.AddEntity(networkEntityData);
        }
    }
示例#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);
        }
    }