Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
PrefabFactory Class Reference

Factory class for creating entities from prefab blueprints. More...

#include <prefabfactory.h>

+ Collaboration diagram for PrefabFactory:

Public Member Functions

void RegisterComponentFactory (const std::string &componentName, std::function< bool(EntityID, const ComponentDefinition &)> factory)
 Register a component factory (called by auto-registration system)
 
bool IsComponentRegistered (const std::string &componentName) const
 Check if a component is registered.
 
std::vector< std::string > GetRegisteredComponents () const
 Get list of all registered components (for debugging)
 
void PreloadAllPrefabs (const std::string &prefabDirectory="Blueprints/EntityPrefab")
 Preload all prefabs from directory.
 
EntityID CreateEntityFromPrefabName (const std::string &prefabName)
 Create entity from prefab name.
 
int GetPrefabCount () const
 Create entity from prefab name with explicit layer override.
 
bool HasPrefab (const std::string &prefabName) const
 Check if prefab exists.
 
void RegisterPrefab (const std::string &name, PrefabBuilder builder)
 Register a legacy prefab builder function.
 
EntityID CreateEntity (const std::string &prefabName)
 Create an entity using legacy prefab system.
 
void SetPrefabRegistry (const PrefabRegistry &registry)
 Set the prefab registry cache.
 
const PrefabRegistryGetPrefabRegistry () const
 Get the cached prefab registry.
 
std::string NormalizeType (const std::string &type) const
 Normalize a type string to canonical form.
 
bool AreTypesEquivalent (const std::string &type1, const std::string &type2) const
 Check if two types are equivalent.
 
bool IsTypeRegistered (const std::string &type) const
 Check if a type is registered.
 
bool GetCanonicalInfo (const std::string &type, std::string &outCanonical, std::string &outPrefabFile) const
 Get canonical type info for debugging.
 
EntityID CreateEntityFromBlueprint (const PrefabBlueprint &blueprint, bool autoAssignLayer=true)
 Create entity from a parsed blueprint.
 
EntityID CreateEntityWithOverrides (const PrefabBlueprint &blueprint, const LevelInstanceParameters &instanceParams, bool autoAssignLayer=true)
 Create entity from blueprint with level instance parameter overrides.
 
bool InstantiateComponent (EntityID entity, const ComponentDefinition &componentDef)
 Instantiate a single component on an entity.
 

Static Public Member Functions

static PrefabFactoryGet ()
 Get singleton instance.
 

Private Member Functions

 PrefabFactory ()=default
 
bool InstantiateIdentity (EntityID entity, const ComponentDefinition &def)
 
bool InstantiatePosition (EntityID entity, const ComponentDefinition &def)
 
bool InstantiatePhysicsBody (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateVisualSprite (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateVisualEditor (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateVisualAnimation (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAIBehavior (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAIBlackboard (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAISenses (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAIState (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateBehaviorTreeRuntime (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateMoveIntent (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAttackIntent (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateBoundingBox (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateMovement (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateHealth (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateTriggerZone (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateCollisionZone (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAnimation (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateFX (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateAudioSource (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateController (EntityID entity, const ComponentDefinition &def)
 
bool InstantiatePlayerController (EntityID entity, const ComponentDefinition &def)
 
bool InstantiatePlayerBinding (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateNPC (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateInventory (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateCamera (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateCameraTarget (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateCameraEffects (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateCameraBounds (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateCameraInputBinding (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateInputMapping (EntityID entity, const ComponentDefinition &def)
 
bool InstantiateNavigationAgent (EntityID entity, const ComponentDefinition &def)
 

Private Attributes

std::map< std::string, PrefabBuilderm_prefabs
 
PrefabRegistry m_prefabRegistry
 
bool m_prefabsPreloaded = false
 
std::unique_ptr< PrefabScannerm_scanner
 
std::map< std::string, std::function< bool(EntityID, const ComponentDefinition &)> > m_componentFactories
 

Detailed Description

Factory class for creating entities from prefab blueprints.

PrefabFactory manages entity creation from JSON blueprint files. It supports both modern component-agnostic instantiation and legacy function-based prefabs.

See also
PrefabBlueprint
ComponentDefinition
Examples
/home/runner/work/Olympe-Engine/Olympe-Engine/Source/World.h.

Definition at line 32 of file prefabfactory.h.

Constructor & Destructor Documentation

◆ PrefabFactory()

PrefabFactory::PrefabFactory ( )
privatedefault

Member Function Documentation

◆ AreTypesEquivalent()

bool PrefabFactory::AreTypesEquivalent ( const std::string &  type1,
const std::string &  type2 
) const

Check if two types are equivalent.

Parameters
type1First type string
type2Second type string
Returns
true if types are equivalent

Definition at line 165 of file PrefabFactory.cpp.

References GetComponentTypeID_Static(), and m_scanner.

+ Here is the call graph for this function:

◆ CreateEntity()

EntityID PrefabFactory::CreateEntity ( const std::string &  prefabName)

Create an entity using legacy prefab system.

Parameters
prefabNameName of the prefab
Returns
EntityID of created entity

Definition at line 129 of file PrefabFactory.cpp.

References World::CreateEntity(), CreateEntityFromPrefabName(), World::Get(), GetComponentTypeID_Static(), m_prefabs, and SYSTEM_LOG.

Referenced by VideoGame::InitializeAITestScene().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateEntityFromBlueprint()

EntityID PrefabFactory::CreateEntityFromBlueprint ( const PrefabBlueprint blueprint,
bool  autoAssignLayer = true 
)

Create entity from a parsed blueprint.

Parameters
blueprintParsed prefab blueprint
autoAssignLayerIf true, automatically assign layer based on EntityType
Returns
EntityID of created entity

Definition at line 193 of file PrefabFactory.cpp.

References World::CreateEntity(), World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::GetDefaultLayerForType(), World::HasComponent(), InstantiateComponent(), INVALID_ENTITY_ID, World::SetEntityLayer(), and SYSTEM_LOG.

Referenced by CreateEntityFromPrefabName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateEntityFromPrefabName()

EntityID PrefabFactory::CreateEntityFromPrefabName ( const std::string &  prefabName)

Create entity from prefab name.

Instantiates a new entity by loading and applying all components defined in the prefab blueprint file.

Parameters
prefabNameName of the prefab (without .json extension)
Returns
EntityID of created entity, or INVALID_ENTITY_ID on failure
See also
PrefabBlueprint
InstantiateComponent

Definition at line 110 of file PrefabFactory.cpp.

References CreateEntityFromBlueprint(), PrefabRegistry::Find(), GetComponentTypeID_Static(), INVALID_ENTITY_ID, m_prefabRegistry, m_prefabsPreloaded, and SYSTEM_LOG.

Referenced by VideoGame::AddPlayerEntity(), and CreateEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateEntityWithOverrides()

EntityID PrefabFactory::CreateEntityWithOverrides ( const PrefabBlueprint blueprint,
const LevelInstanceParameters instanceParams,
bool  autoAssignLayer = true 
)

Create entity from blueprint with level instance parameter overrides.

This is the unified method for both static and dynamic object creation.

Parameters
blueprintParsed prefab blueprint
instanceParamsLevel instance parameters to override blueprint defaults
autoAssignLayerIf true, automatically assign layer based on EntityType
Returns
EntityID of created entity

Definition at line 245 of file PrefabFactory.cpp.

References ComponentDefinition::componentType, World::CreateEntity(), World::Get(), World::GetComponent(), GetComponentTypeID_Static(), World::GetDefaultLayerForType(), World::HasComponent(), InstantiateComponent(), INVALID_ENTITY_ID, Position_data::position, ParameterResolver::Resolve(), World::SetEntityLayer(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ Get()

static PrefabFactory & PrefabFactory::Get ( )
inlinestatic

Get singleton instance.

Returns
Reference to PrefabFactory instance

Definition at line 39 of file prefabfactory.h.

References GetComponentTypeID_Static().

Referenced by VideoGame::AddPlayerEntity(), Olympe::Tiled::TiledToOlympe::Convert(), World::Initialize_ECS_Systems(), VideoGame::InitializeAITestScene(), World::LoadLevelFromTiled(), RegisterComponentFactory_Internal(), BehaviorTreeDependencyScanner::ScanPrefabs(), and World::ValidateLevelPrefabs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCanonicalInfo()

bool PrefabFactory::GetCanonicalInfo ( const std::string &  type,
std::string &  outCanonical,
std::string &  outPrefabFile 
) const

Get canonical type info for debugging.

Parameters
typeType to query
outCanonicalOutput parameter for canonical type name
outPrefabFileOutput parameter for prefab file path
Returns
true if type was found

Definition at line 183 of file PrefabFactory.cpp.

References GetComponentTypeID_Static(), and m_scanner.

+ Here is the call graph for this function:

◆ GetPrefabCount()

int PrefabFactory::GetPrefabCount ( ) const
inline

Create entity from prefab name with explicit layer override.

Get prefab count

Returns
Number of loaded prefabs

Definition at line 94 of file prefabfactory.h.

References PrefabRegistry::GetCount(), and m_prefabRegistry.

+ Here is the call graph for this function:

◆ GetPrefabRegistry()

const PrefabRegistry & PrefabFactory::GetPrefabRegistry ( ) const
inline

Get the cached prefab registry.

Returns
Reference to the prefab registry

Definition at line 142 of file prefabfactory.h.

References m_prefabRegistry.

Referenced by BehaviorTreeDependencyScanner::ScanPrefabs().

+ Here is the caller graph for this function:

◆ GetRegisteredComponents()

std::vector< std::string > PrefabFactory::GetRegisteredComponents ( ) const

Get list of all registered components (for debugging)

Definition at line 51 of file PrefabFactory.cpp.

References GetComponentTypeID_Static(), and m_componentFactories.

+ Here is the call graph for this function:

◆ HasPrefab()

bool PrefabFactory::HasPrefab ( const std::string &  prefabName) const
inline

Check if prefab exists.

Parameters
prefabNameName of the prefab to check
Returns
true if prefab exists in registry

Definition at line 101 of file prefabfactory.h.

References PrefabRegistry::Find(), and m_prefabRegistry.

+ Here is the call graph for this function:

◆ InstantiateAIBehavior()

bool PrefabFactory::InstantiateAIBehavior ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 776 of file PrefabFactory.cpp.

References World::AddComponent(), AIBehavior_data::behaviorType, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateAIBlackboard()

bool PrefabFactory::InstantiateAIBlackboard ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 788 of file PrefabFactory.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), and AIBlackboard_data::targetEntity.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateAISenses()

bool PrefabFactory::InstantiateAISenses ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 825 of file PrefabFactory.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), and AISenses_data::visionRadius.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateAIState()

bool PrefabFactory::InstantiateAIState ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1248 of file PrefabFactory.cpp.

References World::AddComponent(), Combat, AIState_data::currentMode, Dead, Flee, World::Get(), GetComponentTypeID_Static(), Idle, Investigate, Patrol, and SYSTEM_LOG.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateAnimation()

bool PrefabFactory::InstantiateAnimation ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 973 of file PrefabFactory.cpp.

References World::AddComponent(), Animation_data::animationID, Animation_data::currentFrame, Animation_data::frameDuration, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateAttackIntent()

bool PrefabFactory::InstantiateAttackIntent ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1421 of file PrefabFactory.cpp.

References World::AddComponent(), AttackIntent_data::Area, World::Get(), GetComponentTypeID_Static(), AttackIntent_data::Melee, AttackIntent_data::Ranged, SYSTEM_LOG, and AttackIntent_data::targetEntity.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateAudioSource()

bool PrefabFactory::InstantiateAudioSource ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1006 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), AudioSource_data::soundEffectID, and AudioSource_data::volume.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateBehaviorTreeRuntime()

bool PrefabFactory::InstantiateBehaviorTreeRuntime ( EntityID  entity,
const ComponentDefinition def 
)
private

◆ InstantiateBoundingBox()

bool PrefabFactory::InstantiateBoundingBox ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 862 of file PrefabFactory.cpp.

References World::AddComponent(), BoundingBox_data::boundingBox, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateCamera()

bool PrefabFactory::InstantiateCamera ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1110 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and Camera_data::playerId.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateCameraBounds()

bool PrefabFactory::InstantiateCameraBounds ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1167 of file PrefabFactory.cpp.

References World::AddComponent(), CameraBounds_data::boundingBox, World::Get(), GetComponentTypeID_Static(), and CameraBounds_data::useBounds.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateCameraEffects()

bool PrefabFactory::InstantiateCameraEffects ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1149 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and CameraEffects_data::isShaking.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateCameraInputBinding()

bool PrefabFactory::InstantiateCameraInputBinding ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1188 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and CameraInputBinding_data::playerId.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateCameraTarget()

bool PrefabFactory::InstantiateCameraTarget ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1131 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and CameraTarget_data::targetEntityID.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateCollisionZone()

bool PrefabFactory::InstantiateCollisionZone ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 952 of file PrefabFactory.cpp.

References World::AddComponent(), CollisionZone_data::bounds, World::Get(), GetComponentTypeID_Static(), and CollisionZone_data::isStatic.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateComponent()

bool PrefabFactory::InstantiateComponent ( EntityID  entity,
const ComponentDefinition componentDef 
)

◆ InstantiateController()

bool PrefabFactory::InstantiateController ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1021 of file PrefabFactory.cpp.

References World::AddComponent(), Controller_data::controllerID, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateFX()

bool PrefabFactory::InstantiateFX ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 991 of file PrefabFactory.cpp.

References World::AddComponent(), FX_data::effectType, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateHealth()

bool PrefabFactory::InstantiateHealth ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 921 of file PrefabFactory.cpp.

References World::AddComponent(), Health_data::currentHealth, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateIdentity()

bool PrefabFactory::InstantiateIdentity ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 481 of file PrefabFactory.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), Identity_data::name, and StringToEntityType().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateInputMapping()

bool PrefabFactory::InstantiateInputMapping ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1206 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and InputMapping_data::InitializeDefaults().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateInventory()

bool PrefabFactory::InstantiateInventory ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1099 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateMoveIntent()

bool PrefabFactory::InstantiateMoveIntent ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1375 of file PrefabFactory.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), and MoveIntent_data::targetPosition.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateMovement()

bool PrefabFactory::InstantiateMovement ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 889 of file PrefabFactory.cpp.

References World::AddComponent(), Movement_data::direction, World::Get(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateNavigationAgent()

bool PrefabFactory::InstantiateNavigationAgent ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1224 of file PrefabFactory.cpp.

References NavigationAgent_data::agentRadius, World::Get(), World::GetComponent(), GetComponentTypeID_Static(), and SYSTEM_LOG.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateNPC()

bool PrefabFactory::InstantiateNPC ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1087 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and NPC_data::npcType.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiatePhysicsBody()

bool PrefabFactory::InstantiatePhysicsBody ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 544 of file PrefabFactory.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), and PhysicsBody_data::mass.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiatePlayerBinding()

bool PrefabFactory::InstantiatePlayerBinding ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1071 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and PlayerBinding_data::playerIndex.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiatePlayerController()

bool PrefabFactory::InstantiatePlayerController ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 1041 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and PlayerController_data::isJumping.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiatePosition()

bool PrefabFactory::InstantiatePosition ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 514 of file PrefabFactory.cpp.

References World::Get(), World::GetComponent(), GetComponentTypeID_Static(), and Position_data::position.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateTriggerZone()

bool PrefabFactory::InstantiateTriggerZone ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 937 of file PrefabFactory.cpp.

References World::AddComponent(), World::Get(), GetComponentTypeID_Static(), and TriggerZone_data::radius.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateVisualAnimation()

bool PrefabFactory::InstantiateVisualAnimation ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 727 of file PrefabFactory.cpp.

References VisualAnimation_data::bankId, World::Get(), World::GetComponent(), and GetComponentTypeID_Static().

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateVisualEditor()

bool PrefabFactory::InstantiateVisualEditor ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 665 of file PrefabFactory.cpp.

References World::AddComponent(), GameEntity, DataManager::Get(), World::Get(), GetComponentTypeID_Static(), DataManager::GetSprite(), VisualEditor_data::sprite, and SYSTEM_LOG.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstantiateVisualSprite()

bool PrefabFactory::InstantiateVisualSprite ( EntityID  entity,
const ComponentDefinition def 
)
private

Definition at line 578 of file PrefabFactory.cpp.

References GameEntity, DataManager::Get(), World::Get(), World::GetComponent(), GetComponentTypeID_Static(), DataManager::GetSprite(), VisualSprite_data::sprite, and SYSTEM_LOG.

Referenced by InstantiateComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsComponentRegistered()

bool PrefabFactory::IsComponentRegistered ( const std::string &  componentName) const

Check if a component is registered.

Definition at line 46 of file PrefabFactory.cpp.

References GetComponentTypeID_Static(), and m_componentFactories.

+ Here is the call graph for this function:

◆ IsTypeRegistered()

bool PrefabFactory::IsTypeRegistered ( const std::string &  type) const

Check if a type is registered.

Parameters
typeType string to check (will be normalized)
Returns
true if type is registered

Definition at line 174 of file PrefabFactory.cpp.

References m_scanner.

◆ NormalizeType()

std::string PrefabFactory::NormalizeType ( const std::string &  type) const

Normalize a type string to canonical form.

Parameters
typeType string to normalize
Returns
Normalized type string

Definition at line 156 of file PrefabFactory.cpp.

References m_scanner.

◆ PreloadAllPrefabs()

void PrefabFactory::PreloadAllPrefabs ( const std::string &  prefabDirectory = "Blueprints/EntityPrefab")

Preload all prefabs from directory.

Scans and caches all prefab blueprints for fast entity creation. Should be called once at engine startup (World::Initialize).

Parameters
prefabDirectoryPath to prefab directory (default: "Blueprints/EntityPrefab")

Definition at line 73 of file PrefabFactory.cpp.

References PrefabBlueprint::components, PrefabRegistry::Find(), PrefabRegistry::GetAllPrefabNames(), GetComponentTypeID_Static(), PrefabRegistry::GetCount(), m_prefabRegistry, m_prefabsPreloaded, m_scanner, and SYSTEM_LOG.

Referenced by World::Initialize_ECS_Systems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterComponentFactory()

void PrefabFactory::RegisterComponentFactory ( const std::string &  componentName,
std::function< bool(EntityID, const ComponentDefinition &)>  factory 
)

Register a component factory (called by auto-registration system)

Definition at line 31 of file PrefabFactory.cpp.

References GetComponentTypeID_Static(), and m_componentFactories.

Referenced by RegisterComponentFactory_Internal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterPrefab()

void PrefabFactory::RegisterPrefab ( const std::string &  name,
PrefabBuilder  builder 
)
inline

Register a legacy prefab builder function.

Parameters
namePrefab name
builderFunction that builds the entity

Definition at line 115 of file prefabfactory.h.

References GetComponentTypeID_Static(), m_prefabs, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ SetPrefabRegistry()

void PrefabFactory::SetPrefabRegistry ( const PrefabRegistry registry)

Set the prefab registry cache.

Parameters
registryPrefabRegistry to use for lookups

Definition at line 144 of file PrefabFactory.cpp.

References GetComponentTypeID_Static(), PrefabRegistry::GetCount(), m_prefabRegistry, m_prefabsPreloaded, and SYSTEM_LOG.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_componentFactories

std::map<std::string, std::function<bool(EntityID, const ComponentDefinition&)> > PrefabFactory::m_componentFactories
private

◆ m_prefabRegistry

PrefabRegistry PrefabFactory::m_prefabRegistry
private

◆ m_prefabs

std::map<std::string, PrefabBuilder> PrefabFactory::m_prefabs
private

Definition at line 212 of file prefabfactory.h.

Referenced by CreateEntity(), and RegisterPrefab().

◆ m_prefabsPreloaded

bool PrefabFactory::m_prefabsPreloaded = false
private

◆ m_scanner

std::unique_ptr<PrefabScanner> PrefabFactory::m_scanner
private

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