How interaction has changed


I have transitioned from primarily relying on interfaces when interacting with objects to implementing both an interface and an inheritance system, as shown in the diagram above.  All items that can be interacted with will have a script that inherits from a base class, with the base class implementing  an interface. For example, the  GenericInteraction class acts as a base class for Utensil. From here, items that require different logic can simply inherit from GenericInteraction and use override for the interface implementation. 

Code can be recycled quite nicely with this approach.  Using base.functionName if the logic is the same saves repetition in the code. The example below is from the class Utensil, where base.CheckHolding has the logic necessary for this instance. 


Get Cooking With Polygons

Leave a comment

Log in with itch.io to leave a comment.