Arma Reforger Script API
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SCR_InteractionHandlerComponent Interface Reference

This component allows the player to interact with their environment. More...

Inheritance diagram for SCR_InteractionHandlerComponent:
[legend]

Public Member Functions

void ActionPerform (float value, EActionTrigger reason)
 Callback for caching the key press.
 
void ActionScroll (float value, EActionTrigger reason)
 
void OnControlledEntityChanged (IEntity from, IEntity to)
 Method called when player takes controll over an entity.
 
override void OnInit (IEntity owner)
 Called on initialization.
 
override array< IEntity > GetManualOverrideList (IEntity owner, out vector referencePoint)
 Callback whem manual collection override is enabled.
 
float GetRaycastThreshold ()
 
- Public Member Functions inherited from ExtBaseInteractionHandlerComponent
proto external UserActionContext GetCurrentContext ()
 Returns currently gathered (active-preferred) context or null if none.
 
proto external IEntity GetControlledEntity ()
 Returns the controlled entity or null if none.
 
proto external int GetFilteredActions (out notnull array< BaseUserAction > outActions, out notnull array< bool > outCanBePerformed)
 After collection is done, this method can be used for retrieving already checked user actions from current context.
 
proto external bool IsContextAvailable ()
 Returns true when there is a gathered context available.
 
proto external void SetManualCollectionOverride (bool enabled)
 If set to true, we expect a list of entities to be provided from the user instead.
 
proto external bool GetManualCollectionOverride ()
 Returns whether manual collection override is set (we expect a list of entities to be provided from the user instead)
 
proto external void SetNearbyCollectionEnabled (bool enabled)
 Sets whether nearby available context collection should be enabled.
 
proto external bool GetNearbyCollectionEnabled ()
 Returns whether nearby available context collection is enabled.
 
proto external float GetNearbyCollectionRadius ()
 Returns the radius in meters that is used for nearby available context collection.
 
proto external int GetNearbyAvailableContextList (out notnull array< UserActionContext > outContexts)
 If nearby collection is enabled, fills the provided array with collected contexts nearby.
 
proto external int GetNearbyShowableContextList (out notnull array< UserActionContext > outContexts)
 If nearby collection is enabled, fills the provided array with collected contexts nearby.
 
proto external int GetNearbyUnavailableContextList (out notnull array< UserActionContext > outContexts)
 If nearby collection is enabled, fills the provided array with collected contexts nearby.
 
- Public Member Functions inherited from BaseInteractionHandlerComponent
proto external bool IsInteractionAvailable ()
 Returns true if any interaction can be done at given moment, i.e. UI should be shown.
 
proto external BaseUserAction GetSelectedAction ()
 Return currently selected user action or null if none.
 
proto external float GetVisibilityRange ()
 Returns the global actions visibility range value defined by attribute in this component.
 
void OnInit (IEntity owner)
 Called on initialization.
 
void OnFrame (IEntity owner, float timeSlice)
 Called every frame, only for local player controller.
 
void OnAfterPostSimulate (IEntity owner, float timeSlice)
 Called after post simulate, only for local player controller.
 
- Public Member Functions inherited from GameComponent
bool OnTicksOnRemoteProxy ()
 

Static Public Member Functions

static bool CanBeShownInVehicle (notnull ChimeraCharacter character, notnull BaseUserAction userAction, bool pilotOnly=false, bool pilotUncapableOverride=false, bool interiorOnly=false, array< int > definedCompartmentsOnly=null, array< int > excludeDefinedCompartments=null)
 Check if action can be shown when player is inside a vehicle.
 

Protected Member Functions

void RegisterActionListeners ()
 Action listeners that are meant to be registered once per user and only for the user who is the owner of this controller.
 
void RemoveActionListeners ()
 
SCR_BaseInteractionDisplay FindDisplay (IEntity owner)
 
void DoProcessInteraction (ChimeraCharacter user, UserActionContext context, BaseUserAction action, bool canPerform, bool performInput, float timeSlice, SCR_BaseInteractionDisplay display)
 Checks input, compares it to previous states and evaluates what the handler should do next.
 
override bool GetCanInteractScript (IEntity controlledEntity)
 Are we allowed to start collecting and processing interactions? Implement custom logic and return true if yes, false otherwise.
 
override bool GetIsInteractionAvailableScript ()
 Are any user actions available to interact with? Implement and return true if yes, false otherwise.
 
override BaseUserAction GetSelectedActionScript ()
 Currently sected action or null if none.
 
override bool DoIntersectCheck (IEntity controlledEntity)
 Should preferred context collection use intersect checks? This will make a ray check against the context's radius.
 
override void OnContextChanged (UserActionContext previousContext, UserActionContext newContext)
 Event called when InteractionHandlerComponent finds new target UserActionContext and a change occurs.
 
override bool CanContextChange (UserActionContext currentContext, UserActionContext newContext)
 Called before a context is set to determine whether a change can occur.
 
bool IsFreelookEnabled (ChimeraCharacter character)
 display mode is set to automatic freelook mode.
 
bool ShouldBeEnabled (SCR_NearbyContextDisplayMode displayMode, ChimeraCharacter character, bool playerCameraOnly=true)
 
void HandleOverride (notnull ChimeraCharacter character)
 Check if the player is inside a vehicle or is inspecting something and enable/disable ManualCollectionOverride for the nearby contexts based on it.
 
bool HandleVehicle (notnull ChimeraCharacter character)
 Check is player is inside a vehicle and grab all the compartments of that vehicle.
 
bool HandleInspection (notnull ChimeraCharacter character)
 Check if player is inspecting something (weapon, item, etc) and grab the contexts from it.
 
override void OnPostFrame (IEntity owner, IEntity controlledEntity, float timeSlice)
 Called once per frame after simulation.
 
void AggregateActions (array< BaseUserAction > actionsList, array< bool > canPerformList)
 Modifies the input lists (which need to be 1:1 in length and logical sense) so each action which can be aggregated (BaseUserAction.CanAggregate() returns true) only displays the first available (or any first if none is available to perform) action, filtered by BaseUserAction.GetActionName().
 
override bool CanContextChange (UserActionContext currentContext, UserActionContext newContext)
 Called before a context is set to determine whether a change can occur.
 
override bool DoIntersectCheck (IEntity controlledEntity)
 Should preferred context collection use intersect checks? This will make a ray check against the context's radius.
 
override bool GetIsInteractionAvailableScript ()
 Are any user actions available to interact with? Implement and return true if yes, false otherwise.
 
override bool GetCanInteractScript (IEntity controlledEntity)
 Are we allowed to start collecting and processing interactions? Implement custom logic and return true if yes, false otherwise.
 
override BaseUserAction GetSelectedActionScript ()
 Currently sected action or null if none.
 
- Protected Member Functions inherited from ExtBaseInteractionHandlerComponent
proto external void SetSelectedAction (BaseUserAction action)
 Sets currently select action.
 
void OnContextChanged (UserActionContext previousContext, UserActionContext newContext)
 Event called when InteractionHandlerComponent finds new target UserActionContext and a change occurs.
 
void OnPostFrame (IEntity owner, IEntity controlledEntity, float timeSlice)
 Called once per frame after simulation.
 
bool CanContextChange (UserActionContext currentContext, UserActionContext newContext)
 Called before a context is set to determine whether a change can occur.
 
bool DoIntersectCheck (IEntity controlledEntity)
 Should preferred context collection use intersect checks? This will make a ray check against the context's radius.
 
bool GetIsInteractionAvailableScript ()
 Are any user actions available to interact with? Implement and return true if yes, false otherwise.
 
