namespace AcDream.Core.World;
///
/// Should the streaming/render pipeline be allowed to run this frame?
///
///
/// Why this exists (#192, 2026-07-09). Login to a non-Holtburg position
/// sometimes showed stabs/scenery floating in the wrong place. Root cause: the
/// old gate opened as soon as WorldSession reached InWorld — but
/// InWorld fires immediately after the login handshake completes
/// (WorldSession.cs:608), BEFORE the player's own spawn CreateObject
/// (which carries their real position) has even arrived over the network. Any
/// landblock streamed in that window baked its world offset from
/// GameWindow._liveCenterX/Y's startup placeholder (Holtburg, 0xA9B4) — a
/// real position, not a "not known yet" sentinel — because the streaming worker
/// reads that field fresh at build time with no way to know it's still a guess.
/// That stale-baked geometry still got applied once its build finished, landing
/// wherever the guess put it relative to whatever streamed in afterward using the
/// corrected center.
///
///
///
/// The fix is not "pick a better placeholder" — any placeholder racing against
/// the real answer reproduces the same bug. It's gating on whether the real
/// position is actually known yet (, set true
/// exactly when the player's own spawn is processed), independent of session
/// state. alone is deliberately no longer
/// sufficient in live mode.
///
///
public static class StreamingReadinessGate
{
/// Whether a live ACE session is configured at all.
/// False (offline / fly-camera) always streams — there is no real position to
/// wait for, so no race exists.
/// Latches true the first time chase mode
/// engages and stays true for the rest of the session — well past the login
/// race window.
/// The live session has completed the login handshake
/// (WorldSession.State.InWorld). Necessary but NOT sufficient on its
/// own — see class remarks.
/// The player's own spawn CreateObject has
/// been received and processed, so _liveCenterX/Y reflects a real,
/// server-confirmed position rather than the startup placeholder.
public static bool ShouldStream(
bool liveModeEnabled, bool chaseModeEverEntered, bool liveInWorld, bool liveCenterKnown)
{
bool isWaitingForLogin = liveModeEnabled && !chaseModeEverEntered;
return !isWaitingForLogin || (liveInWorld && liveCenterKnown);
}
}