Пример #1
0
        public void ProcessEntitySpawn(int serverTick, int id, ushort typeId)
        {
            FSLog.Info("ProcessEntitySpawns. Server tick:" + serverTick + " id:" + id + " typeid:" + (EntityType)typeId);

            Profiler.BeginSample("ReplicatedEntitySystemClient.ProcessEntitySpawns()");

            if (id < worldSceneEntitiesSystem.SceneEntities.Count)
            {
                replicatedEntities.Register(id, worldSceneEntitiesSystem.SceneEntities[id]);
                return;
            }

            var factory = factoryManager.GetFactory(typeId);

            if (factory == null)
            {
                return;
            }

            var entity = factory.Create(EntityManager, null, null, typeId);

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

            var replicatedDataEntity = EntityManager.GetComponentData <ReplicatedEntityData>(entity);

            replicatedDataEntity.Id = id;
            EntityManager.SetComponentData(entity, replicatedDataEntity);

            replicatedEntities.Register(id, entity);

            Profiler.EndSample();
        }
 public void RegisterEntity(int id, Entity entity)
 {
     replicatedEntityCollection.Register(id, entity);
 }