18 std::cout <<
"=== Test: Creating Entity Blueprint ===" << std::endl;
22 entity.
description =
"A test entity created programmatically";
33 std::string filepath =
"Blueprints/test_entity_generated.json";
36 std::cout <<
"✓ Blueprint saved to: " << filepath << std::endl;
40 std::cout <<
"✗ Failed to save blueprint" << std::endl;
44 std::cout <<
"\nGenerated JSON:\n" << entity.
ToJson().dump(2) << std::endl;
49 std::cout <<
"\n=== Test: Loading and Modifying Blueprint ===" << std::endl;
52 std::string filepath =
"Blueprints/example_entity_simple.json";
55 if (entity.
name.empty())
57 std::cout <<
"✗ Failed to load blueprint from: " << filepath << std::endl;
61 std::cout <<
"✓ Loaded blueprint: " << entity.
name << std::endl;
62 std::cout <<
" Description: " << entity.
description << std::endl;
63 std::cout <<
" Components: " << entity.
components.size() << std::endl;
66 std::cout <<
"\nComponents:" << std::endl;
69 std::cout <<
" - " <<
comp.type << std::endl;
75 std::cout <<
"\n✓ Found Position component" << std::endl;
76 std::cout <<
" Original position: " <<
posComp->properties.dump() << std::endl;
79 posComp->properties[
"position"][
"x"] = 500.0f;
80 posComp->properties[
"position"][
"y"] = 600.0f;
82 std::cout <<
" Modified position: " <<
posComp->properties.dump() << std::endl;
87 std::cout <<
"\n✓ Added Movement component" << std::endl;
90 std::cout <<
"\nComponent checks:" << std::endl;
91 std::cout <<
" Has Position: " << (entity.
HasComponent(
"Position") ?
"Yes" :
"No") << std::endl;
92 std::cout <<
" Has Movement: " << (entity.
HasComponent(
"Movement") ?
"Yes" :
"No") << std::endl;
93 std::cout <<
" Has Health: " << (entity.
HasComponent(
"Health") ?
"Yes" :
"No") << std::endl;
96 std::string
outpath =
"Blueprints/test_entity_modified.json";
99 std::cout <<
"\n✓ Modified blueprint saved to: " <<
outpath << std::endl;
105 std::cout <<
"\n=== Test: Complete Blueprint with All Components ===" << std::endl;
107 std::string filepath =
"Blueprints/example_entity_complete.json";
110 if (entity.
name.empty())
112 std::cout <<
"✗ Failed to load blueprint from: " << filepath << std::endl;
116 std::cout <<
"✓ Loaded complete blueprint: " << entity.
name << std::endl;
117 std::cout <<
" Component count: " << entity.
components.size() << std::endl;
120 std::cout <<
"\nDetailed component properties:" << std::endl;
123 std::cout <<
"\n Component: " <<
comp.type << std::endl;
124 std::cout <<
" Properties: " <<
comp.properties.dump(4) << std::endl;
130 std::cout <<
"Olympe Blueprint Editor - Entity Blueprint Test\n" << std::endl;
138 std::cout <<
"\n=== All tests completed successfully ===" << std::endl;
140 catch (
const std::exception&
e)
142 std::cerr <<
"\n✗ Test failed with exception: " <<
e.what() << std::endl;
ComponentTypeID GetComponentTypeID_Static()
void TestLoadAndModifyBlueprint()
void TestCreateAndSaveBlueprint()
void TestCompleteBlueprint()
ComponentData CreateVisualSpriteComponent(const std::string &spritePath, float srcX, float srcY, float srcWidth, float srcHeight, float hotSpotX, float hotSpotY)
ComponentData CreateBoundingBoxComponent(float x, float y, float width, float height)
ComponentData CreateMovementComponent(float dirX, float dirY, float velX, float velY)
ComponentData CreatePositionComponent(float x, float y)
ComponentData CreatePhysicsBodyComponent(float mass, float speed)
ComponentData CreateHealthComponent(int current, int max)
void AddComponent(const std::string &type, const json &properties)
static EntityBlueprint LoadFromFile(const std::string &filepath)
std::vector< ComponentData > components
bool SaveToFile(const std::string &filepath) const
ComponentData * GetComponent(const std::string &type)
bool HasComponent(const std::string &type) const