43 lines
1.6 KiB
C
43 lines
1.6 KiB
C
// A one-shot policy driven by the existing HQ tick, never a spawn/replacement clock.
|
|
class ERR_ConvoyStartup
|
|
{
|
|
protected bool m_Enabled;
|
|
protected bool m_Finished;
|
|
protected float m_Began = -1;
|
|
protected float m_Last = -1;
|
|
protected float m_Next;
|
|
protected string m_State;
|
|
void ERR_ConvoyStartup(bool enabled)
|
|
{
|
|
m_Enabled = enabled;
|
|
m_Finished = !enabled;
|
|
m_State = "waiting for active round";
|
|
if (!enabled) m_State = "disabled for this round";
|
|
}
|
|
bool Enabled() { return m_Enabled; }
|
|
string Status() { return m_State; }
|
|
bool Finished() { return m_Finished; }
|
|
bool Decide(float now, bool existingTask, bool admitted)
|
|
{
|
|
if (m_Finished || !ERR_ForceRules.Finite(now) || now < 0 || now < m_Last) return false;
|
|
m_Last = now;
|
|
if (existingTask) { m_Finished = true; m_State = "existing canonical convoy retained"; return false; }
|
|
if (m_Began < 0) { m_Began = now; m_Next = now + 30000; m_State = "startup grace"; }
|
|
if (now < m_Next) return false;
|
|
m_Next = now + 5000;
|
|
if (now - m_Began >= 120000)
|
|
{ m_Finished = true; m_State = "startup admission deadline expired"; return false; }
|
|
if (!admitted) { m_State = "waiting for existing force admission"; return false; }
|
|
// Latch before native road survey/dispatch: refusals and losses never retry.
|
|
m_Finished = true; m_State = "single dispatch attempt";
|
|
return true;
|
|
}
|
|
void Complete(bool accepted)
|
|
{
|
|
if (m_State != "single dispatch attempt") return;
|
|
m_State = "dispatch refused; no automatic retry";
|
|
if (accepted) m_State = "canonical convoy dispatched";
|
|
}
|
|
void Stop() { m_Finished = true; m_State = "round stopped"; }
|
|
}
|