2 * Purpose: common client state, usable on client and server
3 * Client: singleton representing the viewed player
4 * Server: instance per client
6 CLASS(ClientState, Object)
7 ATTRIB(ClientState, m_client, entity, NULL)
8 CONSTRUCTOR(ClientState, entity client)
10 CONSTRUCT(ClientState);
11 this.m_client = client;
18 #define CS(this) (this._cs)
20 ClientState CS(entity this) { assert(IS_CLIENT(this)); assert(this._cs); return this._cs; }
23 void ClientState_attach(entity this)
25 this._cs = NEW(ClientState, this);
28 void ClientState_detach(entity this)
37 * Purpose: common player state, usable on client and server
38 * Client: singleton representing the viewed player
39 * Server: instance per client, clients decoupled from players
41 CLASS(PlayerState, Object)
42 ATTRIB(PlayerState, m_client, entity, NULL)
43 CONSTRUCTOR(PlayerState, entity client)
45 CONSTRUCT(PlayerState);
46 this.m_client = client;
48 ATTRIB(PlayerState, m_switchingweapon, Weapon, Weapons_from(-1))
49 ATTRIB(PlayerState, m_switchweapon, Weapon, Weapons_from(-1))
50 ATTRIB(PlayerState, m_weapon, Weapon, Weapons_from(-1))
51 METHOD(PlayerState, ps_push, void(PlayerState this))
53 STAT(SWITCHWEAPON, this.m_client) = this.m_switchweapon.m_id;
59 #define PS(this) (this._ps)
61 PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; }
64 void PlayerState_attach(entity this)
66 LOG_INFO("Attached\n");
67 this._ps = NEW(PlayerState, this);
70 void PlayerState_detach(entity this)
72 if (!PS(this)) return; // initial connect