Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/198596573633064961
deleted 20 characters in body; edited title
Source Link
user1430
user1430

GetComponent<T> : <T> How can I store a set of concrete components and implement "GetComponent<T>()?"

I would like an abstract class, AbstractComponentAggregate, which has many AbstractComponents. Users of my framework will create their components by extending AbstractComponent and appending the component to this AbstractComponentAggregate.

I would like to know if there is an elegant way to have AbstractComponentAggregate to store a dictionary of the concrete classes that extend AbstractComponents. Note, that I want to store many concrete classes, each of which is an AbstractComponent. This is different than storing a list of AbstractComponents.

Thus, you can invoke a method on AbstractComponentAggregate, such as:

AbstractComponentAggregate.GetComponent(), which returns type T. T is the concrete class, and we ensure T is of type AbstractComponent.

Something similar to this is done in Unity3d, and I would like to emulate this.

Thanks in advance!

GetComponent<T> : <T>

I would like an abstract class, AbstractComponentAggregate, which has many AbstractComponents. Users of my framework will create their components by extending AbstractComponent and appending the component to this AbstractComponentAggregate.

I would like to know if there is an elegant way to have AbstractComponentAggregate to store a dictionary of the concrete classes that extend AbstractComponents. Note, that I want to store many concrete classes, each of which is an AbstractComponent. This is different than storing a list of AbstractComponents.

Thus, you can invoke a method on AbstractComponentAggregate, such as:

AbstractComponentAggregate.GetComponent(), which returns type T. T is the concrete class, and we ensure T is of type AbstractComponent.

Something similar to this is done in Unity3d, and I would like to emulate this.

Thanks in advance!

How can I store a set of concrete components and implement "GetComponent<T>()?"

I would like an abstract class, AbstractComponentAggregate, which has many AbstractComponents. Users of my framework will create their components by extending AbstractComponent and appending the component to this AbstractComponentAggregate.

I would like to know if there is an elegant way to have AbstractComponentAggregate to store a dictionary of the concrete classes that extend AbstractComponents. Note, that I want to store many concrete classes, each of which is an AbstractComponent. This is different than storing a list of AbstractComponents.

Thus, you can invoke a method on AbstractComponentAggregate, such as:

AbstractComponentAggregate.GetComponent(), which returns type T. T is the concrete class, and we ensure T is of type AbstractComponent.

Something similar to this is done in Unity3d, and I would like to emulate this.

Source Link
Alex
  • 205
  • 2
  • 4

GetComponent<T> : <T>

I would like an abstract class, AbstractComponentAggregate, which has many AbstractComponents. Users of my framework will create their components by extending AbstractComponent and appending the component to this AbstractComponentAggregate.

I would like to know if there is an elegant way to have AbstractComponentAggregate to store a dictionary of the concrete classes that extend AbstractComponents. Note, that I want to store many concrete classes, each of which is an AbstractComponent. This is different than storing a list of AbstractComponents.

Thus, you can invoke a method on AbstractComponentAggregate, such as:

AbstractComponentAggregate.GetComponent(), which returns type T. T is the concrete class, and we ensure T is of type AbstractComponent.

Something similar to this is done in Unity3d, and I would like to emulate this.

Thanks in advance!