There is progress, but I'm having some difficulty implementing all the feature requests into the collector.
- Electricity consumption
- Animations
- Ability to see the amount of pollution when building a collector.
The current collector is basically just a storage tank with different graphics, and storage tanks can't do much in game. Thus the original creator did everything using a script to make the collector work. To implement these features, a storage tank won't be good enough.
Electricity: Someone requested to let the collector have some energy consumption. Makes sense, it's a machine sucking in air and filtering out the pollution, it shouldn't do it for free. And although implementing electricity usage onto an entity is easy, it becomes problematic when trying to calculate how much pollution to remove from the air. For example, say the collector would suck 100 pollution out of the air every second. If it can maintain 100% energy usage for the entire second, then it's easy. Remove 100 pollution from the surface, add 100 polluted air into the tank, and done. But what if energy drops to 70% for 1 tick? (60 ticks per second btw) There's no way in the game to know how much energy was used in a certain amount of time by an entity. So to implement this I need an entity that can:
- do a job and keep track of its progress;
- has an energy source;
- can be manipulated based on changing pollution levels.
There are only two entity types that fit these requirements: a mining drill (a pumpjack is also a mining drill internally) and a crafting machine. Luckily these two can also handle animations.
An alternative would have been an entity that outputs fluid every tick. An offshore pump can do that, but I can't change it's pumping speed during runtime.
Between using a mining drill and a crafting machine, the mining drill has the advantage of being able to see the resource amount as you move the cursor. Unfortunately, you need a resource entity in every chunk or else the mining drill can't be placed. I have been testing that approach, but that ultimately failed because updating the resource entities every 64 ticks in every chunk quickly slows down the game.
So I will probably have to go with the crafting machine approach, and will start testing with that.