Esempio n. 1
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));
        }
Esempio n. 2
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);
        }