コード例 #1
0
        private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 c = IntVec3.FromVector3(clickPos);

            foreach (Thing thing2 in c.GetThingList(pawn.Map))
            {
                Thing t = thing2;
                if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow)
                {
                    string text = (!t.def.ingestible.ingestCommandString.NullOrEmpty()) ? string.Format(t.def.ingestible.ingestCommandString, t.LabelShort) : "ConsumeThing".Translate(t.LabelShort);
                    if (!t.IsSociallyProper(pawn))
                    {
                        text = text + " (" + "ReservedForPrisoners".Translate() + ")";
                    }
                    FloatMenuOption item3;
                    if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler())
                    {
                        item3 = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item3 = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else
                    {
                        MenuOptionPriority priority = (MenuOptionPriority)((!(t is Corpse)) ? 4 : 2);
                        item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate
                        {
                            t.SetForbidden(false, true);
                            Job job13   = new Job(JobDefOf.Ingest, t);
                            job13.count = FoodUtility.WillIngestStackCountOf(pawn, t.def);
                            pawn.jobs.TryTakeOrderedJob(job13, JobTag.Misc);
                        }, priority, null, null, 0f, null, null), pawn, t, "ReservedBy");
                    }
                    opts.Add(item3);
                }
            }
            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (LocalTargetInfo item7 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    Pawn victim = (Pawn)item7.Thing;
                    if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true))
                    {
                        if (!victim.IsPrisonerOfColony && !victim.InMentalState && (victim.Faction == Faction.OfPlayer || victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer)))
                        {
                            string label  = "Rescue".Translate(victim.LabelCap);
                            Action action = delegate
                            {
                                Building_Bed building_Bed2 = RestUtility.FindBedFor(victim, pawn, false, false, false);
                                if (building_Bed2 == null)
                                {
                                    building_Bed2 = RestUtility.FindBedFor(victim, pawn, false, false, true);
                                }
                                if (building_Bed2 == null)
                                {
                                    string str2 = (!victim.RaceProps.Animal) ? "NoNonPrisonerBed".Translate() : "NoAnimalBed".Translate();
                                    Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageTypeDefOf.RejectInput);
                                }
                                else
                                {
                                    Job job12 = new Job(JobDefOf.Rescue, victim, building_Bed2);
                                    job12.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job12, JobTag.Misc);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total);
                                }
                            };
                            MenuOptionPriority priority2 = MenuOptionPriority.RescueOrCapture;
                            Pawn revalidateClickTarget   = victim;
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy"));
                        }
                        if (!victim.NonHumanlikeOrWildMan() && (victim.InMentalState || victim.Faction != Faction.OfPlayer || (victim.Downed && (victim.guilt.IsGuilty || victim.IsPrisonerOfColony))))
                        {
                            string label  = "Capture".Translate(victim.LabelCap);
                            Action action = delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, true);
                                }
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageTypeDefOf.RejectInput);
                                }
                                else
                                {
                                    Job job11 = new Job(JobDefOf.Capture, victim, building_Bed);
                                    job11.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job11, JobTag.Misc);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total);
                                }
                            };
                            MenuOptionPriority priority2 = MenuOptionPriority.RescueOrCapture;
                            Pawn revalidateClickTarget   = victim;
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy"));
                        }
                    }
                }
                foreach (LocalTargetInfo item8 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    LocalTargetInfo localTargetInfo = item8;
                    Pawn            victim2         = (Pawn)localTargetInfo.Thing;
                    if (victim2.Downed && pawn.CanReserveAndReach(victim2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, true) != null)
                    {
                        string text2   = "CarryToCryptosleepCasket".Translate(localTargetInfo.Thing.LabelCap);
                        JobDef jDef    = JobDefOf.CarryToCryptosleepCasket;
                        Action action2 = delegate
                        {
                            Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, false);
                            if (building_CryptosleepCasket == null)
                            {
                                building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, true);
                            }
                            if (building_CryptosleepCasket == null)
                            {
                                Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim2, MessageTypeDefOf.RejectInput);
                            }
                            else
                            {
                                Job job10 = new Job(jDef, victim2, building_CryptosleepCasket);
                                job10.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job10, JobTag.Misc);
                            }
                        };
                        string label  = text2;
                        Action action = action2;
                        Pawn   revalidateClickTarget = victim2;
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.Default, null, revalidateClickTarget, 0f, null, null), pawn, victim2, "ReservedBy"));
                    }
                }
            }
            foreach (LocalTargetInfo item9 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true))
            {
                LocalTargetInfo stripTarg = item9;
                FloatMenuOption item4     = pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Strip".Translate(stripTarg.Thing.LabelCap), delegate
                {
                    stripTarg.Thing.SetForbidden(false, false);
                    pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Strip, stripTarg), JobTag.Misc);
                }, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, stripTarg, "ReservedBy") : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                opts.Add(item4);
            }
            if (pawn.equipment != null)
            {
                ThingWithComps equipment = null;
                List <Thing>   thingList = c.GetThingList(pawn.Map);
                int            num       = 0;
                while (num < thingList.Count)
                {
                    if (thingList[num].TryGetComp <CompEquippable>() == null)
                    {
                        num++;
                        continue;
                    }
                    equipment = (ThingWithComps)thingList[num];
                    break;
                }
                if (equipment != null)
                {
                    string          labelShort = equipment.LabelShort;
                    FloatMenuOption item5;
                    if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                    {
                        item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                    {
                        item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    }
                    else
                    {
                        string text3 = "Equip".Translate(labelShort);
                        if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                        {
                            text3 = text3 + " " + "EquipWarningBrawler".Translate();
                        }
                        item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate
                        {
                            equipment.SetForbidden(false, true);
                            pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Equip, equipment), JobTag.Misc);
                            MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f);
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy");
                    }
                    opts.Add(item5);
                }
            }
            if (pawn.apparel != null)
            {
                Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(c);
                if (apparel != null)
                {
                    FloatMenuOption item6 = pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) ? (ApparelUtility.HasPartsToWear(pawn, apparel.def) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("ForceWear".Translate(apparel.LabelShort), delegate
                    {
                        apparel.SetForbidden(false, true);
                        Job job9 = new Job(JobDefOf.Wear, apparel);
                        pawn.jobs.TryTakeOrderedJob(job9, JobTag.Misc);
                    }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, apparel, "ReservedBy") : new FloatMenuOption("CannotWear".Translate(apparel.Label) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)) : new FloatMenuOption("CannotWear".Translate(apparel.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                    opts.Add(item6);
                }
            }
            if (!pawn.Map.IsPlayerHome)
            {
                Thing item = c.GetFirstItem(pawn.Map);
                if (item != null && item.def.EverHaulable)
                {
                    if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, 1))
                    {
                        opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else if (item.stackCount == 1)
                    {
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item.Label), delegate
                        {
                            item.SetForbidden(false, false);
                            Job job8   = new Job(JobDefOf.TakeInventory, item);
                            job8.count = 1;
                            pawn.jobs.TryTakeOrderedJob(job8, JobTag.Misc);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                    }
                    else
                    {
                        if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, item.stackCount))
                        {
                            opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item.Label), delegate
                            {
                                item.SetForbidden(false, false);
                                Job job7   = new Job(JobDefOf.TakeInventory, item);
                                job7.count = item.stackCount;
                                pawn.jobs.TryTakeOrderedJob(job7, JobTag.Misc);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                        }
                        opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item.Label), delegate
                        {
                            int to2 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item), item.stackCount);
                            Dialog_Slider window2 = new Dialog_Slider("PickUpCount".Translate(item.LabelShort), 1, to2, delegate(int count)
                            {
                                item.SetForbidden(false, false);
                                Job job6   = new Job(JobDefOf.TakeInventory, item);
                                job6.count = count;
                                pawn.jobs.TryTakeOrderedJob(job6, JobTag.Misc);
                            }, -2147483648);
                            Find.WindowStack.Add(window2);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                    }
                }
            }
            if (!pawn.Map.IsPlayerHome)
            {
                Thing item2 = c.GetFirstItem(pawn.Map);
                if (item2 != null && item2.def.EverHaulable)
                {
                    Pawn bestPackAnimal = GiveToPackAnimalUtility.PackAnimalWithTheMostFreeSpace(pawn.Map, pawn.Faction);
                    if (bestPackAnimal != null)
                    {
                        if (!pawn.CanReach(item2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item2.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item2, 1))
                        {
                            opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item2.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else if (item2.stackCount == 1)
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimal".Translate(item2.Label), delegate
                            {
                                item2.SetForbidden(false, false);
                                Job job5   = new Job(JobDefOf.GiveToPackAnimal, item2);
                                job5.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job5, JobTag.Misc);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy"));
                        }
                        else
                        {
                            if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item2, item2.stackCount))
                            {
                                opts.Add(new FloatMenuOption("CannotGiveToPackAnimalAll".Translate(item2.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                            }
                            else
                            {
                                opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalAll".Translate(item2.Label), delegate
                                {
                                    item2.SetForbidden(false, false);
                                    Job job4   = new Job(JobDefOf.GiveToPackAnimal, item2);
                                    job4.count = item2.stackCount;
                                    pawn.jobs.TryTakeOrderedJob(job4, JobTag.Misc);
                                }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy"));
                            }
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalSome".Translate(item2.Label), delegate
                            {
                                int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item2), item2.stackCount);
                                Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(item2.LabelShort), 1, to, delegate(int count)
                                {
                                    item2.SetForbidden(false, false);
                                    Job job3   = new Job(JobDefOf.GiveToPackAnimal, item2);
                                    job3.count = count;
                                    pawn.jobs.TryTakeOrderedJob(job3, JobTag.Misc);
                                }, -2147483648);
                                Find.WindowStack.Add(window);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy"));
                        }
                    }
                }
            }
            if (!pawn.Map.IsPlayerHome && pawn.Map.exitMapGrid.MapUsesExitGrid)
            {
                foreach (LocalTargetInfo item10 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    Pawn p = (Pawn)item10.Thing;
                    if (p.Faction == Faction.OfPlayer || p.HostFaction == Faction.OfPlayer)
                    {
                        IntVec3 exitSpot;
                        if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot, TraverseMode.ByPawn))
                        {
                            opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("CarryToExit".Translate(p.Label), delegate
                            {
                                Job job2   = new Job(JobDefOf.CarryDownedPawnToExit, p, exitSpot);
                                job2.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job2, JobTag.Misc);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item10, "ReservedBy"));
                        }
                    }
                }
            }
            if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any())
            {
                Action action3 = delegate
                {
                    pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, pawn.equipment.Primary), JobTag.Misc);
                };
                opts.Add(new FloatMenuOption("Drop".Translate(pawn.equipment.Primary.Label), action3, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            foreach (LocalTargetInfo item11 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true))
            {
                LocalTargetInfo dest = item11;
                if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                {
                    opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
                {
                    opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else
                {
                    Pawn   pTarg   = (Pawn)dest.Thing;
                    Action action4 = delegate
                    {
                        Job job = new Job(JobDefOf.TradeWithPawn, pTarg);
                        job.playerForced = true;
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total);
                    };
                    string str = string.Empty;
                    if (pTarg.Faction != null)
                    {
                        str = " (" + pTarg.Faction.Name + ")";
                    }
                    string             label     = "TradeWith".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + str;
                    Action             action    = action4;
                    MenuOptionPriority priority2 = MenuOptionPriority.InitiateSocial;
                    Thing thing = dest.Thing;
                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy"));
                }
            }
            foreach (Thing item12 in pawn.Map.thingGrid.ThingsAt(c))
            {
                foreach (FloatMenuOption floatMenuOption in item12.GetFloatMenuOptions(pawn))
                {
                    opts.Add(floatMenuOption);
                }
            }
        }
コード例 #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            this.ResolveRaidPoints(parms);
            bool result;

            if (!this.TryResolveRaidFaction(parms))
            {
                result = false;
            }
            else
            {
                PawnGroupKindDef combat = PawnGroupKindDefOf.Combat;
                this.ResolveRaidStrategy(parms, combat);
                this.ResolveRaidArriveMode(parms);
                if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms))
                {
                    result = false;
                }
                else
                {
                    parms.points *= parms.raidArrivalMode.pointsFactor;
                    parms.points *= parms.raidStrategy.pointsFactor;
                    parms.points  = Mathf.Max(parms.points, parms.raidStrategy.Worker.MinimumPoints(parms.faction, combat) * 1.05f);
                    PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms, false);
                    List <Pawn>         list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>();
                    if (list.Count == 0)
                    {
                        Log.Error("Got no pawns spawning raid from parms " + parms, false);
                        result = false;
                    }
                    else
                    {
                        parms.raidArrivalMode.Worker.Arrive(list, parms);
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.AppendLine("Points = " + parms.points.ToString("F0"));
                        foreach (Pawn pawn in list)
                        {
                            string str = (pawn.equipment == null || pawn.equipment.Primary == null) ? "unarmed" : pawn.equipment.Primary.LabelCap;
                            stringBuilder.AppendLine(pawn.KindLabel + " - " + str);
                        }
                        string letterLabel = this.GetLetterLabel(parms);
                        string letterText  = this.GetLetterText(parms, list);
                        PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, this.GetRelatedPawnsInfoLetterText(parms), true, true);
                        List <TargetInfo> list2 = new List <TargetInfo>();
                        if (parms.pawnGroups != null)
                        {
                            List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups);
                            List <Pawn>         list4 = list3.MaxBy((List <Pawn> x) => x.Count);
                            if (list4.Any <Pawn>())
                            {
                                list2.Add(list4[0]);
                            }
                            for (int i = 0; i < list3.Count; i++)
                            {
                                if (list3[i] != list4)
                                {
                                    if (list3[i].Any <Pawn>())
                                    {
                                        list2.Add(list3[i][0]);
                                    }
                                }
                            }
                        }
                        else if (list.Any <Pawn>())
                        {
                            list2.Add(list[0]);
                        }
                        Find.LetterStack.ReceiveLetter(letterLabel, letterText, this.GetLetterDef(), list2, parms.faction, stringBuilder.ToString());
                        if (this.GetLetterDef() == LetterDefOf.ThreatBig)
                        {
                            TaleRecorder.RecordTale(TaleDefOf.RaidArrived, new object[0]);
                        }
                        parms.raidStrategy.Worker.MakeLords(parms, list);
                        AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction, map);
                        LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical);
                        if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts))
                        {
                            for (int j = 0; j < list.Count; j++)
                            {
                                Pawn pawn2 = list[j];
                                if (pawn2.apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt))
                                {
                                    LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical);
                                    break;
                                }
                            }
                        }
                        result = true;
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        public static void DoTimeControlsGUI(Rect timerRect)
        {
            TickManager tickManager = Find.TickManager;

            GUI.BeginGroup(timerRect);
            Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);

            for (int i = 0; i < TimeControls.CachedTimeSpeedValues.Length; i++)
            {
                TimeSpeed timeSpeed = TimeControls.CachedTimeSpeedValues[i];
                if (timeSpeed != TimeSpeed.Ultrafast)
                {
                    if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(int)timeSpeed]))
                    {
                        if (timeSpeed == TimeSpeed.Paused)
                        {
                            tickManager.TogglePaused();
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                        }
                        else
                        {
                            tickManager.CurTimeSpeed = timeSpeed;
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                        }
                        TimeControls.PlaySoundOf(tickManager.CurTimeSpeed);
                    }
                    if (tickManager.CurTimeSpeed == timeSpeed)
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }
                    rect.x += rect.width;
                }
            }
            if (Find.TickManager.slower.ForcedNormalSpeed)
            {
                Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f);
            }
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(timerRect);
            UIHighlighter.HighlightOpportunity(timerRect, "TimeControls");
            if (Event.current.type == EventType.KeyDown)
            {
                if (KeyBindingDefOf.TogglePause.KeyDownEvent)
                {
                    Find.TickManager.TogglePaused();
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (KeyBindingDefOf.TimeSpeedNormal.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (KeyBindingDefOf.TimeSpeedFast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Fast;
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (KeyBindingDefOf.TimeSpeedSuperfast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast;
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (Prefs.DevMode)
                {
                    if (KeyBindingDefOf.TimeSpeedUltrafast.KeyDownEvent)
                    {
                        Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast;
                        TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                        Event.current.Use();
                    }
                    if (KeyBindingDefOf.TickOnce.KeyDownEvent && tickManager.CurTimeSpeed == TimeSpeed.Paused)
                    {
                        tickManager.DoSingleTick();
                        SoundDef.Named(TimeControls.SpeedSounds[0]).PlayOneShotOnCamera(null);
                    }
                }
            }
        }
コード例 #4
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.compPower = base.GetComp <CompPowerTrader>();
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.GrowingFood, KnowledgeAmount.Total);
 }
コード例 #5
0
 public static void LessonAutoActivatorUpdate()
 {
     if (!TutorSystem.AdaptiveTrainingEnabled || Current.Game == null || Find.Tutor.learningReadout.ShowAllMode)
     {
         return;
     }
     LessonAutoActivator.timeSinceLastLesson += RealTime.realDeltaTime;
     if (Current.ProgramState == ProgramState.Playing && (Time.timeSinceLevelLoad < 8f || Find.WindowStack.SecondsSinceClosedGameStartDialog < 8f || Find.TickManager.NotPlaying))
     {
         return;
     }
     for (int i = LessonAutoActivator.alertingConcepts.Count - 1; i >= 0; i--)
     {
         if (PlayerKnowledgeDatabase.IsComplete(LessonAutoActivator.alertingConcepts[i]))
         {
             LessonAutoActivator.alertingConcepts.RemoveAt(i);
         }
     }
     if (Time.frameCount % 15 == 0 && Find.ActiveLesson.Current == null)
     {
         for (int j = 0; j < DefDatabase <ConceptDef> .AllDefsListForReading.Count; j++)
         {
             ConceptDef conceptDef = DefDatabase <ConceptDef> .AllDefsListForReading[j];
             if (!PlayerKnowledgeDatabase.IsComplete(conceptDef))
             {
                 float num = PlayerKnowledgeDatabase.GetKnowledge(conceptDef);
                 num -= 0.00015f * Time.deltaTime * 15f;
                 if (num < 0f)
                 {
                     num = 0f;
                 }
                 PlayerKnowledgeDatabase.SetKnowledge(conceptDef, num);
                 if (conceptDef.opportunityDecays)
                 {
                     float num2 = LessonAutoActivator.GetOpportunity(conceptDef);
                     num2 -= 0.4f * Time.deltaTime * 15f;
                     if (num2 < 0f)
                     {
                         num2 = 0f;
                     }
                     LessonAutoActivator.opportunities[conceptDef] = num2;
                 }
             }
         }
         if (Find.Tutor.learningReadout.ActiveConceptsCount < 3)
         {
             ConceptDef conceptDef2 = LessonAutoActivator.MostDesiredConcept();
             if (conceptDef2 != null)
             {
                 float desire = LessonAutoActivator.GetDesire(conceptDef2);
                 if (desire > 0.1f && LessonAutoActivator.RelaxDesire < desire)
                 {
                     LessonAutoActivator.TryInitiateLesson(conceptDef2);
                 }
             }
         }
         else
         {
             LessonAutoActivator.SetLastLessonTimeToNow();
         }
     }
 }
コード例 #6
0
 protected override void FinalizeDesignationSucceeded()
 {
     base.FinalizeDesignationSucceeded();
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HomeArea, KnowledgeAmount.Total);
 }
