Apparatus Version 1.0.0
ECS-like data-driven workflow for Unreal Engine.
SubjectiveActorComponent.h
1 /*
2  * ░▒▓ APPARATUS ▓▒░
3  *
4  * File: SubjectiveUserWidget.h
5  * Created: Friday, 23rd October 2020 7:00:48 pm
6  * Author: Vladislav Dmitrievich Turbanov (vladislav@turbanov.ru)
7  * ───────────────────────────────────────────────────────────────────
8  * Last Modified: Saturday, 3rd April 2021 12:19:22 pm
9  * Modified By: Vladislav Dmitrievich Turbanov (vladislav@turbanov.ru)
10  * ───────────────────────────────────────────────────────────────────
11  *
12  * The Apparatus source code is for your internal usage only.
13  * Redistribution of this file is strictly prohibited.
14  *
15  * Community forums: https://talk.turbanov.ru
16  *
17  * Copyright 2020 - 2021, SP Vladislav Dmitrievich Turbanov
18  * Made in Russia, Moscow City, Chekhov City
19  */
20 
21 #pragma once
22 
23 #include "Components/ActorComponent.h"
24 #include "CoreMinimal.h"
25 #include "Engine/MemberReference.h"
26 
27 #include "Belt.h"
28 #include "Detail.h"
29 #include "Fingerprint.h"
30 #include "Filter.h"
31 #include "Subjective.h"
32 
33 #include "SubjectiveActorComponent.generated.h"
34 
35 UCLASS(ClassGroup = "Apparatus", Meta = (BlueprintSpawnableComponent))
36 class APPARATUSRUNTIME_API USubjectiveActorComponent final
37  : public UActorComponent,
38  public ISubjective
39 {
40  GENERATED_BODY()
41 
42 
45  UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category = Subject,
46  Meta = (AllowPrivateAccess = "true"))
47  mutable FFingerprint Fingerprint;
48 
52  UPROPERTY(Transient)
53  class UBelt* Belt = nullptr;
54 
58  int32 SlotIndex = InvalidSlotIndex;
59 
63  UPROPERTY(EditAnywhere, Category = Subject,
64  Meta = (AllowPrivateAccess = "true"))
65  class UBelt* PreferredBelt = nullptr;
66 
67  friend class FSubjectDetails;
68 
72  UPROPERTY(EditAnywhere, Instanced, Category = Details,
73  Meta = (AllowPrivateAccess = "true"))
74  TArray<UDetail*> Details;
75 
76  public:
77 
78  FORCEINLINE struct FBeltSlot* GetSlot() const override
79  {
80  if (Belt == nullptr)
81  return nullptr;
82  if (SlotIndex == -1)
83  return nullptr;
84  return &(*Belt)[SlotIndex];
85  }
86 
87  // Sets default values for this component's properties
89 
90  protected:
91  virtual void BeginPlay() override;
92 
93  virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
94 
95  FORCEINLINE void TakeBeltSlot(UBelt* InBelt, int32 InSlotIndex) override
96  {
97  if (InBelt == nullptr)
98  {
99  Belt = nullptr;
100  SlotIndex = -1;
101  }
102  else
103  {
104  Belt = InBelt;
105  SlotIndex = InSlotIndex;
106  }
107  }
108 
109  FORCEINLINE TArray<UDetail*>& GetDetailsRef() override
110  {
111  return Details;
112  }
113 
114  FORCEINLINE FFingerprint& GetFingerprint() override
115  {
116  return Fingerprint;
117  }
118 
119  public:
120 
121  FORCEINLINE const TArray<UDetail*>& GetDetailsRef() const override
122  {
123  return Details;
124  }
125 
126  FORCEINLINE const FFingerprint& GetFingerprint() const override
127  {
128  return Fingerprint;
129  }
130 
131  FORCEINLINE class UBelt* GetPreferredBelt() const override
132  {
133  return PreferredBelt;
134  }
135 }; // class USubjectiveActorComponent
136 
137 FORCEINLINE TScriptInterface<class ISubjective> UDetail::GetOwner() const
138 {
139  return TScriptInterface<class ISubjective>(GetOuter());
140 }
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
TScriptInterface< class ISubjective > GetOwner() const
The owning subjective of the detail.
Definition: SubjectiveActorComponent.h:137
Definition: SubjectiveActorComponent.h:39
FFingerprint & GetFingerprint() override
Get the internal fingerprint of the subjective.
Definition: SubjectiveActorComponent.h:114
const TArray< UDetail * > & GetDetailsRef() const override
Direct access for the internal details array.
Definition: SubjectiveActorComponent.h:121
TArray< UDetail * > & GetDetailsRef() override
Direct access for the internal details array.
Definition: SubjectiveActorComponent.h:109
const FFingerprint & GetFingerprint() const override
Get the active fingerprint of the subjective.
Definition: SubjectiveActorComponent.h:126
void TakeBeltSlot(UBelt *InBelt, int32 InSlotIndex) override
Set the current belt slot of the subjective (if any).
Definition: SubjectiveActorComponent.h:95
class UBelt * GetPreferredBelt() const override
Get the preferred belt of the subjective (if any).
Definition: SubjectiveActorComponent.h:131
The belt slot, containing the cached details.
Definition: BeltSlot.h:40
The details fingerprint.
Definition: Fingerprint.h:117