Example #1
0
        public void SpawnConvoyTransport(IMyShipController baseToSpawnAt)
        {
            var factionId       = baseToSpawnAt.OwnerId;
            var spawnerPosition = baseToSpawnAt.GetPosition();
            var gravity         = baseToSpawnAt.GetNaturalGravity();
            var unitType        = baseToSpawnAt.CustomName.Contains("GROUND") ? UnitType.Ground : UnitType.Air;
            var cargoSize       = heatSystem.GenerateCargoShipSize();

            if (unitType == UnitType.Air)
            {
                var positionToSpawn = spawnerPosition + gravity * -5f + baseToSpawnAt.WorldMatrix.Forward * 30;
                var transportPrefab = CalPrefabFactory.GetAirTransport(cargoSize);
                DuckUtils.SpawnInGravity(positionToSpawn, gravity, factionId, transportPrefab.PrefabName,
                                         transportPrefab.InitialBeaconName,
                                         Vector3D.Normalize(baseToSpawnAt.WorldMatrix.Forward));
            }
            else
            {
                var positionToSpawn = spawnerPosition + gravity * -1f + baseToSpawnAt.WorldMatrix.Forward * 35;
                var transportPrefab = CalPrefabFactory.GetGroundTransport(cargoSize);
                DuckUtils.SpawnInGravity(positionToSpawn, gravity, factionId, transportPrefab.PrefabName,
                                         transportPrefab.InitialBeaconName,
                                         Vector3D.Normalize(baseToSpawnAt.WorldMatrix.Forward));
            }
        }
Example #2
0
        private void SpawnEscorts(ICollection <ShipSize> escortsNeededToSpawn, Vector3D gravity,
                                  IList <EscortPosition> allowedPositions, UnitType unitType, IMyCubeGrid convoyLeaderGrid)
        {
            var positionIndex = 0;

            foreach (var escort in escortsNeededToSpawn.Reverse())
            {
                SpawnEscortGrid(CalPrefabFactory.GetEscort(unitType, escort), gravity,
                                allowedPositions[positionIndex], unitType, convoyLeaderGrid);
                positionIndex++;
                escortsNeededToSpawn.Remove(escort);
                if (positionIndex == allowedPositions.Count)
                {
                    break;                     // Can't spawn any more of this type, all positions full
                }
            }
        }
Example #3
0
 public PrefabGrid GetBackupShip()
 {
     return(CalPrefabFactory.GetBackup(heatSystem.GenerateBackupShipSize()));
 }