コード例 #7
0
ファイル: HealthCardUtility.cs プロジェクト: potsh/RimWorld
        private static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMedBills, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part).CapitalizeFirst();

            if (part != null && !recipe.hideBodyPartNames)
            {
                text = text + " (" + part.Label + ")";
            }
            FloatMenuOption floatMenuOption;

            if (missingIngredients.Any())
            {
                text += " (";
                bool flag = true;
                foreach (ThingDef missingIngredient in missingIngredients)
                {
                    if (!flag)
                    {
                        text += ", ";
                    }
                    flag  = false;
                    text += "MissingMedicalBillIngredient".Translate(missingIngredient.label);
                }
                text           += ")";
                floatMenuOption = new FloatMenuOption(text, null);
            }
            else
            {
                Action action = delegate
                {
                    Pawn pawn2 = thingForMedBills as Pawn;
                    if (pawn2 != null)
                    {
                        Bill_Medical bill_Medical = new Bill_Medical(recipe);
                        pawn2.BillStack.AddBill(bill_Medical);
                        bill_Medical.Part = part;
                        if (recipe.conceptLearned != null)
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                        }
                        Map map = thingForMedBills.Map;
                        if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }
                        if (!pawn2.InBed() && pawn2.RaceProps.IsFlesh)
                        {
                            if (pawn2.RaceProps.Humanlike)
                            {
                                if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def) && ((Building_Bed)x).Medical))
                                {
                                    Messages.Message("MessageNoMedicalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput, historical: false);
                                }
                            }
                            else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def)))
                            {
                                Messages.Message("MessageNoAnimalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput, historical: false);
                            }
                        }
                        if (pawn2.Faction != null && !pawn2.Faction.def.hidden && !pawn2.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(pawn2, part, Faction.OfPlayer))
                        {
                            Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(pawn2.Faction), pawn2, MessageTypeDefOf.CautionInput, historical: false);
                        }
                        ThingDef minRequiredMedicine = GetMinRequiredMedicine(recipe);
                        if (minRequiredMedicine != null && pawn2.playerSettings != null && !pawn2.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
                        {
                            Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, pawn2.LabelShort, pawn2.playerSettings.medCare.GetLabel(), pawn2.Named("PAWN")), pawn2, MessageTypeDefOf.CautionInput, historical: false);
                        }
                    }
                };
                floatMenuOption = new FloatMenuOption(text, action);
            }
            floatMenuOption.extraPartWidth = 29f;
            floatMenuOption.extraPartOnGUI = ((Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe));
            return(floatMenuOption);
        }
コード例 #8
0
        public static void DrawWorkBoxFor(float x, float y, Pawn p, WorkTypeDef wType, bool incapableBecauseOfCapacities)
        {
            if (p.story == null || p.story.WorkTypeIsDisabled(wType))
            {
                return;
            }
            Rect rect = new Rect(x, y, 25f, 25f);

            if (incapableBecauseOfCapacities)
            {
                GUI.color = new Color(1f, 0.3f, 0.3f);
            }
            WidgetsWork.DrawWorkBoxBackground(rect, p, wType);
            GUI.color = Color.white;
            if (Find.PlaySettings.useWorkPriorities)
            {
                int priority = p.workSettings.GetPriority(wType);
                if (priority > 0)
                {
                    Text.Anchor = TextAnchor.MiddleCenter;
                    GUI.color   = WidgetsWork.ColorOfPriority(priority);
                    Rect rect2 = rect.ContractedBy(-3f);
                    Widgets.Label(rect2, priority.ToStringCached());
                    GUI.color   = Color.white;
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect))
                {
                    bool flag = p.workSettings.WorkIsActive(wType);
                    if (Event.current.button == 0)
                    {
                        int num = p.workSettings.GetPriority(wType) - 1;
                        if (num < 0)
                        {
                            num = 4;
                        }
                        p.workSettings.SetPriority(wType, num);
                        SoundDefOf.AmountIncrement.PlayOneShotOnCamera(null);
                    }
                    if (Event.current.button == 1)
                    {
                        int num2 = p.workSettings.GetPriority(wType) + 1;
                        if (num2 > 4)
                        {
                            num2 = 0;
                        }
                        p.workSettings.SetPriority(wType, num2);
                        SoundDefOf.AmountDecrement.PlayOneShotOnCamera(null);
                    }
                    if (!flag && p.workSettings.WorkIsActive(wType) && wType.relevantSkills.Any <SkillDef>() && p.skills.AverageOfRelevantSkillsFor(wType) <= 2f)
                    {
                        SoundDefOf.Crunch.PlayOneShotOnCamera(null);
                    }
                    Event.current.Use();
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorkTab, KnowledgeAmount.SpecificInteraction);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ManualWorkPriorities, KnowledgeAmount.SmallInteraction);
                }
            }
            else
            {
                int priority2 = p.workSettings.GetPriority(wType);
                if (priority2 > 0)
                {
                    GUI.DrawTexture(rect, WidgetsWork.WorkBoxCheckTex);
                }
                if (Widgets.ButtonInvisible(rect, false))
                {
                    if (p.workSettings.GetPriority(wType) > 0)
                    {
                        p.workSettings.SetPriority(wType, 0);
                        SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                    }
                    else
                    {
                        p.workSettings.SetPriority(wType, 3);
                        SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                        if (wType.relevantSkills.Any <SkillDef>() && p.skills.AverageOfRelevantSkillsFor(wType) <= 2f)
                        {
                            SoundDefOf.Crunch.PlayOneShotOnCamera(null);
                        }
                    }
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorkTab, KnowledgeAmount.SpecificInteraction);
                }
            }
        }
