I think the current API is missing an on_entity_status_changed event which should listen for changes in LuaEntity.status.
The event should pass the entity (with the new status) and the old status.
This would remove the necessity of mods checking any of the entity statuses using the expensive on_tick event.
One mod in particular that comes to mind is Bottleneck that does mass-checking of entity states on tick and is quite UPS heavy as a result or is forced to slow down updates.
The downside to doing this would be a considerable increase in function calls for megabases though no clue on what the impact would be from the base game code.
Let me know what you think.
Event for entity status change
-
- Manual Inserter
- Posts: 4
- Joined: Sat Oct 12, 2019 12:13 pm
- Contact:
Re: Event for entity status change
The game doesn't store an entities status and dynamically calculates it anytime anything asks for it.
That would mean that:
* Every entity with a status would need to store it (increased memory usage runtime) + save/load it
* Every time it changes a Lua event would have to be fired
That would add a bunch of extra data to runtime memory, the save file, and have a measurable performance overhead due to the spammy nature of the status changing frequently.
So, this isn't going to happen.
That would mean that:
* Every entity with a status would need to store it (increased memory usage runtime) + save/load it
* Every time it changes a Lua event would have to be fired
That would add a bunch of extra data to runtime memory, the save file, and have a measurable performance overhead due to the spammy nature of the status changing frequently.
So, this isn't going to happen.
If you want to get ahold of me I'm almost always on Discord.