feat(flight): add toggle Gizmo, fix missing ForceLand on undraft, update to latest flight logic
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user