コード例 #9
0
        public override void DoWindowContents(Rect inRect)
        {
            Rect rect = inRect.AtZero();

            rect.yMax -= 45f;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = (rect.width - 34f) / 3f;
            listing_Standard.Begin(rect);
            Text.Font = GameFont.Medium;
            listing_Standard.Label("Audiovisuals".Translate(), -1f);
            Text.Font = GameFont.Small;
            listing_Standard.Gap(12f);
            listing_Standard.Gap(12f);
            listing_Standard.Label("GameVolume".Translate(), -1f);
            Prefs.VolumeGame = listing_Standard.Slider(Prefs.VolumeGame, 0f, 1f);
            listing_Standard.Label("MusicVolume".Translate(), -1f);
            Prefs.VolumeMusic = listing_Standard.Slider(Prefs.VolumeMusic, 0f, 1f);
            listing_Standard.Label("AmbientVolume".Translate(), -1f);
            Prefs.VolumeAmbient = listing_Standard.Slider(Prefs.VolumeAmbient, 0f, 1f);
            if (listing_Standard.ButtonTextLabeled("Resolution".Translate(), Dialog_Options.ResToString(Screen.width, Screen.height)))
            {
                Find.WindowStack.Add(new Dialog_ResolutionPicker());
            }
            bool customCursorEnabled = Prefs.CustomCursorEnabled;

            listing_Standard.CheckboxLabeled("CustomCursor".Translate(), ref customCursorEnabled, null);
            Prefs.CustomCursorEnabled = customCursorEnabled;
            bool fullScreen = Screen.fullScreen;
            bool flag       = fullScreen;

            listing_Standard.CheckboxLabeled("Fullscreen".Translate(), ref fullScreen, null);
            if (fullScreen != flag)
            {
                ResolutionUtility.SafeSetFullscreen(fullScreen);
            }
            listing_Standard.Label("UIScale".Translate(), -1f);
            float[] uIScales = Dialog_Options.UIScales;
            for (int i = 0; i < uIScales.Length; i++)
            {
                float num = uIScales[i];
                if (listing_Standard.RadioButton(num.ToString() + "x", Prefs.UIScale == num, 8f))
                {
                    if (!ResolutionUtility.UIScaleSafeWithResolution(num, Screen.width, Screen.height))
                    {
                        Messages.Message("MessageScreenResTooSmallForUIScale".Translate(), MessageTypeDefOf.RejectInput);
                    }
                    else
                    {
                        ResolutionUtility.SafeSetUIScale(num);
                    }
                }
            }
            listing_Standard.Gap(12f);
            bool hatsOnlyOnMap = Prefs.HatsOnlyOnMap;

            listing_Standard.CheckboxLabeled("HatsShownOnlyOnMap".Translate(), ref hatsOnlyOnMap, null);
            if (hatsOnlyOnMap != Prefs.HatsOnlyOnMap)
            {
                PortraitsCache.Clear();
            }
            Prefs.HatsOnlyOnMap = hatsOnlyOnMap;
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label("Gameplay".Translate(), -1f);
            Text.Font = GameFont.Small;
            listing_Standard.Gap(12f);
            listing_Standard.Gap(12f);
            if (listing_Standard.ButtonText("KeyboardConfig".Translate(), null))
            {
                Find.WindowStack.Add(new Dialog_KeyBindings());
            }
            if (listing_Standard.ButtonText("ChooseLanguage".Translate(), null))
            {
                if (Current.ProgramState == ProgramState.Playing)
                {
                    Messages.Message("ChangeLanguageFromMainMenu".Translate(), MessageTypeDefOf.RejectInput);
                }
                else
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (LoadedLanguage current in LanguageDatabase.AllLoadedLanguages)
                    {
                        LoadedLanguage localLang = current;
                        list.Add(new FloatMenuOption(localLang.FriendlyNameNative, delegate
                        {
                            LanguageDatabase.SelectLanguage(localLang);
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }
            if ((Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) && listing_Standard.ButtonText("OpenSaveGameDataFolder".Translate(), null))
            {
                Application.OpenURL(GenFilePaths.SaveDataFolderPath);
            }
            bool adaptiveTrainingEnabled = Prefs.AdaptiveTrainingEnabled;

            listing_Standard.CheckboxLabeled("LearningHelper".Translate(), ref adaptiveTrainingEnabled, null);
            Prefs.AdaptiveTrainingEnabled = adaptiveTrainingEnabled;
            if (listing_Standard.ButtonText("ResetAdaptiveTutor".Translate(), null))
            {
                Messages.Message("AdaptiveTutorIsReset".Translate(), MessageTypeDefOf.TaskCompletion);
                PlayerKnowledgeDatabase.ResetPersistent();
            }
            bool runInBackground = Prefs.RunInBackground;

            listing_Standard.CheckboxLabeled("RunInBackground".Translate(), ref runInBackground, null);
            Prefs.RunInBackground = runInBackground;
            bool edgeScreenScroll = Prefs.EdgeScreenScroll;

            listing_Standard.CheckboxLabeled("EdgeScreenScroll".Translate(), ref edgeScreenScroll, null);
            Prefs.EdgeScreenScroll = edgeScreenScroll;
            bool pauseOnLoad = Prefs.PauseOnLoad;

            listing_Standard.CheckboxLabeled("PauseOnLoad".Translate(), ref pauseOnLoad, null);
            Prefs.PauseOnLoad = pauseOnLoad;
            bool pauseOnUrgentLetter = Prefs.PauseOnUrgentLetter;

            listing_Standard.CheckboxLabeled("PauseOnUrgentLetter".Translate(), ref pauseOnUrgentLetter, null);
            Prefs.PauseOnUrgentLetter = pauseOnUrgentLetter;
            bool showRealtimeClock = Prefs.ShowRealtimeClock;

            listing_Standard.CheckboxLabeled("ShowRealtimeClock".Translate(), ref showRealtimeClock, null);
            Prefs.ShowRealtimeClock = showRealtimeClock;
            bool plantWindSway = Prefs.PlantWindSway;

            listing_Standard.CheckboxLabeled("PlantWindSway".Translate(), ref plantWindSway, null);
            Prefs.PlantWindSway = plantWindSway;
            int maxNumberOfPlayerHomes = Prefs.MaxNumberOfPlayerHomes;

            listing_Standard.Label("MaxNumberOfPlayerHomes".Translate(new object[]
            {
                maxNumberOfPlayerHomes
            }), -1f);
            int num2 = Mathf.RoundToInt(listing_Standard.Slider((float)maxNumberOfPlayerHomes, 1f, 5f));

            Prefs.MaxNumberOfPlayerHomes = num2;
            if (maxNumberOfPlayerHomes != num2 && num2 > 1)
            {
                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.MaxNumberOfPlayerHomes);
            }
            if (listing_Standard.ButtonTextLabeled("TemperatureMode".Translate(), Prefs.TemperatureMode.ToStringHuman()))
            {
                List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                foreach (TemperatureDisplayMode localTmode2 in Enum.GetValues(typeof(TemperatureDisplayMode)))
                {
                    TemperatureDisplayMode localTmode = localTmode2;
                    list2.Add(new FloatMenuOption(localTmode.ToString(), delegate
                    {
                        Prefs.TemperatureMode = localTmode;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list2));
            }
            float  autosaveIntervalDays = Prefs.AutosaveIntervalDays;
            string text  = "Days".Translate();
            string text2 = "Day".Translate().ToLower();

            if (listing_Standard.ButtonTextLabeled("AutosaveInterval".Translate(), autosaveIntervalDays + " " + ((autosaveIntervalDays != 1f) ? text : text2)))
            {
                List <FloatMenuOption> list3 = new List <FloatMenuOption>();
                if (Prefs.DevMode)
                {
                    list3.Add(new FloatMenuOption("0.125 " + text + "(debug)", delegate
                    {
                        Prefs.AutosaveIntervalDays = 0.125f;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    list3.Add(new FloatMenuOption("0.25 " + text + "(debug)", delegate
                    {
                        Prefs.AutosaveIntervalDays = 0.25f;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                list3.Add(new FloatMenuOption("0.5 " + text + string.Empty, delegate
                {
                    Prefs.AutosaveIntervalDays = 0.5f;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                list3.Add(new FloatMenuOption(1.ToString() + " " + text2, delegate
                {
                    Prefs.AutosaveIntervalDays = 1f;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                list3.Add(new FloatMenuOption(3.ToString() + " " + text, delegate
                {
                    Prefs.AutosaveIntervalDays = 3f;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                list3.Add(new FloatMenuOption(7.ToString() + " " + text, delegate
                {
                    Prefs.AutosaveIntervalDays = 7f;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                list3.Add(new FloatMenuOption(14.ToString() + " " + text, delegate
                {
                    Prefs.AutosaveIntervalDays = 14f;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                Find.WindowStack.Add(new FloatMenu(list3));
            }
            if (Current.ProgramState == ProgramState.Playing && Current.Game.Info.permadeathMode && Prefs.AutosaveIntervalDays > 1f)
            {
                GUI.color = Color.red;
                listing_Standard.Label("MaxPermadeathAutosaveIntervalInfo".Translate(new object[]
                {
                    1f
                }), -1f);
                GUI.color = Color.white;
            }
            if (Current.ProgramState == ProgramState.Playing && listing_Standard.ButtonText("ChangeStoryteller".Translate(), "OptionsButton-ChooseStoryteller") && TutorSystem.AllowAction("ChooseStoryteller"))
            {
                Find.WindowStack.Add(new Page_SelectStorytellerInGame());
            }
            if (listing_Standard.ButtonTextLabeled("ShowAnimalNames".Translate(), Prefs.AnimalNameMode.ToStringHuman()))
            {
                List <FloatMenuOption> list4 = new List <FloatMenuOption>();
                foreach (AnimalNameDisplayMode localMode2 in Enum.GetValues(typeof(AnimalNameDisplayMode)))
                {
                    AnimalNameDisplayMode localMode = localMode2;
                    list4.Add(new FloatMenuOption(localMode.ToStringHuman(), delegate
                    {
                        Prefs.AnimalNameMode = localMode;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list4));
            }
            bool devMode = Prefs.DevMode;

            listing_Standard.CheckboxLabeled("DevelopmentMode".Translate(), ref devMode, null);
            Prefs.DevMode = devMode;
            if (Prefs.DevMode)
            {
                bool resetModsConfigOnCrash = Prefs.ResetModsConfigOnCrash;
                listing_Standard.CheckboxLabeled("ResetModsConfigOnCrash".Translate(), ref resetModsConfigOnCrash, null);
                Prefs.ResetModsConfigOnCrash = resetModsConfigOnCrash;
                bool logVerbose = Prefs.LogVerbose;
                listing_Standard.CheckboxLabeled("LogVerbose".Translate(), ref logVerbose, null);
                Prefs.LogVerbose = logVerbose;
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label(string.Empty, -1f);
            Text.Font = GameFont.Small;
            listing_Standard.Gap(12f);
            listing_Standard.Gap(12f);
            if (listing_Standard.ButtonText("ModSettings".Translate(), null))
            {
                Find.WindowStack.Add(new Dialog_ModSettings());
            }
            listing_Standard.Label(string.Empty, -1f);
            listing_Standard.Label("NamesYouWantToSee".Translate(), -1f);
            Prefs.PreferredNames.RemoveAll(new Predicate <string>(GenText.NullOrEmpty));
            for (int j = 0; j < Prefs.PreferredNames.Count; j++)
            {
                string  name    = Prefs.PreferredNames[j];
                PawnBio pawnBio = (from b in SolidBioDatabase.allBios
                                   where b.name.ToString() == name
                                   select b).FirstOrDefault <PawnBio>();
                if (pawnBio == null)
                {
                    name += " [N]";
                }
                else
                {
                    PawnBioType bioType = pawnBio.BioType;
                    if (bioType != PawnBioType.BackstoryInGame)
                    {
                        if (bioType == PawnBioType.PirateKing)
                        {
                            name += " [PK]";
                        }
                    }
                    else
                    {
                        name += " [B]";
                    }
                }
                Rect rect2 = listing_Standard.GetRect(24f);
                Widgets.Label(rect2, name);
                Rect butRect = new Rect(rect2.xMax - 24f, rect2.y, 24f, 24f);
                if (Widgets.ButtonImage(butRect, TexButton.DeleteX))
                {
                    Prefs.PreferredNames.RemoveAt(j);
                    SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                }
            }
            if (Prefs.PreferredNames.Count < 6 && listing_Standard.ButtonText("AddName".Translate() + "...", null))
            {
                Find.WindowStack.Add(new Dialog_AddPreferredName());
            }
            listing_Standard.End();
        }
コード例 #10
0
 public static void LessonAutoActivatorUpdate()
 {
     if (!TutorSystem.AdaptiveTrainingEnabled || Current.Game == null || Find.Tutor.learningReadout.ShowAllMode)
     {
         return;
     }
     timeSinceLastLesson += RealTime.realDeltaTime;
     if (Current.ProgramState == ProgramState.Playing && (Time.timeSinceLevelLoad < 8f || Find.WindowStack.SecondsSinceClosedGameStartDialog < 8f || Find.TickManager.NotPlaying))
     {
         return;
     }
     for (int num = alertingConcepts.Count - 1; num >= 0; num--)
     {
         if (PlayerKnowledgeDatabase.IsComplete(alertingConcepts[num]))
         {
             alertingConcepts.RemoveAt(num);
         }
     }
     if (Time.frameCount % 15 != 0 || Find.ActiveLesson.Current != null)
     {
         return;
     }
     for (int i = 0; i < DefDatabase <ConceptDef> .AllDefsListForReading.Count; i++)
     {
         ConceptDef conceptDef = DefDatabase <ConceptDef> .AllDefsListForReading[i];
         if (PlayerKnowledgeDatabase.IsComplete(conceptDef))
         {
             continue;
         }
         float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conceptDef);
         knowledge -= 0.00015f * Time.deltaTime * 15f;
         if (knowledge < 0f)
         {
             knowledge = 0f;
         }
         PlayerKnowledgeDatabase.SetKnowledge(conceptDef, knowledge);
         if (conceptDef.opportunityDecays)
         {
             float opportunity = GetOpportunity(conceptDef);
             opportunity -= 0.4f * Time.deltaTime * 15f;
             if (opportunity < 0f)
             {
                 opportunity = 0f;
             }
             opportunities[conceptDef] = opportunity;
         }
     }
     if (Find.Tutor.learningReadout.ActiveConceptsCount < 3)
     {
         ConceptDef conceptDef2 = MostDesiredConcept();
         if (conceptDef2 != null)
         {
             float desire = GetDesire(conceptDef2);
             if (desire > 0.1f && RelaxDesire < desire)
             {
                 TryInitiateLesson(conceptDef2);
             }
         }
     }
     else
     {
         SetLastLessonTimeToNow();
     }
 }
コード例 #11
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect rect  = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);
            Rect rect2 = rect.ContractedBy(6f);

            Widgets.DrawWindowBackground(rect);
            Text.Font = GameFont.Small;
            Rect rect3 = rect2;

            rect3.y     += 6f;
            rect3.height = Text.LineHeight;
            Widgets.Label(rect3, "PsychicEntropyShort".Translate());
            Rect rect4 = rect2;

            rect4.y     += 38f;
            rect4.height = Text.LineHeight;
            Widgets.Label(rect4, "Psyfocus".Translate());
            Rect rect5 = rect2;

            rect5.x     += 63f;
            rect5.y     += 6f;
            rect5.width  = 100f;
            rect5.height = 22f;
            float entropyRelativeValue = tracker.EntropyRelativeValue;

            Widgets.FillableBar(rect5, Mathf.Min(entropyRelativeValue, 1f), EntropyBarTex, EmptyBarTex, doBorder: true);
            if (tracker.EntropyValue > tracker.MaxEntropy)
            {
                Widgets.FillableBar(rect5, Mathf.Min(entropyRelativeValue - 1f, 1f), OverLimitBarTex, EntropyBarTex, doBorder: true);
                foreach (KeyValuePair <PsychicEntropySeverity, float> entropyThreshold in Pawn_PsychicEntropyTracker.EntropyThresholds)
                {
                    if (entropyThreshold.Value > 1f && entropyThreshold.Value < 2f)
                    {
                        DrawThreshold(rect5, entropyThreshold.Value - 1f, entropyRelativeValue);
                    }
                }
            }
            string label = tracker.EntropyValue.ToString("F0") + " / " + tracker.MaxEntropy.ToString("F0");

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect5, label);
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Tiny;
            GUI.color   = Color.white;
            Rect rect6 = rect2;

            rect6.width  = 175f;
            rect6.height = 38f;
            TooltipHandler.TipRegion(rect6, delegate
            {
                float f = tracker.EntropyValue / tracker.RecoveryRate;
                return(string.Format("PawnTooltipPsychicEntropyStats".Translate(), Mathf.Round(tracker.EntropyValue), Mathf.Round(tracker.MaxEntropy), tracker.RecoveryRate.ToString("0.#"), Mathf.Round(f)) + "\n\n" + "PawnTooltipPsychicEntropyDesc".Translate());
            }, Gen.HashCombineInt(tracker.GetHashCode(), 133858));
            Rect rect7 = rect2;

            rect7.x     += 63f;
            rect7.y     += 38f;
            rect7.width  = 100f;
            rect7.height = 22f;
            bool flag = Mouse.IsOver(rect7);

            Widgets.FillableBar(rect7, Mathf.Min(tracker.CurrentPsyfocus, 1f), flag ? PsyfocusBarHighlightTex : PsyfocusBarTex, EmptyBarTex, doBorder: true);
            for (int i = 1; i < Pawn_PsychicEntropyTracker.PsyfocusBandPercentages.Count - 1; i++)
            {
                DrawThreshold(rect7, Pawn_PsychicEntropyTracker.PsyfocusBandPercentages[i], tracker.CurrentPsyfocus);
            }
            DrawPsyfocusTarget(rect7, tracker.TargetPsyfocus);
            float   targetPsyfocus = tracker.TargetPsyfocus;
            Vector2 mousePosition  = Event.current.mousePosition;

            if (flag && Input.GetMouseButton(0))
            {
                tracker.SetPsyfocusTarget(Mathf.Round((mousePosition.x - (rect7.x + 3f)) / (rect7.width - 8f) * 16f) / 16f);
                if (Math.Abs(targetPsyfocus - tracker.TargetPsyfocus) > float.Epsilon)
                {
                    SoundDefOf.DragSlider.PlayOneShotOnCamera();
                }
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MeditationDesiredPsyfocus, KnowledgeAmount.Total);
            }
            UIHighlighter.HighlightOpportunity(rect7, "PsyfocusBar");
            GUI.color = Color.white;
            Rect rect8 = rect2;

            rect8.y     += 38f;
            rect8.width  = 175f;
            rect8.height = 38f;
            TooltipHandler.TipRegion(rect8, () => tracker.PsyfocusTipString(), Gen.HashCombineInt(tracker.GetHashCode(), 133873));
            if (tracker.Pawn.IsColonistPlayerControlled)
            {
                float num   = 32f;
                float num2  = 4f;
                float num3  = rect2.height / 2f - num + num2;
                float num4  = rect2.width - num;
                Rect  rect9 = new Rect(rect2.x + num4, rect2.y + num3, num, num);
                if (Widgets.ButtonImage(rect9, tracker.limitEntropyAmount ? LimitedTex : UnlimitedTex))
                {
                    tracker.limitEntropyAmount = !tracker.limitEntropyAmount;
                    if (tracker.limitEntropyAmount)
                    {
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                    }
                    else
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    }
                }
                TooltipHandler.TipRegionByKey(rect9, "PawnTooltipPsychicEntropyLimit");
            }
            if (tracker.PainMultiplier > 1f)
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleCenter;
                string recoveryBonus = (tracker.PainMultiplier - 1f).ToStringPercent("F0");
                string text          = recoveryBonus;
                float  widthCached   = text.GetWidthCached();
                Rect   rect10        = rect2;
                rect10.x     += rect2.width - widthCached / 2f - 16f;
                rect10.y     += 38f;
                rect10.width  = widthCached;
                rect10.height = Text.LineHeight;
                GUI.color     = PainBoostColor;
                Widgets.Label(rect10, text);
                GUI.color   = Color.white;
                Text.Font   = GameFont.Tiny;
                Text.Anchor = TextAnchor.UpperLeft;
                TooltipHandler.TipRegion(rect10.ContractedBy(-1f), () => "PawnTooltipPsychicEntropyPainFocus".Translate(tracker.Pawn.health.hediffSet.PainTotal.ToStringPercent("F0"), recoveryBonus), Gen.HashCombineInt(tracker.GetHashCode(), 133878));
            }
            return(new GizmoResult(GizmoState.Clear));
        }
コード例 #12
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            ResolveRaidPoints(parms);
            if (!TryResolveRaidFaction(parms))
            {
                return(false);
            }
            PawnGroupKindDef combat = PawnGroupKindDefOf.Combat;

            ResolveRaidStrategy(parms, combat);
            ResolveRaidArriveMode(parms);
            parms.raidStrategy.Worker.TryGenerateThreats(parms);
            if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms))
            {
                return(false);
            }
            parms.points = AdjustedRaidPoints(parms.points, parms.raidArrivalMode, parms.raidStrategy, parms.faction, combat);
            List <Pawn> list = parms.raidStrategy.Worker.SpawnThreats(parms);

            if (list == null)
            {
                list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms)).ToList();
                if (list.Count == 0)
                {
                    Log.Error("Got no pawns spawning raid from parms " + parms);
                    return(false);
                }
                parms.raidArrivalMode.Worker.Arrive(list, parms);
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Points = " + parms.points.ToString("F0"));
            foreach (Pawn item in list)
            {
                string str = (item.equipment != null && item.equipment.Primary != null) ? item.equipment.Primary.LabelCap : "unarmed";
                stringBuilder.AppendLine(item.KindLabel + " - " + str);
            }
            TaggedString letterLabel = GetLetterLabel(parms);
            TaggedString letterText  = GetLetterText(parms, list);

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, GetRelatedPawnsInfoLetterText(parms), informEvenIfSeenBefore: true);
            List <TargetInfo> list2 = new List <TargetInfo>();

            if (parms.pawnGroups != null)
            {
                List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups);
                List <Pawn>         list4 = list3.MaxBy((List <Pawn> x) => x.Count);
                if (list4.Any())
                {
                    list2.Add(list4[0]);
                }
                for (int i = 0; i < list3.Count; i++)
                {
                    if (list3[i] != list4 && list3[i].Any())
                    {
                        list2.Add(list3[i][0]);
                    }
                }
            }
            else if (list.Any())
            {
                foreach (Pawn item2 in list)
                {
                    list2.Add(item2);
                }
            }
            SendStandardLetter(letterLabel, letterText, GetLetterDef(), parms, list2);
            parms.raidStrategy.Worker.MakeLords(parms, list);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical);
            if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts))
            {
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt))
                    {
                        LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical);
                        break;
                    }
                }
            }
            return(true);
        }
コード例 #13
0
 public override void PostOpen()
 {
     base.PostOpen();
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.DrugPolicies, KnowledgeAmount.Total);
 }
コード例 #14
0
ファイル: Dialog_Options.cs プロジェクト: potsh/RimWorld
        public override void DoWindowContents(Rect inRect)
        {
            Rect rect = inRect.AtZero();

            rect.yMax -= 35f;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = (rect.width - 34f) / 3f;
            listing_Standard.Begin(rect);
            Text.Font = GameFont.Medium;
            listing_Standard.Label("Audiovisuals".Translate());
            Text.Font = GameFont.Small;
            listing_Standard.Gap();
            listing_Standard.Gap();
            listing_Standard.Label("GameVolume".Translate());
            Prefs.VolumeGame = listing_Standard.Slider(Prefs.VolumeGame, 0f, 1f);
            listing_Standard.Label("MusicVolume".Translate());
            Prefs.VolumeMusic = listing_Standard.Slider(Prefs.VolumeMusic, 0f, 1f);
            listing_Standard.Label("AmbientVolume".Translate());
            Prefs.VolumeAmbient = listing_Standard.Slider(Prefs.VolumeAmbient, 0f, 1f);
            if (listing_Standard.ButtonTextLabeled("Resolution".Translate(), ResToString(Screen.width, Screen.height)))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (Resolution item in from x in UnityGUIBugsFixer.ScreenResolutionsWithoutDuplicates
                         where x.width >= 1024 && x.height >= 768
                         orderby x.width, x.height
                         select x)
                {
                    list.Add(new FloatMenuOption(ResToString(item.width, item.height), delegate
                    {
                        if (!ResolutionUtility.UIScaleSafeWithResolution(Prefs.UIScale, item.width, item.height))
                        {
                            Messages.Message("MessageScreenResTooSmallForUIScale".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else
                        {
                            ResolutionUtility.SafeSetResolution(item);
                        }
                    }));
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            if (listing_Standard.ButtonTextLabeled("UIScale".Translate(), Prefs.UIScale.ToString() + "x"))
            {
                List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                for (int i = 0; i < UIScales.Length; i++)
                {
                    float scale = UIScales[i];
                    list2.Add(new FloatMenuOption(UIScales[i].ToString() + "x", delegate
                    {
                        if (scale != 1f && !ResolutionUtility.UIScaleSafeWithResolution(scale, Screen.width, Screen.height))
                        {
                            Messages.Message("MessageScreenResTooSmallForUIScale".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else
                        {
                            ResolutionUtility.SafeSetUIScale(scale);
                        }
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list2));
            }
            bool checkOn = Prefs.CustomCursorEnabled;

            listing_Standard.CheckboxLabeled("CustomCursor".Translate(), ref checkOn);
            Prefs.CustomCursorEnabled = checkOn;
            bool checkOn2 = Screen.fullScreen;
            bool flag     = checkOn2;

            listing_Standard.CheckboxLabeled("Fullscreen".Translate(), ref checkOn2);
            if (checkOn2 != flag)
            {
                ResolutionUtility.SafeSetFullscreen(checkOn2);
            }
            listing_Standard.Gap();
            bool checkOn3 = Prefs.HatsOnlyOnMap;

            listing_Standard.CheckboxLabeled("HatsShownOnlyOnMap".Translate(), ref checkOn3);
            if (checkOn3 != Prefs.HatsOnlyOnMap)
            {
                PortraitsCache.Clear();
            }
            Prefs.HatsOnlyOnMap = checkOn3;
            bool checkOn4 = Prefs.PlantWindSway;

            listing_Standard.CheckboxLabeled("PlantWindSway".Translate(), ref checkOn4);
            Prefs.PlantWindSway = checkOn4;
            bool checkOn5 = Prefs.ShowRealtimeClock;

            listing_Standard.CheckboxLabeled("ShowRealtimeClock".Translate(), ref checkOn5);
            Prefs.ShowRealtimeClock = checkOn5;
            if (listing_Standard.ButtonTextLabeled("ShowAnimalNames".Translate(), Prefs.AnimalNameMode.ToStringHuman()))
            {
                List <FloatMenuOption> list3       = new List <FloatMenuOption>();
                IEnumerator            enumerator2 = Enum.GetValues(typeof(AnimalNameDisplayMode)).GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        AnimalNameDisplayMode animalNameDisplayMode = (AnimalNameDisplayMode)enumerator2.Current;
                        AnimalNameDisplayMode localMode             = animalNameDisplayMode;
                        list3.Add(new FloatMenuOption(localMode.ToStringHuman(), delegate
                        {
                            Prefs.AnimalNameMode = localMode;
                        }));
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator2 as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list3));
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label("Gameplay".Translate());
            Text.Font = GameFont.Small;
            listing_Standard.Gap();
            listing_Standard.Gap();
            if (listing_Standard.ButtonText("KeyboardConfig".Translate()))
            {
                Find.WindowStack.Add(new Dialog_KeyBindings());
            }
            if (listing_Standard.ButtonText("ChooseLanguage".Translate()))
            {
                if (Current.ProgramState == ProgramState.Playing)
                {
                    Messages.Message("ChangeLanguageFromMainMenu".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    List <FloatMenuOption> list4 = new List <FloatMenuOption>();
                    foreach (LoadedLanguage allLoadedLanguage in LanguageDatabase.AllLoadedLanguages)
                    {
                        LoadedLanguage localLang = allLoadedLanguage;
                        list4.Add(new FloatMenuOption(localLang.FriendlyNameNative, delegate
                        {
                            LanguageDatabase.SelectLanguage(localLang);
                        }));
                    }
                    Find.WindowStack.Add(new FloatMenu(list4));
                }
            }
            if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
            {
                if (listing_Standard.ButtonText("OpenSaveGameDataFolder".Translate()))
                {
                    Application.OpenURL(GenFilePaths.SaveDataFolderPath);
                }
            }
            else if (listing_Standard.ButtonText("ShowSaveGameDataLocation".Translate()))
            {
                Find.WindowStack.Add(new Dialog_MessageBox(Path.GetFullPath(GenFilePaths.SaveDataFolderPath)));
            }
            if (listing_Standard.ButtonText("ResetAdaptiveTutor".Translate()))
            {
                Messages.Message("AdaptiveTutorIsReset".Translate(), MessageTypeDefOf.TaskCompletion, historical: false);
                PlayerKnowledgeDatabase.ResetPersistent();
            }
            bool checkOn6 = Prefs.AdaptiveTrainingEnabled;

            listing_Standard.CheckboxLabeled("LearningHelper".Translate(), ref checkOn6);
            Prefs.AdaptiveTrainingEnabled = checkOn6;
            bool checkOn7 = Prefs.RunInBackground;

            listing_Standard.CheckboxLabeled("RunInBackground".Translate(), ref checkOn7);
            Prefs.RunInBackground = checkOn7;
            bool checkOn8 = Prefs.EdgeScreenScroll;

            listing_Standard.CheckboxLabeled("EdgeScreenScroll".Translate(), ref checkOn8);
            Prefs.EdgeScreenScroll = checkOn8;
            bool checkOn9 = Prefs.PauseOnLoad;

            listing_Standard.CheckboxLabeled("PauseOnLoad".Translate(), ref checkOn9);
            Prefs.PauseOnLoad = checkOn9;
            bool checkOn10 = Prefs.PauseOnUrgentLetter;

            listing_Standard.CheckboxLabeled("PauseOnUrgentLetter".Translate(), ref checkOn10);
            Prefs.PauseOnUrgentLetter = checkOn10;
            int maxNumberOfPlayerSettlements = Prefs.MaxNumberOfPlayerSettlements;

            listing_Standard.Label("MaxNumberOfPlayerSettlements".Translate(maxNumberOfPlayerSettlements));
            int num2 = Prefs.MaxNumberOfPlayerSettlements = Mathf.RoundToInt(listing_Standard.Slider((float)maxNumberOfPlayerSettlements, 1f, 5f));

            if (maxNumberOfPlayerSettlements != num2 && num2 > 1)
            {
                TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.MaxNumberOfPlayerSettlements);
            }
            if (listing_Standard.ButtonTextLabeled("TemperatureMode".Translate(), Prefs.TemperatureMode.ToStringHuman()))
            {
                List <FloatMenuOption> list5       = new List <FloatMenuOption>();
                IEnumerator            enumerator4 = Enum.GetValues(typeof(TemperatureDisplayMode)).GetEnumerator();
                try
                {
                    while (enumerator4.MoveNext())
                    {
                        TemperatureDisplayMode temperatureDisplayMode = (TemperatureDisplayMode)enumerator4.Current;
                        TemperatureDisplayMode localTmode             = temperatureDisplayMode;
                        list5.Add(new FloatMenuOption(localTmode.ToString(), delegate
                        {
                            Prefs.TemperatureMode = localTmode;
                        }));
                    }
                }
                finally
                {
                    IDisposable disposable2;
                    if ((disposable2 = (enumerator4 as IDisposable)) != null)
                    {
                        disposable2.Dispose();
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list5));
            }
            float  autosaveIntervalDays = Prefs.AutosaveIntervalDays;
            string text  = "Days".Translate();
            string text2 = "Day".Translate().ToLower();

            if (listing_Standard.ButtonTextLabeled("AutosaveInterval".Translate(), autosaveIntervalDays + " " + ((autosaveIntervalDays != 1f) ? text : text2)))
            {
                List <FloatMenuOption> list6 = new List <FloatMenuOption>();
                if (Prefs.DevMode)
                {
                    list6.Add(new FloatMenuOption("0.125 " + text + "(debug)", delegate
                    {
                        Prefs.AutosaveIntervalDays = 0.125f;
                    }));
                    list6.Add(new FloatMenuOption("0.25 " + text + "(debug)", delegate
                    {
                        Prefs.AutosaveIntervalDays = 0.25f;
                    }));
                }
                list6.Add(new FloatMenuOption("0.5 " + text + string.Empty, delegate
                {
                    Prefs.AutosaveIntervalDays = 0.5f;
                }));
                list6.Add(new FloatMenuOption(1.ToString() + " " + text2, delegate
                {
                    Prefs.AutosaveIntervalDays = 1f;
                }));
                list6.Add(new FloatMenuOption(3.ToString() + " " + text, delegate
                {
                    Prefs.AutosaveIntervalDays = 3f;
                }));
                list6.Add(new FloatMenuOption(7.ToString() + " " + text, delegate
                {
                    Prefs.AutosaveIntervalDays = 7f;
                }));
                list6.Add(new FloatMenuOption(14.ToString() + " " + text, delegate
                {
                    Prefs.AutosaveIntervalDays = 14f;
                }));
                Find.WindowStack.Add(new FloatMenu(list6));
            }
            if (Current.ProgramState == ProgramState.Playing && Current.Game.Info.permadeathMode && Prefs.AutosaveIntervalDays > 1f)
            {
                GUI.color = Color.red;
                listing_Standard.Label("MaxPermadeathAutosaveIntervalInfo".Translate(1f));
                GUI.color = Color.white;
            }
            if (Current.ProgramState == ProgramState.Playing && listing_Standard.ButtonText("ChangeStoryteller".Translate(), "OptionsButton-ChooseStoryteller") && TutorSystem.AllowAction("ChooseStoryteller"))
            {
                Find.WindowStack.Add(new Page_SelectStorytellerInGame());
            }
            if (!DevModePermanentlyDisabledUtility.Disabled && listing_Standard.ButtonText("PermanentlyDisableDevMode".Translate()))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmPermanentlyDisableDevMode".Translate(), delegate
                {
                    DevModePermanentlyDisabledUtility.Disable();
                }, destructive: true));
            }
            if (!DevModePermanentlyDisabledUtility.Disabled || Prefs.DevMode)
            {
                bool checkOn11 = Prefs.DevMode;
                listing_Standard.CheckboxLabeled("DevelopmentMode".Translate(), ref checkOn11);
                Prefs.DevMode = checkOn11;
            }
            bool checkOn12 = Prefs.TestMapSizes;

            listing_Standard.CheckboxLabeled("EnableTestMapSizes".Translate(), ref checkOn12);
            Prefs.TestMapSizes = checkOn12;
            if (Prefs.DevMode)
            {
                bool checkOn13 = Prefs.ResetModsConfigOnCrash;
                listing_Standard.CheckboxLabeled("ResetModsConfigOnCrash".Translate(), ref checkOn13);
                Prefs.ResetModsConfigOnCrash = checkOn13;
                bool checkOn14 = Prefs.LogVerbose;
                listing_Standard.CheckboxLabeled("LogVerbose".Translate(), ref checkOn14);
                Prefs.LogVerbose = checkOn14;
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label(string.Empty);
            Text.Font = GameFont.Small;
            listing_Standard.Gap();
            listing_Standard.Gap();
            if (listing_Standard.ButtonText("ModSettings".Translate()))
            {
                Find.WindowStack.Add(new Dialog_ModSettings());
            }
            listing_Standard.Label(string.Empty);
            listing_Standard.Label("NamesYouWantToSee".Translate());
            Prefs.PreferredNames.RemoveAll(GenText.NullOrEmpty);
            for (int j = 0; j < Prefs.PreferredNames.Count; j++)
            {
                string  name    = Prefs.PreferredNames[j];
                PawnBio pawnBio = (from b in SolidBioDatabase.allBios
                                   where b.name.ToString() == name
                                   select b).FirstOrDefault();
                if (pawnBio != null)
                {
                    switch (pawnBio.BioType)
                    {
                    case PawnBioType.BackstoryInGame:
                        name += " [B]";
                        break;

                    case PawnBioType.PirateKing:
                        name += " [PK]";
                        break;
                    }
                }
                else
                {
                    name += " [N]";
                }
                Rect rect2 = listing_Standard.GetRect(24f);
                Widgets.Label(rect2, name);
                Rect butRect = new Rect(rect2.xMax - 24f, rect2.y, 24f, 24f);
                if (Widgets.ButtonImage(butRect, TexButton.DeleteX, Color.white, GenUI.SubtleMouseoverColor))
                {
                    Prefs.PreferredNames.RemoveAt(j);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
            }
            if (Prefs.PreferredNames.Count < 6 && listing_Standard.ButtonText("AddName".Translate() + "..."))
            {
                Find.WindowStack.Add(new Dialog_AddPreferredName());
            }
            listing_Standard.Label(string.Empty);
            if (listing_Standard.ButtonText("RestoreToDefaultSettings".Translate()))
            {
                RestoreToDefaultSettings();
            }
            listing_Standard.End();
        }
コード例 #15
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Rect rect2 = new Rect(WinSize.x - PasteX, PasteY, PasteSize, PasteSize);

            if (BillUtility.Clipboard == null)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect2, "PasteBillTip");
            }
            else if (!SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow || !BillUtility.Clipboard.recipe.AvailableOnNow(SelTable))
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect2, "ClipboardBillNotAvailableHere");
            }
            else if (SelTable.billStack.Count >= 15)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")");
                }
            }
            else
            {
                if (Widgets.ButtonImageFitted(rect2, TexButton.Paste, Color.white))
                {
                    Bill bill = BillUtility.Clipboard.Clone();
                    bill.InitializeAfterClone();
                    SelTable.billStack.AddBill(bill);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect2, "PasteBillTip");
            }
            Rect rect3 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                RecipeDef recipe            = default(RecipeDef);
                for (int i = 0; i < SelTable.def.AllRecipes.Count; i++)
                {
                    if (SelTable.def.AllRecipes[i].AvailableNow && SelTable.def.AllRecipes[i].AvailableOnNow(SelTable))
                    {
                        recipe = SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill2 = recipe.MakeNewBill();
                            SelTable.billStack.AddBill(bill2);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve());
                            }
                        }, recipe.UIIconThing, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null));
                }
                return(list);
            };

            mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
        }
コード例 #16
0
 public static void Init()
 {
     PlayerKnowledgeDatabase.Save();
     ShipCountdown.CancelCountdown();
     MainMenuDrawer.anyMapFiles = GenFilePaths.AllSavedGameFiles.Any();
 }
コード例 #17
0
        protected override void FillTab()
        {
            IStoreSettingsParent storeSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings            = storeSettingsParent.GetStoreSettings();
            Rect position = new Rect(0f, 0f, ITab_Storage.WinSize.x, ITab_Storage.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label().CapitalizeFirst(), true, false, true))
                {
                    List <FloatMenuOption> list       = new List <FloatMenuOption>();
                    IEnumerator            enumerator = Enum.GetValues(typeof(StoragePriority)).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            object          obj             = enumerator.Current;
                            StoragePriority storagePriority = (StoragePriority)obj;
                            if (storagePriority != StoragePriority.Unstored)
                            {
                                StoragePriority localPr = storagePriority;
                                list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate()
                                {
                                    settings.Priority = localPr;
                                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable;
                        if ((disposable = (enumerator as IDisposable)) != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            ThingFilter parentFilter = null;

            if (storeSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = storeSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            Bill[] first = (from b in BillUtility.GlobalBills()
                            where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                            select b).ToArray <Bill>();
            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, null, null);
            Bill[] second = (from b in BillUtility.GlobalBills()
                             where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                             select b).ToArray <Bill>();
            IEnumerable <Bill> enumerable = first.Except(second);

            foreach (Bill bill in enumerable)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(new object[]
                {
                    bill.LabelCap,
                    bill.billStack.billGiver.LabelShort.CapitalizeFirst(),
                    bill.GetStoreZone().label
                }), bill.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, false);
            }
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
コード例 #18
0
        private void DoGraphPage(Rect rect)
        {
            rect.yMin += 17f;
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width, 450f);
            Rect legendRect = new Rect(0f, graphRect.yMax, rect.width / 2f, 40f);
            Rect rect2      = new Rect(0f, legendRect.yMax, rect.width, 40f);

            if (historyAutoRecorderGroup != null)
            {
                marks.Clear();
                List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading;
                for (int i = 0; i < allTalesListForReading.Count; i++)
                {
                    Tale tale = allTalesListForReading[i];
                    if (tale.def.type == TaleType.PermanentHistorical)
                    {
                        float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f;
                        marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                historyAutoRecorderGroup.DrawGraph(graphRect, legendRect, graphSection, marks);
            }
            Text.Font = GameFont.Small;
            float num = (float)Find.TickManager.TicksGame / 60000f;

            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width, legendRect.yMin, 110f, 40f), "Last30Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 30f), num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 110f + 4f, legendRect.yMin, 110f, 40f), "Last100Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 100f), num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 228f, legendRect.yMin, 110f, 40f), "Last300Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 300f), num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 342f, legendRect.yMin, 110f, 40f), "AllDays".Translate()))
            {
                graphSection = new FloatRange(0f, num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(rect2.x, rect2.y, 110f, 40f), "SelectGraph".Translate()))
            {
                List <FloatMenuOption>          list  = new List <FloatMenuOption>();
                List <HistoryAutoRecorderGroup> list2 = Find.History.Groups();
                for (int j = 0; j < list2.Count; j++)
                {
                    HistoryAutoRecorderGroup groupLocal = list2[j];
                    if (!groupLocal.def.devModeOnly || Prefs.DevMode)
                    {
                        list.Add(new FloatMenuOption(groupLocal.def.LabelCap, delegate
                        {
                            historyAutoRecorderGroup = groupLocal;
                        }));
                    }
                }
                FloatMenu window = new FloatMenu(list, "SelectGraph".Translate());
                Find.WindowStack.Add(window);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total);
            }
            GUI.EndGroup();
        }
