Re: Make the API less rigid.
Posted: Sun Sep 20, 2015 9:30 pm
Ok, I've thought over things abit and have come to a thought. (this is coming from java knowledge but should still be applicable)
the entities that use "energy_source" can have a just variable for it, all that info is passed to an abstract object which will build one of the two types: "electric" or "burner".
The two objects will handle most everything inside themselves in relation to energy, some stuff can be in the abstract higher object. They will both have a GUI element for the electrical info, the electric can have just a bar showing its buffer, the burner will have the buffer in addition to the fuel slots. The electric object will also handle all the connections to the power networks and can set the placing GUI effect to show the power network ranges (blue boxes from the poles).
With that refactor, it becomes increasingly simple to have a more dynamic power solution. a mod could then do something surprisingly crazy and go through all of the data.raw during the data-final-updates.lua and switch all electric to burners and all burners to electric, and the game should be able to handle that just fine.
I could also see a split for producing and consuming. consuming takes power from the power buffer, refilled from network if no producer on entity, and producing gives power to the buffer/network. which would allow for "burner-producer" which allows you to make power directly from coal. "electric-producer" pretty much all power gen right now, and accumulators. "burner-consumer" pretty much all the burners. "electric-consumer" everything that runs off the power network, and accumulators.
I think this part is actually half done, "energy_source" is producer, "energy_usage" is consumer. only thing is that the accumulator needs both but right now forces source to steal input_flow_limit from usage. I could see usage being extended with a default true for a "can take from accumulators" variable... source maybe having one for can give...
the entities that use "energy_source" can have a just variable for it, all that info is passed to an abstract object which will build one of the two types: "electric" or "burner".
The two objects will handle most everything inside themselves in relation to energy, some stuff can be in the abstract higher object. They will both have a GUI element for the electrical info, the electric can have just a bar showing its buffer, the burner will have the buffer in addition to the fuel slots. The electric object will also handle all the connections to the power networks and can set the placing GUI effect to show the power network ranges (blue boxes from the poles).
With that refactor, it becomes increasingly simple to have a more dynamic power solution. a mod could then do something surprisingly crazy and go through all of the data.raw during the data-final-updates.lua and switch all electric to burners and all burners to electric, and the game should be able to handle that just fine.
I could also see a split for producing and consuming. consuming takes power from the power buffer, refilled from network if no producer on entity, and producing gives power to the buffer/network. which would allow for "burner-producer" which allows you to make power directly from coal. "electric-producer" pretty much all power gen right now, and accumulators. "burner-consumer" pretty much all the burners. "electric-consumer" everything that runs off the power network, and accumulators.
I think this part is actually half done, "energy_source" is producer, "energy_usage" is consumer. only thing is that the accumulator needs both but right now forces source to steal input_flow_limit from usage. I could see usage being extended with a default true for a "can take from accumulators" variable... source maybe having one for can give...