Example #1
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            // Ammo gizmos
            if (compAmmo != null)
            {
                foreach (Command com in compAmmo.CompGetGizmosExtra())
                {
                    yield return(com);
                }
            }
            // Fire mode gizmos
            if (compFireModes != null)
            {
                foreach (Command com in compFireModes.GenerateGizmos())
                {
                    yield return(com);
                }
            }
            if (Faction == Faction.OfPlayer)
            {
                // Stop forced attack gizmo
                Gizmo stop = new Command_Action()
                {
                    defaultLabel = "CommandStopForceAttack".Translate(),
                    defaultDesc  = "CommandStopForceAttackDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true),
                    action       = new Action(delegate
                    {
                        forcedTarget = LocalTargetInfo.Invalid;
                        SoundDefOf.TickLow.PlayOneShotOnCamera();
                    }),
                    hotKey = KeyBindingDefOf.Misc5
                };
                yield return(stop);

                // Set forced target gizmo
                if ((mannableComp != null && mannableComp.MannedNow && mannableComp.ManningPawn.Faction == Faction.OfPlayer) ||
                    (mannableComp == null && Faction == Faction.OfPlayer))
                {
                    Gizmo attack = new Command_VerbTarget()
                    {
                        defaultLabel = "CommandSetForceAttackTarget".Translate(),
                        defaultDesc  = "CommandSetForceAttackTargetDesc".Translate(),
                        icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true),
                        verb         = GunCompEq.PrimaryVerb,
                        hotKey       = KeyBindingDefOf.Misc4
                    };
                    yield return(attack);
                }
            }

            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
        }
Example #2
0
        public override IEnumerable <Gizmo> GetGizmos()              // Modified
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            // Ammo gizmos
            if (CompAmmo != null && (PlayerControlled || Prefs.DevMode))
            {
                foreach (Command com in CompAmmo.CompGetGizmosExtra())
                {
                    if (!PlayerControlled && Prefs.DevMode && com is GizmoAmmoStatus)
                    {
                        (com as GizmoAmmoStatus).prefix = "DEV: ";
                    }

                    yield return(com);
                }
            }
            // Don't show CONTROL gizmos on enemy turrets (even with dev mode enabled)
            if (PlayerControlled)
            {
                // Fire mode gizmos
                if (CompFireModes != null)
                {
                    foreach (Command com in CompFireModes.GenerateGizmos())
                    {
                        yield return(com);
                    }
                }
                // Set forced target gizmo
                if (CanSetForcedTarget)
                {
                    var vt = new Command_VerbTarget
                    {
                        defaultLabel = "CommandSetForceAttackTarget".Translate(),
                        defaultDesc  = "CommandSetForceAttackTargetDesc".Translate(),
                        icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true),
                        verb         = GunCompEq.PrimaryVerb,
                        hotKey       = KeyBindingDefOf.Misc4
                    };
                    if (Spawned && IsMortarOrProjectileFliesOverhead && Position.Roofed(Map))
                    {
                        vt.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                    }
                    yield return(vt);
                }
                // Stop forced attack gizmo
                if (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
                    {
                        ResetForcedTarget();
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                    };
                    if (!this.forcedTarget.IsValid)
                    {
                        stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                    }
                    stop.hotKey = KeyBindingDefOf.Misc5;
                    yield return(stop);
                }
                // Toggle fire gizmo
                if (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
                        {
                            holdFire = !holdFire;
                            if (holdFire)
                            {
                                ResetForcedTarget();
                            }
                        },
                        isActive = (() => holdFire)
                    });
                }
            }
        }