#ifdef WORKBENCH // Test access only: trigger the real delivered-order method on an existing // registered squad. Radio transit is intentionally not simulated by this test. modded class ERR_HQ { bool ERR_TestPatrolSearch(SCR_AIGroup group, out AIWaypoint search) { foreach (ERR_HQUnit unit : m_Units) { if (unit.Group != group) continue; if (unit.Assignment || unit.PendingOrder || unit.Waypoint || !unit.Eligible(m_Mode)) return false; ERR_HQReport order = new ERR_HQReport(); order.Position = group.GetOrigin() + "40 0 0"; order.ObservedAt = GetGame().GetWorld().GetWorldTime(); order.MessageId = m_Journal.Message(); unit.PendingOrder = order; DeliverOrder(unit, order.ObservedAt); search = unit.Waypoint; return search && unit.Assignment == order; } return false; } bool ERR_TestPatrolRelease(SCR_AIGroup group, AIWaypoint search) { foreach (ERR_HQUnit unit : m_Units) { if (unit.Group != group || unit.Waypoint != search) continue; unit.Release(); return !unit.Assignment && !unit.PendingOrder && !unit.Waypoint; } return false; } } class ERR_NativePatrolHQProbe { protected ERR_GameMode m_Mode; protected ERR_SiteRuntime m_Site; protected AIWaypoint m_Search; protected ref array m_Baseline = {}; protected int m_Step; protected float m_Wait; void ERR_NativePatrolHQProbe(ERR_GameMode mode) { m_Mode = mode; } protected bool Check(bool condition, string detail) { if (condition) { Print("ERR SMOKE PASS: patrol HQ " + detail); return true; } Print("ERR SMOKE FAIL: patrol HQ " + detail, LogLevel.ERROR); return false; } int Tick(float now) { if (now < m_Wait) return 0; ERR_HQ hq = ERR_HQ.Get(); if (!Check(hq != null, "real HQ available")) return -1; if (m_Step == 0) { m_Site = m_Mode.Sites().Find("everon-outpost-1"); if (!Check(m_Site && m_Site.Group && m_Site.PatrolCycle, "existing outpost route available")) return -1; m_Site.Group.GetWaypoints(m_Baseline); if (!Check(!m_Baseline.IsEmpty() && hq.ERR_TestPatrolSearch(m_Site.Group, m_Search), "real delivered-order method assigns existing squad")) return -1; m_Step = 1; m_Wait = now + 750; return 0; } if (m_Step == 1) { array queue = {}; m_Site.Group.GetWaypoints(queue); if (!Check(m_Search && !queue.IsEmpty() && queue[0] == m_Search && m_Site.Group.GetCurrentWaypoint() == m_Search, "Search preempts native patrol")) return -1; foreach (AIWaypoint waypoint : m_Baseline) if (!Check(queue.Contains(waypoint), "preempted baseline route remains queued")) return -1; if (!Check(hq.ERR_TestPatrolRelease(m_Site.Group, m_Search), "real HQ release removes only its assignment")) return -1; m_Step = 2; m_Wait = now + 750; return 0; } if (m_Step == 2) { AIWaypoint current = m_Site.Group.GetCurrentWaypoint(); if (!Check(current && (current == m_Site.PatrolCycle || m_Site.PatrolWaypoints.Contains(current)), "native patrol resumes after Search release")) return -1; m_Step = 3; return 1; } return 1; } void Stop() { ERR_HQ hq = ERR_HQ.Get(); if (hq && m_Site && m_Search) hq.ERR_TestPatrolRelease(m_Site.Group, m_Search); } void ~ERR_NativePatrolHQProbe() { Stop(); } } #endif