Exemplo n.º 1
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            AbilityDef def  = ability.def;
            Pawn       pawn = ability.pawn;

            disabled = false;
            if (def.EntropyGain > float.Epsilon)
            {
                Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => h.def == HediffDefOf.PsychicAmplifier);
                if (hediff == null || hediff.Severity < (float)def.level)
                {
                    DisableWithReason("CommandPsycastHigherLevelPsylinkRequired".Translate(def.level));
                }
                else if (pawn.psychicEntropy.WouldOverflowEntropy(def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(pawn)))
                {
                    DisableWithReason("CommandPsycastWouldExceedEntropy".Translate(def.label));
                }
            }
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);
            float       num    = topLeft.y + 3f;
            float       num2   = ((def.EntropyGain > float.Epsilon) ? 15 : 0) + ((def.PsyfocusCost > float.Epsilon) ? 15 : 0);

            if (num2 > 0f)
            {
                GUI.DrawTexture(new Rect(topLeft.x + GetWidth(maxWidth) - 38f, num, 43f, num2), TexUI.GrayTextBG);
            }
            Text.Font = GameFont.Tiny;
            if (def.EntropyGain > float.Epsilon)
            {
                TaggedString taggedString = "NeuralHeatLetter".Translate() + ": " + def.EntropyGain.ToString();
                float        x            = Text.CalcSize(taggedString).x;
                Rect         rect         = new Rect(topLeft.x + GetWidth(maxWidth) - x - 2f, num, x, 18f);
                Widgets.Label(rect, taggedString);
                num += rect.height - 4f;
            }
            if (def.PsyfocusCost > float.Epsilon)
            {
                TaggedString taggedString2 = "PsyfocusLetter".Translate() + ": " + def.PsyfocusCost.ToStringPercent();
                float        x2            = Text.CalcSize(taggedString2).x;
                Widgets.Label(new Rect(topLeft.x + GetWidth(maxWidth) - x2 - 2f, num, x2, 18f), taggedString2);
            }
            return(result);
        }
        protected override void DisabledCheck()
        {
            AbilityDef def  = ability.def;
            Pawn       pawn = ability.pawn;

            disabled = false;
            if (def.EntropyGain > float.Epsilon)
            {
                Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => h.def == HediffDefOf.PsychicAmplifier);
                if (hediff == null || hediff.Severity < (float)def.level)
                {
                    DisableWithReason("CommandPsycastHigherLevelPsylinkRequired".Translate(def.level));
                }
                else if (pawn.psychicEntropy.WouldOverflowEntropy(def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(pawn)))
                {
                    DisableWithReason("CommandPsycastWouldExceedEntropy".Translate(def.label));
                }
            }
            base.DisabledCheck();
        }
Exemplo n.º 3
0
        public override bool GizmoDisabled(out string reason)
        {
            if (pawn.psychicEntropy.PsychicSensitivity < float.Epsilon)
            {
                reason = "CommandPsycastZeroPsychicSensitivity".Translate();
                return(true);
            }
            float num = PsycastUtility.TotalPsyfocusCostOfQueuedPsycasts(pawn);

            if (def.level > 0 && pawn.GetPsylinkLevel() < def.level)
            {
                reason = "CommandPsycastHigherLevelPsylinkRequired".Translate(def.level);
                return(true);
            }
            if (def.PsyfocusCost + num > pawn.psychicEntropy.CurrentPsyfocus + 0.0005f)
            {
                reason = "CommandPsycastNotEnoughPsyfocus".Translate(def.PsyfocusCostPercent, (pawn.psychicEntropy.CurrentPsyfocus - num).ToStringPercent("0.#"), def.label.Named("PSYCASTNAME"), pawn.Named("CASTERNAME"));
                return(true);
            }
            if (def.level > pawn.psychicEntropy.MaxAbilityLevel)
            {
                reason = "CommandPsycastLowPsyfocus".Translate(Pawn_PsychicEntropyTracker.PsyfocusBandPercentages[def.RequiredPsyfocusBand].ToStringPercent());
                return(true);
            }
            if (def.EntropyGain > float.Epsilon && pawn.psychicEntropy.WouldOverflowEntropy(def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(pawn)))
            {
                reason = "CommandPsycastWouldExceedEntropy".Translate(def.label);
                return(true);
            }
            return(base.GizmoDisabled(out reason));
        }
