Пример #1
0
        private Command_VerbTarget CreateVerbTargetCommand(Thing ownerThing, Verb verb)
        {
            Command_VerbTarget command_VerbTarget = new Command_VerbTarget();

            command_VerbTarget.defaultDesc = ownerThing.LabelCap + ": " + ownerThing.def.description.CapitalizeFirst();
            command_VerbTarget.icon        = ownerThing.def.uiIcon;
            command_VerbTarget.iconAngle   = ownerThing.def.uiIconAngle;
            command_VerbTarget.iconOffset  = ownerThing.def.uiIconOffset;
            command_VerbTarget.tutorTag    = "VerbTarget";
            command_VerbTarget.verb        = verb;
            if (verb.caster.Faction != Faction.OfPlayer)
            {
                command_VerbTarget.Disable("CannotOrderNonControlled".Translate());
            }
            else if (verb.CasterIsPawn)
            {
                if (verb.CasterPawn.story.WorkTagIsDisabled(WorkTags.Violent))
                {
                    command_VerbTarget.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                }
                else if (!verb.CasterPawn.drafter.Drafted)
                {
                    command_VerbTarget.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                }
            }
            return(command_VerbTarget);
        }
Пример #2
0
        public static bool CreateVerbTargetCommandPrefix(ref Command_VerbTarget __result, Thing ownerThing, Verb verb)
        {
            Command_VerbTarget command_VerbTarget = new Command_VerbTarget();

            if (verb == null || verb.verbProps == null)
            {
                return(false);
            }
            VerbProperties_Custom verbProps = verb.verbProps as VerbProperties_Custom;

            if (verbProps != null)
            {
                command_VerbTarget.defaultDesc  = verbProps.desc;
                command_VerbTarget.defaultLabel = verbProps.label;
                Comp_VerbSaveable comp_VerbSaveable = ownerThing.TryGetComp <Comp_VerbSaveable>();
                if (comp_VerbSaveable != null && comp_VerbSaveable.currentVerb == verb)
                {
                    command_VerbTarget.icon = currentCommandTexture;
                }
                else
                {
                    command_VerbTarget.icon = verbProps.texture;
                }
            }
            else
            {
                command_VerbTarget.icon        = ownerThing.def.uiIcon;
                command_VerbTarget.defaultDesc = ownerThing.LabelCap + ": " + ownerThing.def.description.CapitalizeFirst();
            }
            command_VerbTarget.iconAngle  = ownerThing.def.uiIconAngle;
            command_VerbTarget.iconOffset = ownerThing.def.uiIconOffset;
            command_VerbTarget.tutorTag   = "VerbTarget";
            command_VerbTarget.verb       = verb;
            if (verb.caster.Faction != Faction.OfPlayer)
            {
                command_VerbTarget.Disable("CannotOrderNonControlled".Translate());
            }
            else if (verb.CasterIsPawn)
            {
                if (verb.CasterPawn.WorkTagIsDisabled(WorkTags.Violent))
                {
                    command_VerbTarget.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                }
                else if (!verb.CasterPawn.drafter.Drafted)
                {
                    command_VerbTarget.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                }
            }
            __result = command_VerbTarget;
            return(false);
        }
        public override IEnumerable <Gizmo> EquippedGizmos()
        {
            ThingWithComps owner = IsWorn ? GetWearer : parent;
            bool           flag  = Find.Selector.SingleSelectedThing == GetWearer;

            //   Log.Message(string.Format("0"));
            if (flag)
            {
                CompEquippable c = parent.GetComp <CompEquippable>();
                //   Log.Message(string.Format("there are {0} verbs", c.verbTracker.AllVerbs.Count));
                // Verb verbA = parent.def.Verbs;
                foreach (Verb v in c.verbTracker.AllVerbs)
                {
                    //   Log.Message(string.Format("v fires {0} {1}", v.verbProps.burstShotCount, v.verbProps.defaultProjectile.label));
                    if (v != v.verbTracker.PrimaryVerb && !v.IsMeleeAttack)
                    {
                        //   Log.Message(string.Format("selected v fires {0} {1}", v.verbProps.burstShotCount, v.verbProps.defaultProjectile.label));

                        verb = v;
                        Command_VerbTarget command_VerbTarget = new Command_VerbTarget();
                        command_VerbTarget.defaultDesc    = parent.LabelCap + ": " + parent.def.description.CapitalizeFirst();
                        command_VerbTarget.icon           = parent.def.uiIcon;
                        command_VerbTarget.iconAngle      = parent.def.uiIconAngle;
                        command_VerbTarget.iconOffset     = parent.def.uiIconOffset;
                        command_VerbTarget.tutorTag       = "VerbTarget";
                        command_VerbTarget.verb           = verb;
                        command_VerbTarget.verb.verbProps = verb.verbProps;
                        command_VerbTarget.verb.verbProps.defaultProjectile      = verb.verbProps.defaultProjectile;
                        command_VerbTarget.verb.verbProps.defaultCooldownTime    = verb.verbProps.defaultCooldownTime;
                        command_VerbTarget.verb.verbProps.burstShotCount         = verb.verbProps.burstShotCount;
                        command_VerbTarget.verb.verbProps.verbClass              = verb.verbProps.verbClass;
                        command_VerbTarget.verb.verbProps.warmupTime             = verb.verbProps.warmupTime;
                        command_VerbTarget.verb.verbProps.ticksBetweenBurstShots = verb.verbProps.ticksBetweenBurstShots;
                        command_VerbTarget.verb.verbProps.soundCast              = verb.verbProps.soundCast;
                        command_VerbTarget.defaultLabel  = "Fire: " + parent.def.label;
                        command_VerbTarget.activateSound = SoundDef.Named("Click");
                        if (verb.caster.Faction != Faction.OfPlayer)
                        {
                            command_VerbTarget.Disable("CannotOrderNonControlled".Translate());
                        }
                        else if (verb.CasterIsPawn)
                        {
                            if (verb.CasterPawn.story.WorkTagIsDisabled(WorkTags.Violent))
                            {
                                command_VerbTarget.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                            }
                            else if (!verb.CasterPawn.drafter.Drafted)
                            {
                                command_VerbTarget.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                            }
                        }
                        yield return(command_VerbTarget);
                    }
                    else
                    {
                        Command_Action command_Action = new Command_Action();
                        command_Action.defaultLabel = parent.def.label;
                        command_Action.defaultDesc  = "This colonist is equipped with a " + parent.def.label;
                        command_Action.hotKey       = KeyBindingDefOf.Misc2;
                        command_Action.icon         = parent.def.uiIcon;
                        command_Action.disabled     = true;
                        yield return(command_Action);
                    }
                }
            }
            yield break;
        }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget
                {
                    defaultLabel = "CommandSetForceAttackTarget".Translate(),
                    defaultDesc  = "CommandSetForceAttackTargetDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true),
                    verb         = this.AttackVerb,
                    hotKey       = KeyBindingDefOf.Misc4
                };
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action
                {
                    defaultLabel = "CommandStopForceAttack".Translate(),
                    defaultDesc  = "CommandStopForceAttackDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true),
                    action       = delegate()
                    {
                        this.ResetForcedTarget();
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                    }
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }

            /*
             * if (this.CanToggleHoldFire)
             * {
             *  yield return new Command_Toggle
             *  {
             *      defaultLabel = "CommandHoldFire".Translate(),
             *      defaultDesc = "CommandHoldFireDesc".Translate(),
             *      icon = ContentFinder<Texture2D>.Get("UI/Commands/HoldFire", true),
             *      hotKey = KeyBindingDefOf.Misc6,
             *      toggleAction = delegate ()
             *      {
             *          this.holdFire = !this.holdFire;
             *          if (this.holdFire)
             *          {
             *              this.ResetForcedTarget();
             *          }
             *      },
             *      isActive = (() => this.holdFire)
             *  };
             * }
             */
            yield break;
        }
Пример #5
0
        // Token: 0x06007DD8 RID: 32216 RVA: 0x00054920 File Offset: 0x00052B20
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            IEnumerator <Gizmo> enumerator = null;

            if (this.CanExtractShell)
            {
                AERIALChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <AERIALChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].uiIcon,
                    iconAngle = compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].uiIconAngle,
                    iconOffset = compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1]),
                    action = delegate()
                    {
                        this.ExtractShell();
                    }
                });
            }
            AERIALChangeableProjectile compChangeableProjectile2 = this.gun.TryGetComp <AERIALChangeableProjectile>();

            if (compChangeableProjectile2 != null)
            {
                StorageSettings storeSettings = compChangeableProjectile2.GetStoreSettings();
                foreach (Gizmo gizmo2 in StorageSettingsClipboard.CopyPasteGizmosFor(storeSettings))
                {
                    yield return(gizmo2);
                }
                enumerator = null;
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget command_VerbTarget = new Command_VerbTarget();
                command_VerbTarget.defaultLabel = "CommandSetForceAttackTarget".Translate();
                command_VerbTarget.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                command_VerbTarget.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                command_VerbTarget.verb       = this.AttackVerb;
                command_VerbTarget.hotKey     = KeyBindingDefOf.Misc4;
                command_VerbTarget.drawRadius = false;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    command_VerbTarget.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }

                yield return(command_VerbTarget);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandStopForceAttack".Translate();
                command_Action.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                command_Action.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                command_Action.action = delegate()
                {
                    this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    command_Action.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                command_Action.hotKey = KeyBindingDefOf.Misc5;
                yield return(command_Action);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate()
                    {
                        this.holdFire = !this.holdFire;
                        if (this.holdFire)
                        {
                            this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.holdFire)
                });
            }
            yield break;
            yield break;
        }
Пример #6
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo c = enumerator.Current;
                    yield return(c);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
                yield return((Gizmo) new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    action = delegate
                    {
                        ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_018d: stateMachine*/)._0024this.ExtractShell();
                    }
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget
                {
                    defaultLabel = "CommandSetForceAttackTarget".Translate(),
                    defaultDesc  = "CommandSetForceAttackTargetDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack"),
                    verb         = AttackVerb,
                    hotKey       = KeyBindingDefOf.Misc4
                };
                if (base.Spawned && IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return((Gizmo)attack);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action
                {
                    defaultLabel = "CommandStopForceAttack".Translate(),
                    defaultDesc  = "CommandStopForceAttackDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt"),
                    action       = delegate
                    {
                        ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0333: stateMachine*/)._0024this.ResetForcedTarget();
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                    }
                };
                if (!forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return((Gizmo)stop);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (CanToggleHoldFire)
            {
                yield return((Gizmo) new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire"),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.holdFire = !((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.holdFire;
                        if (((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.holdFire)
                        {
                            ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0426: stateMachine*/)._0024this.holdFire)
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            yield break;
IL_0460:
            /*Error near IL_0461: Unexpected return in MoveNext()*/;
        }
Пример #7
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            if (CanExtractShell)
            {
                CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
                Command_Action           command_Action           = new Command_Action();
                command_Action.defaultLabel  = "CommandExtractShell".Translate();
                command_Action.defaultDesc   = "CommandExtractShellDesc".Translate();
                command_Action.icon          = compChangeableProjectile.LoadedShell.uiIcon;
                command_Action.iconAngle     = compChangeableProjectile.LoadedShell.uiIconAngle;
                command_Action.iconOffset    = compChangeableProjectile.LoadedShell.uiIconOffset;
                command_Action.iconDrawScale = GenUI.IconDrawScale(compChangeableProjectile.LoadedShell);
                command_Action.action        = delegate
                {
                    ExtractShell();
                };
                yield return(command_Action);
            }
            CompChangeableProjectile compChangeableProjectile2 = gun.TryGetComp <CompChangeableProjectile>();

            if (compChangeableProjectile2 != null)
            {
                StorageSettings storeSettings = compChangeableProjectile2.GetStoreSettings();
                foreach (Gizmo item in StorageSettingsClipboard.CopyPasteGizmosFor(storeSettings))
                {
                    yield return(item);
                }
            }
            if (CanSetForcedTarget)
            {
                Command_VerbTarget command_VerbTarget = new Command_VerbTarget();
                command_VerbTarget.defaultLabel = "CommandSetForceAttackTarget".Translate();
                command_VerbTarget.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                command_VerbTarget.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack");

                command_VerbTarget.verb       = AttackVerb;
                command_VerbTarget.hotKey     = KeyBindingDefOf.Misc4;
                command_VerbTarget.drawRadius = false;
                if (base.Spawned && IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    command_VerbTarget.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(command_VerbTarget);
            }
            if (forcedTarget.IsValid)
            {
                Command_Action command_Action2 = new Command_Action();
                command_Action2.defaultLabel = "CommandStopForceAttack".Translate();
                command_Action2.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                command_Action2.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt");

                command_Action2.action = delegate
                {
                    ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                };
                if (!forcedTarget.IsValid)
                {
                    command_Action2.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                command_Action2.hotKey = KeyBindingDefOf.Misc5;
                yield return(command_Action2);
            }
            if (!CanToggleHoldFire)
            {
                yield break;
            }
            Command_Toggle command_Toggle = new Command_Toggle();

            command_Toggle.defaultLabel = "CommandHoldFire".Translate();
            command_Toggle.defaultDesc  = "CommandHoldFireDesc".Translate();
            command_Toggle.icon         = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire");

            command_Toggle.hotKey       = KeyBindingDefOf.Misc6;
            command_Toggle.toggleAction = delegate
            {
                holdFire = !holdFire;
                if (holdFire)
                {
                    ResetForcedTarget();
                }
            };
            command_Toggle.isActive = () => holdFire;
            yield return(command_Toggle);
        }
Пример #8
0
        public static IEnumerable <Gizmo> GetGizmosForVerb(this Verb verb, ManagedVerb man = null)
        {
            AdditionalVerbProps props = null;

            Thing ownerThing = null;

            switch (verb.DirectOwner)
            {
            case ThingWithComps twc when twc.TryGetComp <Comp_VerbGiver>() is Comp_VerbGiver giver:
                ownerThing = twc;

                props = giver.PropsFor(verb);
                break;

            case Thing thing:
                ownerThing = thing;
                break;

            case Comp_VerbGiver comp:
                ownerThing = comp.parent;
                props      = comp.PropsFor(verb);
                break;

            case CompEquippable eq:
                ownerThing = eq.parent;
                break;

            case HediffComp_ExtendedVerbGiver hediffGiver:
                props = hediffGiver.PropsFor(verb);
                break;
            }

            var gizmo = new Command_VerbTarget();

            if (ownerThing != null)
            {
                gizmo.defaultDesc = FirstNonEmptyString(props?.description, ownerThing.def.LabelCap + ": " + ownerThing
                                                        .def.description
                                                        .Truncate(500, __truncateCache)
                                                        .CapitalizeFirst());
                gizmo.icon = verb.Icon(null, ownerThing);
            }
            else if (verb.DirectOwner is HediffComp_VerbGiver hediffGiver)
            {
                var hediff = hediffGiver.parent;
                gizmo.defaultDesc = FirstNonEmptyString(props?.description, hediff.def.LabelCap + ": " +
                                                        hediff.def.description
                                                        .Truncate(500, __truncateCache)
                                                        .CapitalizeFirst());
                gizmo.icon = verb.Icon(null, null);
            }

            gizmo.tutorTag     = "VerbTarget";
            gizmo.verb         = verb;
            gizmo.defaultLabel = verb.Label(props);

            if (verb.caster.Faction != Faction.OfPlayer)
            {
                gizmo.Disable("CannotOrderNonControlled".Translate());
            }
            else if (verb.CasterIsPawn)
            {
                if (verb.CasterPawn.WorkTagIsDisabled(WorkTags.Violent))
                {
                    gizmo.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort,
                                                                    verb.CasterPawn));
                }
                else if (!verb.CasterPawn.drafter.Drafted)
                {
                    gizmo.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort,
                                                           verb.CasterPawn));
                }
            }

            yield return(gizmo);

            if (props != null && props.canBeToggled && man != null && verb.caster.Faction == Faction.OfPlayer &&
                props.separateToggle)
            {
                yield return(new Command_ToggleVerbUsage(man));
            }
        }
Пример #9
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            if (this.CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    action = delegate
                    {
                        this.$this.ExtractShell();
                    }
                });
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget();
                attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                attack.verb   = this.AttackVerb;
                attack.hotKey = KeyBindingDefOf.Misc4;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action();
                stop.defaultLabel = "CommandStopForceAttack".Translate();
                stop.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                stop.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                stop.action = delegate
                {
                    this.$this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        this.$this.holdFire = !this.$this.holdFire;
                        if (this.$this.holdFire)
                        {
                            this.$this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.$this.holdFire)
                });
            }
        }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())             // added
            {
                yield return(c);
            }

            // added
            if (this.def.defName == "AvaliTurretLarge")
            {
                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(-1f);
                    },
                    defaultLabel = "-1",
                    defaultDesc = "CommandDecreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc5,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DecreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(-0.1f);
                    },
                    defaultLabel = "-0.1",
                    defaultDesc = "CommandDecreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc4,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DecreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        turretBurstCooldownTime = defaultDelay;
                        def.building.turretBurstCooldownTime = turretBurstCooldownTime;
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                        MoteMaker.ThrowText(this.TrueCenter() + new Vector3(0.5f, 0f, 0.5f), this.Map, turretBurstCooldownTime.ToString(), Color.white, -1f);
                    },
                    defaultLabel = "CommandDefaultTurretShootDelay".Translate(),
                    defaultDesc = "CommandDefaultTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc1,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DefaultDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(0.1f);
                    },
                    defaultLabel = "+0.1",
                    defaultDesc = "CommandIncreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc2,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/IncreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(1f);
                    },
                    defaultLabel = "+1",
                    defaultDesc = "CommandIncreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc3,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/IncreaseDelay", true)
                });
            }
            // added

            if (this.CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    alsoClickIfOtherInGroupClicked = false,
                    action = delegate
                    {
                        GenPlace.TryPlaceThing(changeableProjectile.RemoveShell(), this.Position, this.Map, ThingPlaceMode.Near, null, null);
                    }
                });
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget();
                attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                attack.verb   = this.AttackVerb;
                attack.hotKey = KeyBindingDefOf.Misc4;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action();
                stop.defaultLabel = "CommandStopForceAttack".Translate();
                stop.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                stop.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                stop.action = delegate
                {
                    this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        this.holdFire = !this.holdFire;
                        if (this.holdFire)
                        {
                            this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.holdFire)
                });
            }
            yield break;
        }
