legatt 32f4597c4d Base frontend module
- Naming style migrated to camel-case
- P7lib logger sources added
- Vcpkg manifest, CMake presets and build moved to root
- SDL2, Vulkan and RmlUi dependencies added
- Logger LOG macro added
- Logger  configuration
- SDL2 window configuration
- Vulkan configuration
- RmlUi configuration
- SDL event loop
2025-08-08 00:07:32 +03:00

22 lines
687 B
C++

#include <ee_economy/economy.hpp>
void ee_economy::mining(entt::registry &registry)
{
auto miners = registry.view<Enterprise, Miner, Container>();
for (auto [entity, enterprise, miner, localStorage]: miners.each())
{
if (enterprise.isBankrupt) continue;
Container& state = registry.get<Container>(enterprise.state);
double minedValue = enterprise.efficiency;
if (localStorage.total + minedValue > localStorage.capacity)
minedValue = localStorage.capacity - localStorage.total;
if (minedValue > state.content[miner.resource])
minedValue = state.content[miner.resource];
localStorage.add(miner.resource, minedValue);
state.add(miner.resource, -minedValue);
}
}