Apparatus Version 1.0.0
ECS-like data-driven workflow for Unreal Engine.
SubjectiveActor.h
1 // Fill out your copyright notice in the Description page of Project Settings.
2 
3 #pragma once
4 
5 #include "CoreMinimal.h"
6 #include "GameFramework/Actor.h"
7 
8 #include "Belt.h"
9 #include "Detail.h"
10 #include "Fingerprint.h"
11 #include "Filter.h"
12 #include "Subjective.h"
13 
14 #include "SubjectiveActor.generated.h"
15 
16 UCLASS(ClassGroup = "Apparatus", Meta = (BlueprintSpawnableComponent))
17 class APPARATUSRUNTIME_API ASubjectiveActor : public AActor, public ISubjective
18 {
19  GENERATED_BODY()
20 
21 
24  UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category = Subject,
25  Meta = (AllowPrivateAccess = "true"))
26  mutable FFingerprint Fingerprint;
27 
31  UPROPERTY(Transient)
32  class UBelt* Belt = nullptr;
33 
37  int32 SlotIndex = InvalidSlotIndex;
38 
42  UPROPERTY(EditAnywhere, Category = Subject,
43  Meta = (AllowPrivateAccess = "true"))
44  class UBelt* PreferredBelt = nullptr;
45 
46  friend class FSubjectDetails;
47 
51  UPROPERTY(EditAnywhere, Instanced, Category = Details,
52  Meta = (AllowPrivateAccess = "true"))
53  TArray<UDetail*> Details;
54 
55 public:
56 
57  FORCEINLINE struct FBeltSlot* GetSlot() const override
58  {
59  if (Belt == nullptr)
60  return nullptr;
61  if (SlotIndex == -1)
62  return nullptr;
63  return &(*Belt)[SlotIndex];
64  }
65 
66  // Sets default values for this actor's properties
68 
69 protected:
70  // Called when the game starts or when spawned
71  virtual void BeginPlay() override;
72 
73 public:
74  // Called every frame
75  virtual void Tick(float DeltaTime) override;
76 
77  virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
78 
79  FORCEINLINE void TakeBeltSlot(UBelt* InBelt, int32 InSlotIndex) override
80  {
81  if (InBelt == nullptr)
82  {
83  Belt = nullptr;
84  SlotIndex = -1;
85  }
86  else
87  {
88  Belt = InBelt;
89  SlotIndex = InSlotIndex;
90  }
91  }
92 
93  FORCEINLINE TArray<UDetail*>& GetDetailsRef() override
94  {
95  return Details;
96  }
97 
98  FORCEINLINE FFingerprint& GetFingerprint() override
99  {
100  return Fingerprint;
101  }
102 
103  public:
104 
105  FORCEINLINE const TArray<UDetail*>& GetDetailsRef() const override
106  {
107  return Details;
108  }
109 
110  FORCEINLINE const FFingerprint& GetFingerprint() const override
111  {
112  return Fingerprint;
113  }
114 
115  FORCEINLINE class UBelt* GetPreferredBelt() const override
116  {
117  return PreferredBelt;
118  }
119 }; // class ASubjectiveActor
Definition: SubjectiveActor.h:18
void TakeBeltSlot(UBelt *InBelt, int32 InSlotIndex) override
Set the current belt slot of the subjective (if any).
Definition: SubjectiveActor.h:79
const TArray< UDetail * > & GetDetailsRef() const override
Direct access for the internal details array.
Definition: SubjectiveActor.h:105
class UBelt * GetPreferredBelt() const override
Get the preferred belt of the subjective (if any).
Definition: SubjectiveActor.h:115
TArray< UDetail * > & GetDetailsRef() override
Direct access for the internal details array.
Definition: SubjectiveActor.h:93
FFingerprint & GetFingerprint() override
Get the internal fingerprint of the subjective.
Definition: SubjectiveActor.h:98
const FFingerprint & GetFingerprint() const override
Get the active fingerprint of the subjective.
Definition: SubjectiveActor.h:110
An interface for all sorts of subjects.
Definition: Subjective.h:42
The conveyor belt consisting of subjects.
Definition: Belt.h:60
static const int32 InvalidSlotIndex
Is this a special buffering belt?
Definition: Belt.h:96
The base subject detail (component) class.
Definition: Detail.h:35
The belt slot, containing the cached details.
Definition: BeltSlot.h:40
The details fingerprint.
Definition: Fingerprint.h:117