fix(uxassist): correct auto-construct settling, altitude and planning

Flight settling never ran its residual-speed check: the caller gated it on
the tick countdown, which always reached exactly zero, so the constant
thresholds were dead and the wait degraded into a fixed delay. Gate it on a
separate pending flag, bound it with a timeout, and re-issue the deferred
route with bypassBrake so a timeout cannot defer the same route again.

Arrival no longer keeps the detour altitude. The planner scores build-range
coverage at ConstructionFlightAltitude, so hovering at AvoidanceAltitude put
part of the counted ghosts out of drone reach.

Also fix four planning defects:

* the route corridor compared an angle against a sine, and could collapse
  instead of widening past 90 degrees;
* candidate near/far separation compared a difference of squared distances
  against a squared merge distance, so any slightly farther ghost claimed the
  far slot, and a displaced near candidate was dropped instead of demoted;
* the angular fan axes mixed the universal player rotation with planet-local
  positions;
* surface distances used chord length where great-circle length was meant.

Ghost eligibility now mirrors the material-delivery filter in
ConstructionModuleComponent.GameTick. A ghost rejected by constructableIdHash
or blocked by a nearby Dark Fog building can never clear itemRequired, so the
mecha would park on a site that makes no progress. The enemy probe is skipped
when the planet has no ground bases.

Drop the OrderNode.Stop in CancelAutoMotion: PlayerOrder.Clear() discards it
before PlayerOrder.GameTick can process it, and the actual braking comes from
PlayerMove_Fly decaying rtsVelocity. It only left a stray order gizmo at the
planet centre.

Untie the Harmony patch from AutoConstructButtonEnabled so hiding the button
cannot silently disable the feature, and throttle the enable diagnostics now
that enabling is an in-game action.

Extract the shared manual-movement input probe, name the obstacle layer mask,
reset a copied Localizer on the cloned count text, and drop the dead
representative-target guard.
This commit is contained in:
soarqin committed 2026-09-16 02:16:14 +08:00
1 parent b7564903d0
commit 3a840e7b2d
4 files changed
+251 -90

No files matched your search

+17 -14
View File
@@ -55,6 +55,10 @@ internal static class AutoConstructUI
ConstructCountText = GameObject.Instantiate(UIRoot.instance.uiGame.assemblerWindow.stateText);
ConstructCountText.gameObject.name = "construct-count-text";
// The runtime object is only a style source. A Localizer copied along with it would
// overwrite the formatted count on the next localization refresh.
var localizer = ConstructCountText.GetComponent<Localizer>();
if (localizer != null) GameObject.DestroyImmediate(localizer);
ConstructCountText.text = String.Format(I18NKeys.BuildingsToConstruct0.Translate(), 0);
ConstructCountText.color = new Color(1f, 1f, 1f, 0.4f);
ConstructCountText.alignment = TextAnchor.MiddleLeft;
@@ -72,19 +76,7 @@ internal static class AutoConstructUI
rectTrans.localScale = new Vector3(1f, 1f, 1f);
UpdateToggleAutoConstructCheckButtonVisiblility();
ToggleAutoConstructChecked();
ToggleAutoConstruct.OnChecked += ToggleAutoConstructChecked;
static void ToggleAutoConstructChecked()
{
if (ToggleAutoConstruct.Checked)
{
ToggleAutoConstruct.SetLabelText(I18NKeys.DisableAutoConstruct);
}
else
{
ToggleAutoConstruct.SetLabelText(I18NKeys.EnableAutoConstruct);
}
}
ToggleAutoConstruct.OnChecked += UpdateToggleAutoConstructLabel;
}
public static void UpdateToggleAutoConstructCheckButtonVisiblility()
@@ -92,8 +84,19 @@ internal static class AutoConstructUI
if (ToggleAutoConstruct == null) return;
var localPlanet = GameMain.localPlanet;
var active = localPlanet != null && localPlanet.factoryLoaded && localPlanet.factory.prebuildCount > 0 && Patches.Factory.FactoryPatch.AutoConstructButtonEnabled.Value;
// The config can also change from outside the button (config file, BepInEx config manager),
// which only refreshes the colours, so reconcile the label here too.
UpdateToggleAutoConstructLabel();
ToggleAutoConstruct.gameObject.SetActive(active);
ConstructCountPanel.gameObject.SetActive(active);
ConstructCountPanel.SetActive(active);
}
private static void UpdateToggleAutoConstructLabel()
{
if (ToggleAutoConstruct == null) return;
ToggleAutoConstruct.SetLabelText(ToggleAutoConstruct.Checked
? I18NKeys.DisableAutoConstruct
: I18NKeys.EnableAutoConstruct);
}
public static void UpdateConstructCountText(int count)