R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
scripting::bindings Namespace Reference

Classes

struct  ComponentBinding
 Information about a registered component. More...
 
class  ComponentBindingHelper
 Helper to simplify component registration. More...
 

Functions

ComponentBindingHelperbindComponents (sol::state &lua, ecs::wrapper::ECSWorld *world)
 Bind ECS component types to Lua.
 
void bindEntity (sol::state &lua, ecs::wrapper::ECSWorld *world, ComponentBindingHelper &helper)
 Bind Entity wrapper class and operations to Lua.
 
void bindServerGame (sol::state &lua, ecs::wrapper::ECSWorld *world, LuaEngine *engine)
 Bind server-specific game logic functions to Lua.
 
void bindWorld (sol::state &lua, ecs::wrapper::ECSWorld *world)
 Bind ECS world operations to Lua.
 

Variables

static ComponentBindingHelper g_componentHelper
 

Function Documentation

◆ bindComponents()

ComponentBindingHelper & scripting::bindings::bindComponents ( sol::state &  lua,
ecs::wrapper::ECSWorld world 
)

Bind ECS component types to Lua.

Binds each component to Lua and registers it with the helper. To add a new component:

  1. Bind it to Lua with lua.new_usertype<T>()
  2. Register it with helper.registerComponent<T>("Name")
Parameters
luaReference to the Lua state
worldPointer to the ECS world
Returns
ComponentBindingHelper& The configured helper
Note
Currently bound components: Transform, Velocity, Health

Definition at line 19 of file ComponentBindings.cpp.

References scripting::bindings::ComponentBindingHelper::clear(), g_componentHelper, ecs::Health::getCurrentHealth(), ecs::Velocity::getDirection(), ecs::Health::getInvincibilityTimer(), ecs::Health::getMaxHealth(), ecs::Transform::getPosition(), ecs::Transform::getRotation(), ecs::Velocity::getSpeed(), ecs::Health::isInvincible(), scripting::bindings::ComponentBindingHelper::registerComponent(), ecs::Health::setCurrentHealth(), ecs::Velocity::setDirection(), ecs::Health::setInvincibilityTimer(), ecs::Health::setInvincible(), ecs::Health::setMaxHealth(), ecs::Transform::setPosition(), ecs::Transform::setRotation(), and ecs::Velocity::setSpeed().

Referenced by scripting::LuaEngine::initializeBindings().

Here is the call graph for this function:

◆ bindEntity()

void scripting::bindings::bindEntity ( sol::state &  lua,
ecs::wrapper::ECSWorld world,
ComponentBindingHelper helper 
)

Bind Entity wrapper class and operations to Lua.

Uses ComponentBindingHelper to automatically generate get/has methods for all registered components.

Parameters
luaReference to the Lua state
worldPointer to the ECS world
helperThe helper with all registered components

Entity methods automatically bound:

  • getAddress() -> Address
  • isValid() -> bool
  • getTransform(), getVelocity(), getHealth() -> auto-generated
  • hasTransform(), hasVelocity(), hasHealth() -> auto-generated

Global functions:

  • removeComponent(addr, "ComponentName") -> auto-generated

Definition at line 10 of file EntityBindings.cpp.

References scripting::bindings::ComponentBindingHelper::applyEntityMethods(), scripting::bindings::ComponentBindingHelper::applyRemoveFunction(), ecs::wrapper::ECSWorld::destroyEntity(), ecs::wrapper::Entity::getAddress(), ecs::wrapper::Entity::isValid(), and LOG_INFO.

Referenced by scripting::LuaEngine::initializeBindings().

Here is the call graph for this function:

◆ bindServerGame()

void scripting::bindings::bindServerGame ( sol::state &  lua,
ecs::wrapper::ECSWorld world,
LuaEngine engine 
)

Bind server-specific game logic functions to Lua.

Provides high-level game functions for:

  • Spawning entities (enemies, projectiles, powerups)
  • Game state queries
  • Utility functions (math, random, etc.)
  • Event callbacks (onGameStart)
Parameters
luaReference to the Lua state
worldPointer to the ECS world
enginePointer to the LuaEngine (for callback registration)
Note
Functions exposed:
  • spawnEnemy(x, y, enemyType) -> Entity
  • spawnProjectile(x, y, dirX, dirY, speed, damage) -> Entity
  • random(min, max) -> float
  • getTime() -> float
  • onGameStart(callback) -> void

Definition at line 27 of file ServerGameBindings.cpp.

References ecs::wrapper::ECSWorld::createEntity(), ecs::DamageBoost, ecs::DoubleShot, ecs::WaveConfig::enemies, ecs::SpawnRequest::enemyType, ecs::FireRateBoost, ecs::wrapper::Entity::get(), ecs::wrapper::Entity::getAddress(), ecs::wrapper::Entity::has(), ecs::SpawnRequest::hasSpawned, ecs::SpawnRequest::health, ecs::HealthRegen, ecs::HomingShot, ecs::wrapper::Entity::isValid(), LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING, ecs::MaxHealthIncrease, ecs::MultiShot, ecs::PiercingShot, ecs::Spawner::queueSpawn(), ecs::SpawnRequest::scoreValue, ecs::SpawnRequest::scriptPath, ecs::Spawner::setConfig(), ecs::Shield, ecs::SpawnRequest::spawnDelay, ecs::WaveConfig::spawnInterval, ecs::SpeedBoost, ecs::TripleShot, ecs::wrapper::Entity::with(), ecs::SpawnRequest::x, and ecs::SpawnRequest::y.

Referenced by scripting::LuaEngine::initializeBindings().

Here is the call graph for this function:

◆ bindWorld()

void scripting::bindings::bindWorld ( sol::state &  lua,
ecs::wrapper::ECSWorld world 
)

Bind ECS world operations to Lua.

Provides global Lua functions for entity management and logging.

Parameters
luaReference to the Lua state
worldPointer to the ECS world (must not be nullptr)
Warning
The world pointer is captured by lambda closures. Ensure the world lifetime exceeds the Lua state lifetime.

Lua functions added:

  • createEntity() -> Entity
  • destroyEntity(Entity e) -> void
  • entityExists(Address addr) -> bool
  • log(string message) -> void

Definition at line 10 of file WorldBindings.cpp.

References ecs::wrapper::ECSWorld::createEntity(), ecs::wrapper::ECSWorld::destroyEntity(), ecs::wrapper::ECSWorld::getEntity(), ecs::wrapper::Entity::isValid(), LOG_DEBUG, LOG_ERROR, and LOG_WARNING.

Referenced by scripting::LuaEngine::initializeBindings().

Here is the call graph for this function:

Variable Documentation

◆ g_componentHelper

ComponentBindingHelper scripting::bindings::g_componentHelper
static

Definition at line 17 of file ComponentBindings.cpp.

Referenced by bindComponents().