Show / Hide Table of Contents

Interface IHasComponents

Interface for an object that has components that can be added, removed, checked for, and retrieved by type. Typically, you would implement this via a backing field of type ComponentContainer, which implements the logic for these functions.

Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public interface IHasComponents

Methods

| Improve this Doc View Source

AddComponent(Object)

Adds the given object as a component. Throws ArgumentException if the specific instance has already been added.

Declaration
void AddComponent(object component)
Parameters
Type Name Description
System.Object component

Component to add.

| Improve this Doc View Source

GetComponent<T>()

Gets the first component of type T that was added, or default(T) if no component of that type has been added.

Declaration
T GetComponent<T>()
Returns
Type Description
T

The first component of Type T that was attached, or default(T) if no components of the given type have been attached.

Type Parameters
Name Description
T

Type of component to retrieve.

| Improve this Doc View Source

GetComponents<T>()

Gets all components of type T that are added.

Declaration
IEnumerable<T> GetComponents<T>()
Returns
Type Description
System.Collections.Generic.IEnumerable<T>

All components of Type T that are attached.

Type Parameters
Name Description
T

Type of components to retrieve.

| Improve this Doc View Source

HasComponent(Type)

Returns whether or not there is at least one component of the specified type attached. Type may be specified by using typeof(MyComponentType).

Declaration
bool HasComponent(Type componentType)
Parameters
Type Name Description
System.Type componentType

The type of component to check for.

Returns
Type Description
System.Boolean

True if the implementer has at least one component of the specified type, false otherwise.

| Improve this Doc View Source

HasComponent<T>()

Returns whether or not there is at least one component of type T attached.

Declaration
bool HasComponent<T>()
Returns
Type Description
System.Boolean

True if the implemented has at least one component of the specified type attached, false otherwise.

Type Parameters
Name Description
T

Type of component to check for.

| Improve this Doc View Source

HasComponents(Type[])

Returns whether or not the implementer has at least one of all of the given types of components attached. Types may be specified by using typeof(MyComponentType)

Declaration
bool HasComponents(params Type[] componentTypes)
Parameters
Type Name Description
System.Type[] componentTypes

One or more component types to check for.

Returns
Type Description
System.Boolean

True if the implementer has at least one component of each specified type, false otherwise.

| Improve this Doc View Source

RemoveComponent(Object)

Removes the given component. Throws an exception if the component isn't attached.

Declaration
void RemoveComponent(object component)
Parameters
Type Name Description
System.Object component

Component to remove.

| Improve this Doc View Source

RemoveComponents(Object[])

Removes the given component(s). Throws an exception if a component given isn't attached.

Declaration
void RemoveComponents(params object[] components)
Parameters
Type Name Description
System.Object[] components

One or more component instances to remove.

Extension Methods

Utility.Yield<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX