Apparatus Version 1.8
ECS data-oriented workflow for Unreal Engine.
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ISubjective Class Reference

An interface for all sorts of subjects. More...

#include <Subjective.h>

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

Public Types

enum  { InvalidSlotIndex = FBeltSlot::InvalidIndex }
 

Public Member Functions

UMechanismGetMechanism () const
 Get the mechanism this subjective is currently part of (if registered). More...
 
virtual const TArray< FTraitRecord > & GetTraitRecordsRef () const
 Direct access for the internal traits array. More...
 
virtual const TArray< UDetail * > & GetDetailsRef () const
 Direct access for the internal details array. More...
 
const FFingerprintGetFingerprint () const
 Get the active fingerprint of the subjective. More...
 
bool Matches (const FFilter &InFilter) const
 Check if the subjective matches a supplied filter. More...
 
bool Matches (const FTraitmark &InTraitmark) const
 Check if the subjective matches a supplied traitmark as a filter. More...
 
bool Matches (const FDetailmark &InDetailmark) const
 Check if the subjective matches a supplied detailmark as a filter. More...
 
bool HasTrait (UScriptStruct *const TraitType) const
 Check if the subjective has a certain trait. More...
 
template<typename T >
bool HasTrait () const
 Check if there is a trait of a specific type in the subjective. More...
 
EApparatusStatus SetTrait (UScriptStruct *TraitType, const void *const TraitData)
 Set a trait of the subjective by its type. More...
 
template<typename T >
EApparatusStatus SetTrait (const T &Trait)
 Set a trait of the subjective. More...
 
EApparatusStatus GetTrait (UScriptStruct *const TraitType, void *const OutTraitData, const bool bTraitDataInitialized=true) const
 Get a trait from a subjective by its type. More...
 
template<typename T >
EApparatusStatus GetTrait (T &OutTrait, const bool bTraitDataInitialized=true) const
 Get a trait from a subjective by its type. More...
 
template<typename T >
GetTrait () const
 Get a copy of a trait from a subjective by its type. More...
 
EApparatusStatus ObtainTrait (UScriptStruct *TraitType, void *const OutTraitData, const bool bTraitDataInitialized=true)
 Obtain a trait from a subjective by its type. More...
 
template<typename T >
EApparatusStatus ObtainTrait (T &OutTrait, const bool bTraitDataInitialized=true)
 Obtain a trait from a subjective. More...
 
template<typename T >
ObtainTrait ()
 Get a copy of an obtained trait from a subjective. More...
 
EApparatusStatus RemoveTrait (UScriptStruct *const TraitType)
 Remove a trait from the subjective. More...
 
template<typename T >
EApparatusStatus RemoveTrait ()
 Remove a trait from the subjective. More...
 
void GetDetails (const bool bIncludeDisabled, TArray< UDetail * > &OutDetails) const
 Get the details of the subjective. More...
 
void GetDetails (TArray< UDetail * > &OutDetails) const
 Get all the enabled details of the subjective. More...
 
UDetailFindDetail (TSubclassOf< UDetail > DetailClass, const bool bIncludeDisabled=false) const
 Find a detail by its class. More...
 
template<class D >
D * FindDetail (const bool bIncludeDisabled=false) const
 Find a detail by its class. More...
 
UDetailGetDetail (TSubclassOf< UDetail > DetailClass, const bool bIncludeDisabled=false) const
 Get a detail by its class. More...
 
template<class D >
D * GetDetail (const bool bIncludeDisabled=false) const
 Get a detail by its class. More...
 
void FindDetails (TSubclassOf< UDetail > DetailClass, TArray< UDetail * > &OutDetails, const bool bIncludeDisabled=false) const
 Find the details by their class. More...
 
bool HasDetail (TSubclassOf< UDetail > DetailClass, const bool bIncludeDisabled=false) const
 Check if there is a detail of a specific class in the subjective. More...
 
template<class T >
bool HasDetail (const bool bIncludeDisabled=false) const
 Check if there is a detail of a specific class in the subjective. More...
 
