2 * Purpose: common player state, usable on client and server
3 * Client: singleton representing the viewed player
4 * Server: instance per client, clients decoupled from players
6 CLASS(PlayerState, Object)
7 ATTRIB(PlayerState, m_client, entity, NULL)
8 CONSTRUCTOR(PlayerState, entity client)
10 CONSTRUCT(PlayerState);
11 this.m_client = client;
13 ATTRIB(PlayerState, m_switchingweapon, Weapon, Weapons_from(-1))
14 ATTRIB(PlayerState, m_switchweapon, Weapon, Weapons_from(-1))
15 ATTRIB(PlayerState, m_weapon, Weapon, Weapons_from(-1))
16 METHOD(PlayerState, ps_push, void(PlayerState this, entity cl))
18 STAT(ACTIVEWEAPON, cl) = this.m_weapon.m_id;
19 STAT(SWITCHINGWEAPON, cl) = this.m_switchingweapon.m_id;
20 STAT(SWITCHWEAPON, cl) = this.m_switchweapon.m_id;
26 #define PS(this) (this._ps)
28 PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; }
31 void PlayerState_attach(entity this)
34 // this._ps = NEW(PlayerState, this);
37 void PlayerState_detach(entity this)
40 // if (!PS(this)) return; // initial connect
46 * Purpose: common client state, usable on client and server
47 * Client: singleton representing the viewed player
48 * Server: instance per client
50 CLASS(ClientState, Object)
51 ATTRIB(ClientState, m_client, entity, NULL)
52 CONSTRUCTOR(ClientState, entity client)
54 CONSTRUCT(ClientState);
55 this.m_client = client;
62 #define CS(this) (this._cs)
64 ClientState CS(entity this) { assert(IS_CLIENT(this)); assert(this._cs); return this._cs; }
67 void ClientState_attach(entity this)
69 this._cs = NEW(ClientState, this);
70 this._ps = NEW(PlayerState, this); // TODO: dynamic
73 void ClientState_detach(entity this)
77 this._ps = NULL; // TODO: dynamic