diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index b9011b20..4e1d9f78 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/ArmedShuttleIncoming.cs b/Source/WulaFallenEmpire/ArmedShuttleIncoming.cs index 7ed990e0..f67faf19 100644 --- a/Source/WulaFallenEmpire/ArmedShuttleIncoming.cs +++ b/Source/WulaFallenEmpire/ArmedShuttleIncoming.cs @@ -2,20 +2,106 @@ using RimWorld; using Verse; using System.Linq; using UnityEngine; +using System.Reflection; // For InnerThing reflection if needed, but innerContainer is directly accessible namespace WulaFallenEmpire { - public class ArmedShuttleIncoming : PassengerShuttleIncoming + // ArmedShuttleIncoming now directly implements the logic from PassengerShuttleIncoming + // It should inherit from ShuttleIncoming, as PassengerShuttleIncoming does. + public class ArmedShuttleIncoming : ShuttleIncoming // Changed from PassengerShuttleIncoming { - public new Building_ArmedShuttle Shuttle => (Building_ArmedShuttle)base.innerContainer.FirstOrDefault(); + private static readonly SimpleCurve AngleCurve = new SimpleCurve + { + new CurvePoint(0f, 30f), + new CurvePoint(1f, 0f) + }; + + // innerContainer is a protected field in Skyfaller, accessible to derived classes like ShuttleIncoming + // So we can directly use innerContainer here. + public Building_ArmedShuttle Shuttle => (Building_ArmedShuttle)innerContainer.FirstOrDefault(); public override Color DrawColor => Shuttle.DrawColor; protected override void Impact() { - Shuttle.TryGetComp()?.Notify_Arrived(); - // Do not call base.Impact(), as it leads to the InvalidCastException in the parent class. - // The base Skyfaller.Tick() will handle the rest of the impact logic after this method returns. + // Re-adding debug logs for stage 6 + Log.Message($"[WULA] Stage 6: Impact - ArmedShuttleIncoming Impact() called. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}"); + + Thing innerThing = innerContainer.FirstOrDefault(); + if (innerThing is Building_ArmedShuttle shuttle) + { + Log.Message("[WULA] Stage 6: Impact - InnerThing is a Building_ArmedShuttle. Attempting to notify arrival."); + shuttle.TryGetComp()?.Notify_Arrived(); + } + else + { + Log.Warning($"[WULA] Stage 6: Impact - InnerThing is NOT a Building_ArmedShuttle or is NULL. Type: {innerThing?.GetType().Name ?? "NULL"}. This is the cause of the issue."); + } + + // Calling base.Impact() will handle the actual spawning of the innerThing. + // This is crucial for "unpacking" the shuttle. + base.Impact(); + } + + public override void SpawnSetup(Map map, bool respawningAfterLoad) + { + base.SpawnSetup(map, respawningAfterLoad); + // Re-adding debug logs for stage 5 + Log.Message($"[WULA] Stage 5: Landing Sequence - ArmedShuttleIncoming spawned. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}"); + if (!respawningAfterLoad && !base.BeingTransportedOnGravship) + { + angle = GetAngle(0f, base.Rotation); + } + } + + public override void Destroy(DestroyMode mode = DestroyMode.Vanish) + { + if (!hasImpacted) + { + Log.Error("Destroying armed shuttle skyfaller without ever having impacted"); // Changed log message + } + base.Destroy(mode); + } + + protected override void GetDrawPositionAndRotation(ref Vector3 drawLoc, out float extraRotation) + { + extraRotation = 0f; + angle = GetAngle(base.TimeInAnimation, base.Rotation); + switch (base.Rotation.AsInt) + { + case 1: + extraRotation += def.skyfaller.rotationCurve.Evaluate(base.TimeInAnimation); + break; + case 3: + extraRotation -= def.skyfaller.rotationCurve.Evaluate(base.TimeInAnimation); + break; + } + drawLoc.z += def.skyfaller.zPositionCurve.Evaluate(base.TimeInAnimation); + } + + public override float DrawAngle() + { + float num = 0f; + switch (base.Rotation.AsInt) + { + case 1: + num += def.skyfaller.rotationCurve.Evaluate(base.TimeInAnimation); + break; + case 3: + num -= def.skyfaller.rotationCurve.Evaluate(base.TimeInAnimation); + break; + } + return num; + } + + private static float GetAngle(float timeInAnimation, Rot4 rotation) + { + return rotation.AsInt switch + { + 1 => rotation.Opposite.AsAngle + AngleCurve.Evaluate(timeInAnimation), + 3 => rotation.Opposite.AsAngle - AngleCurve.Evaluate(timeInAnimation), + _ => rotation.Opposite.AsAngle, + }; } } } \ No newline at end of file diff --git a/Source/WulaFallenEmpire/Building_ArmedShuttle.cs b/Source/WulaFallenEmpire/Building_ArmedShuttle.cs index 373566d6..a1caa41b 100644 --- a/Source/WulaFallenEmpire/Building_ArmedShuttle.cs +++ b/Source/WulaFallenEmpire/Building_ArmedShuttle.cs @@ -370,6 +370,7 @@ namespace WulaFallenEmpire yield return command_Toggle; } foreach (Gizmo gizmo in ShuttleComp.CompGetGizmosExtra()) yield return gizmo; + Log.Message($"[WULA] Stage 2: Launch Sequence - Providing launch gizmos for {this.Label}."); foreach (Gizmo gizmo in LaunchableComp.CompGetGizmosExtra()) yield return gizmo; foreach (Gizmo gizmo in TransporterComp.CompGetGizmosExtra()) yield return gizmo; float fuelInShuttle = FuelInShuttle();