Пример #1
0
        public bool DeleteSelection(CreatureBuilder builder)
        {
            bool creatureChanged = this.selection.Count > 0;

            builder.Delete(this.selection);
            BodyComponent.RemoveDeletedObjects(this.selection);
            return(creatureChanged);
        }
Пример #2
0
        public Creature[] SpawnBatch(SimulationSpawnConfig options)
        {
            var template = new CreatureBuilder(options.Design).Build();

            // SetupCreature(template, physicsScene);
            template.PhysicsScene = options.PhysicsScene;
            template.RemoveMuscleColliders();
            template.SceneContext = options.SceneContext;
            template.Alive        = false;
            template.gameObject.SetActive(true);

            // Determine the spawn position
            // Update safe drop offset
            // Ensures that the creature isn't spawned into the ground
            var lowestY          = template.GetLowestPoint().y;
            var safeHeightOffset = lowestY < 0 ? -lowestY + 1f : 0f;

            // Calculate the drop height
            // float distanceFromGround = template.DistanceFromGround();

            var spawnPosition = template.transform.position;

            if (options.LegacyOptions.LegacyClimbingDropCalculation)
            {
                spawnPosition.y -= template.DistanceFromGround();
                spawnPosition.y += 0.5f;
            }
            else
            {
                spawnPosition.y -= template.SemiSafeDistanceFromGround();
                spawnPosition.y += safeHeightOffset;
                spawnPosition.y += options.SceneDescription.DropHeight;
            }

            var batch = new Creature[options.BatchSize];

            for (int i = 0; i < options.BatchSize; i++)
            {
                var builder  = new CreatureBuilder(options.Design);
                var creature = builder.Build();
                batch[i] = creature;
                creature.transform.position            = spawnPosition;
                creature.SceneContext                  = options.SceneContext;
                creature.usesLegacyRotationCalculation = options.LegacyOptions.LegacyRotationCalculation;
                creature.RefreshLineRenderers();
                creature.PhysicsScene = options.PhysicsScene;
            }

            template.gameObject.SetActive(false);
            Destroy(this.gameObject);
            return(batch);
        }