23 #include "CoreMinimal.h"
24 #include "UObject/Interface.h"
28 #include "Fingerprint.h"
30 #include "Subjective.generated.h"
32 UINTERFACE(MinimalAPI, BlueprintType)
52 static TArray<
UDetail*> EmptyDetails;
67 FORCEINLINE virtual
void TakeBeltSlot(class
UBelt* InBelt, int32 InSlotIndex)
120 return GetFingerprint().Matches(Filter);
126 void GetDetails(
const bool bIncludeDisabled,
127 TArray<UDetail*>& OutDetails)
const;
133 FindDetail(TSubclassOf<UDetail> DetailType,
134 const bool bIncludeDisabled =
false)
const;
140 FindDetails(TSubclassOf<UDetail> DetailType,
141 TArray<UDetail*>& OutDetails,
142 const bool bIncludeDisabled =
false)
const;
149 HasDetail(TSubclassOf<UDetail> DetailType,
150 const bool bIncludeDisabled =
false)
const;
165 EnableDetail(TSubclassOf<UDetail> DetailType);
171 AddDetail(TSubclassOf<UDetail> DetailType,
172 const bool bReuseInactive =
false);
179 bool DisableDetail(TSubclassOf<UDetail> DetailType,
const bool bDisableMultiple =
false);
197 return GetFingerprint().IsBooted();
205 return (uint32)((uint64)
this % (uint64)TNumericLimits<uint32>::Max());
209 FORCEINLINE uint32 GetTypeHash(
const TWeakInterfacePtr<ISubjective>& Subjective)
211 return Subjective->GetHash();
220 TArray<UDetail*>& OutDetails)
const
223 if (bIncludeDisabled)
231 if (Detail ==
nullptr)
233 if (!Detail->IsEnabled())
236 OutDetails.Add(Detail);
242 const bool bIncludeDisabled)
const
251 if (!bIncludeDisabled)
258 if (UNLIKELY(Type == UDetail::StaticClass()))
277 if (Detail->IsA(Type))
287 const bool bIncludeDisabled)
const
293 if (UNLIKELY(Type == UDetail::StaticClass()))
299 if (!bIncludeDisabled && !Detail->IsEnabled())
310 if (!bIncludeDisabled && !Detail->IsEnabled())
312 if (Detail->IsA(Type))
322 TArray<UDetail*>& DetailsOut,
323 const bool bIncludeDisabled)
const
332 if (UNLIKELY(DetailType == UDetail::StaticClass()))
334 if (UNLIKELY(bIncludeDisabled))
336 DetailsOut.Reserve(Details.Num());
337 for (
UDetail* Detail : Details)
341 DetailsOut.Add(Detail);
346 for (
UDetail* Detail : Details)
350 if (!Detail->IsEnabled())
352 DetailsOut.Add(Detail);
358 for (
UDetail* Detail : Details)
362 if (!bIncludeDisabled && !Detail->IsEnabled())
364 if (Detail->IsA(DetailType))
366 DetailsOut.Add(Detail);
373 const bool bDisableMultiple)
375 checkf(DetailType !=
nullptr,
376 TEXT(
"The detail type must be provided to be disabled on %s"),
377 *this->_getUObject()->GetName());
390 if (!Detail->IsEnabled())
392 if (Detail->IsA(DetailType))
397 Detail->SetEnabled(
false);
398 if (!bDisableMultiple)
An interface for all sorts of subjects.
Definition: Subjective.h:42
virtual class UBelt * GetPreferredBelt() const
Get the preferred belt of the subjective (if any).
Definition: Subjective.h:155
virtual uint32 GetHash() const
Get the hash of the subjective.
Definition: Subjective.h:203
virtual const TArray< UDetail * > & GetDetailsRef() const
Direct access for the internal details array.
Definition: Subjective.h:84
virtual TArray< UDetail * > & GetDetailsRef()
Direct access for the internal details array.
Definition: Subjective.h:75
bool HasDetail(TSubclassOf< UDetail > DetailType, const bool bIncludeDisabled=false) const
Check if there is a detail of specific class in the subjective.
Definition: Subjective.h:241
void FindDetails(TSubclassOf< UDetail > DetailType, TArray< UDetail * > &OutDetails, const bool bIncludeDisabled=false) const
Find the details by their type.
Definition: Subjective.h:321
void GetDetails(const bool bIncludeDisabled, TArray< UDetail * > &OutDetails) const
Get the details of the subjective.
Definition: Subjective.h:219
virtual FFingerprint & GetFingerprint()
Get the internal fingerprint of the subjective.
Definition: Subjective.h:93
void MarkBooted()
Set the subjective as booted.
Definition: Subjective.h:214
virtual const FFingerprint & GetFingerprint() const
Get the active fingerprint of the subjective.
Definition: Subjective.h:110
UDetail * FindDetail(TSubclassOf< UDetail > DetailType, const bool bIncludeDisabled=false) const
Find the detail by a type.
Definition: Subjective.h:286
bool IsBooted() const
Check if the subject is booted.
Definition: Subjective.h:195
bool DisableDetail(TSubclassOf< UDetail > DetailType, const bool bDisableMultiple=false)
Disable a certain detail(s) by type.
Definition: Subjective.h:372
bool Matches(const FFilter &Filter) const
Check if the subjective matches a supplied filter.
Definition: Subjective.h:118
virtual struct FBeltSlot * GetSlot() const
Get the current belt slot of the subjective (if any).
Definition: Subjective.h:187
The main Apparatus function library.
Definition: ApparatusFunctionLibrary.h:45
The conveyor belt consisting of subjects.
Definition: Belt.h:60
The base subject detail (component) class.
Definition: Detail.h:35
The main Mechanism function library.
Definition: Mechanism.h:63
Definition: Subjective.h:34
The belt slot, containing the cached details.
Definition: BeltSlot.h:40
static const int32 InvalidIndex
Invalid belt index.
Definition: BeltSlot.h:48
The details filter specification.
Definition: Filter.h:44
The details fingerprint.
Definition: Fingerprint.h:117
void Reset()
Clear the fingerprint without any deallocations.
Definition: Fingerprint.h:756
static const struct FFingerprint ZERO
Definition: Fingerprint.h:768
bool SetBooted(bool bState=true)
Set the new active boot state.
Definition: Fingerprint.h:239