public static void SpawnTraderShip() { List <DebugMenuOption> list = new List <DebugMenuOption>(); list.Add(new DebugMenuOption("Incoming", DebugMenuOptionMode.Tool, delegate() { Thing thing = ThingMaker.MakeThing(Globals.TraderShipsShip, null); CompShip comp = thing.TryGetComp <CompShip>(); comp.GenerateInternalTradeShip(Find.CurrentMap); GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(comp.Props.landAnimation, thing), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4)); })); list.Add(new DebugMenuOption("Stationary", DebugMenuOptionMode.Tool, delegate() { Thing thing = ThingMaker.MakeThing(Globals.TraderShipsShip, null); thing.TryGetComp <CompShip>().GenerateInternalTradeShip(Find.CurrentMap); GenPlace.TryPlaceThing(thing, UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4)); })); list.Add(new DebugMenuOption("Crash", DebugMenuOptionMode.Tool, delegate() { Thing ship = ThingMaker.MakeThing(Globals.TraderShipsShip, null); CompShip comp = ship.TryGetComp <CompShip>(); comp.GenerateInternalTradeShip(Find.CurrentMap); comp.mustCrash = true; GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Globals.TraderShipsShipCrashing, ship), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near); })); List <DebugMenuOption> options = list; Find.WindowStack.Add(new Dialog_DebugOptionListLister(options)); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; Thing ship = ThingMaker.MakeThing(Globals.TraderShipsShip, null); IntVec3 spot = RandomSpot(map); CompShip comp = ship.TryGetComp <CompShip>(); comp.GenerateInternalTradeShip(map); comp.mustCrash = true; GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Globals.TraderShipsShipCrashing, ship), spot, map, ThingPlaceMode.Near); return(true); }
public static Thing MakeTraderShip(Map map) { Thing ship = ThingMaker.MakeThing(Globals.TraderShipsShip, null); TraderKindDef traderKindDef = (from x in DefDatabase <TraderKindDef> .AllDefs where CanSpawn(map, x) select x).RandomElementByWeightWithFallback((TraderKindDef traderDef) => traderDef.CalculatedCommonality); if (traderKindDef == null) { throw new InvalidOperationException(); } CompShip comp = ship.TryGetComp <CompShip>(); comp.GenerateInternalTradeShip(map, traderKindDef); return(ship); }