예제 #1
0
        public static void SelectAndConfigureAutocastProfile(ref PsiTechAbility ability)
        {
            if (!profileCache.TryGetValue(ability.Def, out var profiles))
            {
                Log.Warning("PsiTech tried to retrieve an autocast profile for " + ability.Def.defName + ", which doesn't have any configured.");
                return;
            }

            var profile = profiles.RandomElement();

            ability.AutocastFilter.User             = ability.User;
            ability.AutocastFilter.Ability          = ability;
            ability.AutocastFilter.FilterTargetType = profile.TargetType;
            ability.AutocastFilter.TargetRange      = profile.TargetRange;
            switch (ability.AutocastFilter)
            {
            case AutocastFilter_SingleTarget single: {
                single.MinSuccessChance = profile.MinSuccessChance;

                if (!(Activator.CreateInstance(profile.Selector.SelectorClass) is AutocastFilterSelector instance))
                {
                    Log.Error("PsiTech tried to instantiate an AutocastFilterSelector of type " +
                              profile.Selector.SelectorClass +
                              " and failed. This indicates a misconfigured filter selector def or profile.");
                }
예제 #2
0
        private void RebuildTabCache()
        {
            tabs.Clear();

            var abilities = pawn.PsiTracker().Abilities.Where(ability => ability.Def.Autocastable).ToList();

            foreach (var ability in abilities)
            {
                string title;
                if (ability.Autocast)
                {
                    title = "[A] " + ability.Def.LabelCap;

                    switch (ability.Priority)
                    {
                    case AbilityPriority.High:
                        title += " +";
                        break;

                    case AbilityPriority.Low:
                        title += " -";
                        break;
                    }
                }
                else
                {
                    title = ability.Def.LabelCap;
                }

                tabs.Add(new TabRecord(title, () => curAbility = ability, () => curAbility == ability));
            }
        }
예제 #3
0
        private void Setup()
        {
            forcePause              = true;
            doCloseButton           = false;
            doCloseX                = true;
            absorbInputAroundWindow = true;
            closeOnClickedOutside   = true;
            soundAppear             = SoundDefOf.InfoCard_Open;
            soundClose              = SoundDefOf.InfoCard_Close;

            var abilities = pawn.PsiTracker().Abilities.Where(ability => ability.Def.Autocastable).ToList();

            curAbility = abilities.First();

            RebuildTabCache();
            RebuildConditionCache();

            lastAutocastSetting = curAbility.Autocast;
            lastPrioritySetting = curAbility.Priority;
            lastConditionsCount = curAbility.AutocastConditions.Count;
        }
예제 #4
0
 private static IEnumerable <Widgets.DropdownMenuElement <string> > GeneratePriorityOptions(PsiTechAbility ability)
 {
     foreach (AbilityPriority priorityType in Enum.GetValues(typeof(AbilityPriority)))
     {
         yield return(new Widgets.DropdownMenuElement <string> {
             payload = "",
             option = new FloatMenuOption(LocalizePriority(priorityType),
                                          () => { ability.Priority = priorityType; })
         });
     }
 }
 public override Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool inverted)
 {
     return(inverted
         ? targets.MaxBy(target => target.Position.DistanceTo(user.Position))
         : targets.MinBy(target => target.Position.DistanceTo(user.Position)));
 }
 public override Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool invert)
 {
     return(invert
         ? targets.MinBy(target => target.health.hediffSet.PainTotal)
         : targets.MaxBy(target => target.health.hediffSet.PainTotal));
 }
 public override Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool invert)
 {
     return(invert ? targets.MinBy(AssessThreat) : targets.MaxBy(AssessThreat));
 }
예제 #8
0
 public override Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool inverted)
 {
     return(inverted
         ? targets.MaxBy(target => target.needs.mood.CurLevelPercentage)
         : targets.MinBy(target => target.needs.mood.CurLevelPercentage));
 }
 public override Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool invert)
 {
     return(invert
         ? targets.MaxBy(target => target.health.summaryHealth.SummaryHealthPercent)
         : targets.MinBy(target => target.health.summaryHealth.SummaryHealthPercent));
 }
예제 #10
0
 public abstract Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool inverted);
 public override Pawn SelectBestTarget(Pawn user, IEnumerable <Pawn> targets, PsiTechAbility ability, bool inverted)
 {
     return(inverted
         ? targets.MinBy(ability.SuccessChanceOnTarget)
         : targets.MaxBy(ability.SuccessChanceOnTarget));
 }