'Burnable' "Interface"


I’ve created a ‘burnable’ “Interface”

item.is_burnable

along with an enum “Primary Material” so that anything wooden that gets thrown in the fire will burn.

In oop world, one way to achieve multiple inheritance is to define an abstract type that defines behaviors as method signatures. The interface is “what methods can I call on this object that implements this interface”. I can define an interface named Pet that says “any class that implements Pet must have the functions walk(), eat(), and pet(). So class Dog and Cat can implement Pet.

By “oop”, i mean “Object Oriented Programming

however, gdscript doesn’t support interfaces. gdscript uses duck-typing so i “implement interfaces” the duck typed way.

if object.has_method("method_name"):
  do the thing

not shown in demo: a burnable that is not a FireWood will not start a fire valid FireWood items are "stick_bundle", "wood_fence", "wood", "lumber"

Get Camp Fire Craft

Leave a comment

Log in with itch.io to leave a comment.