Пример #1
0
        // Not a usable gizmo, just shows the cooldown/energy
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (User.IsColonist && !User.Drafted)
            {
                yield break;
            }

            var command = new CommandIndicator {
                defaultLabel = Def.label,
                defaultDesc  = Def.GizmoDesc,
                icon         = ContentFinder <Texture2D> .Get(Def.PathToIcon),
            };

            if (Tracker.Essence < 1e-4)
            {
                command.Disable(EssenceDisableKey.Translate(User.LabelShort, User.health.hediffSet.CountAddedAndImplantedParts()));
            }
            else if (Tracker.PsychicSensitivity < 1e-4)
            {
                command.Disable(SensitivityDisableKey.Translate(User.LabelShort, Tracker.PsychicSensitivity));
            }
            else if (cooldownTicker > 0)   // We're on cooldown
            {
                command.Disable(OnCooldownKey.Translate(Def.label, cooldownTicker.TicksToHours().ToString("0.0")));
            }
            else if (!Tracker.CanUseEnergy(Def.EnergyPerUse))   // Not enough energy to cast
            {
                command.Disable(NotEnoughEnergyKey.Translate(Def.label, Tracker.CurrentEnergy.ToString("0.0"), Def.EnergyPerUse));
            }

            yield return(command);
        }
Пример #2
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (User.IsColonist && !User.Drafted)
            {
                yield break;
            }

            Command command;

            if (User.IsColonist)
            {
                command = new CommandPsionic {
                    Ability      = this,
                    Caster       = User,
                    defaultLabel = Def.label,
                    defaultDesc  = Def.GizmoDesc,
                    icon         = ContentFinder <Texture2D> .Get(Def.PathToIcon)
                };
            }
            else
            {
                command = new CommandIndicator {
                    Ability      = this,
                    Caster       = User,
                    defaultLabel = Def.label,
                    defaultDesc  = Def.GizmoDesc,
                    icon         = ContentFinder <Texture2D> .Get(Def.PathToIcon)
                };
            }

            if (Tracker.Essence < 1e-4)
            {
                command.Disable(EssenceDisableKey.Translate(User.LabelShort, User.health.hediffSet.CountAddedAndImplantedParts()));
            }
            else if (Tracker.PsychicSensitivity < 1e-4)
            {
                command.Disable(SensitivityDisableKey.Translate(User.LabelShort, Tracker.PsychicSensitivity));
            }
            else if (!Tracker.CanUseActiveAbilities())   // Pawn has projection disabled
            {
                command.Disable(ProjectionDisabledKey.Translate(User.LabelShort));
            }
            else if (cooldownTicker > 0)   // We're on cooldown
            {
                command.Disable(OnCooldownKey.Translate(Def.label, cooldownTicker.TicksToHours().ToString("0.0")));
            }
            else if (!Tracker.CanUseEnergy(Def.EnergyPerUse))   // Not enough energy to cast
            {
                command.Disable(NotEnoughEnergyKey.Translate(Def.label, Tracker.CurrentEnergy.ToString("0.0"), Def.EnergyPerUse));
            }
            else if (command is CommandPsionic psi)  // We've got enough energy and we're off cooldown
            {
                var job = JobMaker.MakeJob(PsiTechDefOf.PTBurstPsionic, User);
                job.verbToUse = Verb;
                psi.action    = () => { User.jobs.TryTakeOrderedJob(job); };
            }

            yield return(command);
        }
Пример #3
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (User.IsColonist && !User.Drafted)
            {
                yield break;
            }

            Command command;

            if (User.IsColonist)
            {
                command = new CommandTargetedPsionic {
                    Ability         = this,
                    Caster          = User,
                    defaultLabel    = Def.label,
                    defaultDesc     = Def.GizmoDesc,
                    icon            = ContentFinder <Texture2D> .Get(Def.PathToIcon),
                    targetingParams = TargetingParameters.ForAttackAny(),
                };
            }
            else
            {
                command = new CommandIndicator {
                    Ability      = this,
                    Caster       = User,
                    defaultLabel = Def.label,
                    defaultDesc  = Def.GizmoDesc,
                    icon         = ContentFinder <Texture2D> .Get(Def.PathToIcon)
                };
            }

            if (Tracker.Essence < 1e-4)
            {
                command.Disable(EssenceDisableKey.Translate(User.LabelShort, User.health.hediffSet.CountAddedAndImplantedParts()));
            }
            else if (Tracker.PsychicSensitivity < 1e-4)
            {
                command.Disable(SensitivityDisableKey.Translate(User.LabelShort, Tracker.PsychicSensitivity));
            }
            else if (!Tracker.CanUseActiveAbilities())   // Pawn has projection disabled
            {
                command.Disable(ProjectionDisabledKey.Translate(User.LabelShort));
            }
            else if (CooldownTicker > 0)   // We're on cooldown
            {
                command.Disable(OnCooldownKey.Translate(Def.label, CooldownTicker.TicksToHours().ToString("0.0")));
            }
            else if (!Tracker.CanUseEnergy(Def.EnergyPerUse))   // Not enough energy to cast
            {
                command.Disable(NotEnoughEnergyKey.Translate(Def.label, Tracker.CurrentEnergy.ToString("0.0"), Def.EnergyPerUse));
            }
            else if (command is CommandTargetedPsionic psi) // We've got enough energy and we're off cooldown
            {
                psi.action = target => {
                    if (!User.Position.InHorDistOf(target.Position, Def.Range) || !(target is Pawn pawn) || !Def.TargetValidator.IsValidTarget(User, pawn))
                    {
                        return;
                    }
                    // We're in range and have a valid target
                    var job = JobMaker.MakeJob(PsiTechDefOf.PTSingleTargetPsionic, User, pawn);
                    job.verbToUse = Verb;
                    User.jobs.TryTakeOrderedJob(job);
                };
            }

            yield return(command);
        }