UDetailEnableDetail (const TSubclassOf< UDetail > DetailClass)
 Enable a detail of a certain type. More...
 
template<class D >
D * EnableDetail ()
 Enable a detail of a certain type. More...
 
UDetailAddDetail (const TSubclassOf< UDetail > DetailClass, const bool bReuseDisabled=false)
 Add a new active detail or reuse an inactive one. More...
 
template<class D >
D * AddDetail (const bool bReuseDisabled=false)
 Add a new active detail or reuse an inactive one. More...
 
EApparatusStatus DisableDetail (const TSubclassOf< UDetail > DetailClass, const bool bDisableMultiple=false)
 Disable detail(s) by class. More...
 
template<class D >
EApparatusStatus DisableDetail (const bool bDisableMultiple=false)
 Disable detail(s) by class. More...
 
virtual UBeltGetPreferredBelt () const
 Get the preferred belt of the subjective (if any). More...
 
const struct FBeltSlotGetSlot () const
 Get the current belt slot of the subjective (if any). More...
 
bool IsRegistered () const
 Check if the subjective is registered within the machine. More...
 
int32 GetSlotIndex () const
 Get the current slot index of the subjective. More...
 
bool IsBooted () const
 Check if the subject is booted. More...
 
FSubjectHandle GetHandle ()
 Get the subject handle of this subjective. More...
 
FConstSubjectHandle GetHandle () const
 Get the subject handle of this subjective. More...
 
virtual uint32 CalcHash () const
 Calculate the hash of the subjective. More...
 
void ReceiveHandleDespawned ()
 Called when the subject handle is despawned. More...
 
virtual void HandleDespawned ()
 Called when the subject handle is despawned. More...
 
virtual class AActor * GetActor () const
 Get an actor corresponding to the subjective (if any). More...
 

Protected Member Functions

void MarkBooted ()
 Set the subjective as booted. More...
 
void TakeBeltSlot (UBelt *const InBelt, const int32 InSlotIndex=FBeltSlot::InvalidIndex)
 Set or reset the current belt slot of the subjective. More...
 
void TakeBeltSlot (const int32 InSlotIndex)
 Change the current slot of the subjective, while preserving the belt. More...
 
UBeltGetBelt () const
 Get the active belt of the subjective (if any). More...
 
virtual TArray< FTraitRecord > & GetTraitRecordsRef ()
 Direct access for the internal traits array. More...
 
virtual TArray< UDetail * > & GetDetailsRef ()
 Direct access for the internal details array. More...
 
FFingerprintGetFingerprintRef ()
 Get the internal fingerprint of the subjective. More...
 
struct FBeltSlotGetSlotPtr ()
 Get the current belt slot of the subjective (if any). More...
 
void DoRegister ()
 
void DoUnregister ()
 

Protected Attributes

TWeakObjectPtr< UBeltBelt = nullptr
 A weak reference to a current subjective's belt (if any). More...
 
int32 SlotIndex = FBeltSlot::InvalidIndex
 The index of the belt slot, this subject currently resides in. More...
 
FSubjectHandle Handle
 The subject handle which points to a global subjects registry. More...
 

Friends

struct FFingerprint
 
struct FBeltSlot
 
struct FBeltSlotCache
 
class UDetail
 
class UBelt
 
class UMechanism
 
class UMachine
 
class UApparatusFunctionLibrary
 

Detailed Description

An interface for all sorts of subjects.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
InvalidSlotIndex 

Invalid belt slot index.

Member Function Documentation

◆ AddDetail() [1/2]

template<class D >
D* ISubjective::AddDetail ( const bool  bReuseDisabled = false)
inline

Add a new active detail or reuse an inactive one.

Templated version.

Template Parameters
DA class of detail to add.
Parameters
bReuseDisabledShould disabled details be reused instead of adding a new one?
Returns
The newly added detail.

◆ AddDetail() [2/2]

UDetail * ISubjective::AddDetail ( const TSubclassOf< UDetail DetailClass,
const bool  bReuseDisabled = false 
)
inline

