This is the first time I was confronted with the fact that it's impossible for my mind to design architecture for kind of realistic game with OOP-techniques. It'll be very helpful if you can give me some advices about modeling paradigms and tricks of how to solve the problem.
I want to create an RPG-game with a really rich world, so I started, of course, with ontology. I supposed that in real world you have notions of objects and, for example, notion "human" is unambiguous category for every "man" or "woman" and so on, and I decided to create the my version of game world, starting with Entity, then AbstractEntity and MaterialEntity and etc.
That was simple until once I've asked myself: what is guitar?
Well, it's a class of material object, that may exist in real world. But it's also a musical instrument. Okay, every musical instrument is physical object. Then I realised that guitar is not only musical instrument, it's also a weapon, for example, or wood, that can be placed in furnace, and so on.
It looks like all the behavioural traits of guitar are dynamic. They all depend on what you want and can do with guitar and also on it's physical properties. Look at "Igniteable" trait - there are a bunch of real world objects that can implement it, whether they wood or not.
For now I came to some possible solutions:
- Use interfaces.
With such rich world this will violate SRP extremely fast, but the biggest problem is that you really dont want to let your rocks, guitars and other items to know about how anyone can use them.
- Encapsulate behaviour in state. For example, add material to the physical object and every time you want to burn something check whether it's material is igniteable or not.
Well, this is kinda Strategy pattern, and looks good, but what I can do with "Weapon" aspect of guitar, or, maybe, here is the better example: a creature, on which you can put your armor, and a dummy, on which you can put armor too.
- Use AOP + COP.
This seems like a best choice, but I still thinking, that my OOP-skills just too low to solve the problem.
I found that I percieve every real object as bunch of behaviours (what I can do with it) mapped to traits (what it really is). For example, trait "wooden" can be applied to a lot of objects, but they all can be "ignited" in some way. There are two "igniteable" behaviours type: "igniteable generic" and "igniteable wooden". It looks like in my head there are a lot of atoms, on which all the traits and behaviours of things based.
So the main question is: what OOP tricks I can use to design such rich and complex game world?
P.S. Sorry for such long intrudoction. ^_^
Aucun commentaire:
Enregistrer un commentaire