コード例 #19
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn)
        {
            if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn))
            {
                FloatMenuOption item = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                return(new List <FloatMenuOption>
                {
                    item
                });
            }
            if (base.Spawned && base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.SolarFlare))
            {
                FloatMenuOption item2 = new FloatMenuOption("CannotUseSolarFlare".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                return(new List <FloatMenuOption>
                {
                    item2
                });
            }
            if (!this.powerComp.PowerOn)
            {
                FloatMenuOption item3 = new FloatMenuOption("CannotUseNoPower".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                return(new List <FloatMenuOption>
                {
                    item3
                });
            }
            if (!myPawn.health.capacities.CapableOf(PawnCapacityDefOf.Talking))
            {
                FloatMenuOption item4 = new FloatMenuOption("CannotUseReason".Translate(new object[]
                {
                    "IncapableOfCapacity".Translate(new object[]
                    {
                        PawnCapacityDefOf.Talking.label
                    })
                }), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                return(new List <FloatMenuOption>
                {
                    item4
                });
            }
            if (myPawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                FloatMenuOption item5 = new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(new object[]
                {
                    SkillDefOf.Social.LabelCap
                }), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                return(new List <FloatMenuOption>
                {
                    item5
                });
            }
            if (!this.CanUseCommsNow)
            {
                Log.Error(myPawn + " could not use comm console for unknown reason.");
                FloatMenuOption item6 = new FloatMenuOption("Cannot use now", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                return(new List <FloatMenuOption>
                {
                    item6
                });
            }
            List <FloatMenuOption>      list       = new List <FloatMenuOption>();
            IEnumerable <ICommunicable> enumerable = myPawn.Map.passingShipManager.passingShips.Cast <ICommunicable>().Concat(Find.FactionManager.AllFactionsInViewOrder.Cast <ICommunicable>());

            foreach (ICommunicable commTarget in enumerable)
            {
                ICommunicable localCommTarget = commTarget;
                string        text            = "CallOnRadio".Translate(new object[]
                {
                    localCommTarget.GetCallLabel()
                });
                Faction faction = localCommTarget as Faction;
                if (faction != null)
                {
                    if (faction.IsPlayer)
                    {
                        continue;
                    }
                    if (!Building_CommsConsole.LeaderIsAvailableToTalk(faction))
                    {
                        string str;
                        if (faction.leader != null)
                        {
                            str = "LeaderUnavailable".Translate(new object[]
                            {
                                faction.leader.LabelShort
                            });
                        }
                        else
                        {
                            str = "LeaderUnavailableNoLeader".Translate();
                        }
                        list.Add(new FloatMenuOption(text + " (" + str + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        continue;
                    }
                }
                Action action = delegate
                {
                    ICommunicable localCommTarget = localCommTarget;
                    if (commTarget is TradeShip && !Building_OrbitalTradeBeacon.AllPowered(this.Map).Any <Building_OrbitalTradeBeacon>())
                    {
                        Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), this, MessageTypeDefOf.RejectInput);
                        return;
                    }
                    Job job = new Job(JobDefOf.UseCommsConsole, this);
                    job.commTarget = localCommTarget;
                    myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.OpeningComms, KnowledgeAmount.Total);
                };
                list.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, action, MenuOptionPriority.InitiateSocial, null, null, 0f, null, null), myPawn, this, "ReservedBy"));
            }
            return(list);
        }
