Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""Actual scope sampling/identity selection; native weapon/camera APIs doubled."""
|
||||
from policy_harness import ROOT, body, run
|
||||
p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverScope.c'
|
||||
def adapt(s):
|
||||
import re
|
||||
s=s.replace('out vector view[4]', 'vector (&view)[4]').replace('out vector data','vector& data').replace('out float fov','float& fov').replace('out RplId weaponId','RplId& weaponId').replace('null','nullptr')
|
||||
for cls in ('ChimeraCharacter','CharacterControllerComponent','BaseWeaponManagerComponent','SCR_2DOpticsComponent','SCR_2DPIPSightsComponent','RplComponent'):
|
||||
s=re.sub(r'\b'+cls+r' (\w+)',cls+r'* \1',s);s=s.replace(cls+'.',cls+'::')
|
||||
for name in ('character','control','weapons','optic','rpl','pip','actor'):
|
||||
s=s.replace(name+'.',name+'->')
|
||||
for name in ('GetCharacterController()','GetCurrentWeapon()','GetOwner()','GetPIPCamera()'):
|
||||
s=s.replace(name+'.',name+'->')
|
||||
s=s.replace('FindComponent(RplComponent)','FindComponent()').replace('RplId.','RplId::').replace('Math.','Math::').replace('vector.Zero','vector::Zero')
|
||||
return s
|
||||
run(r'''
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
struct vector{float a=0,b=0,c=0;float&operator[](int i){return i==0?a:(i==1?b:c);}bool operator==(vector o){return a==o.a&&b==o.b&&c==o.c;}static vector Zero;};vector vector::Zero;
|
||||
vector Vector(float a,float b,float c){return {a,b,c};}
|
||||
struct RplId{int id=-1;RplId(int n=-1):id(n){}static RplId Invalid(){return {};}bool operator==(RplId o){return id==o.id;}bool operator!=(RplId o){return id!=o.id;}};
|
||||
namespace Math{float Round(float n){return std::round(n);}}
|
||||
struct RplComponent{RplId id=10;RplId Id(){return id;}static RplComponent*Cast(RplComponent*p){return p;}};
|
||||
struct Camera{void GetWorldCameraTransform(vector (&v)[4]){v[3]={1,2,3};}};
|
||||
struct SCR_2DOpticsComponent{bool ads=true,lit=false;float fov=12,offset=.1;virtual ~SCR_2DOpticsComponent(){}static SCR_2DOpticsComponent*Cast(SCR_2DOpticsComponent*p){return p;}bool IsSightADSActive(){return ads;}float GetFOV(){return fov;}float GetCurrentReticleOffsetY(){return offset;}bool ERR_ObserverIlluminated(){return lit;}};
|
||||
struct SCR_2DPIPSightsComponent:SCR_2DOpticsComponent{bool enabled=true;Camera*camera=nullptr;static SCR_2DPIPSightsComponent*Cast(SCR_2DOpticsComponent*p){return dynamic_cast<SCR_2DPIPSightsComponent*>(p);}bool IsPIPEnabled(){return enabled;}Camera*GetPIPCamera(){return camera;}};
|
||||
struct Weapon{RplComponent rpl;Weapon*GetOwner(){return this;}RplComponent*FindComponent(){return &rpl;}};
|
||||
struct BaseWeaponManagerComponent{Weapon*weapon=nullptr;SCR_2DOpticsComponent*optic=nullptr;int index=0;Weapon*GetCurrentWeapon(){return weapon;}SCR_2DOpticsComponent*GetCurrentSights(){return optic;}int GetCurrentSightsIndex(){return index;}};
|
||||
struct CharacterControllerComponent{bool ads=true;BaseWeaponManagerComponent weapons;bool IsWeaponADS(){return ads;}BaseWeaponManagerComponent*GetWeaponManagerComponent(){return &weapons;}};
|
||||
struct ChimeraCharacter{CharacterControllerComponent control;CharacterControllerComponent*GetCharacterController(){return &control;}static ChimeraCharacter*Cast(ChimeraCharacter*p){return p;}};using IEntity=ChimeraCharacter*;
|
||||
struct Scope{
|
||||
'''+''.join(adapt(body(p,s)) for s in ('static bool Valid(', 'static void Sample(', 'static SCR_2DOpticsComponent Resolve('))+r'''
|
||||
};
|
||||
int main(){
|
||||
ChimeraCharacter actor;Weapon weapon;SCR_2DOpticsComponent optic;actor.control.weapons.weapon=&weapon;actor.control.weapons.optic=&optic;
|
||||
vector view[4],data;float fov=60;RplId id;
|
||||
Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(10)&&fov==12&&data[0]==1&&data[1]==.1f);
|
||||
assert(Scope::Resolve(&actor,id,data)==&optic);
|
||||
actor.control.weapons.index=1;assert(!Scope::Resolve(&actor,id,data));actor.control.weapons.index=0;
|
||||
assert(!Scope::Resolve(&actor,11,data));assert(!Scope::Resolve(nullptr,id,data));
|
||||
actor.control.ads=false;fov=60;Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1)&&data==vector::Zero&&fov==60);actor.control.ads=true;
|
||||
optic.ads=false;Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1));optic.ads=true;
|
||||
optic.fov=std::numeric_limits<float>::quiet_NaN();Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1));optic.fov=12;
|
||||
SCR_2DPIPSightsComponent pip;actor.control.weapons.optic=&pip;
|
||||
Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1)); // no camera yet
|
||||
Camera camera;pip.camera=&camera;pip.lit=true;Scope::Sample(&actor,view,fov,id,data);
|
||||
assert(id==RplId(10)&&data[2]==1&&view[3]==Vector(1,2,3)&&fov==12);
|
||||
pip.enabled=false;view[3]={7,8,9};Scope::Sample(&actor,view,fov,id,data);assert(view[3]==Vector(7,8,9)); // 2D keeps sampled player pose
|
||||
actor.control.weapons.weapon=nullptr;Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1));
|
||||
}
|
||||
''')
|
||||
print('PASS: production scope sampling preserves ordinary views, selects active ADS only, carries zoom/zeroing/illumination and rejects mismatched/unstreamed optics; native APIs doubled')
|
||||
Reference in New Issue
Block a user