Пример #1
0
        public void DoModeSelMenu()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            string text = "BestMix.DoNothing".Translate();

            list.Add(new FloatMenuOption(text, delegate
            {
                SetBMixMode(null, false);
            },
                                         MenuOptionPriority.Default, null, null, 29f, null));

            foreach (string mode in BestMixUtility.BMixModes())
            {
                text = BestMixUtility.GetBMixModeDisplay(mode);
                list.Add(new FloatMenuOption(text, delegate
                {
                    SetBMixMode(mode, true);
                },
                                             MenuOptionPriority.Default, null, null, 29f, null));
            }
            List <FloatMenuOption> sortedlist = list.OrderBy(bm => bm.Label).ToList();

            Find.WindowStack.Add(new FloatMenu(sortedlist));
        }
Пример #2
0
        public static void DoBillModeSelMenu(CompBestMix CBM, Bill bill)
        {
            var list = new List <FloatMenuOption>();

            string text = "BestMix.DoNothing".Translate();

            list.Add(new FloatMenuOption(text, delegate
            {
                SetBMixBillMode(CBM, bill, "NON", true);
            },
                                         MenuOptionPriority.Default, null, null, 29f, null));

            foreach (var mode in BestMixUtility.BMixModes())
            {
                text = BestMixUtility.GetBMixModeDisplay(mode);
                list.Add(new FloatMenuOption(text, delegate
                {
                    SetBMixBillMode(CBM, bill, mode, true);
                },
                                             MenuOptionPriority.Default, null, null, 29f, null));
            }
            var sortedlist = list.OrderBy(bm => bm.Label).ToList();

            Find.WindowStack.Add(new FloatMenu(sortedlist));
        }
Пример #3
0
 public override string CompInspectStringExtra()
 {
     if (BestMixUtility.IsValidForComp(parent))
     {
         string ModeDisplay = BestMixUtility.GetBMixModeDisplay(CurMode);
         return("BestMix.CurrentMode".Translate(ModeDisplay));
     }
     return(null);
 }
Пример #4
0
        protected override bool RegionProcessor(Region r)
        {
            if (BestMixUtility.BMixRegionIsInRange(r, P_billGiver, P_bill))
            {
                Predicate <Thing> BMixValidator = BestMixUtility.BestMixValidator(P_pawn, P_billGiver, P_bill);

                List <Thing> list = r.ListerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.HaulableEver));
                for (var i = 0; i < list.Count; i++)
                {
                    Thing thing = list[i];
                    if (!BestMixUtility.BMIsForbidden(thing))
                    {
                        if (!ProcessedThings.Contains(thing) && ReachabilityWithinRegion.ThingFromRegionListerReachable(thing, r, PathEndMode.ClosestTouch, P_pawn) &&
                            BMixValidator(thing) && (!thing.def.IsMedicine || (!(P_billGiver is Pawn))))
                        {
                            NewRelevantThings.Add(thing);
                            ProcessedThings.Add(thing);
                        }
                    }
                }
                Lf_regionsProcessed++;
                if (NewRelevantThings.Count > 0 && Lf_regionsProcessed > Lf_adjacentRegionsAvailable)
                {
                    Comparison <Thing> comparison = BestMixUtility.GetBMixComparer(P_billGiver, Lf_rootCell, P_bill, out var rnd);
                    //newRelevantThings.Sort(comparison);
                    RelevantThings.AddRange(NewRelevantThings);
                    if (rnd)
                    {
                        RelevantThings.Shuffle();
                    }
                    else
                    {
                        RelevantThings.Sort(comparison);
                    }
                    BestMixUtility.BMixDebugList(RelevantThings, P_billGiver, Lf_rootCell, P_bill);
                    NewRelevantThings.Clear();

                    if (BestMixUtility.TryFindBestMixInSet(RelevantThings, P_bill, P_chosen, IngredientsOrdered))
                    {
                        Lf_foundAll = true;
                        var finishNow = BestMixUtility.BMixFinishedStatus(Lf_foundAll, P_billGiver, P_bill);
                        if (Lf_foundAll && finishNow)
                        {
                            BestMixUtility.DebugChosenList(P_billGiver, P_chosen);
                            BestMixUtility.DebugFoundAll(P_billGiver, Lf_foundAll);
                            return(true);
                        }
                    }
                }
            }
            BestMixUtility.DebugChosenList(P_billGiver, P_chosen);
            BestMixUtility.DebugFoundAll(P_billGiver, Lf_foundAll);
            return(false);
        }
