R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::PrefabFactory Class Reference

Factory for creating game entity prefabs. More...

#include <PrefabFactory.hpp>

Collaboration diagram for ecs::PrefabFactory:
Collaboration graph

Classes

struct  EnemySpawnData
 

Static Public Member Functions

static ecs::Address createPlayer (ecs::Registry &registry, uint32_t playerId)
 Create a player entity.
 
static ecs::Address createEnemy (ecs::Registry &registry, int enemyType, float posX, float posY)
 Create an enemy entity.
 
static ecs::Address createEnemy (ecs::Registry &registry, const std::string &enemyType, float posX, float posY, float health, int scoreValue, const std::string &scriptPath="")
 Create an enemy entity with custom parameters (for SpawnSystem)
 
static ecs::Address createEnemyFromRegistry (ecs::Registry &registry, const std::string &enemyType, float posX, float posY, float health, int scoreValue, const std::string &scriptPath="")
 Create an enemy entity directly from Registry (for SpawnSystem)
 
static ecs::Address createProjectile (ecs::Registry &registry, uint32_t ownerId, float posX, float posY, float dirX, float dirY, float speed, int damage, bool friendly)
 Create a projectile entity.
 
static ecs::Address createPowerUp (ecs::Registry &registry, ecs::BuffType buffType, float duration, float value, float posX, float posY)
 Create a collectible power-up entity.
 
static ecs::Address createHealthPack (ecs::Registry &registry, int healthRestore, float posX, float posY)
 Create a health pack collectible.
 
static ecs::Address createWall (ecs::Registry &registry, float posX, float posY, float width, float height, bool destructible=false, int health=0)
 Create a wall/obstacle entity.
 
static ecs::Address createOrbitalModule (ecs::Registry &registry, uint32_t parentEntityId, float orbitRadius=50.0f, float orbitSpeed=2.0f, float startAngle=0.0f, int damage=10, int moduleHealth=50)
 Create an orbital module (drone) entity.
 

Static Private Member Functions

static EnemySpawnData _getEnemySpawnData (int enemyType)
 
static int _enemyTypeFromString (const std::string &enemyType)
 

Detailed Description

Factory for creating game entity prefabs.

Used to instantiate entities with predefined components and settings.

Definition at line 45 of file PrefabFactory.hpp.

Member Function Documentation

◆ _enemyTypeFromString()

int ecs::PrefabFactory::_enemyTypeFromString ( const std::string &  enemyType)
staticprivate

Definition at line 186 of file PrefabFactory.cpp.

References LOG_WARNING.

Referenced by createEnemy(), and createEnemyFromRegistry().

◆ _getEnemySpawnData()

PrefabFactory::EnemySpawnData ecs::PrefabFactory::_getEnemySpawnData ( int  enemyType)
staticprivate

Definition at line 171 of file PrefabFactory.cpp.

Referenced by createEnemy(), createEnemy(), and createEnemyFromRegistry().

◆ createEnemy() [1/2]

Address ecs::PrefabFactory::createEnemy ( ecs::Registry registry,
const std::string &  enemyType,
float  posX,
float  posY,
float  health,
int  scoreValue,
const std::string &  scriptPath = "" 
)
static

Create an enemy entity with custom parameters (for SpawnSystem)

Parameters
registryECS registry
enemyTypeType string ("basic", "advanced", "fast", "boss")
posXStarting X position
posYStarting Y position
healthCustom health value
scoreValueCustom score value
scriptPathOptional Lua script path for AI behavior
Returns
Entity address or 0 if failed

Definition at line 80 of file PrefabFactory.cpp.

References _enemyTypeFromString(), _getEnemySpawnData(), ecs::PrefabFactory::EnemySpawnData::colliderHeight, ecs::PrefabFactory::EnemySpawnData::colliderWidth, LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), ecs::Registry::setComponent(), and ecs::PrefabFactory::EnemySpawnData::speed.

Here is the call graph for this function:

◆ createEnemy() [2/2]

Address ecs::PrefabFactory::createEnemy ( ecs::Registry registry,
int  enemyType,
float  posX,
float  posY 
)
static

Create an enemy entity.

Parameters
registryECS registry
enemyTypeType of enemy (0=basic, 1=heavy, 2=fast, etc.)
posXStarting X position
posYStarting Y position
Returns
Entity address or 0 if failed

Definition at line 36 of file PrefabFactory.cpp.

References _getEnemySpawnData(), ecs::PrefabFactory::EnemySpawnData::colliderHeight, ecs::PrefabFactory::EnemySpawnData::colliderWidth, ecs::PrefabFactory::EnemySpawnData::health, LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), ecs::PrefabFactory::EnemySpawnData::scoreValue, ecs::Registry::setComponent(), and ecs::PrefabFactory::EnemySpawnData::speed.

Here is the call graph for this function:

◆ createEnemyFromRegistry()

Address ecs::PrefabFactory::createEnemyFromRegistry ( ecs::Registry registry,
const std::string &  enemyType,
float  posX,
float  posY,
float  health,
int  scoreValue,
const std::string &  scriptPath = "" 
)
static

