Files
EscapistsReintroduced/docs/evidence/garage-vehicles-2026-10-30/native-fixture.c
T
2026-10-30 18:56:57 +01:00

73 lines
3.4 KiB
C

#ifdef WORKBENCH
modded class ERR_GameMode
{
protected override void StartScenario() {}
protected override void EOnInit(IEntity owner)
{
super.EOnInit(owner);
if (!SCR_Global.IsEditMode() && Replication.IsServer()) GetGame().GetCallqueue().CallLater(ERR_GarageProbe, 1000, true);
}
void ERR_GarageProbe()
{
if (!m_GarageVehicles || !m_GarageVehicles.Finished()) return;
GetGame().GetCallqueue().Remove(ERR_GarageProbe);
GetGame().GetCallqueue().CallLater(ERR_GarageVerify, 6000, false);
}
void ERR_GarageVerify()
{
if (!m_GarageVehicles.Probe()) { Print("ERR SMOKE FAIL: garage-vehicles validation", LogLevel.ERROR); return; }
Print("ERR SMOKE PASS: garage-vehicles settled, fueled, empty driver seats, collision-free, bounded, no repeated spawn");
Print("ERR SMOKE COMPLETE: garage-vehicles");
}
}
modded class ERR_GarageVehicles
{
protected int m_ProbeTotal, m_ProbeMax, m_ProbeSteps;
protected ref array<vector> m_ProbePositions = {};
protected override bool AwayFromPlayers(vector position) { return true; }
protected override void Step()
{
int began = System.GetTickCount(); super.Step();
int elapsed = System.GetTickCount() - began; m_ProbeTotal += elapsed; m_ProbeMax = Math.Max(m_ProbeMax, elapsed); m_ProbeSteps++;
}
protected override void Park(IEntity garage)
{
int before = m_Spawned;
super.Park(garage);
if (m_Spawned > before) m_ProbePositions.Insert(m_Vehicles[m_Vehicles.Count()-1].GetOrigin());
}
bool Probe()
{
PrintFormat("ERR GARAGE TOTALS: vehicles=%1 requested=%2 garages=%3 cells=%4 bikePrefabs=%5 steps=%6 workMs=%7 maxStepMs=%8", m_Spawned, m_Requested, m_Seen, m_Cells, m_Bikes.Prefabs.Count(), m_ProbeSteps, m_ProbeTotal, m_ProbeMax);
if (m_Spawned != 16 || m_Vehicles.Count() != 16 || !m_Garages.IsEmpty()) return false;
int bikes;
for (int i = 0; i < m_Vehicles.Count(); i++)
{
Vehicle vehicle = m_Vehicles[i];
if (!vehicle) return false;
if (vehicle.GetPrefabData().GetPrefabName().Contains("/RX100/")) bikes++;
vector low, high; vehicle.GetBounds(low, high);
SCR_FuelManagerComponent fuel = SCR_FuelManagerComponent.Cast(vehicle.FindComponent(SCR_FuelManagerComponent));
vector transform[4]; vehicle.GetWorldTransform(transform);
float moved = vector.Distance(vehicle.GetOrigin(), m_ProbePositions[i]);
bool clear = Clear(vehicle.GetOrigin(), transform, vehicle);
array<BaseCompartmentSlot> seats = {}; bool driver;
if (!ERR_ConvoyRules.CollectSeats(vehicle, seats)) return false;
foreach (BaseCompartmentSlot seat : seats)
{
if (seat.GetOccupant()) return false;
if (seat.GetType() == ECompartmentType.PILOT && seat.IsCompartmentAccessible()) driver = true;
}
float litres; if (fuel) litres = fuel.GetTotalFuel();
PrintFormat("ERR GARAGE VEHICLE: prefab=%1 position=%2 low=%3 high=%4 litres=%5 moved=%6 clear=%7 driver=%8", vehicle.GetPrefabData().GetPrefabName(), vehicle.GetOrigin(), low, high, litres, moved, clear, driver);
if (!driver || litres <= 0 || moved > 0.5 || !clear || !ERR_Actors.Alive(vehicle)) return false;
for (int j = 0; j < i; j++) if (vector.DistanceXZ(vehicle.GetOrigin(), m_Vehicles[j].GetOrigin()) < 149) return false;
}
if (!m_Bikes.Prefabs.IsEmpty() && bikes != 4) return false;
PrintFormat("ERR GARAGE MIX: cars=%1 bikes=%2", m_Spawned-bikes, bikes);
int before = m_Spawned; Start(); Step(); Stop(); Step();
return m_Spawned == before;
}
}
#endif