public override bool Trigger(Building building) { base.Trigger(building); if (building.Faction != Faction.OfPlayer || building.Map is null) { return(false); } List <Building> shipParts = ShipUtility.ShipBuildingsAttachedTo(building).ToList(); bool missingParts = false; using (Dictionary <ThingDef, int> .Enumerator enumerator = ShipUtility.RequiredParts().GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <ThingDef, int> partDef = enumerator.Current; int num = shipParts.Count((Building pa) => pa.def == partDef.Key); if (num < partDef.Value) { //DebugWriter.Log(string.Format("{0}: {1}x {2} ({3} {4})", new object[] //{ // "ShipReportMissingPart".Translate(), // partDef.Value - num, // partDef.Key.label, // "ShipReportMissingPartRequires".Translate(), // partDef.Value //})); missingParts = true; } } } return(!missingParts); }
public static void SaveSurvivors_Main() { List <Pawn> pawnsToSave; var savedPawns = FNotAgain_Mod.Settings.GetHandle <CrashlandingHandle>("savedPawns"); if (__instance.journeyDestinationTile >= 0) { CaravanJourneyDestinationUtility.PlayerCaravansAt(__instance.journeyDestinationTile, __instance.caravans); foreach (List <Pawn> p in __instance.caravans) { pawnsToSave.addRange(p); } } else { List <Building> list = ShipUtility.ShipBuildingsAttachedTo(__instance.shipRoot).ToList <Building>(); foreach (Building current in list) { Building_CryptosleepCasket building_CryptosleepCasket = current as Building_CryptosleepCasket; if (building_CryptosleepCasket != null && building_CryptosleepCasket.HasAnyContents && building_CryptosleepCasket.ContainedThing == typeof(Pawn)) { pawnsToSave.add(building_CryptosleepCasket.ContainedThing); } } } }
public static void FindLaunchFailReasonsReally(Building rootBuilding, ref List <string> __result) { __result = new List <string>(); List <Building> shipParts = ShipUtility.ShipBuildingsAttachedTo(rootBuilding); if (shipParts.Count == 0) { __result.Add("Checking ship. Please wait..."); return; } if (!FindLaunchFailReasons.FindEitherThing(shipParts, (ThingDef)ThingDefOf.Ship_CryptosleepCasket, ThingDef.Named("ShipInside_CryptosleepCasket"))) { __result.Add(Translator.Translate("ShipReportMissingPart") + ": " + (string)((Def)ThingDefOf.Ship_CryptosleepCasket).label); } if (!FindLaunchFailReasons.FindTheThing(shipParts, (ThingDef)ThingDefOf.Ship_ComputerCore)) { __result.Add(Translator.Translate("ShipReportMissingPart") + ": " + (string)((Def)ThingDefOf.Ship_ComputerCore).label); } if (!FindLaunchFailReasons.FindTheThing(shipParts, (ThingDef)ThingDefOf.Ship_Reactor)) { __result.Add(Translator.Translate("ShipReportMissingPart") + ": " + (string)((Def)ThingDefOf.Ship_Reactor).label); } if (!FindLaunchFailReasons.FindTheThing(shipParts, (ThingDef)ThingDefOf.Ship_Engine)) { __result.Add(Translator.Translate("ShipReportMissingPart") + ": " + (string)((Def)ThingDefOf.Ship_Engine).label); } bool flag = false; using (List <Building> .Enumerator enumerator = shipParts.GetEnumerator()) { while (enumerator.MoveNext()) { Building current = enumerator.Current; if (((Thing)current).def == ThingDefOf.Ship_CryptosleepCasket || ((Thing)current).def == ThingDef.Named("ShipInside_CryptosleepCasket")) { Building_CryptosleepCasket cryptosleepCasket = current as Building_CryptosleepCasket; if (cryptosleepCasket != null && ((Building_Casket)cryptosleepCasket).HasAnyContents) { flag = true; break; } } } } if (flag) { return; } __result.Add(Translator.Translate("ShipReportNoFullPods")); }
public override void Resolve(ResolveParams rp) { if (rp.thrustAxis == null) { Log.ErrorOnce("No thrust axis when generating ship parts", 50627817, false); } foreach (KeyValuePair <ThingDef, int> keyValuePair in ShipUtility.RequiredParts()) { for (int i = 0; i < keyValuePair.Value; i++) { Rot4 rotation = Rot4.Random; if (keyValuePair.Key == ThingDefOf.Ship_Engine && rp.thrustAxis != null) { rotation = rp.thrustAxis.Value; } this.AttemptToPlace(keyValuePair.Key, rp.rect, rotation, rp.faction); } } }
public override void Resolve(ResolveParams rp) { if (!rp.thrustAxis.HasValue) { Log.ErrorOnce("No thrust axis when generating ship parts", 50627817); } foreach (KeyValuePair <ThingDef, int> item in ShipUtility.RequiredParts()) { for (int i = 0; i < item.Value; i++) { Rot4 rotation = Rot4.Random; if (item.Key == ThingDefOf.Ship_Engine && rp.thrustAxis.HasValue) { rotation = rp.thrustAxis.Value; } AttemptToPlace(item.Key, rp.rect, rotation, rp.faction); } } }
public static bool CountdownEnded() { Log.Message("CountdownEnded"); bool hard_fail = false; List <String> errors = new List <string>(); if (pht_root != null) { Building shipRoot = (Building)pht_root.GetValue(null); List <Building> list = null; try { list = ShipUtility.ShipBuildingsAttachedTo(shipRoot).ToList <Building>(); if (list.Count == 0) { throw new Exception("LIST_EMPTY"); } } catch (Exception e) { Log.Error(e.Message); errors.Add(e.Message); output_errors(errors, true); GameVictoryUtility.ShowCredits("ERROR"); return(false); } Log.Message("creating ending message"); StringBuilder stringBuilder = new StringBuilder(); foreach (Building building in list) { try { Building_CryptosleepCasket building_CryptosleepCasket = building as Building_CryptosleepCasket; if (building_CryptosleepCasket != null && building_CryptosleepCasket.HasAnyContents) { stringBuilder.AppendLine(" " + building_CryptosleepCasket.ContainedThing.LabelCap); Find.StoryWatcher.statsRecord.colonistsLaunched++; TaleRecorder.RecordTale(TaleDefOf.LaunchedShip, new object[] { building_CryptosleepCasket.ContainedThing }); } } catch (Exception e) { Log.Error("error for a building in the list"); Log.Error(e.Message); errors.Add("error for a building in the list"); errors.Add(e.Message); } } Log.Message("ShowCreditsb"); GameVictoryUtility.ShowCredits(GameVictoryUtility.MakeEndCredits("GameOverShipLaunchedIntro".Translate(), "GameOverShipLaunchedEnding".Translate(), stringBuilder.ToString())); Log.Message("ShowCreditsa"); try { List <Building> listcopy = new List <Building>(list); errors = saveShip(listcopy, errors); } catch (Exception e) { hard_fail = true; Log.Message("error while saving"); errors.Add("error while saving"); errors.Add(e.Message); Log.Error(e.Message); } foreach (Building building in list) { building.Destroy(DestroyMode.Vanish); } output_errors(errors, hard_fail); return(false); } else { Log.Error("pht_root null"); errors.Add("pht_root null"); output_errors(errors, true); GameVictoryUtility.ShowCredits("ERROR"); } GameVictoryUtility.ShowCredits(GameVictoryUtility.MakeEndCredits("GameOverShipLaunchedIntro".Translate(), "GameOverShipLaunchedEnding".Translate(), null, "GameOverColonistsEscaped", null), null, false, 5f); return(false); }