Exemplo n.º 4
0
        public override bool GizmoDisabled(out string reason)
        {
            if (pawn.GetStatValue(StatDefOf.PsychicSensitivity) < float.Epsilon)
            {
                reason = "CommandPsycastZeroPsychicSensitivity".Translate();
                return(true);
            }
            Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PsychicAmplifier);

            if ((firstHediffOfDef == null || firstHediffOfDef.Severity < (float)def.level) && def.level > 0)
            {
                reason = "CommandPsycastHigherLevelPsylinkRequired".Translate(def.level);
                return(true);
            }
            if (def.level > pawn.psychicEntropy.MaxAbilityLevel)
            {
                reason = "CommandPsycastLowPsyfocus".Translate(Pawn_PsychicEntropyTracker.PsyfocusBandPercentages[def.RequiredPsyfocusBand].ToStringPercent());
                return(true);
            }
            if (def.PsyfocusCost > pawn.psychicEntropy.CurrentPsyfocus)
            {
                reason = "CommandPsycastNotEnoughPsyfocus".Translate(def.PsyfocusCost.ToStringPercent(), pawn.psychicEntropy.CurrentPsyfocus.ToStringPercent(), def.label.Named("PSYCASTNAME"), pawn.Named("CASTERNAME"));
                return(true);
            }
            if (def.EntropyGain > float.Epsilon && pawn.psychicEntropy.WouldOverflowEntropy(def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(pawn)))
            {
                reason = "CommandPsycastWouldExceedEntropy".Translate(def.label);
                return(true);
            }
            return(base.GizmoDisabled(out reason));
        }
Exemplo n.º 5
0
        public override bool ValidateTarget(LocalTargetInfo target)
        {
            if (!base.ValidateTarget(target))
            {
                return(false);
            }
            if (CasterPawn.psychicEntropy.PsychicSensitivity < float.Epsilon)
            {
                Messages.Message("CommandPsycastZeroPsychicSensitivity".Translate(), caster, MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            if (Psycast.def.EntropyGain > float.Epsilon && CasterPawn.psychicEntropy.WouldOverflowEntropy(Psycast.def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(CasterPawn)))
            {
                Messages.Message("CommandPsycastWouldExceedEntropy".Translate(), caster, MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            float num  = Psycast.FinalPsyfocusCost(target);
            float num2 = PsycastUtility.TotalPsyfocusCostOfQueuedPsycasts(CasterPawn);
            float num3 = num + num2;

            if (num > float.Epsilon && num3 > CasterPawn.psychicEntropy.CurrentPsyfocus + 0.0005f)
            {
                Messages.Message("CommandPsycastNotEnoughPsyfocus".Translate(num3.ToStringPercent("0.#"), (CasterPawn.psychicEntropy.CurrentPsyfocus - num2).ToStringPercent("0.#"), Psycast.def.label.Named("PSYCASTNAME"), caster.Named("CASTERNAME")), caster, MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
 public override bool ValidateTarget(LocalTargetInfo target)
 {
     if (!base.ValidateTarget(target))
     {
         return(false);
     }
     if (CasterPawn.GetStatValue(StatDefOf.PsychicSensitivity) < float.Epsilon)
     {
         Messages.Message("CommandPsycastZeroPsychicSensitivity".Translate(), caster, MessageTypeDefOf.RejectInput);
         return(false);
     }
     if (Psycast.def.EntropyGain > float.Epsilon && CasterPawn.psychicEntropy.WouldOverflowEntropy(Psycast.def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(CasterPawn)))
     {
         Messages.Message("CommandPsycastWouldExceedEntropy".Translate(), caster, MessageTypeDefOf.RejectInput);
         return(false);
     }
     return(true);
 }