Okay I need a little help, mainly because what I've done feels messy but I can't think of a another solution that fits better.
I'm writing a MUD engine and I've just started on the game object model, which needs to be extensible.
Now I have a class called MudObject, and another class called Container, A container can contain multiple MudObjects but is a MudObject itself, however MudObjects need to know what they are contained in
So they look something like this
public abstract class MudObject
{
Container containedBy;
}
public abstract class Container : MudObject
{
List<MudObject> Contains;
}
(please note these are just example and some qualifiers and access modifiers, properties and such are missed off)
Now just this in itself seems messy. But lets add something else to the mix
Item is a MudObject that all visual items (such as weapons) will be inherited from, however some of these need to be containers too (like chests). But theres no such as multiple inheritance in c#, So it comes down to interfaces, the best choice would be to make the container an interface (as far as I can see) However there was a reason I didn't want it to be, that being that adding an MudObject to a container will cause the container to update the MudObjects containedBy value.
So question is, any ideas that would make this work, or am I falling into the trap of making things too complicated? If so what else could you suggest?