class MAGES::InteractionSystemModule

Overview

The interaction system module base class. More…

class InteractionSystemModule: public MAGES::HubModule
{
public:
    // classes

    class InteractableInfo;
    class InteractorInfo;

    // properties

    GameObject LeftHand;
    GameObject RightHand;
    GameObject Avatar;
    List<InteractableInfo> Interactables;
    List<InteractorInfo> Interactors;
    bool AutomaticPlayerRigSetup;

    // methods

    virtual bool TryAddInteractable(
        GameObject gameObject,
        string interactableType,
        out IInteractable component
    );

    virtual IInteractable GetInteractable(
        GameObject gameObject,
        string interactableType
    );

    virtual IInteractable GetOrAddInteractable(
        GameObject gameObject,
        string interactableType
    );

    virtual IInteractable AddGrabbable(GameObject gameObject);
    virtual IInteractable GetGrabbable(GameObject gameObject);
    virtual IInteractable GetOrAddGrabbable(GameObject gameObject);

    virtual bool TryAddInteractor(
        GameObject gameObject,
        string interactorType,
        out IInteractor component
    );

    virtual IInteractor GetInteractor(GameObject gameObject, string interactorType);

    virtual IInteractor GetOrAddInteractor(
        GameObject gameObject,
        string interactorType
    );
};

// direct descendants

class MAGESInteractionSystem;
class StubInteractionSystem;

Inherited Members

public:
    // methods

    virtual abstract void Startup() = 0;
    virtual abstract void Shutdown() = 0;

Detailed Documentation

The interaction system module base class.

Properties

GameObject LeftHand

Gets or sets the left hand gameobject.

GameObject RightHand

Gets or sets the right hand gameobject.

GameObject Avatar

Gets or sets the avatar gameobject.

List<InteractableInfo> Interactables

Gets or sets the available interactables for this interaction system.

List<InteractorInfo> Interactors

Gets or sets the available interactors for this interaction system.

bool AutomaticPlayerRigSetup

Gets or sets a value indicating whether the player rig will be automatically setup when the scene starts.

Methods

virtual bool TryAddInteractable(
    GameObject gameObject,
    string interactableType,
    out IInteractable component
)

Tries to add the given interactableType script to the gameObject.

Parameters:

gameObject

The gameobject to add the interactable to.

interactableType

The identifier name of the interactable type. See the scriptable object for all available types.

component

The IInteractable component added.

Returns:

true if it was possible to find the given interactableType type and add it to the gameObject.

See also:

GetOrAddInteractable(GameObject, string)

virtual IInteractable GetInteractable(
    GameObject gameObject,
    string interactableType
)

Gets the interactable of the given interactableType from the gameObject.

Parameters:

gameObject

The gameobject to get the component from.

interactableType

The type of the interactable to get.

Returns:

The interactable if found as IInteractable or null if it does not exist.

virtual IInteractable GetOrAddInteractable(
    GameObject gameObject,
    string interactableType
)

Gets the interactable of the given interactableType from the gameObject. If the gameObject does not have this interactable type script, it will be added.

Parameters:

gameObject

The gameobject to get the component from or add it to.

interactableType

The type of the interactable to get or add.

Returns:

The interactable if found or added as IInteractable, or null if the interactableType given is invalid.

See also:

GetInteractable(GameObject, string), GetOrAddGrabbable(GameObject), TryAddInteractable(GameObject, string, out IInteractable)

virtual IInteractable AddGrabbable(GameObject gameObject)

Adds a Grabbable to the gameObject.

Parameters:

gameObject

The GameObject in which to add the Grabbable component.

Returns:

The added grabbable component.

virtual IInteractable GetGrabbable(GameObject gameObject)

Gets the Grabbable from the gameObject.

Parameters:

gameObject

The GameObject to get the Grabbable from.

Returns:

The grabbable if found, else null.

virtual IInteractable GetOrAddGrabbable(GameObject gameObject)

Adds a Grabbable to the gameObject or gets the one already on it.

This is the same as doing it with GetOrAddInteractable(GameObject, string), but is added extra to eliminate typo errors when using strings.

Parameters:

gameObject

The GameObject in which to add the Grabbable component.

Returns:

The Grabbable added or found, as IInteractable.

See also:

GetOrAddInteractable(GameObject, string), GetInteractable(GameObject, string), TryAddInteractable(GameObject, string, out IInteractable)

virtual bool TryAddInteractor(
    GameObject gameObject,
    string interactorType,
    out IInteractor component
)

Tries to add the given interactorType script to the gameObject.

Parameters:

gameObject

The gameobject to add the interactor to.

interactorType

The identifier name of the interactor type. See the scriptable object for all available types.

component

The IInteractor component added.

Returns:

true if it was possible to find the given interactorType type and add it to the gameObject.

See also:

GetOrAddInteractor(GameObject, string)

virtual IInteractor GetInteractor(GameObject gameObject, string interactorType)

Gets the interactor of the given interactorType from the gameObject.

Parameters:

gameObject

The gameobject to get the component from.

interactorType

The type of the interactor to get.

Returns:

The interactor if found as IInteractor or null if it does not exist.

See also:

GetOrAddInteractor(GameObject, string), TryAddInteractor(GameObject, string, out IInteractor)

virtual IInteractor GetOrAddInteractor(
    GameObject gameObject,
    string interactorType
)

Gets the interactor of the given interactorType from the gameObject. If the gameObject does not have this interactor type script, it will be added.

Parameters:

gameObject

The gameobject to get the component from or add it to.

interactorType

The type of the interactor to get or add.

Returns:

The interactor if found or added as IInteractor, or null if the interactorType given is invalid.

See also:

GetInteractor(GameObject, string), TryAddInteractor(GameObject, string, out IInteractor)