Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
API

Script-side API exposed to user DLLs. More...

Namespaces

namespace  Raven::Script::Log::Internal
 Internal ABI-stable log sinks. Prefer the typed templates below.

Classes

class  Raven::ScriptBase
 Abstract base class for all user-authored native scripts. More...
struct  Raven::ScriptLifecycle
 Factory and destructor callbacks for a single registered script type. More...

Macros

#define RV_REFLECT(Type)
 Registers a script class with the Ignite reflection and lifecycle system.
#define RV_REFLECT_MEMBER(Type, Member)
 Exposes a member variable of a reflected script class to the inspector and serialisation system.

Typedefs

using RV_RegisterScriptsFn = void (*)(Raven::TypeRegistry*, std::unordered_map<Raven::TypeID, Raven::ScriptLifecycle>*)
 Type alias for the exported registration function pointer.

Functions

template<typename... Args>
void Raven::Script::Log::Debug (std::format_string< Args... > fmt, Args &&... args)
 Logs a debug-level message from a script. Supports std::format syntax.
template<typename... Args>
void Raven::Script::Log::Info (std::format_string< Args... > fmt, Args &&... args)
 Logs an info-level message from a script. Supports std::format syntax.
template<typename... Args>
void Raven::Script::Log::Warning (std::format_string< Args... > fmt, Args &&... args)
 Logs a warning-level message from a script. Supports std::format syntax.
template<typename... Args>
void Raven::Script::Log::Error (std::format_string< Args... > fmt, Args &&... args)
 Logs an error-level message from a script. Supports std::format syntax.
template<typename... Args>
void Raven::Script::Log::Critical (std::format_string< Args... > fmt, Args &&... args)
 Logs a critical-level message from a script. Supports std::format syntax.
void Raven::Script::Physics::AddImpulse (u64 entityID, const Crux::vec3 &impulse)
 Applies an instantaneous linear impulse to an entity's physics body.
void Raven::Script::Physics::AddForce (u64 entityID, const Crux::vec3 &force)
 Applies a continuous force to an entity's physics body for the current sub-step.
void Raven::Script::Physics::AddTorque (u64 entityID, const Crux::vec3 &torque)
 Applies a continuous torque to an entity's physics body for the current sub-step.
void Raven::Script::Physics::AddLinearVelocity (u64 entityID, const Crux::vec3 &velocity)
 Adds a delta to the current linear velocity of an entity's physics body.
void Raven::Script::Physics::SetLinearVelocity (u64 entityID, const Crux::vec3 &velocity)
 Overwrites the linear velocity of an entity's physics body.
Crux::vec3 Raven::Script::Physics::GetLinearVelocity (u64 entityID)
 Returns the current linear velocity of an entity's physics body.
void Raven::Script::Physics::AddAngularImpulse (u64 entityID, const Crux::vec3 &impulse)
 Applies an instantaneous angular impulse to an entity's physics body.
void Raven::Script::Physics::SetAngularVelocity (u64 entityID, const Crux::vec3 &velocity)
 Overwrites the angular velocity of an entity's physics body.
Crux::vec3 Raven::Script::Physics::GetAngularVelocity (u64 entityID)
 Returns the current angular velocity of an entity's physics body.
void Raven::Script::Physics::SetGravityFactor (u64 entityID, float factor)
 Scales the world gravity vector for a single entity's physics body.
void Raven::Script::Physics::SetActive (u64 entityID, bool active)
 Activates or deactivates an entity's physics body in the simulation.
void Raven::Script::Random::Seed (u64 seed)
 Seeds the script-side random engine with an explicit value.
f32 Raven::Script::Random::Float ()
 Returns a random f32 in [0, 1).
f32 Raven::Script::Random::Float (f32 max)
 Returns a random f32 in [0, max).
f32 Raven::Script::Random::Float (f32 min, f32 max)
 Returns a random f32 in [min, max).
u32 Raven::Script::Random::Int ()
 Returns a random u32 over the full range.
u32 Raven::Script::Random::Int (u32 max)
 Returns a random u32 in [0, max).
u32 Raven::Script::Random::Int (u32 min, u32 max)
 Returns a random u32 in [min, max).
