This week, I focused on generalizing the classes and logic for machines. This will allow us to quickly add new machine types to the game and configure them and their uses and purpose.
It's sometimes hard to understand how to design something that can be expanded and will work simply for many use cases, so I started with a specific use case (the furnace) and then generalized from there.
Machine blocks essentially take some form of input(s), and transform them to one or more output.
Examples include:
- Accept an electrical input and output heat
- Accept wood and scrap metal as an input and output a metal ingot
- Accept coal, scrap metal and a metal mold to output a molded metal part
- Accept Seeds, soil and water and grow plants
Specifically, machines can implement the following superset of functionality:
-Consume a particular type of item to power the device
-Allow the player to turn them on/off
-Consume a specified set of items and output another item or set of items
-Accept particular items in specified slot to increase efficiency
-Route outputted items through pipes to other machines
The last task needed is to integrate the machine block class with the pipe routing system, after that it's time to shift our focus to creating the actual machines that the player will be able to craft.
As a bonus, we also switched the inventory class to be more event-driven. Now classes can subscribe to inventory objects and get notified when that inventory changes state. This will make it much less complicated for objects to implement the inventory class in the future.
-Trev