Create an enemy entity directly from Registry (for SpawnSystem)

Parameters
registryECS registry
enemyTypeType string ("basic", "advanced", "fast", "boss")
posXStarting X position
posYStarting Y position
healthCustom health value
scoreValueCustom score value
scriptPathOptional Lua script path for AI behavior
Returns
Entity address or 0 if failed

Definition at line 109 of file PrefabFactory.cpp.

References _enemyTypeFromString(), _getEnemySpawnData(), ecs::PrefabFactory::EnemySpawnData::colliderHeight, ecs::PrefabFactory::EnemySpawnData::colliderWidth, LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), ecs::Registry::setComponent(), and ecs::PrefabFactory::EnemySpawnData::speed.

Here is the call graph for this function:

◆ createHealthPack()

Address ecs::PrefabFactory::createHealthPack ( ecs::Registry registry,
int  healthRestore,
float  posX,
float  posY 
)
static

Create a health pack collectible.

Parameters
registryECS registry
healthRestoreAmount of health to restore
posXStarting X position
posYStarting Y position
Returns
Entity address or 0 if failed

Definition at line 155 of file PrefabFactory.cpp.

References LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), and ecs::Registry::setComponent().

Here is the call graph for this function:

◆ createOrbitalModule()

ecs::Address ecs::PrefabFactory::createOrbitalModule ( ecs::Registry registry,
uint32_t  parentEntityId,
float  orbitRadius = 50.0f,
float  orbitSpeed = 2.0f,
float  startAngle = 0.0f,
int  damage = 10,
int  moduleHealth = 50 
)
static

Create an orbital module (drone) entity.

Parameters
registryECS registry
parentEntityIdID of the entity to orbit around (typically player)
orbitRadiusDistance from parent center
orbitSpeedAngular velocity in radians per second
startAngleInitial angle in radians (default: 0)
damageDamage dealt on contact with enemies
moduleHealthHealth points for the module
Returns
Entity address or 0 if failed

Definition at line 225 of file PrefabFactory.cpp.

References AnimDB::createOrbitalModuleAnimations(), ecs::Registry::getComponent(), ecs::Transform::getPosition(), ecs::Registry::hasComponent(), LOG_ERROR, LOG_INFO, ecs::CollisionLayers::MASK_PLAYER_MODULE, ecs::CollisionLayers::PLAYER_MODULE, and ecs::Registry::setComponent().

Referenced by server::GameLogic::spawnPlayer().

Here is the call graph for this function:

◆ createPlayer()

Address ecs::PrefabFactory::createPlayer ( ecs::Registry registry,
uint32_t  playerId 
)
static

Create a player entity.

Parameters
worldECS world wrapper
playerIdUnique player ID
playerNameDisplay name
Returns
Entity address or 0 if failed

Definition at line 16 of file PrefabFactory.cpp.

References LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), and ecs::Registry::setComponent().

Here is the call graph for this function:

◆ createPowerUp()

Address ecs::PrefabFactory::createPowerUp ( ecs::Registry registry,
ecs::BuffType  buffType,
float  duration,
float  value,
float  posX,
float  posY 
)
static

Create a collectible power-up entity.

Parameters
registryECS registry
buffTypeType of buff to grant
durationDuration of buff (0.0f for permanent)
valueBuff value/multiplier
posXStarting X position
posYStarting Y position
Returns
Entity address or 0 if failed

Definition at line 138 of file PrefabFactory.cpp.

References LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), and ecs::Registry::setComponent().

Here is the call graph for this function:

◆ createProjectile()

Address ecs::PrefabFactory::createProjectile ( ecs::Registry registry,
uint32_t  ownerId,
float  posX,
float  posY,
float  dirX,
float  dirY,
float  speed,
int  damage,
bool  friendly 
)
static

Create a projectile entity.

Parameters
registryECS registry
ownerIdOwner entity ID (shooter)
posXStarting X position
posYStarting Y position
dirXDirection X component
dirYDirection Y component
speedMovement speed
damageDamage value
friendlyTrue for player projectile, false for enemy
Returns
Entity address or 0 if failed

Definition at line 56 of file PrefabFactory.cpp.

References AnimDB::createPlayerBulletAnimations(), LOG_ERROR, ecs::Registry::newEntity(), and ecs::Registry::setComponent().

Here is the call graph for this function:

◆ createWall()

ecs::Address ecs::PrefabFactory::createWall ( ecs::Registry registry,
float  posX,
float  posY,
float  width,
float  height,
bool  destructible = false,
int  health = 0 
)
static

Create a wall/obstacle entity.

Parameters
registryECS registry
posXStarting X position
posYStarting Y position
widthWall width
heightWall height
destructibleWhether the wall can be destroyed
healthHealth points (0 = indestructible)
Returns
Entity address or 0 if failed

Definition at line 199 of file PrefabFactory.cpp.

References LOG_ERROR, LOG_INFO, ecs::Registry::newEntity(), and ecs::Registry::setComponent().

Here is the call graph for this function:

The documentation for this class was generated from the following files: