This is the base class for the components that a game entity is composed/aggregated of. More...
Public Member Functions | |
any | get (string var_name) |
Returns the value of an attribute (a member variable) of this class. More... | |
set (string var_name, any new_value) | |
Sets an attribute (a member variable) of this class to a new value. More... | |
string | GetExtraMessage (string var_name) |
Returns the result of VarBaseT::GetExtraMessage() for the given member variable. More... | |
interpolate (string var_name, number start_value, number end_value, number time) | |
Schedules a value for interpolation between a start and end value over a given period of time. More... | |
EntityT | GetEntity () |
Returns the entity that this component is a part of (or nil if the component is currently "stand-alone", not a part of any entity). More... | |
InitClientApprox (string VarName) | |
Registers the given attribute (a member variable) of this class for interpolation over client frames in order to bridge the larger intervals between server frames. More... | |
Event Handlers (Callbacks) | |
See the Event Handlers (Callbacks) overview page for additional information about the methods in this group. | |
OnInit () | |
This method is called for each component of each entity as the last step of initializing a newly loaded map. More... | |
OnClientFrame (number t) | |
This method is called for each component of each entity before the client renders the next frame. More... | |
This is the base class for the components that a game entity is composed/aggregated of.
Components are the basic building blocks of an entity: their composition defines the properties, the behaviour, and thus virtually every aspect of the entity.
Components of this type are never instantiated directly, but always indirectly through one of the derived classes.
any get | ( | string | var_name | ) |
Returns the value of an attribute (a member variable) of this class.
The variables of this class are also referred to as "Public Attributes" or "Member Data", and include the variables of the concrete, derived component class as well as those of its base classes. (However, there is currently only one base class, ComponentBaseT, which adds methods such as get() and set(), but adds no additional variables to its derived classes.)
At this time, it is not yet possible to write script code like this:
but instead, we have to write it like this:
var_name | The name of the variable whose value is to be retrieved. |
EntityT GetEntity | ( | ) |
Returns the entity that this component is a part of (or nil
if the component is currently "stand-alone", not a part of any entity).
string GetExtraMessage | ( | string | var_name | ) |
Returns the result of VarBaseT::GetExtraMessage()
for the given member variable.
This is currently only used with ComponentModelT components, in order to learn why loading a specific model may have failed:
InitClientApprox | ( | string | VarName | ) |
Registers the given attribute (a member variable) of this class for interpolation over client frames in order to bridge the larger intervals between server frames.
This method only works with variables whose related C++ type is float
, double
, Vector2fT
or Vector3fT
, and is typically used with ComponentTransform::Origin and ComponentTransform::Orientation. For example:
interpolate | ( | string | var_name, |
number | start_value, | ||
number | end_value, | ||
number | time | ||
) |
Schedules a value for interpolation between a start and end value over a given period of time.
Only variables that are floating-point numbers and variables that are tuples whose elements are floating-point numbers can be interpolated. (These are the variables whose underlying C++ type is float
, double
, Vector2fT
or Vector3fT
.) For variables that are tuples, you must append one of the suffixes .x
, .y
, .z
to determine the first, second or third element for interpolation. Alternatively, the suffixes .r
, .g
, .b
are more naturally used with color tuples, and work exactly alike.
var_name | The name of the window attribute to interpolate. Also see set() for details. |
start_value | The start value. |
end_value | The end value. |
time | The time in milliseconds to interpolate the variable from start_value to end_value . |
OnClientFrame | ( | number | t | ) |
This method is called for each component of each entity before the client renders the next frame.
The method is a great opportunity to add eye candy effects to a game world that are not synchronized over the network. (Such effects are not necessarily the same for every player and thus must not be relevant for the gameplay.)
As it is called for each component of each entity with the client's framerate, the implementation must be very careful to keep performance implications light.
While the implementation can generally modify any variable of any component, it is important to note that for any such variable, InitClientApprox() should be called (once beforehand). Even if the implementation is not interested in the so activated interpolation, at this time we rely on InitClientApprox() to restore the previous, original value after the client frame has been rendered. The calls to InitClientApprox() make sure that any changes that the implementation of OnClientFrame() made are properly cleaned up so that the next call to OnClientFrame() re-starts with the original, unmodified (but properly predicted and possibly interpolated) values.
OnInit | ( | ) |
This method is called for each component of each entity as the last step of initializing a newly loaded map.
set | ( | string | var_name, |
any | new_value | ||
) |
Sets an attribute (a member variable) of this class to a new value.
The variables of this class are also referred to as "Public Attributes" or "Member Data", and include the variables of the concrete, derived component class as well as those of its base classes. (However, there is currently only one base class, ComponentBaseT, which adds methods such as get() and set(), but adds no additional variables to its derived classes.)
At this time, it is not yet possible to write script code like this:
but instead, we have to write it like this:
var_name | The name of the variable whose value is to be set. |
new_value | The new value that is assigned to the variable. Note that this can be a tuple if the value itself is a tuple as shown in the example above. |