Jazz2::Scripting::Legacy::jjBEHAVIOR struct

What drives an object every tick.

A small value type that holds exactly one of three things: a built-in BEHAVIOR::Behavior constant, a script function matching jjVOIDFUNCOBJ, or an instance of a script class implementing jjBEHAVIORINTERFACE. It is mainly met as jjOBJ::behavior and as an argument of jjOBJ::behave(). Assignment, comparison and conversion operators accept each form, so the type rarely has to be named explicitly. A held function or object is kept alive for as long as the behavior holds it.

Public static functions

static auto Create(jjBEHAVIOR* self) -> jjBEHAVIOR*
Creates a behavior holding BEHAVIOR::INACTIVE.
static auto CreateFromBehavior(std::uint32_t behavior, jjBEHAVIOR* self) -> jjBEHAVIOR*
Creates a behavior holding the given built-in behavior.
static void Destroy(jjBEHAVIOR* self)
Destroys the behavior, releasing a held function or object.

Constructors, destructors, conversion operators

~jjBEHAVIOR()
jjBEHAVIOR() defaulted
Creates a new instance.
jjBEHAVIOR(const jjBEHAVIOR& other)
operator std::uint32_t()
Converts to the held built-in behavior.
operator asIScriptFunction*()
Casts to the held script function.
operator asIScriptObject*()
Casts to the held jjBEHAVIORINTERFACE instance.

Public functions

auto operator=(const jjBEHAVIOR& other) -> jjBEHAVIOR&
Copies another behavior into this one.
auto operator=(std::uint32_t other) -> jjBEHAVIOR&
Makes this behavior a built-in one, dropping a held function or object.
auto operator=(asIScriptFunction* other) -> jjBEHAVIOR&
Makes this behavior a script function, dropping a held built-in behavior or object.
auto operator=(asIScriptObject* other) -> jjBEHAVIOR&
Makes this behavior a jjBEHAVIORINTERFACE instance, dropping a held built-in behavior or function.
auto operator==(const jjBEHAVIOR& other) const -> bool
Whether both behaviors hold the same built-in behavior, function or object.
auto operator==(std::uint32_t other) const -> bool
Whether this behavior is the given built-in behavior (never true while it holds a function or object).
auto operator==(const asIScriptFunction* other) const -> bool
Whether this behavior holds the given script function.

Public variables

std::uint32_t behaviorId
asIScriptFunction* function
asIScriptObject* object

Function documentation

Jazz2::Scripting::Legacy::jjBEHAVIOR::operator std::uint32_t()

Converts to the held built-in behavior.

Gives BEHAVIOR::INACTIVE when the behavior holds a script function or object instead.

Jazz2::Scripting::Legacy::jjBEHAVIOR::operator asIScriptFunction*()

Casts to the held script function.

Gives null when the behavior holds a built-in behavior or a jjBEHAVIORINTERFACE instance.

Jazz2::Scripting::Legacy::jjBEHAVIOR::operator asIScriptObject*()

Casts to the held jjBEHAVIORINTERFACE instance.

Gives null when the behavior holds a built-in behavior or a script function.