Add a new active detail or reuse an inactive one.

Parameters
DetailClassA class of detail to add.
bReuseDisabledShould disabled details be reused instead of adding a new one?
Returns
The newly added detail.

◆ CalcHash()

virtual uint32 ISubjective::CalcHash ( ) const
inlinevirtual

Calculate the hash of the subjective.

◆ DisableDetail() [1/2]

template<class D >
EApparatusStatus ISubjective::DisableDetail ( const bool  bDisableMultiple = false)
inline

Disable detail(s) by class.

Templated version.

Details can't be removed from subjectives. They can only be disabled.

◆ DisableDetail() [2/2]

EApparatusStatus ISubjective::DisableDetail ( const TSubclassOf< UDetail DetailClass,
const bool  bDisableMultiple = false 
)
inline

Disable detail(s) by class.

Details can't be removed from subjectives. They can only be disabled.

Parameters
DetailClassA class of detail(s) to disable.
bDisableMultipleShould all matching details be disabled instead of first one?
Returns
The status of the operation.

◆ DoRegister()

void ISubjective::DoRegister ( )
inlineprotected

◆ DoUnregister()

void ISubjective::DoUnregister ( )
inlineprotected

◆ EnableDetail() [1/2]

template<class D >
D* ISubjective::EnableDetail ( )
inline

Enable a detail of a certain type.

Templated version.

Adds the detail if there is none of the class already, or reuses an inactive one, enabling it.

Template Parameters
DA class of detail to enable.
Returns
The enabled detail.

◆ EnableDetail() [2/2]

UDetail * ISubjective::EnableDetail ( const TSubclassOf< UDetail DetailClass)
inline

Enable a detail of a certain type.

Adds the detail if there is none of the class already, or reuses an inactive one, enabling it.

Parameters
DetailClassA class of detail to enable.
Returns
The enabled detail.

◆ FindDetail() [1/2]

template<class D >
D* ISubjective::FindDetail ( const bool  bIncludeDisabled = false) const
inline

Find a detail by its class.

Templated version.

Supports searching by a base class.

Template Parameters
DThe class of the detail to search for.
Parameters
bIncludeDisabledShould disabled details be included?
Returns
A detail of the specified class if found, nullptr otherwise.

◆ FindDetail() [2/2]

UDetail * ISubjective::FindDetail ( TSubclassOf< UDetail DetailClass,
const bool  bIncludeDisabled = false 
) const
inline

Find a detail by its class.

Supports searching by a base class.

Parameters
DetailClassThe class of the detail to search for.
bIncludeDisabledShould disabled details be included?
Returns
A detail of the specified class if found, nullptr otherwise.

◆ FindDetails()

void ISubjective::FindDetails ( TSubclassOf< UDetail DetailClass,
TArray< UDetail * > &  OutDetails,
const bool  bIncludeDisabled = false 
) const
inline

Find the details by their class.

Supports searching by a base class.

◆ GetActor()

virtual class AActor* ISubjective::GetActor ( ) const
inlinevirtual

Get an actor corresponding to the subjective (if any).

Reimplemented in USubjectiveActorComponent, and ASubjectiveActor.

◆ GetBelt()

UBelt* ISubjective::GetBelt ( ) const
inlineprotected

Get the active belt of the subjective (if any).

◆ GetDetail() [1/2]

template<class D >
D* ISubjective::GetDetail ( const bool  bIncludeDisabled = false) const
inline

Get a detail by its class.

Templated version.

Asserts success. Supports searching by a base class.

Template Parameters
DThe type of the detail to get.
Parameters
bIncludeDisabledShould disabled details be included?
Returns
A detail of the specified type.

◆ GetDetail() [2/2]

UDetail* ISubjective::GetDetail ( TSubclassOf< UDetail DetailClass,
const bool  bIncludeDisabled = false 
) const
inline

Get a detail by its class.

Asserts success. Supports searching by a base class.

Parameters
DetailClassThe class of the detail to search for.
bIncludeDisabledShould disabled details be considered?
Returns
A detail of the specified class.