bool GetCanInteractScript (IEntity controlledEntity)
 Are we allowed to start collecting and processing interactions? Implement custom logic and return true if yes, false otherwise.
 
BaseUserAction GetSelectedActionScript ()
 Currently sected action or null if none.
 
array< IEntity > GetManualOverrideList (IEntity owner, out vector referencePoint)
 Callback whem manual collection override is enabled.
 

Protected Attributes

SCR_BaseInteractionDisplay m_pDisplay
 Display (action menu) used to show UI to the player regarding collected actions.
 
SCR_NearbyContextDisplayMode m_eDisplayMode
 
float m_fRaycastThreshold
 
string m_sActionName
 
string m_sActionContext
 
UserActionContext m_pLastContext
 Last selected context.
 
BaseUserAction m_pLastUserAction
 Last selected user action.
 
int m_iSelectedActionIndex
 Currently selected action index.
 
bool m_bIsPerforming
 
bool m_bPerformAction
 
bool m_bLastInput
 
float m_fSelectAction
 
float m_fCurrentProgress
 
ref array< IEntity > m_aCollectedEntities = {}
 List of collected entities from which the available contexts will be taken to dispaly (weapon, vehicle, ...)
 
IEntity m_ControlledEntity
 
ref array< BaseUserActionm_ActionsBuffer = {}
 
ref array< bool > m_PerformBuffer = {}
 
ref map< string, ref array< int > > m_IndicesBuffer = new map<string, ref array<int>>()
 

Detailed Description

This component allows the player to interact with their environment.

It collects UserActionContext from ActionsManagerComponent from surrounding entities via queries, filters and finds the most appropriate one and provides script API to work with them.

It should always be attached to PlayerController entity and is local only.

Member Function Documentation

◆ ActionPerform()

void SCR_InteractionHandlerComponent.ActionPerform ( float  value,
EActionTrigger  reason 
)

Callback for caching the key press.

◆ ActionScroll()

void SCR_InteractionHandlerComponent.ActionScroll ( float  value,
EActionTrigger  reason 
)

◆ AggregateActions()

void SCR_InteractionHandlerComponent.AggregateActions ( array< BaseUserAction actionsList,
array< bool >  canPerformList 
)
protected

Modifies the input lists (which need to be 1:1 in length and logical sense) so each action which can be aggregated (BaseUserAction.CanAggregate() returns true) only displays the first available (or any first if none is available to perform) action, filtered by BaseUserAction.GetActionName().

◆ CanBeShownInVehicle()

static bool SCR_InteractionHandlerComponent.CanBeShownInVehicle ( notnull ChimeraCharacter  character,
notnull BaseUserAction  userAction,
bool  pilotOnly = false,
bool  pilotUncapableOverride = false,
bool  interiorOnly = false,
array< int >  definedCompartmentsOnly = null,
array< int >  excludeDefinedCompartments = null 
)
static

Check if action can be shown when player is inside a vehicle.

Parameters
[in]Charactercontrolled by the player
[in]Useraction that is being checked
[in]True,ifthe action can only be seen from the PilotCompartment
[in]True,ifthe action should be available to other passengers as long as pilot is not there or unconscious
[in]True,ifthe action can only be seen when player is sitting in the vehicle, the action belongs to
[in]Arrayof Compartments that the action should be shown in. (Does not work if pilotOnly = true)
[in]Arrayof Compartments that the action can't be shown in. (Does not work if pilotOnly = true)

◆ CanContextChange()

override bool SCR_InteractionHandlerComponent.CanContextChange ( UserActionContext  currentContext,
UserActionContext  newContext 
)
protected

Called before a context is set to determine whether a change can occur.

Implements InteractionHandlerComponent.

◆ DoIntersectCheck()

override bool SCR_InteractionHandlerComponent.DoIntersectCheck ( IEntity  controlledEntity)
protected

Should preferred context collection use intersect checks? This will make a ray check against the context's radius.

This works well in tight places where relying on physical collisions is impossible - e.g. in vehicle interiors.

Implements InteractionHandlerComponent.

◆ DoProcessInteraction()

void SCR_InteractionHandlerComponent.DoProcessInteraction ( ChimeraCharacter  user,
UserActionContext  context,
BaseUserAction  action,
bool  canPerform,
bool  performInput,
float  timeSlice,
SCR_BaseInteractionDisplay  display 
)
protected

Checks input, compares it to previous states and evaluates what the handler should do next.

Parameters
[in]user
[in]context
[in]action
[in]canPerform
[in]performInput
[in]timeSlice
[in]display

◆ FindDisplay()

SCR_BaseInteractionDisplay SCR_InteractionHandlerComponent.FindDisplay ( IEntity  owner)
protected

◆ GetCanInteractScript()

override bool SCR_InteractionHandlerComponent.GetCanInteractScript ( IEntity  controlledEntity)
protected

Are we allowed to start collecting and processing interactions? Implement custom logic and return true if yes, false otherwise.

Parameters
controlledEntityThe entity that wants to be able to interact (player controlled)

Implements InteractionHandlerComponent.

◆ GetIsInteractionAvailableScript()

override bool SCR_InteractionHandlerComponent.GetIsInteractionAvailableScript ( )
protected

Are any user actions available to interact with? Implement and return true if yes, false otherwise.

Implements InteractionHandlerComponent.

◆ GetManualOverrideList()

override array< IEntity > SCR_InteractionHandlerComponent.GetManualOverrideList ( IEntity  owner,
out vector  referencePoint 
)

Callback whem manual collection override is enabled.

See SetManualCollectionOverride. It may return nullptrs inside array if this is called between deletion of instance inside the array and updating of the array.

Parameters
ownerParent entity
referencePointPoint in world space used to calculate distance and sort contexts by

Implements ExtBaseInteractionHandlerComponent.

◆ GetRaycastThreshold()

float SCR_InteractionHandlerComponent.GetRaycastThreshold ( )

◆ GetSelectedActionScript()

override BaseUserAction SCR_InteractionHandlerComponent.GetSelectedActionScript ( )
protected

Currently sected action or null if none.

Implement and return currently selected action.

Implements InteractionHandlerComponent.

◆ HandleInspection()

bool SCR_InteractionHandlerComponent.HandleInspection ( notnull ChimeraCharacter  character)
protected

Check if player is inspecting something (weapon, item, etc) and grab the contexts from it.

Parameters
[in]charactercontrolled by the player
Returns
True if player is inspecting something, false otherwise

◆ HandleOverride()

void SCR_InteractionHandlerComponent.HandleOverride ( notnull ChimeraCharacter  character)
protected

Check if the player is inside a vehicle or is inspecting something and enable/disable ManualCollectionOverride for the nearby contexts based on it.

Parameters
[in]charactercontrolled by the player

◆ HandleVehicle()

bool SCR_InteractionHandlerComponent.HandleVehicle ( notnull ChimeraCharacter  character)
protected

Check is player is inside a vehicle and grab all the compartments of that vehicle.

Parameters
[in]charactercontrolled by the player
Returns
True if player is inside a vehicle, false otherwise

◆ IsFreelookEnabled()

bool SCR_InteractionHandlerComponent.IsFreelookEnabled ( ChimeraCharacter  character)
protected

display mode is set to automatic freelook mode.

Returns
true if nearby action contexts should be shown when

◆ OnContextChanged()

override void SCR_InteractionHandlerComponent.OnContextChanged ( UserActionContext  previousContext,
UserActionContext  newContext 
)
protected

Event called when InteractionHandlerComponent finds new target UserActionContext and a change occurs.

Both previous and new context might be 'null' if no context is caught in collection.

Parameters
previousContextContext that was active up until this collection - can be null
newContextContext that will be active after this collection - can be null if nothing was caught

