Exemple #1
0
        public static List <ShipBase> CreateDropShips(List <Pawn> pawns, Faction faction, List <ThingDef> fixedShipDefs = null)
        {
            List <ShipBase> shipsToDrop = new List <ShipBase>();
            List <ThingDef> defs        = new List <ThingDef>();

            if (fixedShipDefs.NullOrEmpty())
            {
                defs.AddRange(DropShipUtility.AvailableDropShipsForFaction(faction));
            }
            else
            {
                defs.AddRange(fixedShipDefs);
            }
            defs.OrderBy(x => x.GetCompProperties <CompProperties_Ship>().maxPassengers);
            int num = 0;

            while (num < pawns.Count)
            {
                ShipBase newShip = (ShipBase)ThingMaker.MakeThing(defs.RandomElementByWeight(x => x.GetCompProperties <CompProperties_Ship>().maxPassengers));
                newShip.SetFaction(faction);
                newShip.ShouldSpawnFueled = true;
                shipsToDrop.Add(newShip);
                num += newShip.compShip.sProps.maxPassengers;
            }
            DropShipUtility.LoadNewCargoIntoRandomShips(pawns.Cast <Thing>().ToList(), shipsToDrop);
            return(shipsToDrop);
        }