◆ GetDetails() [1/2]

void ISubjective::GetDetails ( const bool  bIncludeDisabled,
TArray< UDetail * > &  OutDetails 
) const
inline

Get the details of the subjective.

Parameters
bIncludeDisabledShould disabled details be included?
OutDetailsAn array to store the details in.

◆ GetDetails() [2/2]

void ISubjective::GetDetails ( TArray< UDetail * > &  OutDetails) const
inline

Get all the enabled details of the subjective.

Parameters
OutDetailsAn array to store the details in.

◆ GetDetailsRef() [1/2]

virtual TArray<UDetail*>& ISubjective::GetDetailsRef ( )
inlineprotectedvirtual

Direct access for the internal details array.

Reimplemented in USubjectiveUserWidget, USubjectiveActorComponent, and ASubjectiveActor.

◆ GetDetailsRef() [2/2]

virtual const TArray<UDetail*>& ISubjective::GetDetailsRef ( ) const
inlinevirtual

Direct access for the internal details array.

Constant version.

Reimplemented in USubjectiveUserWidget, USubjectiveActorComponent, and ASubjectiveActor.

◆ GetFingerprint()

const FFingerprint& ISubjective::GetFingerprint ( ) const
inline

Get the active fingerprint of the subjective.

Constant version.

◆ GetFingerprintRef()

FFingerprint& ISubjective::GetFingerprintRef ( )
inlineprotected

Get the internal fingerprint of the subjective.

◆ GetHandle() [1/2]

FSubjectHandle ISubjective::GetHandle ( )
inline

Get the subject handle of this subjective.

◆ GetHandle() [2/2]

FConstSubjectHandle ISubjective::GetHandle ( ) const
inline

Get the subject handle of this subjective.

Constant version.

◆ GetMechanism()

UMechanism * ISubjective::GetMechanism ( ) const
inline

Get the mechanism this subjective is currently part of (if registered).

◆ GetPreferredBelt()

virtual UBelt* ISubjective::GetPreferredBelt ( ) const
inlinevirtual

Get the preferred belt of the subjective (if any).

Reimplemented in USubjectiveUserWidget, USubjectiveActorComponent, and ASubjectiveActor.

◆ GetSlot()

const struct FBeltSlot * ISubjective::GetSlot ( ) const
inline

Get the current belt slot of the subjective (if any).

Constant version.

Returns
The active belt slot of the subject or nullptr, if the subject is not (yet) part of any belt.

◆ GetSlotIndex()

int32 ISubjective::GetSlotIndex ( ) const
inline

Get the current slot index of the subjective.

◆ GetSlotPtr()

struct FBeltSlot * ISubjective::GetSlotPtr ( )
inlineprotected

Get the current belt slot of the subjective (if any).

Returns
The active belt slot of the subject or nullptr, if the subject is not (yet) part of any belt.

◆ GetTrait() [1/3]

template<typename T >
T ISubjective::GetTrait ( ) const
inline

Get a copy of a trait from a subjective by its type.

If the trait is missing within the subject, the output data is unchanged and EApparatusStatus::NotFound is returned.

Template Parameters
TThe type of the trait to get.
Parameters
OutTraitThe trait receiver.
bTraitDataInitializedIs the OutTrait actually initialized?
Returns
The copy of the trait.

◆ GetTrait() [2/3]

template<typename T >
EApparatusStatus ISubjective::GetTrait ( T &  OutTrait,
const bool  bTraitDataInitialized = true 
) const
inline

Get a trait from a subjective by its type.

Templated version.

If the trait is missing within the subject, the output data is unchanged and EApparatusStatus::NotFound is returned.

Template Parameters
TThe type of the trait to get.
Parameters
OutTraitThe trait receiver.
bTraitDataInitializedIs the OutTrait actually initialized?
Returns
The status of the operation.

◆ GetTrait() [3/3]

EApparatusStatus ISubjective::GetTrait ( UScriptStruct *const  TraitType,
void *const  OutTraitData,
const bool  bTraitDataInitialized = true 
) const
inline

