R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
PrefabFactory.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Created by hugo on 06/12/2025
4** File description:
5** PrefabFactory.hpp
6*/
7
8#pragma once
9
10#include <cstdint>
11#include <memory>
12#include <stdexcept>
13#include <string>
30
31// Forward declarations
32namespace ecs::wrapper {
33 class ECSWorld;
34}
35
36namespace ecs {
37 using Address = std::uint32_t;
38
46 public:
54 static ecs::Address createPlayer(ecs::Registry &registry, uint32_t playerId);
55
64 static ecs::Address createEnemy(ecs::Registry &registry, int enemyType, float posX, float posY);
65
77 static ecs::Address createEnemy(ecs::Registry &registry, const std::string &enemyType, float posX,
78 float posY, float health, int scoreValue,
79 const std::string &scriptPath = "");
80
92 static ecs::Address createEnemyFromRegistry(ecs::Registry &registry, const std::string &enemyType,
93 float posX, float posY, float health, int scoreValue,
94 const std::string &scriptPath = "");
95
109 static ecs::Address createProjectile(ecs::Registry &registry, uint32_t ownerId, float posX,
110 float posY, float dirX, float dirY, float speed, int damage,
111 bool friendly);
112
123 static ecs::Address createPowerUp(ecs::Registry &registry, ecs::BuffType buffType, float duration,
124 float value, float posX, float posY);
125
134 static ecs::Address createHealthPack(ecs::Registry &registry, int healthRestore, float posX,
135 float posY);
136
148 static ecs::Address createWall(ecs::Registry &registry, float posX, float posY, float width,
149 float height, bool destructible = false, int health = 0);
150
162 static ecs::Address createOrbitalModule(ecs::Registry &registry, uint32_t parentEntityId,
163 float orbitRadius = 50.0f, float orbitSpeed = 2.0f,
164 float startAngle = 0.0f, int damage = 10,
165 int moduleHealth = 50);
166
167 private:
175
176 static EnemySpawnData _getEnemySpawnData(int enemyType);
177 static int _enemyTypeFromString(const std::string &enemyType);
178 };
179
180} // namespace ecs
Registry for the ECS (Entity-Component System).
Factory for creating game entity prefabs.
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 createHealthPack(ecs::Registry &registry, int healthRestore, float posX, float posY)
Create a health pack collectible.
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 createPowerUp(ecs::Registry &registry, ecs::BuffType buffType, float duration, float value, float posX, float posY)
Create a collectible power-up entity.
static int _enemyTypeFromString(const std::string &enemyType)
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 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 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 EnemySpawnData _getEnemySpawnData(int enemyType)
Manages entities, their signatures and component type registrations.
Definition Registry.hpp:68
Maximum number of distinct component types supported by the Registry.
Definition GameLogic.hpp:26
BuffType
Types of buffs that can be applied to entities.
Definition Buff.hpp:20
std::uint32_t Address
Type used to represent an entity address/ID.