Files
EscapistsReintroduced/tests/test_actor_group.py
T
jakub cab998fb64 Combine Workshop addon and fix prison startup
Merge owned systems into one addon while preserving resource identities. Gate player admission on the replicated prison scene, restore the original framed door, and hold enemy AI until escape. Correct scenario branding and author metadata, include publishing assets, and retain regression and native verification evidence.
2026-09-20 16:42:52 +02:00

34 lines
2.2 KiB
Python

"""Exercise actual actor-group lookup with distinct inherited vehicle and controlled character agents."""
from policy_harness import ROOT, body, run
source=body(ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_Actors.c','static SCR_AIGroup Group(')
source=source.replace('static SCR_AIGroup Group(IEntity actor)', 'static SCR_AIGroup* Group(IEntity* actor)')
source=source.replace('AIControlComponent control', 'AIControlComponent* control')
source=source.replace('AIControlComponent.Cast(', 'AIControlComponent::Cast(').replace('SCR_AIGroup.Cast(', 'SCR_AIGroup::Cast(')
source=source.replace('actor.FindComponent(AIControlComponent)', 'actor->FindComponent()')
source=source.replace('control.', 'control->').replace('GetControlAIAgent().', 'GetControlAIAgent()->').replace('null', 'nullptr')
run(r'''
#include <cassert>
struct SCR_AIGroup {static SCR_AIGroup* Cast(SCR_AIGroup* g){return g;}};
struct Agent {SCR_AIGroup* parent=nullptr;SCR_AIGroup* GetParentGroup(){return parent;}};
struct AIControlComponent {
Agent* inherited=nullptr;Agent* controlled=nullptr;int inheritedReads=0;
static AIControlComponent* Cast(AIControlComponent* c){return c;}
Agent* GetAIAgent(){inheritedReads++;return inherited;}Agent* GetControlAIAgent(){return controlled;}
};
struct IEntity {AIControlComponent* control=nullptr;AIControlComponent* FindComponent(){return control;}};
struct Actors {
'''+source+r'''
};
int main(){
assert(!Actors::Group(nullptr));IEntity actor;assert(!Actors::Group(&actor));
AIControlComponent control;actor.control=&control;assert(!Actors::Group(&actor));
SCR_AIGroup foot,convoy,vehicle;Agent personal{&foot},delegated{&vehicle};
control.controlled=&personal;control.inherited=&personal;assert(Actors::Group(&actor)==&foot);
personal.parent=&convoy;control.inherited=&delegated;
assert(Actors::Group(&actor)==&convoy&&control.inheritedReads==0);
control.controlled=nullptr;assert(!Actors::Group(&actor)&&control.inheritedReads==0);
control.controlled=&personal;personal.parent=nullptr;assert(!Actors::Group(&actor));
}
''')
print('PASS: actual actor group lookup retains controlled character membership when seated/inherited vehicle agents differ; missing control or parent refuses')