Get a trait from a subjective by its type.

If the trait is missing within the subject, the behavior is undefined an assertion may be raised.

Parameters
TraitTypeThe type of the trait to get.
OutTraitDataThe trait data receiver.
bTraitDataInitializedIs the OutTraitData buffer actually initialized?
Returns
The status of the operation.

◆ GetTraitRecordsRef() [1/2]

virtual TArray<FTraitRecord>& ISubjective::GetTraitRecordsRef ( )
inlineprotectedvirtual

Direct access for the internal traits array.

Reimplemented in USubjectiveUserWidget, USubjectiveActorComponent, and ASubjectiveActor.

◆ GetTraitRecordsRef() [2/2]

virtual const TArray<FTraitRecord>& ISubjective::GetTraitRecordsRef ( ) const
inlinevirtual

Direct access for the internal traits array.

Constant version.

Reimplemented in USubjectiveUserWidget, USubjectiveActorComponent, and ASubjectiveActor.

◆ HandleDespawned()

virtual void ISubjective::HandleDespawned ( )
inlinevirtual

Called when the subject handle is despawned.

Reimplemented in USubjectiveUserWidget, USubjectiveActorComponent, and ASubjectiveActor.

◆ HasDetail() [1/2]

template<class T >
bool ISubjective::HasDetail ( const bool  bIncludeDisabled = false) const
inline

Check if there is a detail of a specific class in the subjective.

Templated version.

Supports examining by a base class.

Template Parameters
TThe class of the detail to test for.
Parameters
bIncludeDisabledShould disabled details be considered?
Returns
The state of examination.

◆ HasDetail() [2/2]

bool ISubjective::HasDetail ( TSubclassOf< UDetail DetailClass,
const bool  bIncludeDisabled = false 
) const
inline

Check if there is a detail of a specific class in the subjective.

Supports examining by a base class.

Parameters
DetailClassThe class of the detail to test for.
bIncludeDisabledShould disabled details be considered?
Returns
The state of examination.

◆ HasTrait() [1/2]

template<typename T >
bool ISubjective::HasTrait ( ) const
inline

Check if there is a trait of a specific type in the subjective.

Templated version.

◆ HasTrait() [2/2]

bool ISubjective::HasTrait ( UScriptStruct *const  TraitType) const
inline

Check if the subjective has a certain trait.

◆ IsBooted()

bool ISubjective::IsBooted ( ) const
inline

Check if the subject is booted.

The subject must be booted (initialized) by the booting mechanics prior to being processed by the ticking mechanics.

◆ IsRegistered()

bool ISubjective::IsRegistered ( ) const
inline

Check if the subjective is registered within the machine.

◆ MarkBooted()

void ISubjective::MarkBooted ( )
inlineprotected

Set the subjective as booted.

◆ Matches() [1/3]

bool ISubjective::Matches ( const FDetailmark InDetailmark) const
inline

Check if the subjective matches a supplied detailmark as a filter.

◆ Matches() [2/3]

bool ISubjective::Matches ( const FFilter InFilter) const
inline

Check if the subjective matches a supplied filter.

◆ Matches() [3/3]

bool ISubjective::Matches ( const FTraitmark InTraitmark) const
inline

Check if the subjective matches a supplied traitmark as a filter.

◆ ObtainTrait() [1/3]

template<typename T >
T ISubjective::ObtainTrait ( )
inline

Get a copy of an obtained trait from a subjective.

If the trait is not currently within the subjective, it gets created anew and the default value gets copied to the receiver.

Template Parameters
TThe type of the trait to obtain.
Returns
The copy of the obtained trait.

◆ ObtainTrait() [2/3]

template<typename T >
EApparatusStatus ISubjective::ObtainTrait ( T &  OutTrait,
const bool  bTraitDataInitialized = true 
)
inline

Obtain a trait from a subjective.

Templated version.

If the trait is not currently within the subjective, it gets created anew and the default value gets copied to the receiver.

