|
![](/i/fill.gif) |
Invisible <voi### [at] dev null> wrote:
> Darren New wrote:
> > Actually, I think that clued me in a bit. They *are* all of type
> > "object". ;-)
> >
> > So I could just have a list of objects, and when I get an update,
> > (dynamic)-cast each element to a IUpdatable and invoke that if it works;
> > when I get a draw, cast each to an IDrawable and invoke that if it
> > works, etc.
> >
> > Ugly, but it'll do the trick, I think.
> Ah yes, ye olde "upcast everything to Object" antipattern. :-D
Yeah, that kind of OO programming has always been considered bad design.
If C# offered multiple inheritance (I don't know if it does), then you
could inherit all the objects you are using from GameComponent and your
own "base class", which is what the container then contains.
(Of course this solution wouldn't help if you have to store objects
which have been eg. instantiated by the library framework itself because
those would not have been inherited from your "base class".)
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |