24#include <unordered_map>
43 std::cout <<
"[ComponentRegistry] Registered: " <<
componentName <<
"\n";
53 std::vector<std::string> components;
57 components.push_back(
kv.first);
77 SYSTEM_LOG <<
"PrefabFactory::PreloadAllPrefabs: Already preloaded\n";
81 SYSTEM_LOG <<
"+===========================================================+\n";
82 SYSTEM_LOG <<
"| PREFAB FACTORY: PRELOADING ALL PREFABS |\n";
83 SYSTEM_LOG <<
"+===========================================================+\n";
100 if (
bp &&
bp->isValid)
106 SYSTEM_LOG <<
"\nok - PrefabFactory ready\n\n";
114 SYSTEM_LOG <<
"/!\\ PrefabFactory: Prefabs not preloaded! Call PreloadAllPrefabs() first\n";
122 SYSTEM_LOG <<
"x PrefabFactory: Prefab '" << prefabName <<
"' not found\n";
136 SYSTEM_LOG <<
"PrefabFactory::CreateEntity '" << prefabName <<
"' created (ID: " <<
newEntity <<
")\n";
178 return m_scanner->IsTypeRegistered(type);
197 SYSTEM_LOG <<
"PrefabFactory::CreateEntityFromBlueprint: Invalid blueprint '"
208 SYSTEM_LOG <<
"PrefabFactory::CreateEntityFromBlueprint: Failed to create entity for '"
226 SYSTEM_LOG <<
"PrefabFactory::CreateEntityFromBlueprint: Failed to instantiate component '"
227 <<
componentDef.componentType <<
"' on entity " << entity <<
"\n";
252 SYSTEM_LOG <<
"PrefabFactory::CreateEntityWithOverrides: Invalid blueprint '"
263 SYSTEM_LOG <<
"PrefabFactory::CreateEntityWithOverrides: Failed to create entity for '"
299 SYSTEM_LOG <<
" /!\\ Failed to instantiate component: " <<
resolved.componentType <<
"\n";
349 if (type ==
"BehaviorTreeRuntime_data")
351 else if (type ==
"Position_data")
353 else if (type ==
"Identity_data")
355 else if (type ==
"PhysicsBody_data")
357 else if (type ==
"VisualSprite_data")
359 else if (type ==
"VisualAnimation_data")
361 else if (type ==
"AIBlackboard_data")
363 else if (type ==
"AISenses_data")
365 else if (type ==
"MoveIntent_data")
367 else if (type ==
"NavigationAgent_data")
376 if (type ==
"Identity" || type ==
"Identity_data")
378 else if (type ==
"Position" || type ==
"Position_data")
380 else if (type ==
"PhysicsBody" || type ==
"PhysicsBody_data")
382 else if (type ==
"VisualSprite" || type ==
"VisualSprite_data")
384 else if (type ==
"VisualAnimation" || type ==
"VisualAnimation_data")
386 else if (type ==
"VisualEditor" || type ==
"VisualEditor_data")
388 else if (type ==
"AIBehavior" || type ==
"AIBehavior_data")
390 else if (type ==
"AIBlackboard" || type ==
"AIBlackboard_data")
392 else if (type ==
"AISenses" || type ==
"AISenses_data")
394 else if (type ==
"AIState" || type ==
"AIState_data")
396 else if (type ==
"BehaviorTreeRuntime" || type ==
"BehaviorTreeRuntime_data")
398 else if (type ==
"MoveIntent" || type ==
"MoveIntent_data")
400 else if (type ==
"AttackIntent" || type ==
"AttackIntent_data")
402 else if (type ==
"BoundingBox" || type ==
"BoundingBox_data")
404 else if (type ==
"Movement" || type ==
"Movement_data")
406 else if (type ==
"Health" || type ==
"Health_data")
408 else if (type ==
"TriggerZone" || type ==
"TriggerZone_data")
410 else if (type ==
"CollisionZone" || type ==
"CollisionZone_data")
412 else if (type ==
"Animation" || type ==
"Animation_data")
414 else if (type ==
"FX" || type ==
"FX_data")
416 else if (type ==
"AudioSource" || type ==
"AudioSource_data")
418 else if (type ==
"Controller" || type ==
"Controller_data")
420 else if (type ==
"PlayerController" || type ==
"PlayerController_data")
422 else if (type ==
"PlayerBinding" || type ==
"PlayerBinding_data")
424 else if (type ==
"NPC" || type ==
"NPC_data")
426 else if (type ==
"Inventory" || type ==
"Inventory_data")
428 else if (type ==
"Camera" || type ==
"Camera_data")
430 else if (type ==
"CameraTarget" || type ==
"CameraTarget_data")
432 else if (type ==
"CameraEffects" || type ==
"CameraEffects_data")
434 else if (type ==
"CameraBounds" || type ==
"CameraBounds_data")
436 else if (type ==
"CameraInputBinding" || type ==
"CameraInputBinding_data")
438 else if (type ==
"InputMapping" || type ==
"InputMapping_data")
442 SYSTEM_LOG <<
"PrefabFactory::InstantiateComponent: Unknown component type '"
444 SYSTEM_LOG <<
" Available auto-registered components:\n";
461 static const std::unordered_map<std::string, EntityType>
typeMap = {
486 std::cerr <<
"[PrefabFactory] ERROR: Identity_data not found for entity " << entity << std::endl;
487 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
495 if (
def.HasParameter(
"name"))
498 if (
def.HasParameter(
"tag"))
499 identity.tag =
def.GetParameter(
"tag")->AsString();
501 if (
def.HasParameter(
"entityType"))
504 identity.type =
def.GetParameter(
"entityType")->AsString();
519 std::cerr <<
"[PrefabFactory] ERROR: Position_data not found for entity " << entity << std::endl;
520 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
528 if (
def.HasParameter(
"position"))
530 position.
position =
def.GetParameter(
"position")->AsVector();
532 else if (
def.HasParameter(
"x") &&
def.HasParameter(
"y"))
534 float x =
def.GetParameter(
"x")->AsFloat();
535 float y =
def.GetParameter(
"y")->AsFloat();
536 float z =
def.HasParameter(
"z") ?
def.GetParameter(
"z")->AsFloat() : 0.0f;
549 std::cerr <<
"[PrefabFactory] ERROR: PhysicsBody_data not found for entity " << entity << std::endl;
550 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
558 if (
def.HasParameter(
"mass"))
561 if (
def.HasParameter(
"speed"))
562 physics.speed =
def.GetParameter(
"speed")->AsFloat();
565 if (
def.HasParameter(
"friction"))
566 physics.friction =
def.GetParameter(
"friction")->AsFloat();
568 if (
def.HasParameter(
"useGravity"))
569 physics.useGravity =
def.GetParameter(
"useGravity")->AsBool();
571 if (
def.HasParameter(
"rotation"))
572 physics.rotation =
def.GetParameter(
"rotation")->AsFloat();
583 std::cerr <<
"[PrefabFactory] ERROR: VisualSprite_data not found for entity " << entity << std::endl;
584 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
592 if (
def.HasParameter(
"spritePath"))
594 std::string spritePath =
def.GetParameter(
"spritePath")->AsString();
601 SYSTEM_LOG <<
"PrefabFactory::InstantiateVisualSprite: Failed to load sprite '"
602 << spritePath <<
"' - component will have null sprite\n";
612 if (
def.HasParameter(
"srcX") &&
def.HasParameter(
"srcY") &&
613 def.HasParameter(
"srcW") &&
def.HasParameter(
"srcH"))
615 visual.srcRect.x =
def.GetParameter(
"srcX")->AsFloat();
616 visual.srcRect.y =
def.GetParameter(
"srcY")->AsFloat();
617 visual.srcRect.w =
def.GetParameter(
"srcW")->AsFloat();
618 visual.srcRect.h =
def.GetParameter(
"srcH")->AsFloat();
627 if (
def.HasParameter(
"hotSpot"))
629 visual.hotSpot =
def.GetParameter(
"hotSpot")->AsVector();
631 else if (
def.HasParameter(
"hotSpotX") &&
def.HasParameter(
"hotSpotY"))
633 float x =
def.GetParameter(
"hotSpotX")->AsFloat();
634 float y =
def.GetParameter(
"hotSpotY")->AsFloat();
646 if (
def.HasParameter(
"color"))
648 visual.color =
def.GetParameter(
"color")->AsColor();
652 if (
def.HasParameter(
"visible"))
654 visual.visible =
def.GetParameter(
"visible")->AsBool();
670 if (
def.HasParameter(
"spritePath"))
672 std::string spritePath =
def.GetParameter(
"spritePath")->AsString();
679 SYSTEM_LOG <<
"PrefabFactory::InstantiateVisualEditor: Failed to load sprite '"
680 << spritePath <<
"' - component will have null sprite\n";
698 if (
def.HasParameter(
"color"))
700 editor.color =
def.GetParameter(
"color")->AsColor();
709 if (
def.HasParameter(
"visible"))
711 editor.isVisible =
def.GetParameter(
"visible")->AsBool();
732 std::cerr <<
"[PrefabFactory] ERROR: VisualAnimation_data not found for entity " << entity << std::endl;
733 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
741 if (
def.HasParameter(
"bankId"))
745 if (
def.HasParameter(
"currentAnimName"))
746 animData.currentAnimName =
def.GetParameter(
"currentAnimName")->AsString();
749 if (
def.HasParameter(
"animGraphPath"))
750 animData.animGraphPath =
def.GetParameter(
"animGraphPath")->AsString();
753 if (
def.HasParameter(
"playbackSpeed"))
754 animData.playbackSpeed =
def.GetParameter(
"playbackSpeed")->AsFloat();
756 if (
def.HasParameter(
"isPlaying"))
757 animData.isPlaying =
def.GetParameter(
"isPlaying")->AsBool();
759 if (
def.HasParameter(
"isPaused"))
760 animData.isPaused =
def.GetParameter(
"isPaused")->AsBool();
762 if (
def.HasParameter(
"loop"))
763 animData.loop =
def.GetParameter(
"loop")->AsBool();
766 if (
def.HasParameter(
"flipX"))
767 animData.flipX =
def.GetParameter(
"flipX")->AsBool();
769 if (
def.HasParameter(
"flipY"))
770 animData.flipY =
def.GetParameter(
"flipY")->AsBool();
781 if (
def.HasParameter(
"behaviorType"))
793 std::cerr <<
"[PrefabFactory] ERROR: AIBlackboard_data not found for entity " << entity << std::endl;
794 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
802 if (
def.HasParameter(
"targetEntity"))
805 if (
def.HasParameter(
"hasTarget"))
806 blackboard.hasTarget =
def.GetParameter(
"hasTarget")->AsBool();
808 if (
def.HasParameter(
"attackCooldown"))
809 blackboard.attackCooldown =
def.GetParameter(
"attackCooldown")->AsFloat();
812 if (
def.HasParameter(
"distanceToTarget"))
813 blackboard.distanceToTarget =
def.GetParameter(
"distanceToTarget")->AsFloat();
815 if (
def.HasParameter(
"targetVisible"))
816 blackboard.targetVisible =
def.GetParameter(
"targetVisible")->AsBool();
818 if (
def.HasParameter(
"targetInRange"))
819 blackboard.targetInRange =
def.GetParameter(
"targetInRange")->AsBool();
830 std::cerr <<
"[PrefabFactory] ERROR: AISenses_data not found for entity " << entity << std::endl;
831 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
839 if (
def.HasParameter(
"visionRadius"))
841 else if (
def.HasParameter(
"visionRange"))
842 senses.visionRadius =
def.GetParameter(
"visionRange")->AsFloat();
844 if (
def.HasParameter(
"visionAngle"))
845 senses.visionAngle =
def.GetParameter(
"visionAngle")->AsFloat();
847 if (
def.HasParameter(
"hearingRadius"))
848 senses.hearingRadius =
def.GetParameter(
"hearingRadius")->AsFloat();
849 else if (
def.HasParameter(
"hearingRange"))
850 senses.hearingRadius =
def.GetParameter(
"hearingRange")->AsFloat();
852 if (
def.HasParameter(
"perceptionHz"))
853 senses.perceptionHz =
def.GetParameter(
"perceptionHz")->AsFloat();
855 if (
def.HasParameter(
"thinkHz"))
856 senses.thinkHz =
def.GetParameter(
"thinkHz")->AsFloat();
867 if (
def.HasParameter(
"width") &&
def.HasParameter(
"height"))
870 bbox.boundingBox.h =
def.GetParameter(
"height")->AsFloat();
873 if (
def.HasParameter(
"x"))
874 bbox.boundingBox.x =
def.GetParameter(
"x")->AsFloat();
875 if (
def.HasParameter(
"y"))
876 bbox.boundingBox.y =
def.GetParameter(
"y")->AsFloat();
879 if (
def.HasParameter(
"offsetX"))
880 bbox.boundingBox.x =
def.GetParameter(
"offsetX")->AsFloat();
881 if (
def.HasParameter(
"offsetY"))
882 bbox.boundingBox.y =
def.GetParameter(
"offsetY")->AsFloat();
894 if (
def.HasParameter(
"direction"))
898 else if (
def.HasParameter(
"directionX") &&
def.HasParameter(
"directionY"))
900 float x =
def.GetParameter(
"directionX")->AsFloat();
901 float y =
def.GetParameter(
"directionY")->AsFloat();
906 if (
def.HasParameter(
"velocity"))
908 movement.velocity =
def.GetParameter(
"velocity")->AsVector();
910 else if (
def.HasParameter(
"velocityX") &&
def.HasParameter(
"velocityY"))
912 float x =
def.GetParameter(
"velocityX")->AsFloat();
913 float y =
def.GetParameter(
"velocityY")->AsFloat();
926 if (
def.HasParameter(
"currentHealth"))
929 if (
def.HasParameter(
"maxHealth"))
930 health.maxHealth =
def.GetParameter(
"maxHealth")->AsInt();
942 if (
def.HasParameter(
"radius"))
945 if (
def.HasParameter(
"triggered"))
946 trigger.triggered =
def.GetParameter(
"triggered")->AsBool();
957 if (
def.HasParameter(
"x") &&
def.HasParameter(
"y") &&
958 def.HasParameter(
"width") &&
def.HasParameter(
"height"))
960 collision.
bounds.x =
def.GetParameter(
"x")->AsFloat();
961 collision.
bounds.y =
def.GetParameter(
"y")->AsFloat();
962 collision.
bounds.w =
def.GetParameter(
"width")->AsFloat();
963 collision.
bounds.h =
def.GetParameter(
"height")->AsFloat();
966 if (
def.HasParameter(
"isStatic"))
967 collision.
isStatic =
def.GetParameter(
"isStatic")->AsBool();
978 if (
def.HasParameter(
"animationID"))
979 animation.
animationID =
def.GetParameter(
"animationID")->AsString();
981 if (
def.HasParameter(
"frameDuration"))
984 if (
def.HasParameter(
"currentFrame"))
996 if (
def.HasParameter(
"effectType"))
999 if (
def.HasParameter(
"duration"))
1000 fx.duration =
def.GetParameter(
"duration")->AsFloat();
1011 if (
def.HasParameter(
"soundEffectID"))
1014 if (
def.HasParameter(
"volume"))
1015 audio.
volume =
def.GetParameter(
"volume")->AsFloat();
1026 if (
def.HasParameter(
"controllerID"))
1034 if (
def.HasParameter(
"isConnected"))
1035 controller.isConnected =
def.GetParameter(
"isConnected")->AsBool();
1046 if (
def.HasParameter(
"isJumping"))
1049 if (
def.HasParameter(
"isShooting"))
1050 playerCtrl.isShooting =
def.GetParameter(
"isShooting")->AsBool();
1052 if (
def.HasParameter(
"isRunning"))
1053 playerCtrl.isRunning =
def.GetParameter(
"isRunning")->AsBool();
1055 if (
def.HasParameter(
"isInteracting"))
1056 playerCtrl.isInteracting =
def.GetParameter(
"isInteracting")->AsBool();
1058 if (
def.HasParameter(
"isWalking"))
1059 playerCtrl.isWalking =
def.GetParameter(
"isWalking")->AsBool();
1061 if (
def.HasParameter(
"isUsingItem"))
1062 playerCtrl.isUsingItem =
def.GetParameter(
"isUsingItem")->AsBool();
1064 if (
def.HasParameter(
"isMenuOpen"))
1065 playerCtrl.isMenuOpen =
def.GetParameter(
"isMenuOpen")->AsBool();
1076 if (
def.HasParameter(
"playerIndex"))
1079 if (
def.HasParameter(
"controllerID"))
1080 binding.controllerID =
static_cast<short>(
def.GetParameter(
"controllerID")->AsInt());
1092 if (
def.HasParameter(
"npcType"))
1115 if (
def.HasParameter(
"playerId"))
1118 if (
def.HasParameter(
"zoom"))
1119 camera.zoom =
def.GetParameter(
"zoom")->AsFloat();
1121 if (
def.HasParameter(
"targetZoom"))
1122 camera.targetZoom =
def.GetParameter(
"targetZoom")->AsFloat();
1124 if (
def.HasParameter(
"position"))
1125 camera.position =
def.GetParameter(
"position")->AsVector();
1136 if (
def.HasParameter(
"targetEntityID"))
1139 if (
def.HasParameter(
"followTarget"))
1140 target.followTarget =
def.GetParameter(
"followTarget")->AsBool();
1142 if (
def.HasParameter(
"smoothFactor"))
1143 target.smoothFactor =
def.GetParameter(
"smoothFactor")->AsFloat();
1154 if (
def.HasParameter(
"isShaking"))
1157 if (
def.HasParameter(
"shakeIntensity"))
1158 effects.shakeIntensity =
def.GetParameter(
"shakeIntensity")->AsFloat();
1160 if (
def.HasParameter(
"shakeDuration"))
1161 effects.shakeDuration =
def.GetParameter(
"shakeDuration")->AsFloat();
1172 if (
def.HasParameter(
"useBounds"))
1173 bounds.
useBounds =
def.GetParameter(
"useBounds")->AsBool();
1175 if (
def.HasParameter(
"x") &&
def.HasParameter(
"y") &&
1176 def.HasParameter(
"width") &&
def.HasParameter(
"height"))
1193 if (
def.HasParameter(
"playerId"))
1196 if (
def.HasParameter(
"useKeyboard"))
1197 binding.useKeyboard =
def.GetParameter(
"useKeyboard")->AsBool();
1199 if (
def.HasParameter(
"deadzone"))
1200 binding.deadzone =
def.GetParameter(
"deadzone")->AsFloat();
1214 if (
def.HasParameter(
"deadzone"))
1215 mapping.deadzone =
def.GetParameter(
"deadzone")->AsFloat();
1217 if (
def.HasParameter(
"sensitivity"))
1218 mapping.sensitivity =
def.GetParameter(
"sensitivity")->AsFloat();
1229 SYSTEM_LOG <<
"[PrefabFactory] ERROR: NavigationAgent_data should exist (auto-registration)\n";
1236 if (
def.HasParameter(
"agentRadius"))
1239 if (
def.HasParameter(
"maxSpeed"))
1240 navAgent.maxSpeed =
def.GetParameter(
"maxSpeed")->AsFloat();
1242 if (
def.HasParameter(
"layerMask"))
1243 navAgent.layerMask =
static_cast<int>(
def.GetParameter(
"layerMask")->AsInt());
1253 if (
def.HasParameter(
"currentState"))
1255 std::string
stateStr =
def.GetParameter(
"currentState")->AsString();
1264 SYSTEM_LOG <<
"PrefabFactory::InstantiateAIState: Warning - Unknown state '"
1265 <<
stateStr <<
"', defaulting to Idle\n";
1269 if (
def.HasParameter(
"previousState"))
1271 std::string
stateStr =
def.GetParameter(
"previousState")->AsString();
1279 SYSTEM_LOG <<
"PrefabFactory::InstantiateAIState: Warning - Unknown previousState '"
1280 <<
stateStr <<
"', defaulting to Idle\n";
1284 if (
def.HasParameter(
"combatEngageDistance"))
1285 aiState.combatEngageDistance =
def.GetParameter(
"combatEngageDistance")->AsFloat();
1287 if (
def.HasParameter(
"fleeHealthThreshold"))
1288 aiState.fleeHealthThreshold =
def.GetParameter(
"fleeHealthThreshold")->AsFloat();
1290 if (
def.HasParameter(
"investigateTimeout"))
1291 aiState.investigateTimeout =
def.GetParameter(
"investigateTimeout")->AsFloat();
1302 std::cerr <<
"[PrefabFactory] ERROR: BehaviorTreeRuntime_data not found for entity " << entity << std::endl;
1303 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
1314 if (
def.HasParameter(
"AITreeAssetId"))
1317 std::cerr <<
"[PrefabFactory] Entity " << entity <<
" AITreeAssetId set to " <<
btRuntime.AITreeAssetId << std::endl;
1319 else if (
def.HasParameter(
"treeAssetId"))
1322 std::cerr <<
"[PrefabFactory] Entity " << entity <<
" treeAssetId (old) set to " <<
btRuntime.AITreeAssetId << std::endl;
1326 std::string treePath;
1327 if (
def.HasParameter(
"AITreePath"))
1329 treePath =
def.GetParameter(
"AITreePath")->AsString();
1331 else if (
def.HasParameter(
"treePath"))
1333 treePath =
def.GetParameter(
"treePath")->AsString();
1336 if (!treePath.empty())
1349 std::cerr <<
"[PrefabFactory] Mapped BehaviorTree: " << treePath <<
" -> ID " << treeId <<
" for entity " <<
identity->name << std::endl;
1351 std::cerr <<
"[PrefabFactory] Mapped BehaviorTree: " << treePath <<
" -> ID " << treeId <<
" for entity " << entity << std::endl;
1357 std::cerr <<
"[PrefabFactory] WARNING: BehaviorTree not loaded: " << treePath
1358 <<
" (ID=" << treeId <<
") - this should not happen if dependencies were loaded correctly" << std::endl;
1362 if (
def.HasParameter(
"active"))
1363 btRuntime.isActive =
def.GetParameter(
"active")->AsBool();
1366 if (
def.HasParameter(
"AICurrentNodeIndex"))
1367 btRuntime.AICurrentNodeIndex =
static_cast<uint32_t>(
def.GetParameter(
"AICurrentNodeIndex")->AsInt());
1368 else if (
def.HasParameter(
"currentNodeIndex"))
1369 btRuntime.AICurrentNodeIndex =
static_cast<uint32_t>(
def.GetParameter(
"currentNodeIndex")->AsInt());
1380 std::cerr <<
"[PrefabFactory] ERROR: MoveIntent_data not found for entity " << entity << std::endl;
1381 std::cerr <<
"[PrefabFactory] This should have been created by auto-registration!" << std::endl;
1389 if (
def.HasParameter(
"targetX") &&
def.HasParameter(
"targetY"))
1391 float x =
def.GetParameter(
"targetX")->AsFloat();
1392 float y =
def.GetParameter(
"targetY")->AsFloat();
1396 if (
def.HasParameter(
"targetPosition"))
1397 moveIntent.targetPosition =
def.GetParameter(
"targetPosition")->AsVector();
1399 if (
def.HasParameter(
"desiredSpeed"))
1400 moveIntent.desiredSpeed =
def.GetParameter(
"desiredSpeed")->AsFloat();
1402 if (
def.HasParameter(
"hasTarget"))
1403 moveIntent.hasIntent =
def.GetParameter(
"hasTarget")->AsBool();
1405 if (
def.HasParameter(
"hasIntent"))
1406 moveIntent.hasIntent =
def.GetParameter(
"hasIntent")->AsBool();
1408 if (
def.HasParameter(
"arrivalThreshold"))
1409 moveIntent.arrivalThreshold =
def.GetParameter(
"arrivalThreshold")->AsFloat();
1411 if (
def.HasParameter(
"usePathfinding"))
1412 moveIntent.usePathfinding =
def.GetParameter(
"usePathfinding")->AsBool();
1414 if (
def.HasParameter(
"avoidObstacles"))
1415 moveIntent.avoidObstacles =
def.GetParameter(
"avoidObstacles")->AsBool();
1426 if (
def.HasParameter(
"targetEntity"))
1429 if (
def.HasParameter(
"targetPosition"))
1430 attackIntent.targetPosition =
def.GetParameter(
"targetPosition")->AsVector();
1432 if (
def.HasParameter(
"damage"))
1435 if (
def.HasParameter(
"range"))
1438 if (
def.HasParameter(
"attackRange"))
1441 if (
def.HasParameter(
"hasIntent"))
1444 if (
def.HasParameter(
"cooldown"))
1447 if (
def.HasParameter(
"attackType"))
1449 std::string
typeStr =
def.GetParameter(
"attackType")->AsString();
1454 SYSTEM_LOG <<
"PrefabFactory::InstantiateAttackIntent: Warning - Unknown attackType '"
1455 <<
typeStr <<
"', defaulting to Melee\n";
Data-driven behavior tree system for AI decision making.
Core ECS component definitions.
RenderLayer
Render layer enumeration for Z-ordering.
ComponentTypeID GetComponentTypeID_Static()
const EntityID INVALID_ENTITY_ID
static EntityType StringToEntityType(const std::string &typeStr)
void RegisterComponentFactory_Internal(const char *componentName, std::function< bool(EntityID, const ComponentDefinition &)> factory)
World and ECS Manager for Olympe Engine.
uint32_t GetTreeIdFromPath(const std::string &treePath) const
const BehaviorTreeAsset * GetTree(uint32_t treeId) const
static BehaviorTreeManager & Get()
static DataManager & Get()
Sprite * GetSprite(const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::GameEntity)
std::vector< ResolvedComponentInstance > Resolve(const PrefabBlueprint &prefab, const LevelInstanceParameters &instanceParams)
bool InstantiatePosition(EntityID entity, const ComponentDefinition &def)
bool InstantiateAIBehavior(EntityID entity, const ComponentDefinition &def)
void RegisterComponentFactory(const std::string &componentName, std::function< bool(EntityID, const ComponentDefinition &)> factory)
Register a component factory (called by auto-registration system)
bool InstantiateComponent(EntityID entity, const ComponentDefinition &componentDef)
Instantiate a single component on an entity.
bool InstantiateAttackIntent(EntityID entity, const ComponentDefinition &def)
bool InstantiateAudioSource(EntityID entity, const ComponentDefinition &def)
bool InstantiateCameraEffects(EntityID entity, const ComponentDefinition &def)
std::unique_ptr< PrefabScanner > m_scanner
std::map< std::string, std::function< bool(EntityID, const ComponentDefinition &)> > m_componentFactories
bool InstantiateCameraBounds(EntityID entity, const ComponentDefinition &def)
bool IsComponentRegistered(const std::string &componentName) const
Check if a component is registered.
bool InstantiatePhysicsBody(EntityID entity, const ComponentDefinition &def)
bool InstantiateCamera(EntityID entity, const ComponentDefinition &def)
bool InstantiatePlayerController(EntityID entity, const ComponentDefinition &def)
std::string NormalizeType(const std::string &type) const
Normalize a type string to canonical form.
bool InstantiateAIBlackboard(EntityID entity, const ComponentDefinition &def)
PrefabRegistry m_prefabRegistry
bool AreTypesEquivalent(const std::string &type1, const std::string &type2) const
Check if two types are equivalent.
bool InstantiateController(EntityID entity, const ComponentDefinition &def)
bool GetCanonicalInfo(const std::string &type, std::string &outCanonical, std::string &outPrefabFile) const
Get canonical type info for debugging.
void SetPrefabRegistry(const PrefabRegistry ®istry)
Set the prefab registry cache.
bool IsTypeRegistered(const std::string &type) const
Check if a type is registered.
bool InstantiateBoundingBox(EntityID entity, const ComponentDefinition &def)
EntityID CreateEntityWithOverrides(const PrefabBlueprint &blueprint, const LevelInstanceParameters &instanceParams, bool autoAssignLayer=true)
Create entity from blueprint with level instance parameter overrides.
bool InstantiateVisualSprite(EntityID entity, const ComponentDefinition &def)
bool InstantiateVisualAnimation(EntityID entity, const ComponentDefinition &def)
bool InstantiateMoveIntent(EntityID entity, const ComponentDefinition &def)
std::vector< std::string > GetRegisteredComponents() const
Get list of all registered components (for debugging)
bool InstantiatePlayerBinding(EntityID entity, const ComponentDefinition &def)
bool InstantiateBehaviorTreeRuntime(EntityID entity, const ComponentDefinition &def)
EntityID CreateEntityFromBlueprint(const PrefabBlueprint &blueprint, bool autoAssignLayer=true)
Create entity from a parsed blueprint.
bool InstantiateCollisionZone(EntityID entity, const ComponentDefinition &def)
std::map< std::string, PrefabBuilder > m_prefabs
bool InstantiateVisualEditor(EntityID entity, const ComponentDefinition &def)
bool InstantiateFX(EntityID entity, const ComponentDefinition &def)
bool InstantiateAIState(EntityID entity, const ComponentDefinition &def)
static PrefabFactory & Get()
Get singleton instance.
bool InstantiateInputMapping(EntityID entity, const ComponentDefinition &def)
bool InstantiateNavigationAgent(EntityID entity, const ComponentDefinition &def)
bool InstantiateCameraInputBinding(EntityID entity, const ComponentDefinition &def)
bool InstantiateAISenses(EntityID entity, const ComponentDefinition &def)
bool InstantiateIdentity(EntityID entity, const ComponentDefinition &def)
EntityID CreateEntity(const std::string &prefabName)
Create an entity using legacy prefab system.
EntityID CreateEntityFromPrefabName(const std::string &prefabName)
Create entity from prefab name.
bool InstantiateAnimation(EntityID entity, const ComponentDefinition &def)
bool InstantiateHealth(EntityID entity, const ComponentDefinition &def)
bool InstantiateNPC(EntityID entity, const ComponentDefinition &def)
void PreloadAllPrefabs(const std::string &prefabDirectory="Blueprints/EntityPrefab")
Preload all prefabs from directory.
bool InstantiateTriggerZone(EntityID entity, const ComponentDefinition &def)
bool InstantiateMovement(EntityID entity, const ComponentDefinition &def)
bool InstantiateInventory(EntityID entity, const ComponentDefinition &def)
bool InstantiateCameraTarget(EntityID entity, const ComponentDefinition &def)
const PrefabBlueprint * Find(const std::string &name) const
std::vector< std::string > GetAllPrefabNames() const
Core ECS manager and world coordinator.
static World & Get()
Get singleton instance (short form)
T & AddComponent(EntityID entity, Args &&... args)
bool HasComponent(EntityID entity) const
RenderLayer GetDefaultLayerForType(EntityType type) const
Get the default render layer for an entity type Automatically assigns appropriate layer based on enti...
T & GetComponent(EntityID entity)
void SetEntityLayer(EntityID entity, RenderLayer layer)
Set entity render layer (updates position.z)
Header file for PrefabFactory class, responsible for creating game object prefabs.
std::string soundEffectID
Bounding box component for collision detection.
SDL_FRect boundingBox
Collision rectangle.
std::string componentType
Identity component for entity identification.
std::string name
Entity name identifier.
Position component for spatial location.
Vector position
2D/3D position vector
std::vector< ComponentDefinition > components
ECS component for animated sprites.