Пример #11
0
        /*public static void GizmoOnGUIPostfix(ref GizmoResult __result, Vector2 topLeft, float maxWidth, Command_VerbTarget __instance)
         * {
         *  Text.Font = GameFont.Tiny;
         *  Rect rect = new Rect(topLeft.x, topLeft.y, __instance.GetWidth(maxWidth), 75f);
         *
         *  if (((Verb_Shoot_Cooldown)__instance.verb).RemainingProgressBeforeFire() != 0)
         *  {
         *      Widgets.FillableBar(rect,
         *          ((Verb_Shoot_Cooldown)__instance.verb).RemainingProgressBeforeFire(),
         *          ((VerbProperties_Custom)((Verb_Shoot_Cooldown)__instance.verb).verbProps).texture,
         *          ((VerbProperties_Custom)((Verb_Shoot_Cooldown)__instance.verb).verbProps).textureCooldown,
         *          false
         *          );
         *  }
         *
         *  bool flag = false;
         *  if (Mouse.IsOver(rect))
         *  {
         *      flag = true;
         *      if (!__instance.disabled)
         *      {
         *          GUI.color = GenUI.MouseoverColor;
         *      }
         *  }
         *  Texture2D badTex = __instance.icon;
         *  if (badTex == null)
         *  {
         *      badTex = BaseContent.BadTex;
         *  }
         *  Material material = (!__instance.disabled) ? null : TexUI.GrayscaleGUI;
         *  GenUI.DrawTextureWithMaterial(rect, Command.BGTex, material, default(Rect));
         *  MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
         *  Rect outerRect = rect;
         *  outerRect.position += new Vector2(__instance.iconOffset.x * outerRect.size.x, __instance.iconOffset.y * outerRect.size.y);
         *  GUI.color = __instance.IconDrawColor;
         *  Widgets.DrawTextureFitted(outerRect, badTex, __instance.iconDrawScale * 0.85f, __instance.iconProportions, __instance.iconTexCoords, __instance.iconAngle, material);
         *  GUI.color = Color.white;
         *  bool flag2 = false;
         *  KeyCode keyCode = (__instance.hotKey != null) ? __instance.hotKey.MainKey : KeyCode.None;
         *  if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
         *  {
         *      Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
         *      Widgets.Label(rect2, keyCode.ToStringReadable());
         *      GizmoGridDrawer.drawnHotKeys.Add(keyCode);
         *      if (__instance.hotKey.KeyDownEvent)
         *      {
         *          flag2 = true;
         *          Event.current.Use();
         *      }
         *  }
         *  if (Widgets.ButtonInvisible(rect, false))
         *  {
         *      flag2 = true;
         *  }
         *  string labelCap = __instance.LabelCap;
         *  if (!labelCap.NullOrEmpty())
         *  {
         *      float num = Text.CalcHeight(labelCap, rect.width);
         *      Rect rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
         *      GUI.DrawTexture(rect3, TexUI.GrayTextBG);
         *      GUI.color = Color.white;
         *      Text.Anchor = TextAnchor.UpperCenter;
         *      Widgets.Label(rect3, labelCap);
         *      Text.Anchor = TextAnchor.UpperLeft;
         *      GUI.color = Color.white;
         *  }
         *  GUI.color = Color.white;
         *  if (true)
         *  {
         *      TipSignal tip = __instance.Desc;
         *      if (__instance.disabled && !__instance.disabledReason.NullOrEmpty())
         *      {
         *          string text = tip.text;
         *          tip.text = string.Concat(new string[]
         *          {
         *              text,
         *              "\n\n",
         *              "DisabledCommand".Translate(),
         *              ": ",
         *              __instance.disabledReason
         *          });
         *      }
         *      TooltipHandler.TipRegion(rect, tip);
         *  }
         *  if (!__instance.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
         *  {
         *      UIHighlighter.HighlightOpportunity(rect, __instance.HighlightTag);
         *  }
         *  Text.Font = GameFont.Small;
         *  if (flag2)
         *  {
         *      if (__instance.disabled)
         *      {
         *          if (!__instance.disabledReason.NullOrEmpty())
         *          {
         *              Messages.Message(__instance.disabledReason, MessageTypeDefOf.RejectInput, false);
         *          }
         *          __result = new GizmoResult(GizmoState.Mouseover, null);
         *          return;
         *      }
         *      GizmoResult result;
         *      if (Event.current.button == 1)
         *      {
         *          result = new GizmoResult(GizmoState.OpenedFloatMenu, Event.current);
         *      }
         *      else
         *      {
         *          if (!TutorSystem.AllowAction(__instance.TutorTagSelect))
         *          {
         *              __result = new GizmoResult(GizmoState.Mouseover, null);
         *              return;
         *          }
         *          result = new GizmoResult(GizmoState.Interacted, Event.current);
         *          TutorSystem.Notify_Event(__instance.TutorTagSelect);
         *      }
         *      __result = result;
         *      return;
         *  }
         *  else
         *  {
         *      if (flag)
         *      {
         *          __result = new GizmoResult(GizmoState.Mouseover, null);
         *          return;
         *      }
         *      __result = new GizmoResult(GizmoState.Clear, null);
         *      return;
         *  }
         * }
         *
         * public static void GizmoOnGUIPostfix(ref GizmoResult __result, Command_VerbTarget __instance, Vector2 topLeft, float maxWidth)
         * {
         *  GizmoOnGUIPostfixPRE(ref __result, __instance, topLeft, maxWidth);
         *
         *  var rect = new Rect(topLeft.x, topLeft.y, __instance.GetWidth(maxWidth), 75f);
         *  if (((Verb_Shoot_Cooldown)__instance.verb).RemainingProgressBeforeFire() != 0)
         *  {
         *      Widgets.FillableBar(rect,
         *          ((Verb_Shoot_Cooldown)__instance.verb).RemainingProgressBeforeFire(),
         *          ((VerbProperties_Custom)((Verb_Shoot_Cooldown)__instance.verb).verbProps).texture,
         *          ((VerbProperties_Custom)((Verb_Shoot_Cooldown)__instance.verb).verbProps).textureCooldown,
         *          false
         *          );
         *  }
         * }*/

        public static bool CreateVerbTargetCommandPrefix(ref Command_VerbTarget __result, Thing ownerThing, Verb verb)
        {
            Command_VerbTarget    command_VerbTarget = new Command_VerbTarget();
            VerbProperties_Custom verbProps          = verb.verbProps as VerbProperties_Custom;
            Verb_Shoot_Cooldown   verb_with_cooldown = verb is Verb_Shoot_Cooldown ? verb as Verb_Shoot_Cooldown : null;

            if (verbProps != null)
            {
                command_VerbTarget.defaultDesc  = verbProps.desc;
                command_VerbTarget.defaultLabel = verbProps.label;
                Comp_VerbSaveable comp_VerbSaveable = ownerThing.TryGetComp <Comp_VerbSaveable>();
                if (!verbProps.disable)
                {
                    if (verb_with_cooldown != null)
                    {
                        if (!verb_with_cooldown.CanFire())
                        {
                            command_VerbTarget.Disable("Magnuassembly_AdditionalVerbPatch_CooldownDisableReason".Translate(
                                                           FormattingTickTime(verb_with_cooldown.RemainingTickBeforeFire() / 60.0D)
                                                           )
                                                       );
                        }
                        else
                        {
                            command_VerbTarget.disabled = false;
                        }
                    }
                }
                if (comp_VerbSaveable != null && comp_VerbSaveable.currentVerb == verb)
                {
                    command_VerbTarget.icon = verb_with_cooldown != null?
                                              FloodingTexture(
                        verbProps.textureSelected,
                        verb_with_cooldown.RemainingProgressBeforeFire()
                        ) : verbProps.textureSelected;

                    if (command_VerbTarget.disabled && verb_with_cooldown != null)
                    {
                        comp_VerbSaveable.SwitchVerb(verbProps.redirectVerbAfterShoot);
                    }
                }
                else
                {
                    command_VerbTarget.icon = verb_with_cooldown != null?
                                              FloodingTexture(
                        verbProps.texture,
                        verb_with_cooldown.RemainingProgressBeforeFire()
                        ) : verbProps.texture;
                }
            }
            else
            {
                command_VerbTarget.icon        = ownerThing.def.uiIcon;
                command_VerbTarget.defaultDesc = ownerThing.LabelCap + ": " + ownerThing.def.description.CapitalizeFirst();
            }
            command_VerbTarget.iconAngle  = ownerThing.def.uiIconAngle;
            command_VerbTarget.iconOffset = ownerThing.def.uiIconOffset;
            command_VerbTarget.tutorTag   = "VerbTarget";
            command_VerbTarget.verb       = verb;
            bool disableReasonOverwrite = false;

            if (verb.caster.Faction == Faction.OfPlayer)
            {
                if (verb.CasterIsPawn)
                {
                    if (verb.CasterPawn.WorkTagIsDisabled(WorkTags.Violent))
                    {
                        command_VerbTarget.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                        disableReasonOverwrite = true;
                    }
                    else if (!verb.CasterPawn.drafter.Drafted)
                    {
                        command_VerbTarget.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn));
                        disableReasonOverwrite = true;
                    }
                }
            }
            else
            {
                command_VerbTarget.Disable("CannotOrderNonControlled".Translate());
                disableReasonOverwrite = true;
            }
            if (disableReasonOverwrite)
            {
                if (verbProps != null && verbProps.disable)
                {
                    command_VerbTarget.disabledReason = verbProps.disableReason + "\n" + command_VerbTarget.disabledReason;
                }
                else if (verb_with_cooldown != null && !verb_with_cooldown.CanFire())
                {
                    command_VerbTarget.disabledReason =
                        "Magnuassembly_AdditionalVerbPatch_CooldownDisableReason".Translate(
                            FormattingTickTime(verb_with_cooldown.RemainingTickBeforeFire() / 60.0D)
                            ) + "\n" + command_VerbTarget.disabledReason;
                }
            }
            else if (verbProps != null && verbProps.disable)
            {
                command_VerbTarget.Disable(verbProps.disableReason);
            }
            __result = command_VerbTarget;
            return(false);
        }