Class: object_binder<T>
Script-side binder attached to a client game_object.
Source
src/xrGame/script_binder_object_script.cpp, object_binder binding.
Source
src/xrGame/script_binder.cpp, CScriptBinder.
Custom Constructor
object_binder
Remarks
A config section can name a script_binding function. During reload, the engine calls that function with the object's game_object; the script normally creates an object_binder subclass for it. Binder hooks are client-object hooks. Server ALife objects use cse_alife_dynamic_object lifecycle methods instead.
Base hook implementations are empty, except net_spawn returns true and net_save_relevant returns false. If a hook throws, the engine clears the binder.
Extends
Type Parameters
| Type Parameter | Default type |
|---|---|
T | game_object |
Constructors
Constructor
new object_binder<T>(object: T): object_binder<T>;Create a binder for a script game object.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | T | Script game object controlled by this binder. |
Returns
object_binder<T>
Overrides
Methods
load()
load(reader: reader): void;Load binder state.
Parameters
| Parameter | Type | Description |
|---|---|---|
reader | reader | Source save reader. |
Returns
void
Remarks
Read data written by save. The engine does not validate custom binder packet layouts.
net_destroy()
net_destroy(): void;Handle this client object destruction.
Returns
void
Remarks
Called when this client object goes offline or is destroyed. This is the binder's own cleanup hook. net_Relcase is for another object being released.
net_export()
net_export(net_packet: net_packet): void;Export binder network state.
Parameters
| Parameter | Type | Description |
|---|---|---|
net_packet | net_packet | Destination network packet. |
Returns
void
Remarks
Pair this with net_import when the binder participates in network state synchronization.
net_import()
net_import(net_packet: net_packet): void;Import binder network state.
Parameters
| Parameter | Type | Description |
|---|---|---|
net_packet | net_packet | Source network packet. |
Returns
void
Remarks
Pair this with net_export when the binder participates in network state synchronization.
net_Relcase()
net_Relcase(object: T): void;Release references to a game object that is about to be destroyed.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | T | Object being released. |
Returns
void
Source
src/xrEngine/xr_object_list.cpp, CObjectList::SingleUpdate.
Source
src/xrGame/GameObject.cpp, CGameObject::net_Relcase.
Source
src/xrGame/script_binder.cpp, CScriptBinder::net_Relcase.
Remarks
The engine broadcasts this to every active and sleeping client object for every object in the destroy queue. Use it only to drop references to object; the callback is not limited to binders that reference it.
Keep overrides small, tolerate unrelated objects, and do not store or use object after this callback returns. The broadcast cost is roughly (active + sleeping client objects) * destroyed objects.
net_save_relevant()
net_save_relevant(): boolean;Decide whether binder state should be saved over the network.
Returns
boolean
Whether the state is relevant for network save.
Remarks
The base implementation returns false.
net_spawn()
net_spawn(object: cse_alife_object): boolean;Handle network spawn.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | cse_alife_object | Server object used for spawn data. |
Returns
boolean
Whether spawn succeeded.
Source
src/xrGame/script_binder.cpp, CScriptBinder::net_Spawn.
Remarks
Client-side online spawn hook. It can run again for the same logical ALife object when the engine recreates its online client object. Return false to reject the client spawn. The base implementation returns true.
reinit()
reinit(): void;Reinitialize binder runtime state.
Returns
void
Remarks
Called when the owning client object is reinitialized. Keep persistent state in save and load, not here.
reload()
reload(section: string): void;Reload binder configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
section | string | Object config section. |
Returns
void
Remarks
Called after the engine creates the script binder from the section's script_binding callback.
save()
save(packet: net_packet): void;Save binder state.
Parameters
| Parameter | Type | Description |
|---|---|---|
packet | net_packet | Destination save packet. |
Returns
void
Remarks
Write only data that load will read back in the same order.
update()
update(delta: number): void;Update binder logic.
Parameters
| Parameter | Type | Description |
|---|---|---|
delta | number | Time since last update in milliseconds. |
Returns
void
Remarks
Called from the owning client object's scheduled update while the object is online.
Properties
__name
readonly __name: string;LuaBind instance constructor name.
Inherited from
object
readonly object: T;Client game_object controlled by this binder.
Remarks
The engine passes this object to the constructor and stores the binder on the native client object. Treat the reference as engine-owned.
__name
readonly static __name: string;LuaBind class constructor name.