I have been using a 2d engine called NEZ. They use a List of class objects called "components" that are attached to an entity. Component
is a public class that can be inherited.
Like let's say:
public class Ninja : Component
This is the Code:
/// <summary>
/// Adds a Component to the components list. Returns the Component.
/// </summary>
/// <returns>Scene.</returns>
/// <param name="component">Component.</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public T AddComponent<T>(T component) where T : Component
{
component.Entity = this;
Components.Add(component);
component.Initialize();
return component;
}
/// <summary>
/// Adds a Component to the components list. Returns the Component.
/// </summary>
/// <returns>Scene.</returns>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public T AddComponent<T>() where T : Component, new()
{
var component = new T();
component.Entity = this;
Components.Add(component);
component.Initialize();
return component;
}
So the thing that is annoying is that Visual Studio doesn't give me a list of class objects that have the Component
in them.
So, how would I know that _animator = Entity.AddComponent<SpriteAnimator>();
is a Component
?
Besides that obvious answer that I would have to look at each .CS file and see if they inherit the Component
class.
The question is: The object in <T>
doesn't auto complete or doesn't even give me a possible items to fill the blank.
Is there a way for IntelliSense to search for each object that inherits the class Component
?
If not, do you know if other IDE or intelli-tool (like Resharper) does the job?
I'm using Visual Studio 2019 with Roslynator Refactorings addon and also using Visual Assistance from Tomatoes Software.