Template Parameters
TThe type of the trait to obtain.
Parameters
OutTraitThe trait receiver.
bTraitDataInitializedIs the OutTrait actually initialized?
Returns
The status of the operation.

◆ ObtainTrait() [3/3]

EApparatusStatus ISubjective::ObtainTrait ( UScriptStruct *  TraitType,
void *const  OutTraitData,
const bool  bTraitDataInitialized = true 
)
inline

Obtain a trait from a subjective by its type.

If the trait is missing within the subject, the output data is unchanged and EApparatusStatus::NotFound is returned.

Parameters
TraitTypeThe type of the trait to obtain.
OutTraitDataThe trait data receiver.
bTraitDataInitializedIs the TraitData buffer actually initialized?
Returns
The status of the operation.

◆ ReceiveHandleDespawned()

void ISubjective::ReceiveHandleDespawned ( )

Called when the subject handle is despawned.

◆ RemoveTrait() [1/2]

template<typename T >
EApparatusStatus ISubjective::RemoveTrait ( )
inline

Remove a trait from the subjective.

Templated version.

If there is no such trait in the subjective, nothing is performed and EApparatusStatus::Noop is returned.

Template Parameters
TThe type of the trait to remove.
Returns
The status of the operation.

◆ RemoveTrait() [2/2]

EApparatusStatus ISubjective::RemoveTrait ( UScriptStruct *const  TraitType)
inline

Remove a trait from the subjective.

If there is no such trait in the subjective, nothing is performed and EApparatusStatus::Noop is returned.

Parameters
TraitTypeThe type of the trait to remove.
Returns
The status of the operation.

◆ SetTrait() [1/2]

template<typename T >
EApparatusStatus ISubjective::SetTrait ( const T &  Trait)
inline

Set a trait of the subjective.

Templated version.

If the trait is not currently within the subjective, it gets created anew and set accordingly.

Template Parameters
TA type of the trait to add.
Parameters
TraitA trait to initialize with.
Returns
The status of the operation.

◆ SetTrait() [2/2]

EApparatusStatus ISubjective::SetTrait ( UScriptStruct *  TraitType,
const void *const  TraitData 
)
inline

Set a trait of the subjective by its type.

If the trait is not currently within the subjective, it gets created anew and set accordingly

Parameters
TraitTypeThe type of the trait to add.
TraitDataThe trait data to initialize with.
Returns
The status of the operation.

◆ TakeBeltSlot() [1/2]

void ISubjective::TakeBeltSlot ( const int32  InSlotIndex)
inlineprotected

Change the current slot of the subjective, while preserving the belt.

This is a simple internal fields setter with minimal logic.

Parameters
InSlotIndexThe slot index to set.

◆ TakeBeltSlot() [2/2]

void ISubjective::TakeBeltSlot ( UBelt *const  InBelt,
const int32  InSlotIndex = FBeltSlot::InvalidIndex 
)
inlineprotected

Set or reset the current belt slot of the subjective.

This is a simple internal fields setter with minimal logic.

Parameters
InBeltThe belt to set.
InSlotIndexThe slot index to set.

Friends And Related Function Documentation

◆ FBeltSlot

friend struct FBeltSlot
friend

◆ FBeltSlotCache

friend struct FBeltSlotCache
friend

◆ FFingerprint

friend struct FFingerprint
friend

◆ UApparatusFunctionLibrary

friend class UApparatusFunctionLibrary
friend

◆ UBelt

friend class UBelt
friend

◆ UDetail

friend class UDetail
friend

◆ UMachine

friend class UMachine
friend

◆ UMechanism

friend class UMechanism
friend

Member Data Documentation

◆ Belt

TWeakObjectPtr<UBelt> ISubjective::Belt = nullptr
protected

A weak reference to a current subjective's belt (if any).

◆ Handle

FSubjectHandle ISubjective::Handle
protected

The subject handle which points to a global subjects registry.

◆ SlotIndex

int32 ISubjective::SlotIndex = FBeltSlot::InvalidIndex
protected

The index of the belt slot, this subject currently resides in.


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