UMassRepresentationSubsystem

Subsystem responsible for all visual of mass agents, will handle actors spawning and static mesh instances

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

MassRepresentation

Header

/Engine/Plugins/Runtime/MassGameplay/Source/MassRepresentation/Public/MassRepresentationSubsystem.h

Include

#include "MassRepresentationSubsystem.h"

Syntax

UCLASS()
class UMassRepresentationSubsystem : public UWorldSubsystem

Remarks

Subsystem responsible for all visual of mass agents, will handle actors spawning and static mesh instances

Variables

Name Description

Protected variable UProperty Transient

UMassActorSpawn...

 

ActorSpawnerSubsystem

Protected variable UProperty Transient

UMassEntitySubs...

 

EntitySubsystem

Protected variable

TMap< FMassEnti...

 

HandledMassAgents

Keeping track of all the mass agent this subsystem is responsible for spawning actors

Protected variable

float

 

RetryMovedDistanceSq

The time to wait before retrying a to spawn actor that failed

Protected variable

float

 

RetryTimeInterval

The distance a failed spawned actor needs to move before we retry

Protected variable UProperty Transient

TArray< TSubcla...

 

TemplateActors

The array of all the template actors

Protected variable

FRWAccessDetect...

 

TemplateActorsMTAccessDetector

Protected variable UProperty Transient

UMassVisualizat...

 

VisualizationComponent

The component that handles all the static mesh instances

Protected variable UProperty Transient

AMassVisualizer...

 

Visualizer

The actor owning the above visualization component

Protected variable UProperty Transient

UWorldPartition...

 

WorldPartitionSubsystem

Functions

Name Description

Public function

bool

 

CancelSpawning

(
    const FMassEntityHandle MassAgent,
    const int16 TemplateActorIndex,
    FMassActorSpawnRequestHandle& Spaw...
)

Cancel spawning request that is matching the TemplateActorIndex

Protected function

bool

 

CancelSpawningInternal

(
    const int16 TemplateActorIndex,
    FMassActorSpawnRequestHandle& Spaw...
)

Public function Const

void

 

DirtyStaticMeshInstances()

Mark render state of the static mesh instances dirty

Public function

bool

 

DoesActorMatchTemplate

(
    const AActor& Actor,
    const int16 TemplateActorIndex
)

Compare if an actor matches the registered template actor

Public function Const

int16

 

FindOrAddStaticMeshDesc

(
    const FStaticMeshInstanceVisualizat...
)

Get the index of the static mesh visual type, will add a new one if does not exist

Public function

int16

 

FindOrAddTemplateActor

(
    const TSubclassOf< AActor >& Actor...
)

Store the template actor uniquely and return an index to it

Public function Const

FMassInstanc...

 

GetMutableInstancedStaticMeshInfos()

Public function

AActor *

 

GetOrSpawnActorFromTemplate

(
    const FMassEntityHandle MassAgent,
    const FTransform& Transform,
    const int16 TemplateActorIndex,
    FMassActorSpawnRequestHandle& Spaw...,
    float Priority,
    FMassActorPreSpawnDelegate ActorPre...,
    FMassActorPostSpawnDelegate ActorPo...
)

Get or spawn an actor from the TemplateActorIndex

Public function

TSubclassOf<...

 

GetTemplateActorClass

(
    const int16 TemplateActorIndex
)

Public function Const

bool

 

IsCollisionLoaded

(
    const FName TargetGrid,
    const FTransform& Transform
)

Protected function

void

 

OnMassAgentComponentEntityAssociated

(
    const UMassAgentComponent& AgentCo...
)

Protected function

void

 

OnMassAgentComponentEntityDetaching

(
    const UMassAgentComponent& AgentCo...
)

Protected function Const

void

 

OnProcessingPhaseStarted

(
    const float DeltaSeconds,
    const EMassProcessingPhase Phase
)

Needed for batching the update of static mesh transform

Public function

void

 

ReleaseAllResources()

Release all references to static meshes and template actors Use with caution, all entities using this representation subsystem must be destroy otherwise they will point to invalid resources

Public function

bool

 

ReleaseTemplateActor

(
    const FMassEntityHandle MassAgent,
    const int16 TemplateActorIndex,
    AActor* ActorToRelease,
    bool bImmediate
)

Release an actor that is matching the TemplateActorIndex

Protected function

bool

 

ReleaseTemplateActorInternal

(
    const int16 TemplateActorIndex,
    AActor* ActorToRelease,
    bool bImmediate
)

Public function

bool

 

ReleaseTemplateActorOrCancelSpawning

(
    const FMassEntityHandle MassAgent,
    const int16 TemplateActorIndex,
    AActor* ActorToRelease,
    FMassActorSpawnRequestHandle& Spaw...
)

Release an actor or cancel its spawning if it is matching the TemplateActorIndex

Overridden from USubsystem

Name Description

Protected function Virtual

void

 

Deinitialize()

Implement this for deinitialization of instances of the system

Protected function Virtual

void

 

Initialize

(
    FSubsystemCollectionBase& Collecti...
)

USubsystem BEGIN.