コード例 #20
0
 public override void OnActivated()
 {
     PlayerKnowledgeDatabase.SetKnowledge(def.concept, 0f);
     base.OnActivated();
 }
コード例 #21
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.FrameDisplayed);
            Text.Font = GameFont.Small;
            Rect             rect = new Rect(0f, 0f, size.x, size.y).ContractedBy(10f);
            bool             isPrisonerOfColony = base.SelPawn.IsPrisonerOfColony;
            bool             flag             = base.SelPawn.IsWildMan();
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.maxOneColumn = true;
            listing_Standard.Begin(rect);
            Rect rect2 = listing_Standard.GetRect(28f);

            rect2.width = 140f;
            MedicalCareUtility.MedicalCareSetter(rect2, ref base.SelPawn.playerSettings.medCare);
            listing_Standard.Gap(4f);
            if (isPrisonerOfColony)
            {
                if (!flag)
                {
                    Rect rect3 = listing_Standard.Label("RecruitmentDifficulty".Translate() + ": " + base.SelPawn.RecruitDifficulty(Faction.OfPlayer).ToStringPercent());
                    if (base.SelPawn.royalty != null)
                    {
                        RoyalTitle title2 = base.SelPawn.royalty.MostSeniorTitle;
                        if (title2 != null && Mouse.IsOver(rect3))
                        {
                            string valueString = title2.def.recruitmentDifficultyOffset.ToStringByStyle(ToStringStyle.PercentOne, ToStringNumberSense.Offset);
                            TooltipHandler.TipRegion(rect3, () => "RecruitmentValueOffsetRoyal".Translate() + " (" + title2.def.GetLabelCapFor(base.SelPawn) + ")" + ": " + valueString, 947584751);
                            Widgets.DrawHighlight(rect3);
                        }
                    }
                    string value  = RecruitUtility.RecruitChanceFactorForRecruitDifficulty(base.SelPawn, Faction.OfPlayer).ToStringPercent();
                    string value2 = RecruitUtility.RecruitChanceFactorForMood(base.SelPawn).ToStringPercent();
                    string text   = base.SelPawn.RecruitChanceFinalByFaction(Faction.OfPlayer).ToStringPercent();
                    Rect   rect4  = listing_Standard.Label("RecruitmentChance".Translate() + ": " + text);
                    if (Mouse.IsOver(rect4))
                    {
                        string recruitmentChanceTooltip = null;
                        recruitmentChanceTooltip = "RecruitmentChanceExplanation".Translate(value, value2, text);
                        if (!base.SelPawn.guest.lastRecruiterName.NullOrEmpty())
                        {
                            recruitmentChanceTooltip += "RecruitmentChanceWithLastRecruiterExplanationPart".Translate().Formatted(value, value2, text, base.SelPawn.guest.lastRecruiterName, base.SelPawn.guest.lastRecruiterNegotiationAbilityFactor.ToStringPercent(), base.SelPawn.guest.lastRecruiterOpinionChanceFactor.ToStringPercent(), base.SelPawn.guest.hasOpinionOfLastRecruiter ? base.SelPawn.guest.lastRecruiterOpinion.ToStringWithSign() : "-", base.SelPawn.guest.lastRecruiterFinalChance.ToStringPercent(), base.SelPawn.guest.lastRecruiterResistanceReduce.ToString("0.0"));
                            if (base.SelPawn.guest.lastRecruiterResistanceReduce > 0f)
                            {
                                recruitmentChanceTooltip += "RecruitmentLastRecruiterResistanceReduceExplanationPart".Translate(base.SelPawn.guest.lastRecruiterResistanceReduce.ToString("0.0"));
                            }
                        }
                        TooltipHandler.TipRegion(rect4, () => recruitmentChanceTooltip, 947584753);
                    }
                    Widgets.DrawHighlightIfMouseover(rect4);
                    Rect rect5 = listing_Standard.Label("RecruitmentResistance".Translate() + ": " + base.SelPawn.guest.resistance.ToString("F1"));
                    if (base.SelPawn.royalty != null)
                    {
                        RoyalTitle title = base.SelPawn.royalty.MostSeniorTitle;
                        if (title != null && Mouse.IsOver(rect5))
                        {
                            TooltipHandler.TipRegion(rect5, delegate
                            {
                                StringBuilder stringBuilder = new StringBuilder();
                                if (title.def.recruitmentResistanceOffset != 1f)
                                {
                                    stringBuilder.AppendLine("RecruitmentValueFactorRoyal".Translate() + " (" + title.def.GetLabelCapFor(base.SelPawn) + ")" + ": " + title.def.recruitmentResistanceFactor.ToStringPercent());
                                }
                                if (title.def.recruitmentResistanceOffset != 0f)
                                {
                                    string t2 = title.def.recruitmentDifficultyOffset.ToStringByStyle(ToStringStyle.FloatMaxOne, ToStringNumberSense.Offset);
                                    stringBuilder.AppendLine("RecruitmentValueOffsetRoyal".Translate() + " (" + title.def.GetLabelCapFor(base.SelPawn) + ")" + ": " + t2);
                                }
                                return(stringBuilder.ToString().TrimEndNewlines());
                            }, 947584755);
                            Widgets.DrawHighlight(rect5);
                        }
                    }
                }
                listing_Standard.Label("SlavePrice".Translate() + ": " + base.SelPawn.GetStatValue(StatDefOf.MarketValue).ToStringMoney());
                TaggedString t;
                if (base.SelPawn.Faction == null || base.SelPawn.Faction.IsPlayer || !base.SelPawn.Faction.CanChangeGoodwillFor(Faction.OfPlayer, 1))
                {
                    t = "None".Translate();
                }
                else
                {
                    bool isHealthy;
                    int  goodwillGainForPrisonerRelease = base.SelPawn.Faction.GetGoodwillGainForPrisonerRelease(base.SelPawn, out isHealthy);
                    t = ((!isHealthy) ? ("None".Translate() + " (" + "UntendedInjury".Translate().ToLower() + ")") : (base.SelPawn.Faction.NameColored + " " + goodwillGainForPrisonerRelease.ToStringWithSign()));
                }
                TooltipHandler.TipRegionByKey(listing_Standard.Label("PrisonerReleasePotentialRelationGains".Translate() + ": " + t), "PrisonerReleaseRelationGainsDesc");
                if (base.SelPawn.guilt.IsGuilty)
                {
                    listing_Standard.Label("ConsideredGuilty".Translate(base.SelPawn.guilt.TicksUntilInnocent.ToStringTicksToPeriod().Colorize(ColoredText.DateTimeColor)));
                }
                int    num   = (int)PrisonBreakUtility.InitiatePrisonBreakMtbDays(base.SelPawn);
                string text2 = "PrisonBreakMTBDays".Translate() + ": ";
                text2 = ((!base.SelPawn.Awake()) ? ((string)(text2 + "NotWhileAsleep".Translate())) : ((num >= 0) ? (text2 + "PeriodDays".Translate(num).ToString().Colorize(ColoredText.DateTimeColor)) : ((string)(text2 + "Never".Translate()))));
                TooltipHandler.TipRegionByKey(listing_Standard.Label(text2), "PrisonBreakMTBDaysDescription");
                Rect rect6 = listing_Standard.GetRect(160f).Rounded();
                Widgets.DrawMenuSection(rect6);
                Rect position = rect6.ContractedBy(10f);
                GUI.BeginGroup(position);
                Rect rect7 = new Rect(0f, 0f, position.width, 30f);
                foreach (PrisonerInteractionModeDef item in DefDatabase <PrisonerInteractionModeDef> .AllDefs.OrderBy((PrisonerInteractionModeDef pim) => pim.listOrder))
                {
                    if (!flag || item.allowOnWildMan)
                    {
                        if (Widgets.RadioButtonLabeled(rect7, item.LabelCap, base.SelPawn.guest.interactionMode == item))
                        {
                            base.SelPawn.guest.interactionMode = item;
                            if (item == PrisonerInteractionModeDefOf.Execution && base.SelPawn.MapHeld != null && !ColonyHasAnyWardenCapableOfViolence(base.SelPawn.MapHeld))
                            {
                                Messages.Message("MessageCantDoExecutionBecauseNoWardenCapableOfViolence".Translate(), base.SelPawn, MessageTypeDefOf.CautionInput, historical: false);
                            }
                        }
                        rect7.y += 28f;
                    }
                }
                GUI.EndGroup();
            }
            listing_Standard.End();
            size = new Vector2(280f, listing_Standard.CurHeight + 10f + 24f);
        }
