Ejemplo n.º 1
0
        public void Prepare(Entity parentEntity, DeterministicBatchGenerator deterministicBatchGenerator)
        {
            for (int spawnPointCounter = 0; spawnPointCounter < LocalCreatureSpawnPoints.Count; spawnPointCounter++)
            {
                Vector3 localSpawnPosition   = LocalCreatureSpawnPoints[spawnPointCounter];
                float   targetProbabilitySum = (float)deterministicBatchGenerator.NextDouble() * creatureProbabiltySum;
                float   probabilitySum       = 0;

                foreach (ReefbackEntity creature in SpawnableCreatures)
                {
                    probabilitySum += creature.probability;

                    if (probabilitySum >= targetProbabilitySum)
                    {
                        int totalToSpawn = deterministicBatchGenerator.NextInt(creature.minNumber, creature.maxNumber + 1);

                        for (int i = 0; i < totalToSpawn; i++)
                        {
                            string guid  = deterministicBatchGenerator.NextGuid();
                            Entity child = new Entity(parentEntity.Position + localSpawnPosition, parentEntity.Rotation, parentEntity.Scale, creature.techType.Model(), parentEntity.Level, creature.classId, true, guid);
                            parentEntity.ChildEntities.Add(child);
                        }

                        break;
                    }
                }
            }
        }
        private Entity SpawnChild(Entity parentEntity, DeterministicBatchGenerator deterministicBatchGenerator, TechType techType, string classId)
        {
            string guid = deterministicBatchGenerator.NextGuid();

            return(new Entity(parentEntity.Position, parentEntity.Rotation, new UnityEngine.Vector3(1, 1, 1), techType, parentEntity.Level, classId, true, guid));
        }
Ejemplo n.º 3
0
        private Entity SpawnChild(Entity parentEntity, DeterministicBatchGenerator deterministicBatchGenerator, TechType techType)
        {
            string guid = deterministicBatchGenerator.NextGuid();

            return(new Entity(parentEntity.Position, parentEntity.Rotation, techType, parentEntity.Level, parentEntity.ClassId, true, guid));
        }