diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index d171064..30181a2 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Defs/ThingDefs_Misc/ThingDef_Projectile_CatastropheMissile.xml b/1.6/1.6/Defs/ThingDefs_Misc/ThingDef_Projectile_CatastropheMissile.xml index 56e0dc2..da4a71f 100644 --- a/1.6/1.6/Defs/ThingDefs_Misc/ThingDef_Projectile_CatastropheMissile.xml +++ b/1.6/1.6/Defs/ThingDefs_Misc/ThingDef_Projectile_CatastropheMissile.xml @@ -8,7 +8,7 @@ Graphic_Single_AgeSecs Things/Projectile/FleshmassSpitterProjectileSheet - (3,3) + (3,3) MoteGlow @@ -18,7 +18,7 @@ 200 80 15 - true0 + true Filth_SpentAcid 4 Shell_AcidSpitImpact @@ -65,7 +65,7 @@ Graphic_Single_AgeSecs Things/Projectile/FleshmassSpitterProjectileSheet - (3,3) + (3,3) MoteGlow @@ -106,26 +106,6 @@ 5.0 50 - -
  • - Verb_Shoot - false - 4.0 - 9 - 13 - true - false - 29.9 - 500 - 1 - Mortar_LaunchA - 16 - 1 - - true - -
  • -
  • ArachnaeSwarm.Verb_LaunchCatastropheMissile diff --git a/Source/ArachnaeSwarm/Buildings/Building_CatastropheMissileSilo.cs b/Source/ArachnaeSwarm/Buildings/Building_CatastropheMissileSilo.cs index 23d082c..0902cad 100644 --- a/Source/ArachnaeSwarm/Buildings/Building_CatastropheMissileSilo.cs +++ b/Source/ArachnaeSwarm/Buildings/Building_CatastropheMissileSilo.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Reflection; using UnityEngine; using Verse; using Verse.AI; @@ -14,6 +15,10 @@ namespace ArachnaeSwarm [StaticConstructorOnStartup] public class Building_CatastropheMissileSilo : Building_TurretGun { + // Reflection to access the private 'holdFire' field in the base class, as there is no public accessor. + private static readonly FieldInfo holdFireField = + typeof(Building_TurretGun).GetField("holdFire", BindingFlags.NonPublic | BindingFlags.Instance); + public GlobalTargetInfo longTarget; public static readonly Texture2D FireMissionTex = ContentFinder.Get("UI/Commands/Attack", true); @@ -36,30 +41,40 @@ namespace ArachnaeSwarm protected override void Tick() { - // --- Attack Priority Logic (Remote Target has higher priority) --- - // Prio 1: Remote Target - if (this.longTarget.IsValid) + // Always run base.Tick() first. This handles all local targeting, aiming, warmup, + // cooldowns, and calling the Verb for local shots. This is the key to fixing the bug. + base.Tick(); + + // --- Mutual Exclusivity: Prioritize Local Target --- + // If a local target is set (either by player or automatically), clear the remote target. + if (this.forcedTarget.IsValid && this.longTarget.IsValid) { - if (base.Active && this.burstCooldownTicksLeft <= 0 && CanFireGlobal(out _)) + this.longTarget = GlobalTargetInfo.Invalid; + } + + // --- Debug Logging (every 120 ticks, approx 2 seconds) --- + if (Find.TickManager.TicksGame % 120 == 0) + { + bool isHoldingFireForLog = (bool)holdFireField.GetValue(this); + string reason; + CanFireGlobal(out reason); // To get the reason string + Log.Message($"[Silo Debug] Tick: {Find.TickManager.TicksGame}\n" + + $"- Cooldown: {this.burstCooldownTicksLeft}\n" + + $"- Active (Power): {base.Active}\n" + + $"- HoldFire: {isHoldingFireForLog}\n" + + $"- CanFireGlobal (Fuel?): {CanFireGlobal(out reason)} (Reason: {reason})\n" + + $"- Local Target: {this.forcedTarget.ToString()}\n" + + $"- Remote Target: {this.longTarget.ToString()}"); + } + + // --- Remote Firing Logic --- + bool isHoldingFire = (bool)holdFireField.GetValue(this); + if (this.longTarget.IsValid && !isHoldingFire && this.burstCooldownTicksLeft <= 0 && base.Active && CanFireGlobal(out _)) + { + if (!this.forcedTarget.IsValid) { this.FireMission(this.longTarget); } - else - { - // Manually tick cooldown and turret top rotation when in remote mode to prevent auto-targeting - if(this.burstCooldownTicksLeft > 0) this.burstCooldownTicksLeft--; - this.top.TurretTopTick(); - } - } - // Prio 2: Forced Local Target (Only if no remote target) - else if (this.forcedTarget.IsValid) - { - base.Tick(); // Let base class handle it - } - // Prio 3: Auto Target (if no manual targets) - else - { - base.Tick(); // Let base class handle it } }