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); }
public override void GenerateIntoMap(Map map) { if (Find.TickManager.TicksGame < 1000) { ShipBase newShip = (ShipBase)ThingMaker.MakeThing(this.ShipDef); newShip.SetFaction(Faction.OfPlayer); Thing initialFuel = ThingMaker.MakeThing(ShipNamespaceDefOfs.Chemfuel); newShip.refuelableComp.Refuel(500); this.StartingShips.Add(newShip); DropShipUtility.LoadNewCargoIntoRandomShips(this.PlayerStartingThings().ToList(), this.StartingShips); DropShipUtility.DropShipGroups(map.Center, map, this.StartingShips, ShipArrivalAction.EnterMapFriendly); } }
public static void InitiateGovernorArrestEvent(Map map) { if (CorruptionStoryTrackerUtilities.currentStoryTracker.PlanetaryGovernor == null) { return; } Faction faction = CorruptionStoryTrackerUtilities.currentStoryTracker.ImperialGuard; List <Pawn> arbites = new List <Pawn>(); for (int i = 0; i < 5; i++) { Pawn member = PawnGenerator.GeneratePawn(PawnKindDef.Named("IoM_Arbites"), faction); arbites.Add(member); } OHUShips.ShipBase dropShip = (OHUShips.ShipBase)ThingMaker.MakeThing(ThingDef.Named("AquilaLander")); dropShip.shipState = OHUShips.ShipState.Incoming; dropShip.drawTickOffset = dropShip.compShip.sProps.TicksToImpact; Thing initialFuel = ThingMaker.MakeThing(DefOfs.C_ThingDefOfs.Chemfuel); initialFuel.stackCount = 2000; dropShip.refuelableComp.Refuel(initialFuel); dropShip.SetFaction(arbites[0].Faction); foreach (Pawn current in arbites) { dropShip.GetInnerContainer().TryAdd(current); } List <ShipBase> tmp = new List <ShipBase>(); tmp.Add(dropShip); IntVec3 dropCenter; if (!DropCellFinder.TryFindRaidDropCenterClose(out dropCenter, map)) { dropCenter = DropCellFinder.FindRaidDropCenterDistant(map); } DropShipUtility.DropShipGroups(dropCenter, map, tmp, TravelingShipArrivalAction.EnterMapFriendly); LordMaker.MakeNewLord(dropShip.Faction, new IoM.LordJob_ArrestGovernor(dropShip, dropCenter), map, arbites); }