23 #include "CoreMinimal.h"
24 #include "UObject/Interface.h"
28 #include "Fingerprint.h"
29 #include "ApparatusRuntime.h"
31 #include "Mechanical.generated.h"
33 UINTERFACE(MinimalAPI, BlueprintType)
53 uint32 bInsideTick : 1;
58 uint32 bInsideSteadyTick : 1;
63 uint32 bInsidePresentationTick : 1;
73 int32 SteadyFrame = 0;
78 int32 ProcessedSteadyFrame = -1;
83 virtual
UBelt* GetBufferingBelt()
const
95 virtual void DoTick(
float NewTime,
97 float SteadyDeltaTime);
102 if (ProcessedSteadyFrame == -1)
104 return ProcessedSteadyFrame * SteadyDeltaTime;
107 virtual FORCEINLINE
float
109 const float SteadyDeltaTime)
const
111 if (!bInsidePresentationTick)
113 UE_LOG(LogApparatus, Error, TEXT(
"Steady Frame Ratio is only available during a presentation tick handling. "
114 "Are you using it within Steady ticking?"));
117 check(ProcessedSteadyFrame != -1);
118 const float ProcessedSteadyTime = ProcessedSteadyFrame * SteadyDeltaTime;
119 if (Time >= ProcessedSteadyTime + SteadyDeltaTime)
121 if (Time <= ProcessedSteadyTime)
123 return (Time - ProcessedSteadyTime) / SteadyDeltaTime;
126 virtual FORCEINLINE
float
128 const float SteadyDeltaTime)
const
130 if (!bInsidePresentationTick)
132 UE_LOG(LogApparatus, Error, TEXT(
"Steady Future Factor is only available during a presentation tick handling. "
133 "Are you using it within Steady ticking?"));
136 if (!FMath::IsFinite(PrevTime))
140 const float FutureSteadyTime = (ProcessedSteadyFrame + 1) * SteadyDeltaTime;
141 if (Time >= FutureSteadyTime)
143 if (Time <= PrevTime)
145 return (Time - PrevTime) / (FutureSteadyTime - PrevTime);
153 UFUNCTION(BlueprintCallable, BlueprintNativeEvent,
154 Meta = (DisplayName =
"Boot"),
155 Category =
"Apparatus|Mechanism")
161 UFUNCTION(BlueprintCallable, BlueprintNativeEvent,
162 Meta = (DisplayName = "Input Tick"),
163 Category = "Apparatus|Mechanism")
164 void ReceiveInputTick();
169 UFUNCTION(BlueprintCallable, BlueprintNativeEvent,
170 Meta = (DisplayName = "Steady Tick"),
171 Category = "Apparatus|Mechanism")
172 void ReceiveSteadyTick(
float DeltaSeconds);
181 UFUNCTION(BlueprintCallable, BlueprintNativeEvent,
182 Meta = (DisplayName = "Presentation Tick"),
183 Category = "Apparatus|Mechanism")
184 void ReceivePresentationTick(
float DeltaSeconds,
float FrameRatio,
float FutureFactor);
189 virtual FORCEINLINE
void Boot()
191 Execute_ReceiveBoot(this->_getUObject());
199 Execute_ReceiveInputTick(this->_getUObject());
207 Execute_ReceiveSteadyTick(this->_getUObject(), DeltaTime);
219 Execute_ReceivePresentationTick(this->_getUObject(), DeltaSeconds, FrameRatio, FutureFactor);
225 bInsideSteadyTick =
false;
226 bInsidePresentationTick =
false;
232 float SteadyDeltaTime)
239 const int32 NeededSteadyFrame = int32(NewTime / SteadyDeltaTime);
247 UE_LOG(LogApparatus, Fatal, TEXT(
"Steady frame count overflow detected. "
248 "Was your game session running for too long?"));
262 AActor* Actor = Cast<AActor>(
this);
265 Actor->AActor::Tick(DeltaTime);
A common interface for all mechanisms.
Definition: Mechanical.h:43
IMechanical()
Definition: Mechanical.h:222
int32 ProcessedSteadyFrame
The last, actually processed steady frame.
Definition: Mechanical.h:78
int32 SteadyFrame
The steady frame we are currently part of.
Definition: Mechanical.h:73
virtual void DoTick(float NewTime, float DeltaTime, float SteadyDeltaTime)
Perform a standard ticking routine.
Definition: Mechanical.h:230
virtual void InputTick()
Process a pre-steady input tick.
Definition: Mechanical.h:197
uint32 bInsidePresentationTick
Is this mechanism currently in the process of presentation ticking?
Definition: Mechanical.h:63
virtual void SteadyTick(float DeltaTime)
Process a fixed-rate steady tick.
Definition: Mechanical.h:205
float PrevTime
The game time of the previous tick.
Definition: Mechanical.h:68
virtual float DoCalcSteadyFutureFactor(const float Time, const float SteadyDeltaTime) const
Definition: Mechanical.h:127
uint32 bInsideSteadyTick
Is this mechanism currently in the process of steady ticking?
Definition: Mechanical.h:58
uint32 bInsideTick
Is this mechanism currently updating?
Definition: Mechanical.h:53
virtual void PresentationTick(float DeltaSeconds, float FrameRatio, float FutureFactor)
Process a past-steady presentation tick.
Definition: Mechanical.h:217
virtual float DoCalcSteadyFrameRatio(const float Time, const float SteadyDeltaTime) const
Definition: Mechanical.h:108
float DoGetProcessedSteadyTime(float SteadyDeltaTime) const
Definition: Mechanical.h:100
The conveyor belt consisting of subjects.
Definition: Belt.h:60
Definition: Mechanical.h:35
The main Mechanism function library.
Definition: Mechanism.h:63