compile error fix
This commit is contained in:
@@ -18,7 +18,7 @@ struct InventoryT
|
||||
|
||||
public:
|
||||
InventoryT() = default;
|
||||
InventoryT(size_t itemAmount) { Slots = { itemAmount, InventoryMeta{} }; }
|
||||
InventoryT(size_t itemAmount) { Slots = { static_cast<int>(itemAmount), InventoryMeta{} }; }
|
||||
|
||||
public:
|
||||
IntegralType GetItemsAmount(uint16_t id) const { Assert(id); return Slots[id]; }
|
||||
@@ -91,7 +91,7 @@ struct FixedInventoryBase
|
||||
|
||||
tcb::span<FixedInventoryEntry> GetInventoryData()
|
||||
{
|
||||
return {&Data[0], InventorySize);
|
||||
return {&Data[0], InventorySize};
|
||||
}
|
||||
tcb::span<const FixedInventoryEntry> GetInventoryData() const
|
||||
{
|
||||
@@ -140,8 +140,9 @@ inline void Flecs_Inventory(flecs::world& world)
|
||||
.member<uint16_t>("Amount")
|
||||
.member<uint16_t>("MaxAmount");
|
||||
|
||||
world.component<FixedInventory1>()
|
||||
.add(flecs::Inheritable)
|
||||
auto fixedInv1 = world.component<FixedInventory1>();
|
||||
fixedInv1.add(flecs::Inheritable);
|
||||
fixedInv1
|
||||
.opaque(world.vector<FixedInventoryEntry>())
|
||||
.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<WorldInventory>()
|
||||
.add(flecs::Singleton)
|
||||
auto worldInv = world.component<WorldInventory>();
|
||||
worldInv.add(flecs::Singleton);
|
||||
worldInv
|
||||
.opaque(world.vector<uint64_t>())
|
||||
.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<uint8_t>("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");
|
||||
|
||||
@@ -45,9 +45,11 @@ inline void Flecs_Resource(flecs::world& world)
|
||||
|
||||
world.system<ResourceInfo, ResourceTick>()
|
||||
.without<ResourceHealth>()
|
||||
.with<WorldInventory>()
|
||||
.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>();
|
||||
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<ResourceInfo>(info);
|
||||
entity.add<ResourceTick>(tick);
|
||||
entity.set<ResourceInfo>(info);
|
||||
entity.set<ResourceTick>(tick);
|
||||
}
|
||||
Reference in New Issue
Block a user