23 #include "CoreMinimal.h"
24 #include "UObject/NoExportTypes.h"
25 #include "UObject/WeakInterfacePtr.h"
27 #include "BeltSlotCache.h"
28 #include "Fingerprint.h"
31 #include "BeltSlot.generated.h"
38 USTRUCT(BlueprintType)
48 static const int32 InvalidIndex = -1;
58 mutable TWeakInterfacePtr<class ISubjective> Subjective =
nullptr;
63 UPROPERTY(Meta = (AllowPrivateAccess =
"true"))
69 mutable int32 DetailsCount = 0;
74 mutable int32 Iteration = 0;
79 mutable int32 IterationsCount = 0;
84 TWeakObjectPtr<class
UBelt> Owner;
89 mutable int32 Index = InvalidIndex;
96 FORCEINLINE class
UBelt* GetOwner()
const {
return Owner.Get(); }
108 FORCEINLINE int32
GetIndex()
const {
return Index; }
120 TScriptInterface<class ISubjective> GetSubjective()
const;
125 void SetSubjective(TScriptInterface<class ISubjective> InSubject);
130 void ClearDetails()
const;
171 if (DetailIndex >= DetailsCount)
174 return Details[DetailIndex].GetDetailsCount() > 0;
180 UDetail* GetDetail(
const int32 DetailIndex)
const;
185 UDetail* GetDetail(
const TSubclassOf<UDetail> DetailType)
const;
192 return GetDetail(DetailIndex);
213 bool IsValid()
const;
223 FORCEINLINE
operator bool()
const {
return IsValid(); }
235 return Owner != slot.Owner || Index != slot.Index;
243 return Owner == slot.Owner && Index == slot.Index;
251 checkf(Owner == Slot.Owner,
252 TEXT(
"Move-copying slots from different belts is not supported."));
253 checkf(DetailsCount == Slot.DetailsCount,
254 TEXT(
"Move-copying slots of different details counts is not supported."));
256 check(Slot.Index != -1);
258 if (Index == Slot.Index)
return *
this;
260 for (int32 i = 0; i < Slot.DetailsCount; i++)
262 Details[i] = Slot.Details[i];
265 Subjective = Slot.Subjective;
266 IterationsCount = Slot.IterationsCount;
284 const int32 TypeIndex = Filter.
IndexOf(DetailType);
285 checkf(TypeIndex >= 0, TEXT(
"Invalid index for type: %s"),
286 *DetailType->GetName());
292 if (Subjective.IsValid())
294 return Subjective.ToScriptInterface();
302 for (int32 i = 0; i < DetailsCount; i++)
312 if (Subjective == TWeakInterfacePtr<ISubjective>(*InSubjective))
318 Subjective = InSubjective;
The conveyor belt consisting of subjects.
Definition: Belt.h:60
void FetchDetails()
Fetch all of the current active details in this belt.
Definition: Belt.cpp:267
friend struct FBeltSlot
Definition: Belt.h:208
bool IsBuffering() const
Is this a special belt, used for buffering other belts?
Definition: Belt.h:101
const FFilter & GetFilter() const
The active filter of the belt.
Definition: Belt.h:111
The base subject detail (component) class.
Definition: Detail.h:35
Definition: SubjectiveActorComponent.h:39
A detail caching for subjects used in the belts' slots.
Definition: BeltSlotCache.h:34
The belt slot, containing the cached details.
Definition: BeltSlot.h:40
bool FetchDetails(const TArray< class UDetail * > &Details)
Fetch the details from the list of details supplied.
bool IsPresent(const int32 DetailIndex)
Does detail at specified index exist?
Definition: BeltSlot.h:167
UDetail * GetDetail(const int32 DetailIndex) const
Get the detail by its index.
Definition: BeltSlot.cpp:389
int32 GetIteration() const
The current iteration of the slot.
Definition: BeltSlot.h:115
TScriptInterface< class ISubjective > GetSubjective() const
Get the subjective of the slot.
Definition: BeltSlot.h:290
FBeltSlot(class UBelt *o, int32 i)
The main slot constructor.
Definition: BeltSlot.h:140
int32 GetIndex() const
Get the index of the slot in the belt.
Definition: BeltSlot.h:108
FBeltSlot & operator=(const FBeltSlot &Slot)
Assignment operator.
Definition: BeltSlot.h:249
void ClearDetails() const
Clear all of the cached details in the slot.
Definition: BeltSlot.h:300
UDetail * operator[](const int32 DetailIndex)
Get the detail by its index.
Definition: BeltSlot.h:190
const FFilter & GetFilter() const
The active filter of the slot, which is the same as its owning belt's.
Definition: Belt.h:570
void SetSubjective(TScriptInterface< class ISubjective > InSubject)
Set the subjective of the slot.
Definition: BeltSlot.h:310
FBeltSlot()
The default slot constructor.
Definition: BeltSlot.h:135
~FBeltSlot()
Deinitialize the belt slot.
Definition: BeltSlot.h:278
bool operator==(const FBeltSlot &slot) const
Compare two belt slots for equality.
Definition: BeltSlot.h:241
bool operator!=(const FBeltSlot &slot) const
Compare two belt slots for inequality.
Definition: BeltSlot.h:233
The details filter specification.
Definition: Filter.h:44
int32 IndexOf(const TSubclassOf< class UDetail > DetailType) const
Get the index of a specific detail type.
Definition: Filter.h:179