2/15/2026

This commit is contained in:
Connor
2026-02-15 18:42:47 +09:00
parent 524ba9691b
commit 22e754cd75
10 changed files with 58 additions and 17 deletions

View File

@@ -1,13 +1,15 @@
#include "Components/Configs/WorldConfig.hpp"
void WorldConfig::RegisterItem(const std::string& name)
uint16_t WorldConfig::RegisterItem(const std::string& name)
{
for (const auto& item : Items)
for (uint16_t i = 0; i < Items.size(); ++i)
{
if (item.Name == name) return;
if (Items[i].Name == name) return i;
}
ItemConfig cfg{};
cfg.Name = name;
Items.push_back(std::move(cfg));
return static_cast<uint16_t>(Items.size() - 1);
}

View File

@@ -9,7 +9,10 @@ WorldInstance::WorldInstance(const WorldConfig& worldConfig)
{
RegisterTypes(EcsWorld);
WorldInventory newInventory = WorldInventory{worldConfig.GetItems().size()};
EcsWorld.set<WorldConfig>(worldConfig);
EcsWorld.set<WorldInventory>(newInventory);
}
void WorldInstance::RegisterTypes(flecs::world &world)
@@ -20,3 +23,8 @@ void WorldInstance::RegisterTypes(flecs::world &world)
Flecs_Tick(world);
Flecs_Resource(world);
}
void WorldInstance::ProcessFrame()
{
EcsWorld.progress();
}

View File

@@ -14,9 +14,9 @@ int main()
config.RegisterItem("Stick");
config.RegisterItem("Copper Ore");
WorldInstance worldInstance{ config };
worldInstance.ProcessFrame();
std::cout << "test\n";