示例#1
0
        public void ProcessEntityUpdate(int serverTick, int id, ref NetworkReader reader)
        {
            replicatedEntities.ProcessEntityUpdate(serverTick, id, ref reader);

            //Update localPlayer
            var entity = replicatedEntities.GetEntity(id);

            if (entity == Entity.Null)
            {
                return;
            }

            if (EntityManager.HasComponent <NewServerEntity>(entity))
            {
                var newServerEntity = EntityManager.GetComponentData <NewServerEntity>(entity);
                if (newServerEntity.Tick == 0)
                {
                    EntityManager.RemoveComponent <NewServerEntity>(entity);
                }
                else
                {
                    newServerEntity.Tick--;
                    EntityManager.SetComponentData(entity, newServerEntity);
                }
            }

            var replicatedData = EntityManager.GetComponentData <ReplicatedEntityData>(entity);
            var localPlayer    = GetSingleton <LocalPlayer>();

            if (EntityManager.HasComponent <Character>(entity) &&
                localPlayer.CharacterEntity == Entity.Null &&
                replicatedData.PredictingPlayerId == localPlayer.PlayerId)
            {
                EntityManager.AddComponentData(entity, new LocalCharacter());
                localPlayer.CharacterEntity = entity;

                SetSingleton(localPlayer);
            }
        }
        public bool HasEntity(Entity owner)
        {
            var replicatedData = EntityManager.GetComponentData <ReplicatedEntityData>(owner);

            return(replicatedEntityCollection.GetEntity(replicatedData.Id) == owner);
        }