コード例 #22
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.FrameDisplayed);
            Text.Font = GameFont.Small;
            Rect rect  = new Rect(0f, 0f, this.size.x, this.size.y);
            Rect rect2 = rect.ContractedBy(10f);

            rect2.yMin += 24f;
            bool             isPrisonerOfColony = base.SelPawn.IsPrisonerOfColony;
            Listing_Standard listing_Standard   = new Listing_Standard();

            listing_Standard.Begin(rect2);
            Rect rect3 = listing_Standard.GetRect(Text.LineHeight);

            rect3.width *= 0.75f;
            bool getsFood = base.SelPawn.guest.GetsFood;

            Widgets.CheckboxLabeled(rect3, "GetsFood".Translate(), ref getsFood, false);
            base.SelPawn.guest.GetsFood = getsFood;
            listing_Standard.Gap(12f);
            Rect rect4 = listing_Standard.GetRect(28f);

            rect4.width = 140f;
            MedicalCareUtility.MedicalCareSetter(rect4, ref base.SelPawn.playerSettings.medCare);
            listing_Standard.Gap(4f);
            if (isPrisonerOfColony)
            {
                listing_Standard.Label("RecruitmentDifficulty".Translate() + ": " + base.SelPawn.RecruitDifficulty(Faction.OfPlayer, false).ToStringPercent(), -1f);
                if (base.SelPawn.guilt.IsGuilty)
                {
                    listing_Standard.Label("ConsideredGuilty".Translate(new object[]
                    {
                        base.SelPawn.guilt.TicksUntilInnocent.ToStringTicksToPeriod(true, false, true)
                    }), -1f);
                }
                if (Prefs.DevMode)
                {
                    listing_Standard.Label("Dev: Prison break MTB days: " + (int)PrisonBreakUtility.InitiatePrisonBreakMtbDays(base.SelPawn), -1f);
                }
                Rect rect5 = listing_Standard.GetRect(200f).Rounded();
                Widgets.DrawMenuSection(rect5);
                Rect position = rect5.ContractedBy(10f);
                GUI.BeginGroup(position);
                Rect rect6 = new Rect(0f, 0f, position.width, 30f);
                foreach (PrisonerInteractionModeDef current in from pim in DefDatabase <PrisonerInteractionModeDef> .AllDefs
                         orderby pim.listOrder
                         select pim)
                {
                    if (Widgets.RadioButtonLabeled(rect6, current.LabelCap, base.SelPawn.guest.interactionMode == current))
                    {
                        base.SelPawn.guest.interactionMode = current;
                        if (current == PrisonerInteractionModeDefOf.Execution && base.SelPawn.MapHeld != null && !this.ColonyHasAnyWardenCapableOfViolence(base.SelPawn.MapHeld))
                        {
                            Messages.Message("MessageCantDoExecutionBecauseNoWardenCapableOfViolence".Translate(), base.SelPawn, MessageTypeDefOf.CautionInput);
                        }
                    }
                    rect6.y += 28f;
                }
                GUI.EndGroup();
            }
            listing_Standard.End();
        }
