private static bool GunNeedsLoading(Building b)
        {
            Building_TurretGun building_TurretGun = b as Building_TurretGun;

            if (building_TurretGun == null)
            {
                return(false);
            }
            CompChangeableProjectile compChangeableProjectile = building_TurretGun.gun.TryGetComp <CompChangeableProjectile>();

            if (compChangeableProjectile == null || compChangeableProjectile.Loaded)
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            string        inspectString = base.GetInspectString();

            if (!inspectString.NullOrEmpty())
            {
                stringBuilder.AppendLine(inspectString);
            }
            if (this.AttackVerb.verbProps.minRange > 0f)
            {
                stringBuilder.AppendLine("MinimumRange".Translate() + ": " + this.AttackVerb.verbProps.minRange.ToString("F0"));
            }
            if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
            {
                stringBuilder.AppendLine("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
            }
            else if (base.Spawned && this.burstCooldownTicksLeft > 0 && this.BurstCooldownTime() > 5f)
            {
                stringBuilder.AppendLine("CanFireIn".Translate() + ": " + this.burstCooldownTicksLeft.ToStringSecondsFromTicks());
            }
            CompChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();

            if (compChangeableProjectile != null)
            {
                if (compChangeableProjectile.Loaded)
                {
                    stringBuilder.AppendLine("ShellLoaded".Translate(new object[]
                    {
                        compChangeableProjectile.LoadedShell.LabelCap
                    }));
                }
                else
                {
                    stringBuilder.AppendLine("ShellNotLoaded".Translate());
                }
            }
            return(stringBuilder.ToString().TrimEndNewlines());
        }
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            string        inspectString = base.GetInspectString();

            if (!inspectString.NullOrEmpty())
            {
                stringBuilder.AppendLine(inspectString);
            }
            stringBuilder.AppendLine("GunInstalled".Translate() + ": " + this.gun.Label);
            if (this.GunCompEq.PrimaryVerb.verbProps.minRange > 0f)
            {
                stringBuilder.AppendLine("MinimumRange".Translate() + ": " + this.GunCompEq.PrimaryVerb.verbProps.minRange.ToString("F0"));
            }
            if (base.Spawned && this.burstCooldownTicksLeft > 0)
            {
                stringBuilder.AppendLine("CanFireIn".Translate() + ": " + this.burstCooldownTicksLeft.TicksToSecondsString());
            }
            CompChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();

            if (compChangeableProjectile != null)
            {
                if (compChangeableProjectile.Loaded)
                {
                    stringBuilder.AppendLine("ShellLoaded".Translate(new object[]
                    {
                        compChangeableProjectile.LoadedShell.LabelCap
                    }));
                }
                else
                {
                    stringBuilder.AppendLine("ShellNotLoaded".Translate());
                }
            }
            return(stringBuilder.ToString().TrimEndNewlines());
        }
