Add own-body spectator camera and player names; record Workshop 0.0.139
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-11-03 21:16:05 +01:00
parent 4f02ad64b4
commit 828bb0a1a7
17 changed files with 1048 additions and 35 deletions
+6 -3
View File
@@ -62,7 +62,7 @@ struct Math {
static float Cos(float v){return std::cos(v);}
};
struct Entity {
bool alive=true;Entity* vehicle=nullptr;
bool alive=true,conscious=true;Entity* vehicle=nullptr;
vector transform[4]={{1,0,0},{0,1,0},{0,0,1},{200,30,300}};
vector lower={190,28,290},upper={210,36,310};
void GetWorldTransform(vector* out){for(int i=0;i<4;i++)out[i]=transform[i];}
@@ -70,7 +70,7 @@ struct Entity {
};
using IEntity=Entity*;
struct CompartmentAccessComponent {static IEntity GetVehicleIn(IEntity e){return e->vehicle;}};
struct ERR_Actors {static bool Alive(IEntity e){return e&&e->alive;}};
struct ERR_Actors {static bool Alive(IEntity e){return e&&e->alive;}static bool CanFight(IEntity e){return Alive(e)&&e->conscious;}};
struct Controller {IEntity target=nullptr;vector anchor={100,20,300};vector ERR_ObserverAnchor(){return anchor;}} owner;
Controller* controller=&owner;
struct Inputs {
@@ -123,7 +123,10 @@ int main(){
Follow corpse;corpse.m_PlayerView=true;corpse.Frame(p);
assert(near(corpse.m_Yaw,189)&&near(world.last.Start,actor.transform[3]+vector(0,.4,0)));
assert(world.last.Exclude==&actor);
actor.alive=true;Follow living;living.Frame(p);
actor.alive=true;actor.conscious=false;Follow casualty;casualty.m_PlayerView=true;casualty.Frame(p);
assert(near(casualty.m_Yaw,189)&&near(world.last.Start,actor.transform[3]+vector(0,.4,0)));
inputs.zoom=.1;float previousDistance=casualty.m_Distance;casualty.Frame(p);assert(casualty.m_Distance>previousDistance);
actor.conscious=true;inputs={1,0,0};Follow living;living.Frame(p);
assert(near(living.m_Yaw,189)&&near(world.last.Start,actor.transform[3]+vector(0,1.5,0)));
// A living teammate's unavailable sampled player view keeps its existing
// stable fallback; this fix must not introduce mouse-driven shoulder drift.
+9 -3
View File
@@ -84,11 +84,17 @@ int main(){
Spawn mixed;assert(mixed.SpawnPosition(&mode,p)&&p==other.origin&&mixed.m_Placement.last==&other);
Observer mixedFollow;mixedFollow.m_ERRServerObserved=&replacement;mixedFollow.ERR_UpdateObserverServer();assert(mixedFollow.m_ERRServerObserved==&other&&mixedFollow.releases==1);
manager.controlled[1]=&original;Observer cycling;cycling.ERR_UpdateObserverServer();assert(cycling.m_ERRServerObserved==&original);cycling.ERR_UpdateObserverServer(1);assert(cycling.m_ERRServerObserved==&other);cycling.ERR_UpdateObserverServer(1);assert(cycling.m_ERRServerObserved==&original);cycling.ERR_UpdateObserverServer(-1);assert(cycling.m_ERRServerObserved==&other);
// Unconscious player keeps possession and follows only conscious canonical teammates.
// Unconscious player keeps possession and cycles conscious teammates plus their own body.
Observer casualty;casualty.own=&original;casualty.m_ERRObserverReason=0;original.conscious=false;
casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRObserverReason==4&&casualty.m_ERRServerObserved==&other&&casualty.own==&original);
other.conscious=false;casualty.ERR_UpdateObserverServer();assert(!casualty.m_ERRServerObserved&&casualty.m_ERRObserverAnchor==original.origin);
other.conscious=true;casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRServerObserved==&other);
casualty.ERR_UpdateObserverServer(1);assert(casualty.m_ERRServerObserved==&original&&casualty.own==&original);
casualty.ERR_UpdateObserverServer(0);assert(casualty.m_ERRServerObserved==&original); // polling retains own body
casualty.ERR_UpdateObserverServer(1);assert(casualty.m_ERRServerObserved==&other);
casualty.ERR_UpdateObserverServer(-1);assert(casualty.m_ERRServerObserved==&original);
other.conscious=false;casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRServerObserved==&original&&casualty.m_ERRObserverAnchor==original.origin);
casualty.ERR_UpdateObserverServer(1);assert(casualty.m_ERRServerObserved==&original); // no duplicate own-body entries
other.conscious=true;casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRServerObserved==&original); // do not switch automatically
casualty.ERR_UpdateObserverServer(1);assert(casualty.m_ERRServerObserved==&other);
original.conscious=true;casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRObserverReason==0&&!casualty.m_ERRServerObserved&&casualty.own==&original);
original.conscious=false;life.Connected=false;casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRObserverReason==0);
life.Connected=true;casualty.ERR_UpdateObserverServer();assert(casualty.m_ERRObserverReason==4);