2/15/2026
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ int main()
|
||||
config.RegisterItem("Stick");
|
||||
config.RegisterItem("Copper Ore");
|
||||
|
||||
|
||||
WorldInstance worldInstance{ config };
|
||||
|
||||
worldInstance.ProcessFrame();
|
||||
|
||||
std::cout << "test\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user