示例#4
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            _003CGetGizmos_003Ec__Iterator0 _003CGetGizmos_003Ec__Iterator = (_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0044: stateMachine*/;

            using (IEnumerator <Gizmo> enumerator = this._003CGetGizmos_003E__BaseCallProxy0().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo c = enumerator.Current;
                    yield return(c);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();

            if (changeableProjectile != null)
            {
                Command_Action extract = new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc  = "CommandExtractShellDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("Things/Item/Resource/Shell/Shell_HighExplosive", true),
                    alsoClickIfOtherInGroupClicked = false,
                    action = delegate
                    {
                        GenPlace.TryPlaceThing(changeableProjectile.RemoveShell(), _003CGetGizmos_003Ec__Iterator._0024this.Position, _003CGetGizmos_003Ec__Iterator._0024this.Map, ThingPlaceMode.Near, null);
                    }
                };
                if (changeableProjectile.Projectile == null)
                {
                    extract.Disable("CommandExtractShellFailNoShell".Translate());
                }
                yield return((Gizmo)extract);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (this.CanSetForcedTarget)
            {
                yield return((Gizmo) new Command_VerbTarget
                {
                    defaultLabel = "CommandSetForceAttackTarget".Translate(),
                    defaultDesc = "CommandSetForceAttackTargetDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true),
                    verb = this.GunCompEq.PrimaryVerb,
                    hotKey = KeyBindingDefOf.Misc4
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (base.forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action
                {
                    defaultLabel = "CommandStopForceAttack".Translate(),
                    defaultDesc  = "CommandStopForceAttackDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true),
                    action       = delegate
                    {
                        _003CGetGizmos_003Ec__Iterator._0024this.ResetForcedTarget();
                        SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                    }
                };
                if (!base.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 (!this.CanToggleHoldFire)
            {
                yield break;
            }
            yield return((Gizmo) new Command_Toggle
            {
                defaultLabel = "CommandHoldFire".Translate(),
                defaultDesc = "CommandHoldFireDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                hotKey = KeyBindingDefOf.Misc6,
                toggleAction = delegate
                {
                    _003CGetGizmos_003Ec__Iterator._0024this.holdFire = !_003CGetGizmos_003Ec__Iterator._0024this.holdFire;
                    if (_003CGetGizmos_003Ec__Iterator._0024this.holdFire)
                    {
                        _003CGetGizmos_003Ec__Iterator._0024this.ResetForcedTarget();
                    }
                },
                isActive = (() => _003CGetGizmos_003Ec__Iterator._0024this.holdFire)
            });

            /*Error: Unable to find new state assignment for yield return*/;
IL_0407:
            /*Error near IL_0408: Unexpected return in MoveNext()*/;
        }
示例#5
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()*/;
        }
示例#6
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);
        }
示例#7
0
 public override void Tick()
 {
     base.Tick();
     if (CanExtractShell && MannedByColonist)
     {
         CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
         if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell))
         {
             ExtractShell();
         }
     }
     if (forcedTarget.IsValid && !CanSetForcedTarget)
     {
         ResetForcedTarget();
     }
     if (!CanToggleHoldFire)
     {
         holdFire = false;
     }
     if (forcedTarget.ThingDestroyed)
     {
         ResetForcedTarget();
     }
     if (Active && (mannableComp == null || mannableComp.MannedNow) && !stunner.Stunned && base.Spawned)
     {
         GunCompEq.verbTracker.VerbsTick();
         if (AttackVerb.state == VerbState.Bursting)
         {
             return;
         }
         if (WarmingUp)
         {
             burstWarmupTicksLeft--;
             if (burstWarmupTicksLeft == 0)
             {
                 BeginBurst();
             }
         }
         else
         {
             if (burstCooldownTicksLeft > 0)
             {
                 burstCooldownTicksLeft--;
                 if (IsMortar)
                 {
                     if (progressBarEffecter == null)
                     {
                         progressBarEffecter = EffecterDefOf.ProgressBar.Spawn();
                     }
                     progressBarEffecter.EffectTick(this, TargetInfo.Invalid);
                     MoteProgressBar mote = ((SubEffecter_ProgressBar)progressBarEffecter.children[0]).mote;
                     mote.progress = 1f - (float)Math.Max(burstCooldownTicksLeft, 0) / (float)BurstCooldownTime().SecondsToTicks();
                     mote.offsetZ  = -0.8f;
                 }
             }
             if (burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10))
             {
                 TryStartShootSomething(canBeginBurstImmediately: true);
             }
         }
         top.TurretTopTick();
     }
     else
     {
         ResetCurrentTarget();
     }
 }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();

            if (changeableProjectile != null)
            {
                Command_Action extract = new Command_Action();
                extract.defaultLabel = "CommandExtractShell".Translate();
                extract.defaultDesc  = "CommandExtractShellDesc".Translate();
                extract.icon         = ContentFinder <Texture2D> .Get("Things/Item/Resource/Shell/Shell_HighExplosive", true);

                extract.alsoClickIfOtherInGroupClicked = false;
                extract.action = delegate
                {
                    GenPlace.TryPlaceThing(changeableProjectile.RemoveShell(), this.$this.Position, this.$this.Map, ThingPlaceMode.Near, null);
                };
                if (changeableProjectile.Projectile == null)
                {
                    extract.Disable("CommandExtractShellFailNoShell".Translate());
                }
                yield return(extract);
            }
            if (this.CanSetForcedTarget)
            {
                yield return(new Command_VerbTarget
                {
                    defaultLabel = "CommandSetForceAttackTarget".Translate(),
                    defaultDesc = "CommandSetForceAttackTargetDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true),
                    verb = this.GunCompEq.PrimaryVerb,
                    hotKey = KeyBindingDefOf.Misc4
                });
            }
            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.TickLow.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())
            {
                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)
                });
            }
        }