u64 Raven::Script::Random::U64 ()
 Returns a random u64 constructed from two u32 draws.
f64 Raven::Script::Random::Double ()
 Returns a random f64 in [0, 1).
f64 Raven::Script::Random::Double (f64 max)
 Returns a random f64 in [0, max).
f64 Raven::Script::Random::Double (f64 min, f64 max)
 Returns a random f64 in [min, max).
void Raven::Script::Renderer::CreateMesh (Entity &entity, const std::string &path)
 Loads a static mesh asset and attaches it to an entity.
void Raven::Script::Scene::SetContext (class Scene *scene)
 Sets the scene that all Script::Scene API calls will operate on.
Entity Raven::Script::Scene::CreateEntity (const std::string &name)
 Creates a new entity in the active scene.
void Raven::Script::Scene::DestroyEntity (u64 entityID)
 Destroys the entity with the given ID in the active scene.
Entity Raven::Script::Scene::FindEntityByName (const std::string &name)
 Searches the active scene for an entity whose TagComponent matches name.

Detailed Description

Script-side API exposed to user DLLs.

Contains the base class, lifecycle descriptors, reflection registration machinery (RV_REFLECT / RV_REFLECT_MEMBER macros and the pending-registration lists), the scene context, and the facade namespaces scripts call into.

Macro Definition Documentation

◆ RV_REFLECT

#define RV_REFLECT ( Type)
Value:
RV_REFLECT_INTERN(Type, __COUNTER__)

Registers a script class with the Ignite reflection and lifecycle system.

Place at file scope in ScriptEntry.cpp, after including the class header. The class must inherit from Raven::ScriptBase. Generates a static Raven::PendingRegistration instance that self-registers at DLL load time and is flushed into the engine registry when RV_RegisterScripts is called.

Parameters
TypeFully-qualified script class name.
// ScriptEntry.cpp
#include "Assets/Scripts/PlayerController.h"
RV_REFLECT(Sandbox::PlayerController)
extern "C" __declspec(dllexport)
void RV_RegisterScripts(Raven::TypeRegistry* r, std::unordered_map<Raven::TypeID, Raven::ScriptLifecycle>* lc)
{
}
Global runtime type registry for Raven Engine.
Definition Type.h:46
#define RV_REFLECT(Type)
Registers a script class with the Ignite reflection and lifecycle system.
Definition ScriptEntry.h:253
static void FlushInto(TypeRegistry *registry, std::unordered_map< TypeID, ScriptLifecycle > *lifecycles)
Flushes all pending types, members, and lifecycles into the registry.
Definition ScriptEntry.h:163

◆ RV_REFLECT_MEMBER

#define RV_REFLECT_MEMBER ( Type,
Member )
Value:
RV_REFLECT_MEMBER_INTERN(Type, Member, __COUNTER__)

Exposes a member variable of a reflected script class to the inspector and serialisation system.

Place at file scope in ScriptEntry.cpp immediately after the RV_REFLECT call for the owning class. Generates a static Raven::PendingMemberRegistration that records the member's name, type, and byte offset. Supported member types are those covered by TypeCategoryTrait (scalars, strings, and Crux vector types).

Parameters
TypeFully-qualified script class name.
MemberUnqualified member variable name.
RV_REFLECT(Sandbox::PlayerController)
RV_REFLECT_MEMBER(Sandbox::PlayerController, Speed)
RV_REFLECT_MEMBER(Sandbox::PlayerController, JumpHeight)
#define RV_REFLECT_MEMBER(Type, Member)
Exposes a member variable of a reflected script class to the inspector and serialisation system.
Definition ScriptEntry.h:277

Typedef Documentation

◆ RV_RegisterScriptsFn

Type alias for the exported registration function pointer.

Raven::ScriptRegistry resolves this symbol via GetProcAddress and calls it to populate the engine's type registry and lifecycle map.

Function Documentation

◆ AddAngularImpulse()

IGNITE_API void Raven::Script::Physics::AddAngularImpulse ( u64 entityID,
const Crux::vec3 & impulse )

Applies an instantaneous angular impulse to an entity's physics body.

Parameters
entityIDECS entity identifier.
impulseAngular impulse in world space (kg*m²/s).

