Simplify content controls and add vehicle roles; record Workshop 0.0.144
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Discover installed mod vehicles and save independent garage, traffic, patrol and convoy assignments. Retire the superseded RHS 1.9 overrides. Include native menu, crew/driving and publication evidence.
This commit is contained in:
@@ -7,6 +7,7 @@ source=path.read_text()
|
||||
# Dispatch's native calls are doubled; budget behavior is executed separately.
|
||||
code=body(path,'ERR_ConvoyTask Dispatch(')
|
||||
code=re.sub(r'//[^\n]*','',code)
|
||||
code=code.replace('array<ResourceName>', 'Array<string>').replace('ResourceName','string').replace('prefab.IsEmpty()', 'prefab.empty()').replace('unit->Entity.FindComponent(InventoryStorageManagerComponent)', 'unit->Entity->storage').replace('GetGame().ERR_ServerVehicles().Reject', 'Reject')
|
||||
code=code.replace('array<vector>','Array<vector>&')
|
||||
code=code.replace('SCR_AIGroup.Cast(', 'static_cast<SCR_AIGroup*>(').replace('Vehicle.Cast(', 'static_cast<Vehicle*>(')
|
||||
code=code.replace('FactionAffiliationComponent.Cast(unit.Entity.FindComponent(FactionAffiliationComponent))','&unit->Entity->affiliation').replace('AICarMovementComponent.Cast(unit.Entity.FindComponent(AICarMovementComponent))','&unit->Entity->movement')
|
||||
@@ -14,8 +15,9 @@ for cls in ['ERR_ConvoyTask','ERR_ConvoyReceipt','ERR_ForceRoute','ERR_ConvoyVeh
|
||||
code=re.sub(r'\b'+cls+r' ([A-Za-z_]\w*)',cls+r'* \1',code)
|
||||
for obj in ['m_Mode','m_Pool','task','unit','affiliation','movement']:
|
||||
code=re.sub(r'\b'+obj+r'\.',obj+'->',code)
|
||||
for cls in ['ERR_ForceRules','ERR_ConvoyRules','ERR_ConvoyResources','ERR_Actors','ERR_HQ']:
|
||||
for cls in ['ERR_ForceRules','ERR_ConvoyRules','ERR_ConvoyResources','ERR_Actors','ERR_HQ','ERR_VehicleSelection']:
|
||||
code=code.replace(cls+'.',cls+'::')
|
||||
code=code.replace('unit->Entity.FindComponent(InventoryStorageManagerComponent)', 'unit->Entity->storage')
|
||||
code=code.replace('EnemyFaction().','EnemyFaction()->').replace('Group.Get','Group->Get').replace('null','nullptr')
|
||||
run(r'''
|
||||
#include <cassert>
|
||||
@@ -28,7 +30,7 @@ struct IEntity{virtual ~IEntity()=default;};
|
||||
struct FactionAffiliationComponent{void SetAffiliatedFaction(Faction*){}};
|
||||
struct AICarMovementComponent{int speed=0;void SetCruiseSpeed(int v){speed=v;}};
|
||||
struct SCR_AIGroup:IEntity{Faction* GetFaction(){return &enemy;}int GetAgentsCount(){return 0;}};
|
||||
struct Vehicle:IEntity{FactionAffiliationComponent affiliation;AICarMovementComponent movement;};
|
||||
struct Vehicle:IEntity{bool storage=true;FactionAffiliationComponent affiliation;AICarMovementComponent movement;};
|
||||
struct ERR_GameMode{Array<IEntity*>owned;Faction* EnemyFaction(){return &enemy;}void Own(IEntity* e){owned.Insert(e);}};
|
||||
struct ERR_ForceRoute{};
|
||||
struct ERR_ConvoyReceipt{bool used=false;};
|
||||
@@ -40,6 +42,8 @@ namespace ERR_ConvoyRules{bool valid=true,clear=true,empty=true;bool EmptyCrewTe
|
||||
namespace ERR_ConvoyResources{bool available=true;bool Available(){return available;}string GroupPrefab(){return "group";}string VehiclePrefab(int i){return "vehicle"+std::to_string(i);}}
|
||||
namespace ERR_HQ{void Event(string,string){}}
|
||||
namespace ERR_Actors{int calls=0,fail=0;IEntity* Spawn(string prefab,vector,vector=vector{}){calls++;if(calls==fail)return nullptr;if(prefab=="group")return new SCR_AIGroup();return new Vehicle();}}
|
||||
namespace ERR_VehicleSelection{bool empty=false;bool fit=true;string ForRole(int,string preferred){return empty?"":preferred;}bool RoadFit(Vehicle* v){return v&&fit;}}
|
||||
void Reject(string,int){}
|
||||
struct Service{ERR_GameMode* m_Mode;ERR_ConvoyPool* m_Pool;Array<ERR_ConvoyTask*>m_Tasks;bool current=true;int crews=0,failCrew=-1;
|
||||
ERR_ConvoyTask* NewTask(){return new ERR_ConvoyTask();} ERR_ConvoyVehicle* NewVehicle(){return new ERR_ConvoyVehicle();}
|
||||
bool Current(){return current;}bool FillCrew(ERR_ConvoyVehicle* unit){crews++;return unit->Index!=failCrew;}
|
||||
@@ -50,6 +54,7 @@ int main(){
|
||||
ERR_ConvoyRules::valid=false;assert(!service.Dispatch(&receipt,positions,angles,&route,100));assert(!receipt.used&&ERR_Actors::calls==0);ERR_ConvoyRules::valid=true;
|
||||
ERR_ConvoyRules::clear=false;assert(!service.Dispatch(&receipt,positions,angles,&route,100));assert(!receipt.used&&ERR_Actors::calls==0);ERR_ConvoyRules::clear=true;
|
||||
ERR_ConvoyResources::available=false;assert(!service.Dispatch(&receipt,positions,angles,&route,100));assert(!receipt.used&&ERR_Actors::calls==0);ERR_ConvoyResources::available=true;
|
||||
ERR_VehicleSelection::empty=true;assert(!service.Dispatch(&receipt,positions,angles,&route,100)&&!receipt.used&&ERR_Actors::calls==0);ERR_VehicleSelection::empty=false;
|
||||
enemy.key="US"; // A selected non-USSR enemy uses the same finite dispatch transaction.
|
||||
auto task=service.Dispatch(&receipt,positions,angles,&route,100);assert(task&&task->Vehicles.Count()==6&&!task->stopped&&receipt.used&&pool.consumes==1&&ERR_Actors::calls==10&&mode.owned.Count()==10&&service.crews==5);
|
||||
assert(task->Vehicles[2]->Released&&!task->Vehicles[2]->Entity&&!task->Vehicles[2]->Group);
|
||||
|
||||
Reference in New Issue
Block a user