Implements ExtBaseInteractionHandlerComponent.

◆ OnControlledEntityChanged()

void SCR_InteractionHandlerComponent.OnControlledEntityChanged ( IEntity  from,
IEntity  to 
)

Method called when player takes controll over an entity.

Parameters
[in]fromentity which was previously controlled
[in]toentity which is now controlled

◆ OnInit()

override void SCR_InteractionHandlerComponent.OnInit ( IEntity  owner)

Called on initialization.

Might not be called unless we already own this item.

Implements BaseInteractionHandlerComponent.

◆ OnPostFrame()

override void SCR_InteractionHandlerComponent.OnPostFrame ( IEntity  owner,
IEntity  controlledEntity,
float  timeSlice 
)
protected

Called once per frame after simulation.

Can be used for drawing and updating UI.

Implements ExtBaseInteractionHandlerComponent.

◆ RegisterActionListeners()

void SCR_InteractionHandlerComponent.RegisterActionListeners ( )
protected

Action listeners that are meant to be registered once per user and only for the user who is the owner of this controller.

◆ RemoveActionListeners()

void SCR_InteractionHandlerComponent.RemoveActionListeners ( )
protected

◆ ShouldBeEnabled()

bool SCR_InteractionHandlerComponent.ShouldBeEnabled ( SCR_NearbyContextDisplayMode  displayMode,
ChimeraCharacter  character,
bool  playerCameraOnly = true 
)
protected

Member Data Documentation

◆ m_aCollectedEntities

ref array<IEntity> SCR_InteractionHandlerComponent.m_aCollectedEntities = {}
protected

List of collected entities from which the available contexts will be taken to dispaly (weapon, vehicle, ...)

◆ m_ActionsBuffer

ref array<BaseUserAction> SCR_InteractionHandlerComponent.m_ActionsBuffer = {}
protected

◆ m_bIsPerforming

bool SCR_InteractionHandlerComponent.m_bIsPerforming
protected

◆ m_bLastInput

bool SCR_InteractionHandlerComponent.m_bLastInput
protected

◆ m_bPerformAction

bool SCR_InteractionHandlerComponent.m_bPerformAction
protected

◆ m_ControlledEntity

IEntity SCR_InteractionHandlerComponent.m_ControlledEntity
protected

◆ m_eDisplayMode

SCR_NearbyContextDisplayMode SCR_InteractionHandlerComponent.m_eDisplayMode
protected

◆ m_fCurrentProgress

float SCR_InteractionHandlerComponent.m_fCurrentProgress
protected

◆ m_fRaycastThreshold

float SCR_InteractionHandlerComponent.m_fRaycastThreshold
protected

◆ m_fSelectAction

float SCR_InteractionHandlerComponent.m_fSelectAction
protected

◆ m_IndicesBuffer

ref map<string, ref array<int> > SCR_InteractionHandlerComponent.m_IndicesBuffer = new map<string, ref array<int>>()
protected

◆ m_iSelectedActionIndex

int SCR_InteractionHandlerComponent.m_iSelectedActionIndex
protected

Currently selected action index.

◆ m_pDisplay

SCR_BaseInteractionDisplay SCR_InteractionHandlerComponent.m_pDisplay
protected

Display (action menu) used to show UI to the player regarding collected actions.

◆ m_PerformBuffer

ref array<bool> SCR_InteractionHandlerComponent.m_PerformBuffer = {}
protected

◆ m_pLastContext

UserActionContext SCR_InteractionHandlerComponent.m_pLastContext
protected

Last selected context.

◆ m_pLastUserAction

BaseUserAction SCR_InteractionHandlerComponent.m_pLastUserAction
protected

Last selected user action.

◆ m_sActionContext

string SCR_InteractionHandlerComponent.m_sActionContext
protected

◆ m_sActionName

string SCR_InteractionHandlerComponent.m_sActionName
protected

The documentation for this interface was generated from the following file: