Apparatus Version 1.23
ECS data-oriented workflow for Unreal Engine.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
UMachine Class Reference

The global state manager. More...

#include <Machine.h>

Inheritance diagram for UMachine:
Inheritance graph
[legend]
Collaboration diagram for UMachine:
Collaboration graph
[legend]

Public Types

enum  { InvalidChainId = FChain::InvalidId , FirstChainId = FChain::FirstId , InvalidSubjectIndex = FSubjectInfo::InvalidSlotIndex }
 
typedef FSubjectInfo::IdType SubjectIdType
 

Public Member Functions

template<EParadigm Paradigm = EParadigm::Default>
TOutcome< Paradigm > CopyTraitsFromTo (const FSubjectHandle &SrcSubjectHandle, const FSubjectHandle &DstSubjectHandle)
 Copy an existing subject traits to another one.
 

Static Public Member Functions

static int32 ObtainTraitId (const UScriptStruct *TraitType)
 Obtain a trait's unique identifier.
 
static int32 RegisteredTraitsNum ()
 Get the total number of registered traits so far.
 
static const FBitMaskObtainTraitMask (const UScriptStruct *TraitType)
 Obtain the cached mask for a trait type.
 
template<typename T >
static const FBitMaskObtainTraitMask ()
 Obtain the mask of a trait.
 
static int32 ObtainDetailId (const TSubclassOf< UDetail > DetailClass)
 Obtain a detail's unique identifier.
 
static int32 RegisteredDetailsNum ()
 Get the total number of registered details so far.
 
static const FBitMaskObtainDetailMask (const TSubclassOf< UDetail > DetailClass)
 Obtain the cached mask of a detail type.
 
static const FBitMaskObtainExcludedDetailMask (const TSubclassOf< UDetail > DetailClass)
 Obtain the excluded mask of a detail class.
 
static const FBitMaskObtainDetailMask (const UDetail *Detail)
 Obtain the cached mask of a detail's class.
 
static const FBitMaskObtainExcludedDetailMask (const UDetail *Detail)
 Obtain the excluded mask of a details's class.
 
template<class T >
static const FBitMaskObtainDetailMask ()
 Obtain the mask of a detail class.
 
template<class T >
static const FBitMaskObtainExcludedDetailMask ()
 Obtain the excluding mask of a detail class.
 
static bool HasInstance ()
 Check if there is a global machine instance currently.
 
static UMachineObtainInstance ()
 Obtain the global machine instance.
 
static AMechanismObtainMechanism (UPackage *const InPackage)
 Obtain a default mechanism instance for a package.
 
static AMechanismObtainMechanism (UWorld *const InWorld)
 Obtain a mechanism instance for a world.
 
static int32 MechanismsNum ()
 Get the number of currently registered (active) mechanisms.
 
static int32 CountSubjectsNum ()
 Count the current number of effective subjects within all registered (active) mechanisms.
 
template<EParadigm Paradigm = EParadigm::Default>
static TOutcome< Paradigm > DespawnSubjects (const EFlagmark Flagmark, const EFlagmark ExcludingFlagmark=FM_None)
 Despawn all the subjects matching a filter within all of the mechanisms.
 
template<EParadigm Paradigm = EParadigm::Default>
static TOutcome< Paradigm > DespawnAllSubjects ()
 Despawn all the available subjects within all of the mechanisms.
 
template<EParadigm Paradigm = EParadigm::Default>
static TOutcome< Paradigm > Reset ()
 Reset the machine completely, removing all of the subjects, unregistering all of the parts.
 
static EApparatusStatus ReleaseInstance (const bool bReset=true)
 Release the machine from the root set, but only if it's no longer needed, i.e.
 

Static Public Attributes

static constexpr SubjectIdType InvalidSubjectId = FSubjectInfo::InvalidId
 Invalid subject identifier.
 
static constexpr SubjectIdType FirstSubjectPlace = FSubjectInfo::FirstPlace
 A first valid subject place.
 
static constexpr SubjectIdType LastSubjectPlace = FSubjectInfo::LastPlace
 The last valid subject place.
 

Protected Member Functions

void BeginDestroy () override
 Destroy the machine object.
 
 UMachine ()
 The default constructor for the machine.
 

Friends

struct FSubjectInfo
 
struct FSubjectNetworkState
 
struct FCommonSubjectHandle
 
struct FChunkSlot
 
class IIterable
 
class ISubjective
 
class IMechanical
 
class UBelt
 
class UChunk
 
class UNetworkBearerComponent
 
class AMechanism
 
class UApparatusFunctionLibrary
 
template<typename SubjectHandleT >
struct TChunkIt
 
template<typename SubjectHandleT >
struct TBeltIt
 
template<typename ChunkItT , typename BeltItT , EParadigm Paradigm>
struct TChain
 

Detailed Description

The global state manager.

This is the root Apparatus object. It is created automatically and persists until it's no longer needed.

Member Typedef Documentation

◆ SubjectIdType

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
InvalidChainId 

Invalid chain identifier.

FirstChainId 

First valid chain identifier.

InvalidSubjectIndex 

Invalid subject's slot index.

Constructor & Destructor Documentation

◆ UMachine()

UMachine::UMachine ( )
inlineprotected

The default constructor for the machine.

The constructor is made non-public, cause it shouldn't be called directly but only through new object creation procedure, which is called as a result of a machine's obtainment/retainment flow.

Member Function Documentation

◆ BeginDestroy()

void UMachine::BeginDestroy ( )
overrideprotected

Destroy the machine object.

This should happen when the machine is no longer needed.

◆ CopyTraitsFromTo()

template<EParadigm Paradigm = EParadigm::Default>
TOutcome< Paradigm > UMachine::CopyTraitsFromTo ( const FSubjectHandle SrcSubjectHandle,
const FSubjectHandle DstSubjectHandle 
)

Copy an existing subject traits to another one.

The existing traits of the destination subject are not removed but the new ones are added and override the existing matching. Supports copying traits among subjects of different mechanisms.

Template Parameters
ParadigmThe paradigm to work under.
Parameters
SrcSubjectHandleThe source subject handle to copy from.
DstSubjectHandleThe destination subject handle to copy to.
Returns
The status of the operation.

◆ CountSubjectsNum()

static int32 UMachine::CountSubjectsNum ( )
inlinestatic

Count the current number of effective subjects within all registered (active) mechanisms.

Note
This method is generally not thread-safe and shouldn't be called during spawning/despawning of the subjects on different threads.

The method is generally not optimized and should be used occasionally.

◆ DespawnAllSubjects()

template<EParadigm Paradigm = EParadigm::Default>
static TOutcome< Paradigm > UMachine::DespawnAllSubjects ( )
inlinestatic

Despawn all the available subjects within all of the mechanisms.

Template Parameters
ParadigmThe paradigm to work under.
Returns
The outcome of the operation.

◆ DespawnSubjects()

template<EParadigm Paradigm = EParadigm::Default>
static TOutcome< Paradigm > UMachine::DespawnSubjects ( const EFlagmark  Flagmark,
const EFlagmark  ExcludingFlagmark = FM_None 
)
inlinestatic

Despawn all the subjects matching a filter within all of the mechanisms.

Template Parameters
ParadigmThe paradigm to work under.
Parameters
FlagmarkThe including flagmark to match.
ExcludingFlagmarkThe excluding flagmark to match.
Returns
The outcome of the operation.

◆ HasInstance()

static bool UMachine::HasInstance ( )
inlinestatic

Check if there is a global machine instance currently.

◆ MechanismsNum()

static int32 UMachine::MechanismsNum ( )
inlinestatic

Get the number of currently registered (active) mechanisms.

◆ ObtainDetailId()

static int32 UMachine::ObtainDetailId ( const TSubclassOf< UDetail DetailClass)
inlinestatic

Obtain a detail's unique identifier.

◆ ObtainDetailMask() [1/3]

template<class T >
static const FBitMask & UMachine::ObtainDetailMask ( )
inlinestatic

Obtain the mask of a detail class.

Templated version.

◆ ObtainDetailMask() [2/3]

static const FBitMask & UMachine::ObtainDetailMask ( const TSubclassOf< UDetail DetailClass)
inlinestatic

Obtain the cached mask of a detail type.

◆ ObtainDetailMask() [3/3]

static const FBitMask & UMachine::ObtainDetailMask ( const UDetail Detail)
inlinestatic

Obtain the cached mask of a detail's class.

◆ ObtainExcludedDetailMask() [1/3]

template<class T >
static const FBitMask & UMachine::ObtainExcludedDetailMask ( )
inlinestatic

Obtain the excluding mask of a detail class.

Templated version.

◆ ObtainExcludedDetailMask() [2/3]

static const FBitMask & UMachine::ObtainExcludedDetailMask ( const TSubclassOf< UDetail DetailClass)
inlinestatic

Obtain the excluded mask of a detail class.

◆ ObtainExcludedDetailMask() [3/3]

static const FBitMask & UMachine::ObtainExcludedDetailMask ( const UDetail Detail)
inlinestatic

Obtain the excluded mask of a details's class.

◆ ObtainInstance()

static UMachine * UMachine::ObtainInstance ( )
inlinestatic

Obtain the global machine instance.

The returned instance doesn't actually gets retained and will be a subject to garbage collection, unless explicitly retained.

This may only be called during the game running as the machine should not be part of the normal editing context.

◆ ObtainMechanism() [1/2]

static AMechanism * UMachine::ObtainMechanism ( UPackage *const  InPackage)
inlinestatic

Obtain a default mechanism instance for a package.

Note
If you want to prevent the resulting mechanism from being destroyed by the garbage collector, you have to add an explicit UPROPERTY pointer to it.
Parameters
InPackageThe package to get a mechanism for.
Returns
The resulting mechanism.

◆ ObtainMechanism() [2/2]

static AMechanism * UMachine::ObtainMechanism ( UWorld *const  InWorld)
inlinestatic

Obtain a mechanism instance for a world.

Parameters
InWorldA world to obtain a mechanism for.
Returns
The resulting mechanism.

◆ ObtainTraitId()

static int32 UMachine::ObtainTraitId ( const UScriptStruct *  TraitType)
inlinestatic

Obtain a trait's unique identifier.

◆ ObtainTraitMask() [1/2]

template<typename T >
static const FBitMask & UMachine::ObtainTraitMask ( )
inlinestatic

Obtain the mask of a trait.

Templated version.

◆ ObtainTraitMask() [2/2]

static const FBitMask & UMachine::ObtainTraitMask ( const UScriptStruct *  TraitType)
inlinestatic

Obtain the cached mask for a trait type.

◆ RegisteredDetailsNum()

static int32 UMachine::RegisteredDetailsNum ( )
inlinestatic

Get the total number of registered details so far.

◆ RegisteredTraitsNum()

static int32 UMachine::RegisteredTraitsNum ( )
inlinestatic

Get the total number of registered traits so far.

◆ ReleaseInstance()

static EApparatusStatus UMachine::ReleaseInstance ( const bool  bReset = true)
inlinestatic

Release the machine from the root set, but only if it's no longer needed, i.e.

has no entities registered.

You can call this method explicitly after the UMachine::Reset().

Parameters
bResetShould the machine be reset before releasing? Guarantees the machine to be released.
Returns
The status of the operation.

◆ Reset()

template<EParadigm Paradigm = EParadigm::Default>
static TOutcome< Paradigm > UMachine::Reset ( )
static

Reset the machine completely, removing all of the subjects, unregistering all of the parts.

This will also clear up the network id assignment state for the subjects completely.

Note
This won't automatically trigger the release of the machine, which must be executed explicitly.
Template Parameters
ParadigmThe paradigm to work under.
Returns
The outcome of the operation.

Friends And Related Function Documentation

◆ AMechanism

friend class AMechanism
friend

◆ FChunkSlot

friend struct FChunkSlot
friend

◆ FCommonSubjectHandle

friend struct FCommonSubjectHandle
friend

◆ FSubjectInfo

friend struct FSubjectInfo
friend

◆ FSubjectNetworkState

friend struct FSubjectNetworkState
friend

◆ IIterable

friend class IIterable
friend

◆ IMechanical

friend class IMechanical
friend

◆ ISubjective

friend class ISubjective
friend

◆ TBeltIt

template<typename SubjectHandleT >
friend struct TBeltIt
friend

◆ TChain

template<typename ChunkItT , typename BeltItT , EParadigm Paradigm>
friend struct TChain
friend

◆ TChunkIt

template<typename SubjectHandleT >
friend struct TChunkIt
friend

◆ UApparatusFunctionLibrary

friend class UApparatusFunctionLibrary
friend

◆ UBelt

friend class UBelt
friend

◆ UChunk

friend class UChunk
friend

◆ UNetworkBearerComponent

friend class UNetworkBearerComponent
friend

Member Data Documentation

◆ FirstSubjectPlace

constexpr SubjectIdType UMachine::FirstSubjectPlace = FSubjectInfo::FirstPlace
staticconstexpr

A first valid subject place.

◆ InvalidSubjectId

constexpr SubjectIdType UMachine::InvalidSubjectId = FSubjectInfo::InvalidId
staticconstexpr

Invalid subject identifier.

◆ LastSubjectPlace

constexpr SubjectIdType UMachine::LastSubjectPlace = FSubjectInfo::LastPlace
staticconstexpr

The last valid subject place.


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