Navigation
API > API/Plugins > API/Plugins/MLAdapter > API/Plugins/MLAdapter/Sessions
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UMLAdapterSession
- UMLAdapterLocalDataCollectionSession
References
| Module | MLAdapter |
| Header | /Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Public/Sessions/MLAdapterSession.h |
| Include | #include "Sessions/MLAdapterSession.h" |
Syntax
UCLASS ()
class UMLAdapterSession : public UObject
Remarks
Container for agents that exist in the world. Ticks the agents. Finds avatars for the agents.
Variables
| Type | Name | Description | |
|---|---|---|---|
| FDelegateHandle | ActorSpawnedDelegateHandle | ||
| FCriticalSection | AgentOpCS | ||
| TArray< TObjectPtr< UMLAdapterAgent > > | Agents | ||
| TMap< uint32, TObjectPtr< UMLAdapterAgent > > | AvatarToAgent | ||
| TArray< TObjectPtr< UMLAdapterAgent > > | AwaitingAvatar | ||
| bool | bActive | ||
| bool | bTickWorldManually | ||
| TObjectPtr< AGameModeBase > | CachedGameMode | ||
| TObjectPtr< UWorld > | CachedWorld | ||
| float | LastTimestamp | ||
| FOnAgentAvatarChangedDelegate | OnAgentAvatarChanged | ||
| FOnBeginAgentRemove | OnBeginAgentRemove | ||
| EMLAdapterSimState | SimulationState | ||
| TSharedPtr< FWorldTicker > | WorldTicker |
Functions
| Type | Name | Description | |
|---|---|---|---|
| FMLAdapter::FAgentID | AddAgent () |
Agent/Avatar management. | |
| FMLAdapter::FAgentID | AddAgent
(
const FMLAdapterAgentConfig& InConfig |
Add an agent using the specified config. | |
| void | BindAvatar
(
UMLAdapterAgent& Agent, |
Sets a new avatar on the agent after clearing any existing avatar. | |
| void | ClearAvatar
(
UMLAdapterAgent& Agent |
Remove the existing avatar from the given agent. | |
| void | Close () |
Mark the session as inactive and cleanup all agents. | |
| void | This is where Session can add Client-side-specific functions by calling UMLAdapterManager::Get().AddClientFunctionBind. | ||
| void | This is where Session can add Authority-side-specific functions by calling UMLAdapterManager::Get().AddServerFunctionBind | ||
| void | EnableActionDuration
(
FMLAdapter::FAgentID AgentID, |
Enable/disable the action durations with the specified time duration in seconds. | |
| const UMLAdapterAgent * | FindAgentByAvatar
(
AActor& Avatar |
Find an agent that is controlling the given avatar if one exists. Returns nullptr if not. | |
| void | FindAvatars
(
UWorld& World |
Finds avatar in given World for every avatar-less agent in AwaitingAvatar | |
| UMLAdapterAgent * | GetAgent
(
FMLAdapter::FAgentID AgentID |
Returns the agent corresponding to the given ID. Returns nullptr if the ID is invalid. | |
| int32 | |||
| UGameInstance * | |||
| FMLAdapter::FAgentID | GetNextAgentID
(
FMLAdapter::FAgentID ReferenceAgentID |
||
| FOnAgentAvatarChangedDelegate | |||
| FOnBeginAgentRemove | |||
| float | GetTimestamp () |
Get the world time in seconds at the most recent time this session ticked. | |
| UWorld * | GetWorld () |
Get this session's cached world. | |
| uint32 | HashAvatar
(
const AActor& Avatar |
||
| bool | IsAgentReady
(
FMLAdapter::FAgentID AgentID |
Returns true if the agent with the given ID has a valid avatar assigned. | |
| bool | IsDone () |
A session is done if the SimulationState == Finished or the game mode's match has ended. | |
| bool | IsReady () |
A session is ready if the SimulationState == InProgress or the game mode's match has started but not ended. | |
| void | OnActorSpawned
(
AActor* InActor |
If there are agents waiting for an avatar, then check if a newly spawned actor fits the agent. | |
| void | OnGameModeInitialized
(
AGameModeBase& GameModeBase |
||
| void | OnGameModeMatchStateSet
(
FName InMatchState |
||
| void | OnGameModePostLogin
(
AGameModeBase* GameMode, |
||
| void | OnPostWorldInit
(
UWorld& World |
||
| void | OnWorldCleanup
(
UWorld& World, |
||
| void | Open () |
Mark the session as active. | |
| void | RemoveAgent
(
FMLAdapter::FAgentID AgentID |
Remove the agent with the given ID from this session. | |
| void | RemoveAvatars
(
UWorld* World |
Processes Agents and removes all agent avatars belonging to World. | |
| bool | RequestAvatarForAgent
(
FMLAdapter::FAgentID& AgentID, |
Calls RequestAvatarForAgent(UMLAdapterAgent& Agent, ...) after looking up the agent by its ID. | |
| bool | RequestAvatarForAgent
(
UMLAdapterAgent& Agent, |
Finds a suitable avatar in InWorld (or CachedWorld, if InWorld is null) for given agent, as specified by FMLAdapterAgentConfig.AvatarClass and confirmed by Agent->IsSuitableAvatar call. | |
| void | ResetWorld
(
FMLAdapter::FAgentID AgentID |
Using FMLAdapter::InvalidAgentID for AgentID will reset all agents. | |
| void | SetGameMode
(
AGameModeBase* GameModeBase |
Debug | |
| void | SetManualWorldTickEnabled
(
bool bEnable |
If true, the world's ticking will be controlled by the remote client. | |
| void | Sets the world that this session will use to find avatars for agents | ||
| void | Tick
(
float DeltaTime |
Call all agents' Sense(), Think(), and Act() methods. | |
| bool | TryResetActionDuration
(
FMLAdapter::FAgentID AgentID |
Resets the action duration flag if it has elapsed. |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | BeginDestroy () |
Called before destroying the object. | |
| void | Called after the C++ constructor and after the properties have been initialized, including those loaded from config. |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FWorldTicker |
Typedefs
| Name | Description |
|---|---|
| FOnAgentAvatarChangedDelegate | |
| FOnBeginAgentRemove |