4 ms·
Of course, but their use of the ECS seems excessive. I'd have expected a few big systems for each area of the game, clicking on Game.Simulation.AdjustElectricit
by speps 3y ago
Of course, but their use of the ECS seems excessive. I'd have expected a few big systems for each area of the game, clicking on Game.Simulation.AdjustElectricityConsumptionSystem for example reveals quite a lot of things that could be within one system. I bet the current design passes and queries data all over the place, very redundantly.
- meheleventyone 3y agoOne of the main benefits of doing things with an ECS is composition though so you'd expect more granularity than you'd get in other modular approaches which is of course a tradeoff in some respects.
- foota 3y agoI assume they've split it out so much to better allow smaller systems over larger ones. In theory this should allow better access patterns, for instance for the electricity, the AdjustElectricityConsumptionSystem has to consider each building and the information about it, but the ElectricityFlowSystem only has to consider the edges for electricity flow. This means the ElectricityFlowSystem can be access only the data it needs and in theory allows for better code cache efficiency (since the loops are tighter and more focused than they would be if they were all in one).
- meheleventyone 3y agoSplitting things this way is also handy because you can avoid branches, rather than one big loop with lots of conditional branching you have many loops one for each set of elements represented by a branch. Except rather than having to untangle and manage that yourself the granular systems approach make it a more natural way to implement things. Although probably once you're at that stage of optimizing gameplay code it's also probably time to write something specific for the problem rather than trying to fit it into a general purpose framework.
- CaptainOfCoit 3y ago> I assume they've split it out so much to better allow smaller systems over larger ones. In theory this should allow better access patterns Not only that, but modding becomes easier as well, and modding is a big part of the game. If all the electricity stuff was jammed into just one System, it would be harder to modify just some parts of it while remaining compatible with other mods modifying other parts. Instead, Systems are broken down into relevant parts so modders can add easier to it or replace whole Systems, without replacing ALL electricity code.
- deleted 3y ago[deleted]
- ajmmertens 3y ago> I bet the current design passes and queries data all over the place, very redundantly That's not how ECS works. A system has one or more queries that provide it direct access to the data. There's no passing around of queries or data.