protected override bool TryCastShot() { Log.Message("test3"); AERIALChangeableProjectile comp = EquipmentSource.GetComp <AERIALChangeableProjectile>(); Thing launcher = caster; ThingDef projectile = Projectile; if (projectile == null) { return(false); } Log.Message("test"); Thing equipment = EquipmentSource; Vector3 drawPos = this.caster.DrawPos; ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(caster.Position, currentTarget, out shootLine); float num = VerbUtility.CalculateAdjustedForcedMiss(this.verbProps.forcedMissRadius, this.currentTarget.Cell - this.caster.Position); int max = GenRadial.NumCellsInRadius(num); int num2 = Rand.Range(0, max); IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num2]; this.ThrowDebugText("ToRadius"); this.ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } if (!this.canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } IntVec3 pos = shootLine.Source; pos.x += 20; pos.z += 20; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, pos, this.caster.Map, WipeMode.Vanish); projectile2.Launch(launcher, drawPos, c, this.currentTarget, projectileHitFlags, equipment, null); comp.loadedShells.RemoveAt(comp.loadedShells.Count - 1); if (!comp.loadedShells.NullOrEmpty()) { pos = shootLine.Source; pos.z -= 20; pos.x -= 20; projectile = Projectile; projectile2 = (Projectile)GenSpawn.Spawn(projectile, pos, this.caster.Map, WipeMode.Vanish); projectile2.Launch(launcher, drawPos, c, this.currentTarget, projectileHitFlags, equipment, null); comp.loadedShells.RemoveAt(comp.loadedShells.Count - 1); } Log.Message($"{comp.loadedShells.Count}"); return(true); }
private static bool GunNeedsLoading(Building b) { AERIALSYSTEM building_TurretGun = b as AERIALSYSTEM; if (building_TurretGun == null) { return(false); } AERIALChangeableProjectile compChangeableProjectile = building_TurretGun.gun.TryGetComp <AERIALChangeableProjectile>(); return(compChangeableProjectile != null && !(compChangeableProjectile.loadedShells.Count >= compChangeableProjectile.Props.maxShellCount)); }
// Token: 0x06007DD5 RID: 32213 RVA: 0x002587E8 File Offset: 0x002569E8 public override string GetInspectString() { StringBuilder stringBuilder = new StringBuilder(); string inspectString = ""; AERIALChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <AERIALChangeableProjectile>(); if (!inspectString.NullOrEmpty()) { stringBuilder.AppendLine(inspectString); } if (this.AttackVerb.verbProps.minRange > 0f) { stringBuilder.AppendLine("MinimumRange".Translate() + ": " + this.AttackVerb.verbProps.minRange.ToString("F0")); } stringBuilder.AppendLine("AERIALShellSpaceLeft".Translate($"{compChangeableProjectile.loadedShells.Count}/{compChangeableProjectile.Props.maxShellCount}".Named("SPACE"))); 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()); } if (compChangeableProjectile != null) { if (compChangeableProjectile.Loaded) { stringBuilder.AppendLine("ShellLoaded".Translate(compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].LabelCap, compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1])); } else { stringBuilder.AppendLine("ShellNotLoaded".Translate()); } } return(stringBuilder.ToString().TrimEndNewlines()); }
// 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; }
public override void Tick() { if (this.CanExtractShell && this.MannedByColonist) { AERIALChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <AERIALChangeableProjectile>(); if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1])) { this.ExtractShell(); } } if (this.forcedTarget.IsValid && !this.CanSetForcedTarget) { this.ResetForcedTarget(); } if (!this.CanToggleHoldFire) { this.holdFire = false; } if (this.forcedTarget.ThingDestroyed) { this.ResetForcedTarget(); } if (this.Active && !this.stunner.Stunned && base.Spawned) { this.GunCompEq.verbTracker.VerbsTick(); if (this.AttackVerb.state != VerbState.Bursting) { if (this.WarmingUp) { this.burstWarmupTicksLeft--; if (this.burstWarmupTicksLeft == 0) { this.BeginBurst(); } } else { if (this.burstCooldownTicksLeft > 0) { this.burstCooldownTicksLeft--; if (this.IsMortar) { if (this.progressBarEffecter == null) { this.progressBarEffecter = EffecterDefOf.ProgressBar.Spawn(); } this.progressBarEffecter.EffectTick(this, TargetInfo.Invalid); MoteProgressBar mote = ((SubEffecter_ProgressBar)this.progressBarEffecter.children[0]).mote; mote.progress = 1f - (float)Math.Max(this.burstCooldownTicksLeft, 0) / (float)this.BurstCooldownTime().SecondsToTicks(); mote.offsetZ = -0.8f; } } if (this.burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10)) { Log.Message("trystartshootsomething"); this.TryStartShootSomethingAERIAL(true); } } this.top.TurretTopTick(); return; } } else { Log.Message("resetcurrenttarget"); this.ResetCurrentTarget(); } }
protected bool oldShotCast() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (base.EquipmentSource != null) { AERIALChangeableProjectile comp = base.EquipmentSource.GetComp <AERIALChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } CompReloadable comp2 = base.EquipmentSource.GetComp <CompReloadable>(); if (comp2 != null) { comp2.UsedOnce(); } } Thing launcher = this.caster; Thing equipment = base.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map, WipeMode.Vanish); if (this.verbProps.forcedMissRadius > 0.5f) { float num = VerbUtility.CalculateAdjustedForcedMiss(this.verbProps.forcedMissRadius, this.currentTarget.Cell - this.caster.Position); if (num > 0.5f) { int max = GenRadial.NumCellsInRadius(num); int num2 = Rand.Range(0, max); if (num2 > 0) { IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num2]; this.ThrowDebugText("ToRadius"); this.ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } if (!this.canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, c, this.currentTarget, projectileHitFlags, equipment, null); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = (randomCoverToMissInto != null) ? randomCoverToMissInto.def : null; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); this.ThrowDebugText("ToWild" + (this.canHitNonTargetPawnsNow ? "\nchntp" : "")); this.ThrowDebugText("Wild\nDest", shootLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) { this.ThrowDebugText("ToCover" + (this.canHitNonTargetPawnsNow ? "\nchntp" : "")); this.ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (this.canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, this.currentTarget, projectileHitFlags3, equipment, targetCoverDef); return(true); } ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; if (this.canHitNonTargetPawnsNow) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns; } if (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld; } this.ThrowDebugText("ToHit" + (this.canHitNonTargetPawnsNow ? "\nchntp" : "")); if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); }