public static IEnumerable <string> LaunchFailReasons(Building rootBuilding)
        {
            List <Building> shipParts = ArchotechUtility.ShipBuildingsAttachedTo(rootBuilding).ToList <Building>();

            foreach (KeyValuePair <ThingDef, int> partDef in ArchotechUtility.RequiredParts())
            {
                int shipPartCount = shipParts.Count((Building pa) => pa.def == partDef.Key);
                if (shipPartCount < partDef.Value)
                {
                    yield return(string.Format("{0}: {1}x {2} ({3} {4})", new object[]
                    {
                        "ShipReportMissingPart".Translate(),
                        partDef.Value - shipPartCount,
                        partDef.Key.label,
                        "ShipReportMissingPartRequires".Translate(),
                        partDef.Value
                    }));
                }
            }

            foreach (Building part in shipParts)
            {
                CompHibernatable hibernatable = part.TryGetComp <CompHibernatable>();
                if (hibernatable != null && hibernatable.State == HibernatableStateDefOf.Hibernating)
                {
                    yield return(string.Format("{0}: {1}", "ShipReportHibernating".Translate(), part.LabelCap));
                }
                if (hibernatable != null && !hibernatable.Running)
                {
                    yield return(string.Format("{0}: {1}", "ShipReportNotReady".Translate(), part.LabelCap));
                }
            }
        }
 public static IEnumerable <Gizmo> ShipStartupGizmos(Building building)
 {
     if (ArchotechUtility.HasHibernatingParts(building))
     {
         yield return(new Command_Action
         {
             action = delegate
             {
                 DiaNode diaNode = new DiaNode("GR_ArchotechProjectText".Translate());
                 DiaOption diaOption = new DiaOption("Confirm".Translate());
                 diaOption.action = delegate
                 {
                     ArchotechUtility.StartupHibernatingParts(building);
                 };
                 diaOption.resolveTree = true;
                 diaNode.options.Add(diaOption);
                 DiaOption diaOption2 = new DiaOption("GoBack".Translate());
                 diaOption2.resolveTree = true;
                 diaNode.options.Add(diaOption2);
                 Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, null));
             },
             defaultLabel = "GR_CommandArchotechStartup".Translate(),
             defaultDesc = "GR_CommandArchotechStartupDesc".Translate(),
             hotKey = KeyBindingDefOf.Misc1,
             icon = ContentFinder <Texture2D> .Get("ui/commands/GR_Microscope", true)
         });
     }
 }
Example #3
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            foreach (Gizmo c2 in ArchotechUtility.ShipStartupGizmos(this))
            {
                yield return(c2);
            }
            Command_Action launch = new Command_Action();

            launch.action       = new Action(this.TryLaunch);
            launch.defaultLabel = "GR_ArchotechProjectLaunch".Translate();
            launch.defaultDesc  = "GR_ArchotechProjectLaunchDesc".Translate();
            if (!this.CanLaunchNow)
            {
                launch.Disable(ArchotechUtility.LaunchFailReasons(this).First <string>());
            }
            if (ShipCountdown.CountingDown)
            {
                launch.Disable(null);
            }
            launch.hotKey = KeyBindingDefOf.Misc1;
            launch.icon   = ContentFinder <Texture2D> .Get("ui/commands/GR_AwakenArchotech", true);

            yield return(launch);
        }
 public override IEnumerable <Gizmo> GetGizmos()
 {
     foreach (Gizmo c in base.GetGizmos())
     {
         yield return(c);
     }
     foreach (Gizmo c2 in ArchotechUtility.ShipStartupGizmos(this))
     {
         yield return(c2);
     }
 }
        public static void StartupHibernatingParts(Building rootBuilding)
        {
            List <Building> list = ArchotechUtility.ShipBuildingsAttachedTo(rootBuilding).ToList <Building>();

            foreach (Building current in list)
            {
                CompHibernatable compHibernatable = current.TryGetComp <CompHibernatable>();
                if (compHibernatable != null && compHibernatable.State == HibernatableStateDefOf.Hibernating)
                {
                    compHibernatable.Startup();
                }
            }
        }
Example #6
0
        public void ShowReport()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (!ArchotechUtility.LaunchFailReasons((Building)this.parent).Any <string>())
            {
                stringBuilder.AppendLine("GR_ArchotechReportCanLaunch".Translate());
            }
            else
            {
                stringBuilder.AppendLine("GR_ArchotechReportCannotLaunch".Translate());
                foreach (string current in ArchotechUtility.LaunchFailReasons((Building)this.parent))
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine(current);
                }
            }
            Dialog_MessageBox window = new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null);

            Find.WindowStack.Add(window);
        }
Example #7
0
        private static void CountdownEnded()
        {
            List <Building> list           = ArchotechUtility.ShipBuildingsAttachedTo(ArchotechCountdown.shipRoot).ToList <Building>();
            StringBuilder   stringBuilder  = new StringBuilder();
            Pawn            theFutureTamer = null;

            foreach (Pawn current in PawnsFinder.AllMaps_FreeColonistsSpawned)
            {
                stringBuilder.AppendLine("   " + current.LabelCap);
                theFutureTamer = current;
            }

            foreach (Building current in list)
            {
                if (current.def.defName == "GR_ArchotechPlatform")
                {
                    Map     mapToPlaceAt      = current.Map;
                    IntVec3 positionToPlaceAt = current.Position;
                    current.Destroy(DestroyMode.Vanish);
                    Building new_Platform = (Building)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GR_SpentArchotechPlatform", true));
                    new_Platform.SetFaction(Faction.OfPlayer);
                    GenSpawn.Spawn(new_Platform, positionToPlaceAt, mapToPlaceAt);

                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named("GR_ArchotechCentipede"), Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    pawn.training.Train(TrainableDefOf.Obedience, theFutureTamer, true);
                    pawn.training.Train(TrainableDefOf.Release, theFutureTamer, true);


                    PawnUtility.TrySpawnHatchedOrBornPawn(pawn, new_Platform);
                }
            }
            string victoryText = "GR_GameOverArchotech".Translate(stringBuilder.ToString());

            GameVictoryUtility.ShowCredits(victoryText);
        }