コード例 #23
0
ファイル: LessonAutoActivator.cs プロジェクト: potsh/RimWorld
        private static ConceptDef MostDesiredConcept()
        {
            float             num    = -9999f;
            ConceptDef        result = null;
            List <ConceptDef> allDefsListForReading = DefDatabase <ConceptDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                ConceptDef conceptDef = allDefsListForReading[i];
                float      desire     = GetDesire(conceptDef);
                if (desire > num && (!conceptDef.needsOpportunity || !(GetOpportunity(conceptDef) < 0.1f)) && !(PlayerKnowledgeDatabase.GetKnowledge(conceptDef) > 0.15f))
                {
                    num    = desire;
                    result = conceptDef;
                }
            }
            return(result);
        }
コード例 #24
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    draft              = new Command_Toggle();
                    draft.hotKey       = KeyBindingDefOf.Command_ColonistDraft;
                    draft.isActive     = new Func <bool>(base.get_Drafted);
                    draft.toggleAction = delegate()
                    {
                        base.Drafted = !base.Drafted;
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Drafting, KnowledgeAmount.SpecificInteraction);
                        if (base.Drafted)
                        {
                            LessonAutoActivator.TeachOpportunity(ConceptDefOf.QueueOrders, OpportunityType.GoodToKnow);
                        }
                    };
                    draft.defaultDesc  = "CommandToggleDraftDesc".Translate();
                    draft.icon         = TexCommand.Draft;
                    draft.turnOnSound  = SoundDefOf.DraftOn;
                    draft.turnOffSound = SoundDefOf.DraftOff;
                    if (!base.Drafted)
                    {
                        draft.defaultLabel = "CommandDraftLabel".Translate();
                    }
                    if (this.pawn.Downed)
                    {
                        draft.Disable("IsIncapped".Translate(new object[]
                        {
                            this.pawn.LabelShort
                        }));
                    }
                    if (!base.Drafted)
                    {
                        draft.tutorTag = "Draft";
                    }
                    else
                    {
                        draft.tutorTag = "Undraft";
                    }
                    this.$current = draft;
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    if (base.Drafted && this.pawn.equipment.Primary != null && this.pawn.equipment.Primary.def.IsRangedWeapon)
                    {
                        Command_Toggle toggleFireAtWill = new Command_Toggle();
                        toggleFireAtWill.hotKey       = KeyBindingDefOf.Misc6;
                        toggleFireAtWill.isActive     = new Func <bool>(base.get_FireAtWill);
                        toggleFireAtWill.toggleAction = delegate()
                        {
                            base.FireAtWill = !base.FireAtWill;
                        };
                        toggleFireAtWill.icon         = TexCommand.FireAtWill;
                        toggleFireAtWill.defaultLabel = "CommandFireAtWillLabel".Translate();
                        toggleFireAtWill.defaultDesc  = "CommandFireAtWillDesc".Translate();
                        toggleFireAtWill.tutorTag     = "FireAtWillToggle";
                        this.$current = toggleFireAtWill;
                        if (!this.$disposing)
                        {
                            this.$PC = 2;
                        }
                        return(true);
                    }
                    break;

                case 2u:
                    break;

                default:
                    return(false);
                }
                this.$PC = -1;
                return(false);
            }
コード例 #25
0
 protected override Zone MakeNewZone()
 {
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.GrowingFood, KnowledgeAmount.Total);
     return(new Zone_Growing(Find.VisibleMap.zoneManager));
 }
