feat(flight): add toggle Gizmo, fix missing ForceLand on undraft, update to latest flight logic
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -9,6 +9,40 @@ namespace ArachnaeSwarm
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CompPawnFlight : ThingComp
|
public class CompPawnFlight : ThingComp
|
||||||
{
|
{
|
||||||
|
public bool flightEnabled = true;
|
||||||
|
|
||||||
public CompProperties_PawnFlight Props => (CompProperties_PawnFlight)props;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ namespace ArachnaeSwarm
|
|||||||
{
|
{
|
||||||
// --- Custom Flight Logic ---
|
// --- Custom Flight Logic ---
|
||||||
public FlightCondition flightCondition = FlightCondition.Drafted;
|
public FlightCondition flightCondition = FlightCondition.Drafted;
|
||||||
|
public bool showFlightToggle = true;
|
||||||
|
|
||||||
// --- Vanilla PawnKindDef Flight Parameters ---
|
// --- Vanilla PawnKindDef Flight Parameters ---
|
||||||
[NoTranslate]
|
[NoTranslate]
|
||||||
|
|||||||
@@ -65,17 +65,22 @@ namespace ArachnaeSwarm
|
|||||||
|
|
||||||
bool shouldBeFlying = false;
|
bool shouldBeFlying = false;
|
||||||
var compProps = flightComp.Props;
|
var compProps = flightComp.Props;
|
||||||
if (compProps.flightCondition == FlightCondition.Always)
|
|
||||||
|
// Gizmo toggle check — if flight is disabled, never fly
|
||||||
|
if (flightComp.flightEnabled)
|
||||||
{
|
{
|
||||||
shouldBeFlying = true;
|
if (compProps.flightCondition == FlightCondition.Always)
|
||||||
}
|
{
|
||||||
else if (compProps.flightCondition == FlightCondition.DraftedAndMove && (___pawn.Drafted || ___pawn.pather.MovingNow))
|
shouldBeFlying = true;
|
||||||
{
|
}
|
||||||
shouldBeFlying = true;
|
else if (compProps.flightCondition == FlightCondition.DraftedAndMove && (___pawn.Drafted || ___pawn.pather.MovingNow))
|
||||||
}
|
{
|
||||||
else if (compProps.flightCondition == FlightCondition.Drafted && ___pawn.Drafted)
|
shouldBeFlying = true;
|
||||||
{
|
}
|
||||||
shouldBeFlying = true;
|
else if (compProps.flightCondition == FlightCondition.Drafted && ___pawn.Drafted)
|
||||||
|
{
|
||||||
|
shouldBeFlying = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldBeFlying)
|
if (shouldBeFlying)
|
||||||
@@ -104,6 +109,14 @@ namespace ArachnaeSwarm
|
|||||||
var flightComp = ___pawn?.TryGetComp<CompPawnFlight>();
|
var flightComp = ___pawn?.TryGetComp<CompPawnFlight>();
|
||||||
if (flightComp == null) return;
|
if (flightComp == null) return;
|
||||||
|
|
||||||
|
if (!flightComp.flightEnabled)
|
||||||
|
{
|
||||||
|
__instance.ForceLand();
|
||||||
|
if (___pawn.CurJob != null)
|
||||||
|
___pawn.CurJob.flying = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (___pawn.GetPosture() != PawnPosture.Standing)
|
if (___pawn.GetPosture() != PawnPosture.Standing)
|
||||||
{
|
{
|
||||||
__instance.ForceLand();
|
__instance.ForceLand();
|
||||||
|
|||||||
Reference in New Issue
Block a user