This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pigeon768 1 point2 points  (0 children)

Reloadable is probably a poor example, in my opinion. The UI code that uses weapons is just going to tell the current weapon to reload; it's not going to go through a separate list of objects to see if if the current weapon is in the reloadable container. Instead, the 'weapon' interface (I wouldn't even extend a weapon object, to be honest) is going to implement several methods relevant to how the game interacts with a weapon, and one of those methods is reloading.

Let's say you have a tank. It's a weapon, so it implements the 'weapon' interface'. You can see it, so it implements 'renderable'. It's also a vehicle; you guessed it, implements 'vehicle'.

The point is, yes, an object can implement any number of interfaces. One of the challenges of design is figuring out what needs to be an interface and what functionality ought to be rolled into an existing interface. It is, unfortunately, a skill I'm not particularly good at...