Ejemplo n.º 1
0
        static bool Prefix(CompLongRangeMineralScanner __instance, Pawn worker, ref ThingDef ___targetMineable)
        {
            if (__instance != null)
            {
                if (___targetMineable == null)
                {
                    return(true);
                }
                if (___targetMineable == WTH_DefOf.WTH_MineableMechanoidParts)
                {
                    //    Traverse.Create(__instance).Field("daysWorkingSinceLastMinerals").SetValue(0f);
                    if (!TileFinder.TryFindNewSiteTile(out int tile, MinDistance, MaxDistance, true, false))
                    {
                        return(false);
                    }

                    Slate slate = new Slate();
                    slate.Set <Map>("map", worker.Map, false);
                    slate.Set <ThingDef>("targetMineable", ___targetMineable, false);
                    slate.Set <Pawn>("worker", worker, false);
                    if (!WTH_DefOf.WTH_LongRangeMineralScannerMechParts.CanRun(slate))
                    {
                        return(true);
                    }
                    Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(WTH_DefOf.WTH_LongRangeMineralScannerMechParts, slate);
                    Find.LetterStack.ReceiveLetter(quest.name, quest.description, LetterDefOf.PositiveEvent, null, null, quest, null, null);
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static void AddMechPartsOption(WindowStack instance, FloatMenu menu)
        {
            List <FloatMenuOption> options = Traverse.Create(menu).Field("options").GetValue <List <FloatMenuOption> >();
            //options.Add(new FloatMenuOption());
            bool researchComplete = DefDatabase <ResearchProjectDef> .AllDefs.FirstOrDefault((ResearchProjectDef rp) => rp == WTH_DefOf.WTH_LRMSTuning && rp.IsFinished) != null;

            ThingDef mechanoidParts = WTH_DefOf.WTH_MineableMechanoidParts;

            if (researchComplete)
            {
                FloatMenuOption item = new FloatMenuOption("WTH_MechanoidParts_LabelShort".Translate(), delegate
                {
                    foreach (object selectedObject in Find.Selector.SelectedObjects)
                    {
                        Thing selection = selectedObject as Thing;
                        if (selection != null)
                        {
                            CompLongRangeMineralScanner compLongRangeMineralScanner = selection.TryGetComp <CompLongRangeMineralScanner>();
                            if (compLongRangeMineralScanner != null)
                            {
                                Traverse.Create(compLongRangeMineralScanner).Field("targetMineable").SetValue(mechanoidParts);
                            }
                        }
                    }
                }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2, mechanoidParts.GetConcreteExample()), null);
                options.Add(item);
            }

            Traverse.Create(menu).Field("options").SetValue(options);
            instance.Add(menu);
        }
Ejemplo n.º 3
0
        static bool Prefix(CompLongRangeMineralScanner __instance)
        {
            if (Traverse.Create(__instance).Field("targetMineable").GetValue <ThingDef>() == WTH_DefOf.WTH_MechanoidParts)
            {
                Traverse.Create(__instance).Field("daysWorkingSinceLastMinerals").SetValue(0f);
                if (!TileFinder.TryFindNewSiteTile(out int tile, MinDistance, MaxDistance, true, false))
                {
                    return(false);
                }

                Site site = SiteMaker.MakeSite(WTH_DefOf.WTH_MechanoidTempleCore,
                                               WTH_DefOf.WTH_MechanoidTemplePart,
                                               tile, Faction.OfMechanoids, ifHostileThenMustRemainHostile: true);

                if (site == null)
                {
                    return(false);
                }

                int randomInRange = TimeoutDaysRange.RandomInRange;

                site.Tile = tile;
                site.GetComponent <TimeoutComp>().StartTimeout(ticks: randomInRange * GenDate.TicksPerDay);
                site.SetFaction(Faction.OfMechanoids);

                //site.customLabel = "TODO";
                Find.WorldObjects.Add(o: site);
                Find.LetterStack.ReceiveLetter(label: "WTH_Letter_LRMS_Label".Translate(), text: "WTH_Letter_LRMS_Description".Translate(), textLetterDef: LetterDefOf.PositiveEvent, lookTargets: site);

                return(false);
            }
            return(true);
        }