Пример #5
0
        public static Texture2D GetBillBMTex(Thing billGiver, Bill bill)
        {
            string mode    = GetBillBMMode(billGiver, bill);
            string TexPath = "UI/BestMix/NONIcon";

            if (mode != "NON")
            {
                TexPath = BestMixUtility.GetBMixIconPath(mode);
            }
            TexPath += "Bill";

            //Log.Message("TexPath: " + TexPath);

            Texture2D tex = ContentFinder <Texture2D> .Get(TexPath, false);

            return(tex);
        }
Пример #6
0
        protected override bool RegionProcessor(Region r)
        {
            if (BestMixUtility.BMixRegionIsInRange(r, p_billGiver, p_bill))
            {
                Predicate <Thing> BMixValidator = BestMixUtility.BestMixValidator(p_pawn, p_billGiver, p_bill);

                List <Thing> list = r.ListerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.HaulableEver));
                for (int i = 0; i < list.Count; i++)
                {
                    Thing thing = list[i];
                    if (!processedThings.Contains(thing) && ReachabilityWithinRegion.ThingFromRegionListerReachable(thing, r, PathEndMode.ClosestTouch, p_pawn) &&
                        BMixValidator(thing) && (!thing.def.IsMedicine || (!(p_billGiver is Pawn))))
                    {
                        newRelevantThings.Add(thing);
                        processedThings.Add(thing);
                    }
                }
                lf_regionsProcessed++;
                if (newRelevantThings.Count > 0 && lf_regionsProcessed > lf_adjacentRegionsAvailable)
                {
                    Comparison <Thing> comparison = BestMixUtility.GetBMixComparer(p_billGiver, lf_rootCell);
                    //newRelevantThings.Sort(comparison);
                    relevantThings.AddRange(newRelevantThings);
                    relevantThings.Sort(comparison);
                    BestMixUtility.BMixDebugList(relevantThings, p_billGiver, lf_rootCell);
                    newRelevantThings.Clear();

                    if (BestMixUtility.TryFindBestMixInSet(relevantThings, p_bill, p_chosen, ingredientsOrdered))
                    {
                        lf_foundAll = true;
                        bool finishNow = BestMixUtility.BMixFinishedStatus(lf_foundAll, p_billGiver);
                        if ((lf_foundAll) && (finishNow))
                        {
                            BestMixUtility.DebugChosenList(p_billGiver, p_chosen);
                            BestMixUtility.DebugFoundAll(p_billGiver, lf_foundAll);
                            return(true);
                        }
                    }
                }
            }
            BestMixUtility.DebugChosenList(p_billGiver, p_chosen);
            BestMixUtility.DebugFoundAll(p_billGiver, lf_foundAll);
            return(false);
        }
Пример #7
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            foreach (Gizmo item in base.CompGetGizmosExtra())
            {
                yield return(item);
            }
            if (BestMixUtility.IsValidForComp(parent))
            {
                if (parent.Spawned && parent.Faction == Faction.OfPlayer)
                {
                    string BMixIconPath = BestMixUtility.GetBMixIconPath(CurMode);
                    yield return(new Command_Action
                    {
                        action = delegate
                        {
                            SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                            DoModeSelMenu();
                        },
                        hotKey = KeyBindingDefOf.Misc1,
                        defaultLabel = "BestMix.SelectModeLabel".Translate(),
                        defaultDesc = "BestMix.SelectModeDesc".Translate(),
                        icon = ContentFinder <Texture2D> .Get(BMixIconPath)
                    });

                    if ((Prefs.DevMode) && (Controller.Settings.DebugMaster))
                    {
                        string DebugIconPath = "UI/BestMix/DebugList";
                        yield return(new Command_Toggle
                        {
                            icon = ContentFinder <Texture2D> .Get(DebugIconPath),
                            defaultLabel = "BestMix.DebugLabel".Translate(),
                            defaultDesc = "BestMix.DebugDesc".Translate(),
                            isActive = (() => (BMixDebug == true)),
                            toggleAction = delegate
                            {
                                ToggleDebug(BMixDebug);
                            }
                        });
                    }
                }
            }
            yield break;
        }