Show / Hide Table of Contents

    Interface IComponentsCollection

    A collection of componenets: allows you to add, remove, get and iterate components.

    Inherited Members
    System.Collections.Generic.IEnumerable<AGS.API.IComponent>.GetEnumerator()
    System.IDisposable.Dispose()
    Namespace: AGS.API
    Assembly: AGS.API.dll
    Syntax
    public interface IComponentsCollection : IEnumerable<IComponent>, IEnumerable, IDisposable

    Properties

    | Improve this Doc View Source

    ComponentsInitialized

    Gets a value indicating whether the components were already initialized.

    Declaration
    bool ComponentsInitialized { get; }
    Property Value
    Type Description
    System.Boolean

    true if components initialized; otherwise, false.

    | Improve this Doc View Source

    Count

    Gets the number of components.

    Declaration
    int Count { get; }
    Property Value
    Type Description
    System.Int32

    The count.

    | Improve this Doc View Source

    OnComponentsChanged

    An event which is triggered whenever a component is added/removed.

    Declaration
    IBlockingEvent<AGSListChangedEventArgs<IComponent>> OnComponentsChanged { get; }
    Property Value
    Type Description
    IBlockingEvent<AGSListChangedEventArgs<IComponent>>

    The event.

    | Improve this Doc View Source

    OnComponentsInitialized

    An event that fires after all components were initialized.

    Declaration
    IBlockingEvent OnComponentsInitialized { get; }
    Property Value
    Type Description
    IBlockingEvent

    The event.

    Methods

    | Improve this Doc View Source

    AddComponent(Type)

    Adds a new component with the specified type.

    Declaration
    IComponent AddComponent(Type componentType)
    Parameters
    Type Name Description
    System.Type componentType

    The component type.

    Returns
    Type Description
    IComponent

    The component, if added successfully, null otherwise (if a component with this type already exists).

    | Improve this Doc View Source

    AddComponent<TComponent>()

    Adds a new component with the specified type.

    Declaration
    TComponent AddComponent<TComponent>()
        where TComponent : IComponent
    Returns
    Type Description
    TComponent

    The component, if added successfully, null otherwise (if a component with this type already exists).

    Type Parameters
    Name Description
    TComponent

    The component type.

    | Improve this Doc View Source

    AddComponent<TComponent>(IComponent)

    Adds the specified component.

    Declaration
    bool AddComponent<TComponent>(IComponent component)
        where TComponent : IComponent
    Parameters
    Type Name Description
    IComponent component

    Component.

    Returns
    Type Description
    System.Boolean

    true, if component was added, false otherwise (if a component with this type already exists).

    Type Parameters
    Name Description
    TComponent

    The component type (with which it will be registered and can be queried by other components).

    Examples

    The type parameter is used to specify under which type the component will be registed in the entity. Suppose you want to replace an existing component in the entity, for example the rotation component. By using IRotateComponent as your type parameter, other components will get your component back when querying for IRotateComponent. Your component should implement IRotateComponent.

    public class MyRotateComponent : AGSComponent, IRotateComponent
    {
     ...
    }
    
    var myRotate = new MyRotateComponent();
    var existingRotate = obj.GetComponent<IRotateComponent>();
    Console.WriteLine(myRotate == existingRotate); //Writes "false"
    
    obj.RemoveComponent<IRotateComponent>();
    obj.AddComponent<IRotateComponent>(myRotate);
    
    existingRotate = obj.GetComponent<IRotateComponent>();
    Console.WriteLine(myRotate == existingRotate); //Writes "true"
    | Improve this Doc View Source

    Bind<TComponent>(Action<TComponent>, Action<TComponent>)

    Bind actions to when a component is added/removed.

    Declaration
    IComponentBinding Bind<TComponent>(Action<TComponent> onAdded, Action<TComponent> onRemoved)
        where TComponent : IComponent
    Parameters
    Type Name Description
    System.Action<TComponent> onAdded

    Callback to be called when component is added.

    System.Action<TComponent> onRemoved

    Callback to be called when component is removed.

    Returns
    Type Description
    IComponentBinding

    The binding.

    Type Parameters
    Name Description
    TComponent

    The 1st type parameter.

    | Improve this Doc View Source

    GetComponent(Type)

    Gets the component of the specified type.

    Declaration
    IComponent GetComponent(Type componentType)
    Parameters
    Type Name Description
    System.Type componentType
    Returns
    Type Description
    IComponent

    The component if found, null if no components of this type in the collection.

    | Improve this Doc View Source

    GetComponent<TComponent>()

    Gets the component of the specified type.

    Declaration
    TComponent GetComponent<TComponent>()
        where TComponent : IComponent
    Returns
    Type Description
    TComponent

    The component if found, null if no components of this type in the collection.

    Type Parameters
    Name Description
    TComponent

    The component type.

    | Improve this Doc View Source

    HasComponent(IComponent)

    Is the specified component in the collection?

    Declaration
    bool HasComponent(IComponent component)
    Parameters
    Type Name Description
    IComponent component
    Returns
    Type Description
    System.Boolean

    true, if component exists, false otherwise.

    | Improve this Doc View Source

    HasComponent(Type)

    Is there a component of the specified type in the collection?

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

    true, if component exists, false otherwise.

    | Improve this Doc View Source

    HasComponent<TComponent>()

    Is there a component of the specified type in the collection?

    Declaration
    bool HasComponent<TComponent>()
        where TComponent : IComponent
    Returns
    Type Description
    System.Boolean

    true, if component exists, false otherwise.

    Type Parameters
    Name Description
    TComponent

    The component type.

    | Improve this Doc View Source

    OnDisposed(Action)

    Subscribe to actions that will happen once the entity is disposed. If then entity was already disposed when calling this, the action will be executed immediately.

    Declaration
    void OnDisposed(Action onDisposed)
    Parameters
    Type Name Description
    System.Action onDisposed

    The action to perform on entity disposal.

    | Improve this Doc View Source

    PopComponent<TComponent>()

    Removes the component with the specified type and returns it (if it exists).

    Declaration
    TComponent PopComponent<TComponent>()
        where TComponent : IComponent
    Returns
    Type Description
    TComponent

    The component if it was found and removed, null otherwise.

    Type Parameters
    Name Description
    TComponent

    The component type.

    | Improve this Doc View Source

    RemoveComponent(IComponent)

    Removes the specified component.

    Declaration
    bool RemoveComponent(IComponent component)
    Parameters
    Type Name Description
    IComponent component

    Component.

    Returns
    Type Description
    System.Boolean

    true, if component was removed, false otherwise.

    | Improve this Doc View Source

    RemoveComponent(Type)

    Removes the component with the specified type (if it exists).

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

    The component type.

    Returns
    Type Description
    System.Boolean

    true, if component was removed, false otherwise.

    | Improve this Doc View Source

    RemoveComponent<TComponent>()

    Removes the component with the specified type (if it exists).

    Declaration
    bool RemoveComponent<TComponent>()
        where TComponent : IComponent
    Returns
    Type Description
    System.Boolean

    true, if component was removed, false otherwise.

    Type Parameters
    Name Description
    TComponent

    The component type.

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX