From c7c679c37813566f4165b8c739c6210cf30c6bf7 Mon Sep 17 00:00:00 2001 From: Connor Date: Sun, 15 Feb 2026 19:06:20 +0900 Subject: [PATCH] compile error fix --- include/Components/Inventory.hpp | 22 ++++++++++++---------- include/Components/Resource.hpp | 12 +++++++----- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/Components/Inventory.hpp b/include/Components/Inventory.hpp index 08bfe9f..c5bc8ca 100644 --- a/include/Components/Inventory.hpp +++ b/include/Components/Inventory.hpp @@ -18,7 +18,7 @@ struct InventoryT public: InventoryT() = default; - InventoryT(size_t itemAmount) { Slots = { itemAmount, InventoryMeta{} }; } + InventoryT(size_t itemAmount) { Slots = { static_cast(itemAmount), InventoryMeta{} }; } public: IntegralType GetItemsAmount(uint16_t id) const { Assert(id); return Slots[id]; } @@ -91,7 +91,7 @@ struct FixedInventoryBase tcb::span GetInventoryData() { - return {&Data[0], InventorySize); + return {&Data[0], InventorySize}; } tcb::span GetInventoryData() const { @@ -140,8 +140,9 @@ inline void Flecs_Inventory(flecs::world& world) .member("Amount") .member("MaxAmount"); - world.component() - .add(flecs::Inheritable) + auto fixedInv1 = world.component(); + fixedInv1.add(flecs::Inheritable); + fixedInv1 .opaque(world.vector()) .serialize([](const flecs::serializer *s, const FixedInventory1 *data) { for (uint8_t i = 0; i < data->InventorySize; ++i) @@ -151,7 +152,7 @@ inline void Flecs_Inventory(flecs::world& world) .count([](const FixedInventory1 *data) -> size_t { return data->InventorySize; }) - .ensure_element([](FixedInventory1 *data, size_t elem) -> FixedInventoryEntry* { + .ensure_element([](FixedInventory1 *data, size_t elem) -> void* { return &data->Data[elem]; }); @@ -176,16 +177,17 @@ inline void Flecs_Inventory(flecs::world& world) return data->Slots.GetSize(); }); - world.component() - .add(flecs::Singleton) + auto worldInv = world.component(); + worldInv.add(flecs::Singleton); + worldInv .opaque(world.vector()) - .serialize([](const flecs::serializer *s, const Inventory *data) { + .serialize([](const flecs::serializer *s, const WorldInventory *data) { if (!data->Slots) return 0; for (uint64_t i = 0; i < data->Slots.GetSize(); ++i) s->value(data->Slots[i]); return 0; }) - .count([](const Inventory *data) -> size_t { + .count([](const WorldInventory *data) -> size_t { if (!data->Slots) return 0; return data->Slots.GetSize(); }); @@ -196,7 +198,7 @@ inline void Flecs_Inventory(flecs::world& world) .member("Size")) .serialize([](const flecs::serializer *s, const InventoryAreaOfEffect *data) { uint8_t isCircle = data->IsCircle; - uint8_t size = data->Size; + uint8_t size = data->ShapeSize; s->member("IsCircle"); s->value(isCircle); s->member("Size"); diff --git a/include/Components/Resource.hpp b/include/Components/Resource.hpp index f8d50be..950802e 100644 --- a/include/Components/Resource.hpp +++ b/include/Components/Resource.hpp @@ -45,9 +45,11 @@ inline void Flecs_Resource(flecs::world& world) world.system() .without() - .with() - .each([](ResourceInfo info, ResourceTick tick, WorldInventory& worldInventory) { - if (tick.Finished()) worldInventory.AddItems(info.ResourceID, 1); + .each([&world](ResourceInfo info, ResourceTick tick) { + if (tick.Finished()) { + auto& worldInventory = world.ensure(); + worldInventory.AddItems(info.ResourceID, 1); + } }); } @@ -60,6 +62,6 @@ inline void Resource_Ore_Helper(const flecs::entity& entity, uint16_t resourceID ResourceTick tick{}; tick.MaxTick = gatherTicks; - entity.add(info); - entity.add(tick); + entity.set(info); + entity.set(tick); } \ No newline at end of file