コード例 #1
0
        private void AssignPlaceholderEntitiesIfRequired(Entity entity, TechType techType, int cellLevel, string classId, DeterministicBatchGenerator deterministicBatchGenerator)
        {
            List <PrefabAsset> prefabs;

            // Check to see if this entity is a PrefabPlaceholderGroup.  If it is,
            // we want to add the children that would be spawned here.  This is
            // surpressed on the client so we don't get virtual entities that the
            // server doesn't know about.
            if (placeholderPrefabsByGroupClassId.TryGetValue(classId, out prefabs))
            {
                foreach (PrefabAsset prefab in prefabs)
                {
                    TransformAsset transform = prefab.TransformAsset;

                    Vector3 position = transform.Position + entity.Position;

                    Entity prefabEntity = new Entity(position,
                                                     transform.Rotation,
                                                     transform.Scale,
                                                     techType,
                                                     cellLevel,
                                                     prefab.ClassId,
                                                     true,
                                                     deterministicBatchGenerator.NextGuid());

                    entity.ChildEntities.Add(prefabEntity);
                }
            }
        }
コード例 #2
0
        private IEnumerable <Entity> CreateEntityWithChildren(EntitySpawnPoint entitySpawnPoint, TechType techType, LargeWorldEntity.CellLevel cellLevel, string classId, DeterministicBatchGenerator deterministicBatchGenerator)
        {
            Entity spawnedEntity = new Entity(entitySpawnPoint.Position,
                                              entitySpawnPoint.Rotation,
                                              entitySpawnPoint.Scale,
                                              techType,
                                              (int)cellLevel,
                                              classId,
                                              true,
                                              deterministicBatchGenerator.NextGuid());

            yield return(spawnedEntity);

            IEntityBootstrapper bootstrapper;

            if (customBootstrappersByTechType.TryGetValue(spawnedEntity.TechType, out bootstrapper))
            {
                bootstrapper.Prepare(spawnedEntity, deterministicBatchGenerator);

                foreach (Entity childEntity in spawnedEntity.ChildEntities)
                {
                    yield return(childEntity);
                }
            }
        }
コード例 #3
0
        private IEnumerable <Entity> CreateEntityWithChildren(EntitySpawnPoint entitySpawnPoint, UnityEngine.Vector3 scale, TechType techType, int cellLevel, string classId, DeterministicBatchGenerator deterministicBatchGenerator)
        {
            Entity spawnedEntity = new Entity(entitySpawnPoint.Position,
                                              entitySpawnPoint.Rotation,
                                              scale,
                                              techType,
                                              cellLevel,
                                              classId,
                                              true,
                                              deterministicBatchGenerator.NextGuid());


            yield return(spawnedEntity);

            AssignPlaceholderEntitiesIfRequired(spawnedEntity, techType, cellLevel, classId, deterministicBatchGenerator);

            IEntityBootstrapper bootstrapper;

            if (customBootstrappersByTechType.TryGetValue(techType, out bootstrapper))
            {
                bootstrapper.Prepare(spawnedEntity, deterministicBatchGenerator);
            }

            // Children are yielded as well so they can be indexed at the top level (for use by simulation
            // ownership and various other consumers).  The parent should always be yielded before the children
            foreach (Entity childEntity in spawnedEntity.ChildEntities)
            {
                yield return(childEntity);
            }
        }