I’m trying to create a “sims-like” context menu when an item / game object is clicked.
This comes as an add-on question from this question: How to design context menus based on whatever the object is?
Each object of class Item would have a list of components like Equipable, Edible, Sellable, Drinkable, etc. An item can have one or none of each component (for example, a helmet made of chocolate would be both Equipable and Edible, and when it is not a plot-critical quest item also Sellable). The programming logic which is specific to the component is implemented in that component. When the user right-clicks on an item, the components of the item are iterated and context-menu entries are added for each component which exists. When the user selects one of these entries, the component which added that entry processes the option.
You could represent this in your XML-file by having a sub-node for each component. Example:
<item> <name>Chocolate Helmet</name> <sprite>helmet-chocolate.png</sprite> <description>Protects you from enemies and from starving</description> <edible> <taste>sweet</taste> <calories>2560</calories> </edible> <equipable> <slot>head</slot> <def>20</def> </equipable> <sellable> <value>120</value> </sellable> </item>
When I read this, it reminds me of an interface in programming. My question is, how do you implement this? Perhaps a better question is “is the answer still valid” but it does seem relevant to me.
What have I tried? Nothing at this point, because I’m not sure where to start. Given the example above, I’d guess that
Item would have a list of… interfaces? that it could implement? This is why I am a bit confused.
- Rugby University model should be reconsidered
- Exclusive: More Models Come Forward With Allegations Against Fashion Photographer
- 'Absolutely stunning!' Kylie Jenner is praised for featuring a 'beautiful' model covered in distinctive freckles in her latest Kylie Skin campaign
- Rajasthan learning model added as case study by Harvard
- Teams return to practice, unity displays still in focus
- The Latest: Putin: Russia backs Iraq’s unity in Kurd dispute
- Big 12 stands pat, touts unity, but still has revenue concerns
- Big 12 stands pat and touts unity, but is it built to last?
- Chris Wilbers' Fast Thoughts for April 12: Let's hope local tracks don't get left behind in new NASCAR sponsorship model
- Lafayette, Lehigh showed unity in taking a risky idea and turning it into something special at Yankee Stadium