POV-Ray : Newsgroups : povray.off-topic : Generics annoyance : Re: Generics annoyance Server Time
4 Sep 2024 13:16:09 EDT (-0400)
  Re: Generics annoyance  
From: scott
Date: 19 Apr 2010 04:26:59
Message: <4bcc13d3$1@news.povray.org>
> In MS's simple game libraries, there's a class called GameComponent.
> It inherits from IUpdatable, IDrawable, and IMumble, each of which 
> provides the declaration of one of the main routines in a game (update, 
> draw, and initialize, respectively).
>
> Now, if I wanted (and I do) to make a collection of things that act like 
> GameComponent objects but aren't necessarily game components, I don't 
> think I can do that in C#. I would have to have a collection parameterized 
> on all three of those interfaces.

If you cannot (or don't want to) derive your custom class(es) from 
GameComponent then the common base class will be System.Object.  You then 
have to make a collection of these if you want to store both GameComponent 
and your custom class, eg:

List<Object> myList;
...
foreach( Object o in myList )
 if( o is IUpdatable )
    (o as IUpdatable).Update();

> In any case, it's rather annoying. :-) I might have to figure out how to 
> patch up MS's samples to also host a collection of game components as well 
> as the scene-activation/deactivation they do.

Yeh, I think the XNA management classes are only meant to be simple ones to 
get you started, most things I've read advocate replacing the whole 
GameComponent system with your own (usually based on "screens" and adding 
components to each "screen").


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.