◆ AddForce()

IGNITE_API void Raven::Script::Physics::AddForce ( u64 entityID,
const Crux::vec3 & force )

Applies a continuous force to an entity's physics body for the current sub-step.

Parameters
entityIDECS entity identifier.
forceForce vector in world space (N).

◆ AddImpulse()

IGNITE_API void Raven::Script::Physics::AddImpulse ( u64 entityID,
const Crux::vec3 & impulse )

Applies an instantaneous linear impulse to an entity's physics body.

Parameters
entityIDECS entity identifier.
impulseImpulse vector in world space (kg*m/s).

◆ AddLinearVelocity()

IGNITE_API void Raven::Script::Physics::AddLinearVelocity ( u64 entityID,
const Crux::vec3 & velocity )

Adds a delta to the current linear velocity of an entity's physics body.

Parameters
entityIDECS entity identifier.
velocityVelocity delta in world space (m/s).

◆ AddTorque()

IGNITE_API void Raven::Script::Physics::AddTorque ( u64 entityID,
const Crux::vec3 & torque )

Applies a continuous torque to an entity's physics body for the current sub-step.

Parameters
entityIDECS entity identifier.
torqueTorque vector in world space (N*m).

◆ CreateEntity()

IGNITE_API Entity Raven::Script::Scene::CreateEntity ( const std::string & name)

Creates a new entity in the active scene.

Parameters
nameDisplay name assigned to the entity's TagComponent.
Returns
The newly created Entity.

◆ CreateMesh()

IGNITE_API void Raven::Script::Renderer::CreateMesh ( Entity & entity,
const std::string & path )

Loads a static mesh asset and attaches it to an entity.

Parameters
entityReference to the entity that will receive a StaticMeshComponent.
pathProject-relative path to the mesh asset.

◆ Critical()

template<typename... Args>
void Raven::Script::Log::Critical ( std::format_string< Args... > fmt,
Args &&... args )

Logs a critical-level message from a script. Supports std::format syntax.

Template Parameters
ArgsFormat argument types.
Parameters
fmtFormat string.
argsFormat arguments.

◆ Debug()

template<typename... Args>
void Raven::Script::Log::Debug ( std::format_string< Args... > fmt,
Args &&... args )

Logs a debug-level message from a script. Supports std::format syntax.

Template Parameters
ArgsFormat argument types.
Parameters
fmtFormat string.
argsFormat arguments.

◆ DestroyEntity()

IGNITE_API void Raven::Script::Scene::DestroyEntity ( u64 entityID)

Destroys the entity with the given ID in the active scene.

Parameters
entityIDECS entity identifier (ScriptBase::EntityID).

◆ Double() [1/3]

IGNITE_API f64 Raven::Script::Random::Double ( )

Returns a random f64 in [0, 1).

Note
Implemented by widening a f32 draw; precision beyond ~7 significant digits is not guaranteed.

◆ Double() [2/3]

IGNITE_API f64 Raven::Script::Random::Double ( f64 max)

Returns a random f64 in [0, max).

Parameters
maxExclusive upper bound.

◆ Double() [3/3]

IGNITE_API f64 Raven::Script::Random::Double ( f64 min,
f64 max )

Returns a random f64 in [min, max).

Parameters
minInclusive lower bound.
maxExclusive upper bound.

◆ Error()

template<typename... Args>
void Raven::Script::Log::Error ( std::format_string< Args... > fmt,
Args &&... args )

Logs an error-level message from a script. Supports std::format syntax.

Template Parameters
ArgsFormat argument types.
Parameters
fmtFormat string.
argsFormat arguments.

◆ FindEntityByName()

IGNITE_API Entity Raven::Script::Scene::FindEntityByName ( const std::string & name)

Searches the active scene for an entity whose TagComponent matches name.

Parameters
nameName to search for (exact match against TagComponent::Tag).
Returns
The matching Entity, or an entity wrapping a null UUID if not found.

◆ Float() [1/3]

IGNITE_API f32 Raven::Script::Random::Float ( )

Returns a random f32 in [0, 1).

◆ Float() [2/3]

IGNITE_API f32 Raven::Script::Random::Float ( f32 max)

Returns a random f32 in [0, max).

Parameters
maxExclusive upper bound.

◆ Float() [3/3]

IGNITE_API f32 Raven::Script::Random::Float ( f32 min,
f32 max )

Returns a random f32 in [min, max).

Parameters
minInclusive lower bound.
maxExclusive upper bound.

◆ GetAngularVelocity()

IGNITE_API Crux::vec3 Raven::Script::Physics::GetAngularVelocity ( u64 entityID)

Returns the current angular velocity of an entity's physics body.

Parameters
entityIDECS entity identifier.
Returns
Angular velocity in world space (rad/s), or zero if the entity has no body.

◆ GetLinearVelocity()

IGNITE_API Crux::vec3 Raven::Script::Physics::GetLinearVelocity ( u64 entityID)

Returns the current linear velocity of an entity's physics body.

Parameters
entityIDECS entity identifier.
Returns
Linear velocity in world space (m/s), or zero if the entity has no body.

◆ Info()

template<typename... Args>
void Raven::Script::Log::Info ( std::format_string< Args... > fmt,
Args &&... args )

Logs an info-level message from a script. Supports std::format syntax.

Template Parameters
ArgsFormat argument types.
Parameters
fmtFormat string.
argsFormat arguments.

◆ Int() [1/3]

IGNITE_API u32 Raven::Script::Random::Int ( )

Returns a random u32 over the full range.

◆ Int() [2/3]

IGNITE_API u32 Raven::Script::Random::Int ( u32 max)

Returns a random u32 in [0, max).

Parameters
maxExclusive upper bound.

◆ Int() [3/3]

IGNITE_API u32 Raven::Script::Random::Int ( u32 min,
u32 max )

Returns a random u32 in [min, max).

Parameters
minInclusive lower bound.
maxExclusive upper bound.

◆ Seed()

IGNITE_API void Raven::Script::Random::Seed ( u64 seed)

Seeds the script-side random engine with an explicit value.

If never called, the engine is seeded lazily on first use via Crux::Entropy::GetSeedPair.

Parameters
seedSeed value. The internal sequence is derived as seed ^ 0xdeadbeef.

◆ SetActive()

IGNITE_API void Raven::Script::Physics::SetActive ( u64 entityID,
bool active )

Activates or deactivates an entity's physics body in the simulation.

Parameters
entityIDECS entity identifier.
activetrue to activate (wake), false to deactivate (sleep).

◆ SetAngularVelocity()

IGNITE_API void Raven::Script::Physics::SetAngularVelocity ( u64 entityID,
const Crux::vec3 & velocity )

Overwrites the angular velocity of an entity's physics body.

Parameters
entityIDECS entity identifier.
velocityNew angular velocity in world space (rad/s).

◆ SetContext()

IGNITE_API void Raven::Script::Scene::SetContext ( class Scene * scene)

Sets the scene that all Script::Scene API calls will operate on.

Called by ScriptRuntime::OnRuntimeStart with the active scene and by ScriptRuntime::OnRuntimeStop with nullptr.

Parameters
sceneScene to make active, or nullptr to clear the context.

◆ SetGravityFactor()

IGNITE_API void Raven::Script::Physics::SetGravityFactor ( u64 entityID,
float factor )

Scales the world gravity vector for a single entity's physics body.

Parameters
entityIDECS entity identifier.
factorGravity multiplier: 0 = weightless, 1 = full gravity, negative = anti-gravity.

◆ SetLinearVelocity()

IGNITE_API void Raven::Script::Physics::SetLinearVelocity ( u64 entityID,
const Crux::vec3 & velocity )

Overwrites the linear velocity of an entity's physics body.

Parameters
entityIDECS entity identifier.
velocityNew linear velocity in world space (m/s).

◆ U64()

IGNITE_API u64 Raven::Script::Random::U64 ( )

Returns a random u64 constructed from two u32 draws.

◆ Warning()

template<typename... Args>
void Raven::Script::Log::Warning ( std::format_string< Args... > fmt,
Args &&... args )

Logs a warning-level message from a script. Supports std::format syntax.

Template Parameters
ArgsFormat argument types.
Parameters
fmtFormat string.
argsFormat arguments.