feat(flight): add toggle Gizmo, fix missing ForceLand on undraft, update to latest flight logic

This commit is contained in:
2026-02-27 14:21:08 +08:00
parent 8c991d6588
commit 9ed9cd7959
5 changed files with 58 additions and 10 deletions

View File

@@ -9,6 +9,40 @@ namespace WulaFallenEmpire
/// </summary>
public class CompPawnFlight : ThingComp
{
public bool flightEnabled = true;
public CompProperties_PawnFlight Props => (CompProperties_PawnFlight)props;
public override void PostExposeData()
{
base.PostExposeData();
Scribe_Values.Look(ref flightEnabled, "flightEnabled", true);
}
public override System.Collections.Generic.IEnumerable<Gizmo> CompGetGizmosExtra()
{
if (Props.showFlightToggle && parent is Pawn pawn && pawn.Faction == RimWorld.Faction.OfPlayer)
{
yield return new Verse.Command_Toggle
{
defaultLabel = "Toggle Flight",
defaultDesc = "Toggle flight mode on or off.",
Order = 100f,
icon = Verse.ContentFinder<UnityEngine.Texture2D>.Get("StellarisDaughter/UI/Commands/SD_FlightToggle", false)
?? RimWorld.TexCommand.GatherSpotActive,
isActive = () => flightEnabled,
toggleAction = () =>
{
flightEnabled = !flightEnabled;
if (!flightEnabled && pawn.flight != null && pawn.flight.Flying)
{
pawn.flight.ForceLand();
if (pawn.CurJob != null)
pawn.CurJob.flying = false;
}
}
};
}
}
}
}