コード例 #26
0
        private Rect DrawInfoPane(ConceptDef conc)
        {
            float knowledge       = PlayerKnowledgeDatabase.GetKnowledge(conc);
            bool  complete        = PlayerKnowledgeDatabase.IsComplete(conc);
            bool  drawProgressBar = !complete && knowledge > 0f;

            Text.Font = GameFont.Medium;
            float titleHeight = Text.CalcHeight(conc.LabelCap, 276f);

            Text.Font = GameFont.Small;
            float textHeight = Text.CalcHeight(conc.HelpTextAdjusted, 296f);
            float num        = titleHeight + textHeight + 14f + 5f;

            if (this.selectedConcept == conc)
            {
                num += 40f;
            }
            if (drawProgressBar)
            {
                num += 30f;
            }
            Rect outRect  = new Rect((float)UI.screenWidth - 8f - 200f - 8f - 310f, 8f, 310f, num);
            Rect outRect2 = outRect;

            Find.WindowStack.ImmediateWindow(987612111, outRect, WindowLayer.Super, delegate
            {
                outRect   = outRect.AtZero();
                Rect rect = outRect.ContractedBy(7f);
                Widgets.DrawShadowAround(outRect);
                Widgets.DrawWindowBackgroundTutor(outRect);
                Rect rect2   = rect;
                rect2.width -= 20f;
                rect2.height = titleHeight + 5f;
                Text.Font    = GameFont.Medium;
                Widgets.Label(rect2, conc.LabelCap);
                Text.Font    = GameFont.Small;
                Rect rect3   = rect;
                rect3.yMin   = rect2.yMax;
                rect3.height = textHeight;
                Widgets.Label(rect3, conc.HelpTextAdjusted);
                if (drawProgressBar)
                {
                    Rect rect4   = rect;
                    rect4.yMin   = rect3.yMax;
                    rect4.height = 30f;
                    Widgets.FillableBar(rect4, PlayerKnowledgeDatabase.GetKnowledge(conc), LearningReadout.ProgressBarFillTex);
                }
                if (this.selectedConcept == conc)
                {
                    if (Widgets.CloseButtonFor(outRect))
                    {
                        this.selectedConcept = null;
                        SoundDefOf.PageChange.PlayOneShotOnCamera(null);
                    }
                    Rect rect5 = new Rect(rect.center.x - 70f, rect.yMax - 30f, 140f, 30f);
                    if (!complete)
                    {
                        if (Widgets.ButtonText(rect5, "MarkLearned".Translate(), true, false, true))
                        {
                            this.selectedConcept = null;
                            SoundDefOf.PageChange.PlayOneShotOnCamera(null);
                            PlayerKnowledgeDatabase.SetKnowledge(conc, 1f);
                        }
                    }
                    else
                    {
                        GUI.color   = new Color(1f, 1f, 1f, 0.5f);
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(rect5, "AlreadyLearned".Translate());
                        Text.Anchor = TextAnchor.UpperLeft;
                        GUI.color   = Color.white;
                    }
                }
            }, false, false, 1f);
            return(outRect2);
        }
コード例 #27
0
 static PlayerKnowledgeDatabase()
 {
     PlayerKnowledgeDatabase.ReloadAndRebind();
 }
コード例 #28
0
 protected override void FinalizeDesignationSucceeded()
 {
     base.FinalizeDesignationSucceeded();
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Mining, KnowledgeAmount.SpecificInteraction);
 }
コード例 #29
0
 private static void DoModalDialogIfNotKnownInner(ConceptDef conc, string msg)
 {
     Find.WindowStack.Add(new Dialog_MessageBox(msg));
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(conc, KnowledgeAmount.Total);
 }
コード例 #30
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect            rect            = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);
            Rect            rect2           = rect.ContractedBy(6f);
            Command_Psycast command_Psycast = ((MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow)?.LastMouseoverGizmo as Command_Psycast;
            float           num             = Mathf.Repeat(Time.time, 0.85f);
            float           num2            = 1f;

            if (num < 0.1f)
            {
                num2 = num / 0.1f;
            }
            else if (num >= 0.25f)
            {
                num2 = 1f - (num - 0.25f) / 0.6f;
            }
            Widgets.DrawWindowBackground(rect);
            Text.Font = GameFont.Small;
            Rect rect3 = rect2;

            rect3.y     += 6f;
            rect3.height = Text.LineHeight;
            Widgets.Label(rect3, "PsychicEntropyShort".Translate());
            Rect rect4 = rect2;

            rect4.y     += 38f;
            rect4.height = Text.LineHeight;
            Widgets.Label(rect4, "PsyfocusLabelGizmo".Translate());
            Rect rect5 = rect2;

            rect5.x     += 63f;
            rect5.y     += 6f;
            rect5.width  = 100f;
            rect5.height = 22f;
            float entropyRelativeValue = tracker.EntropyRelativeValue;

            Widgets.FillableBar(rect5, Mathf.Min(entropyRelativeValue, 1f), EntropyBarTex, EmptyBarTex, doBorder: true);
            if (tracker.EntropyValue > tracker.MaxEntropy)
            {
                Widgets.FillableBar(rect5, Mathf.Min(entropyRelativeValue - 1f, 1f), OverLimitBarTex, EntropyBarTex, doBorder: true);
            }
            if (command_Psycast != null)
            {
                Ability ability = command_Psycast.Ability;
                if (ability.def.EntropyGain > float.Epsilon)
                {
                    Rect  rect6 = rect5.ContractedBy(3f);
                    float width = rect6.width;
                    float num3  = tracker.EntropyToRelativeValue(tracker.EntropyValue + ability.def.EntropyGain);
                    float num4  = entropyRelativeValue;
                    if (num4 > 1f)
                    {
                        num4 -= 1f;
                        num3 -= 1f;
                    }
                    rect6.xMin  = Widgets.AdjustCoordToUIScalingFloor(rect6.xMin + num4 * width);
                    rect6.width = Widgets.AdjustCoordToUIScalingFloor(Mathf.Max(Mathf.Min(num3, 1f) - num4, 0f) * width);
                    GUI.color   = new Color(1f, 1f, 1f, num2 * 0.7f);
                    GenUI.DrawTextureWithMaterial(rect6, EntropyBarTexAdd, null);
                    GUI.color = Color.white;
                }
            }
            if (tracker.EntropyValue > tracker.MaxEntropy)
            {
                foreach (KeyValuePair <PsychicEntropySeverity, float> entropyThreshold in Pawn_PsychicEntropyTracker.EntropyThresholds)
                {
                    if (entropyThreshold.Value > 1f && entropyThreshold.Value < 2f)
                    {
                        DrawThreshold(rect5, entropyThreshold.Value - 1f, entropyRelativeValue);
                    }
                }
            }
            string label = tracker.EntropyValue.ToString("F0") + " / " + tracker.MaxEntropy.ToString("F0");

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect5, label);
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Tiny;
            GUI.color   = Color.white;
            Rect rect7 = rect2;

            rect7.width  = 175f;
            rect7.height = 38f;
            TooltipHandler.TipRegion(rect7, delegate
            {
                float f = tracker.EntropyValue / tracker.RecoveryRate;
                return(string.Format("PawnTooltipPsychicEntropyStats".Translate(), Mathf.Round(tracker.EntropyValue), Mathf.Round(tracker.MaxEntropy), tracker.RecoveryRate.ToString("0.#"), Mathf.Round(f)) + "\n\n" + "PawnTooltipPsychicEntropyDesc".Translate());
            }, Gen.HashCombineInt(tracker.GetHashCode(), 133858));
            Rect rect8 = rect2;

            rect8.x     += 63f;
            rect8.y     += 38f;
            rect8.width  = 100f;
            rect8.height = 22f;
            bool flag = Mouse.IsOver(rect8);

            Widgets.FillableBar(rect8, Mathf.Min(tracker.CurrentPsyfocus, 1f), flag ? PsyfocusBarHighlightTex : PsyfocusBarTex, EmptyBarTex, doBorder: true);
            if (command_Psycast != null)
            {
                float min = command_Psycast.Ability.def.PsyfocusCostRange.min;
                if (min > float.Epsilon)
                {
                    Rect  rect9  = rect8.ContractedBy(3f);
                    float num5   = Mathf.Max(tracker.CurrentPsyfocus - min, 0f);
                    float width2 = rect9.width;
                    rect9.xMin  = Widgets.AdjustCoordToUIScalingFloor(rect9.xMin + num5 * width2);
                    rect9.width = Widgets.AdjustCoordToUIScalingCeil((tracker.CurrentPsyfocus - num5) * width2);
                    GUI.color   = new Color(1f, 1f, 1f, num2);
                    GenUI.DrawTextureWithMaterial(rect9, PsyfocusBarTexReduce, null);
                    GUI.color = Color.white;
                }
            }
            for (int i = 1; i < Pawn_PsychicEntropyTracker.PsyfocusBandPercentages.Count - 1; i++)
            {
                DrawThreshold(rect8, Pawn_PsychicEntropyTracker.PsyfocusBandPercentages[i], tracker.CurrentPsyfocus);
            }
            float num6     = Mathf.Clamp(Mathf.Round((Event.current.mousePosition.x - (rect8.x + 3f)) / (rect8.width - 8f) * 16f) / 16f, 0f, 1f);
            Event current2 = Event.current;

            if (current2.type == EventType.MouseDown && current2.button == 0 && flag)
            {
                selectedPsyfocusTarget = num6;
                draggingPsyfocusBar    = true;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MeditationDesiredPsyfocus, KnowledgeAmount.Total);
                SoundDefOf.DragSlider.PlayOneShotOnCamera();
                current2.Use();
            }
            if (current2.type == EventType.MouseDrag && current2.button == 0 && draggingPsyfocusBar && flag)
            {
                if (Math.Abs(num6 - selectedPsyfocusTarget) > float.Epsilon)
                {
                    SoundDefOf.DragSlider.PlayOneShotOnCamera();
                }
                selectedPsyfocusTarget = num6;
                current2.Use();
            }
            if (current2.type == EventType.MouseUp && current2.button == 0 && draggingPsyfocusBar)
            {
                if (selectedPsyfocusTarget >= 0f)
                {
                    tracker.SetPsyfocusTarget(selectedPsyfocusTarget);
                }
                selectedPsyfocusTarget = -1f;
                draggingPsyfocusBar    = false;
                current2.Use();
            }
            UIHighlighter.HighlightOpportunity(rect8, "PsyfocusBar");
            DrawPsyfocusTarget(rect8, draggingPsyfocusBar ? selectedPsyfocusTarget : tracker.TargetPsyfocus);
            GUI.color = Color.white;
            Rect rect10 = rect2;

            rect10.y     += 38f;
            rect10.width  = 175f;
            rect10.height = 38f;
            TooltipHandler.TipRegion(rect10, () => tracker.PsyfocusTipString_NewTemp(selectedPsyfocusTarget), Gen.HashCombineInt(tracker.GetHashCode(), 133873));
            if (tracker.Pawn.IsColonistPlayerControlled)
            {
                float num7   = 32f;
                float num8   = 4f;
                float num9   = rect2.height / 2f - num7 + num8;
                float num10  = rect2.width - num7;
                Rect  rect11 = new Rect(rect2.x + num10, rect2.y + num9, num7, num7);
                if (Widgets.ButtonImage(rect11, tracker.limitEntropyAmount ? LimitedTex : UnlimitedTex))
                {
                    tracker.limitEntropyAmount = !tracker.limitEntropyAmount;
                    if (tracker.limitEntropyAmount)
                    {
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                    }
                    else
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    }
                }
                TooltipHandler.TipRegionByKey(rect11, "PawnTooltipPsychicEntropyLimit");
            }
            if (tracker.PainMultiplier > 1f)
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleCenter;
                string recoveryBonus = (tracker.PainMultiplier - 1f).ToStringPercent("F0");
                string text          = recoveryBonus;
                float  widthCached   = text.GetWidthCached();
                Rect   rect12        = rect2;
                rect12.x     += rect2.width - widthCached / 2f - 16f;
                rect12.y     += 38f;
                rect12.width  = widthCached;
                rect12.height = Text.LineHeight;
                GUI.color     = PainBoostColor;
                Widgets.Label(rect12, text);
                GUI.color   = Color.white;
                Text.Font   = GameFont.Tiny;
                Text.Anchor = TextAnchor.UpperLeft;
                TooltipHandler.TipRegion(rect12.ContractedBy(-1f), () => "PawnTooltipPsychicEntropyPainFocus".Translate(tracker.Pawn.health.hediffSet.PainTotal.ToStringPercent("F0"), recoveryBonus), Gen.HashCombineInt(tracker.GetHashCode(), 133878));
            }
            return(new GizmoResult(GizmoState.Clear));
        }