From 755ee3434334a2837ddd9a1742fdd68d71196946 Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Sat, 21 Oct 2023 18:51:04 -0400 Subject: [PATCH] Move fixed framerate logic from SNG to FF --- Content/BPML_StateMacros.uasset | Bin 118896 -> 118616 bytes .../GameplayFramework/FFGameState.cpp | 25 +++++++++++ .../GameplayFramework/FFGameState.h | 41 ++++++++++++++++++ .../State/FFStateMachineComponent.cpp | 15 ++----- .../State/FFStateMachineComponent.h | 19 +++++++- 5 files changed, 86 insertions(+), 14 deletions(-) create mode 100644 Source/UnrealFightingFramework/GameplayFramework/FFGameState.cpp create mode 100644 Source/UnrealFightingFramework/GameplayFramework/FFGameState.h diff --git a/Content/BPML_StateMacros.uasset b/Content/BPML_StateMacros.uasset index 092c1de36d56509c641b38d7f2593f76f95b5e3b..35fbad5e0ca0b19d98bc03daa46be187b3797785 100644 GIT binary patch delta 17134 zcmcgz33wDm_Mg%ONK8yZLP8)WK@t)|B;7MTeF!RjOdF066g)Uhgb;2J5)eE<0YMH0 zTPQ$5P>?8y$l-yUii*npcNe@CBBy^{iTkOj?8?6C>F&9DCQ-un_l2H*^{VQ<-#hA6 zbyK&p>G2g!7i>p03wOBVHHX7-2{|0s!u{gH%S_kwWQU_AJoHU)IF=SV9MI;NPdglo z;O`CiJ6d_X?~|97%37C_-6#7`82x5yDr03bHd>m3#9x*n}0;hqC2#O-`$5#7+q0y*My4kO2yz&<>M=csMTWzR}CLK zrlg{(d`Nj!xnmOh^gL~D)A>m;z)z?Op`M<$Mcdr68Qnzdcl~Em#~CwCH16NSbPpN7 zON=|Y+40S6Am0<=`KCJjC!Q6aF@SG&1Nok;mv5@WK{TFIFQb=lZUgwfgYnb`@;wFf z>sKVG$$(Ecfbai-Z$bn4stmrVktQYsPHEtP^BTbSEsXbYAfH$NVCN!?j|4L6PvZ@m zISAo<(1z~;gJudv6q#(pH_l<;zrbiDHxg*%vO~t7&lI{oK2sQ5zRupc^nXq5>=>Uh z_=v_Gjo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|Nep%y5o0T4Z6Pi0-bO$x>H~Dqx<-a5zy7PVeCu( z(>b4eYQujY4lVE5t;lf|5c~E>aDu5Nd#jVz={pUu%Pmlavsm+VIv}y9?~VoR=H1sG zY$)s5amKF0LZ7q`TXonsfTzs!GE5|;X7V~bUPu^abus?Ek!Py4tL(P5ALjJF;T-$kt`DR1U;T_ z)!+4m=+8QimIx|zf|xRS6Qrd`NS%Gdk5uZLV8E%75|jqmzBfbT$N&GKK|Q(p%+@; mriIfQ)J-t9XJnu?yaK3;!FhOw{! diff --git a/Source/UnrealFightingFramework/GameplayFramework/FFGameState.cpp b/Source/UnrealFightingFramework/GameplayFramework/FFGameState.cpp new file mode 100644 index 0000000..ebb0e9a --- /dev/null +++ b/Source/UnrealFightingFramework/GameplayFramework/FFGameState.cpp @@ -0,0 +1,25 @@ +// Project Sword & Gun Copyright Kevin Poretti + +#include "GameplayFramework/FFGameState.h" + +void AFFGameState::OnFixedTick(float OneTick) +{ +} + + +void AFFGameState::Tick(float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); + + // Run anything game logic related at a fixed tick rate + // TODO: Interpolate between prev and current game state if there is time left in accumulator + AccumulatedTime += DeltaSeconds; + while(AccumulatedTime > ONE_TICK) + { + OnFixedTick(ONE_TICK); + + AccumulatedTime -= ONE_TICK; + + CurrentTick++; + } +} diff --git a/Source/UnrealFightingFramework/GameplayFramework/FFGameState.h b/Source/UnrealFightingFramework/GameplayFramework/FFGameState.h new file mode 100644 index 0000000..7e89f24 --- /dev/null +++ b/Source/UnrealFightingFramework/GameplayFramework/FFGameState.h @@ -0,0 +1,41 @@ +// Project Sword & Gun Copyright Kevin Poretti + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/GameState.h" +#include "FFGameState.generated.h" + +constexpr float ONE_TICK = 0.0083333333; +constexpr int64 TICKS_PER_SECOND = 120; + +/** + * + */ +UCLASS() +class UNREALFIGHTINGFRAMEWORK_API AFFGameState : public AGameState +{ + GENERATED_BODY() + +public: + + UFUNCTION(BlueprintPure) + int64 GetCurrentTick() const { return CurrentTick; } + + virtual void OnFixedTick(float OneTick); + + // Begin AActor interface + virtual void Tick(float DeltaSeconds) override; + // End AActor interface +private: + /** + * Amount of time accumulated from ticks. When Tick is called the delta time since the + * last Tick will be added to this variable. + * + * Once enough time has accumulated to simulate at least one frame (defined by the value ONE_TICK) then the + * game logic will update/tick. ONE_TICK's worth of time will be subtracted from the this variable + */ + float AccumulatedTime = 0; + + int64 CurrentTick = 0; +}; diff --git a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp index b942bbf..679111c 100644 --- a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp +++ b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp @@ -4,9 +4,11 @@ // FF includes #include "FFState.h" +#include "GameplayFramework/FFGameState.h" #include "Input/FFPlayerController.h" #if !UE_BUILD_SHIPPING +class ASNGGameState; static int32 StateMachineDebug = 0; FAutoConsoleVariableRef CVARStateMachineDebug(TEXT("ff.StateMachine.ShowDebug"), StateMachineDebug, @@ -116,6 +118,7 @@ void UFFStateMachineComponent::GoToState(UFFState* NewState) CurrentState->Exit(GetCurrentStateContext()); CurrentState = NewState; TicksInState = 0; + TickStateWasEntered = GetWorld()->GetGameState()->GetCurrentTick(); CurrentSubStateLabel = NAME_None; CurrentState->Enter(GetCurrentStateContext()); } @@ -129,12 +132,6 @@ void UFFStateMachineComponent::GoToEntryState() } -int64 UFFStateMachineComponent::GetTicksInState() const -{ - return TicksInState; -} - - FName UFFStateMachineComponent::GetCurrentStateName() const { check(CurrentState) @@ -143,12 +140,6 @@ FName UFFStateMachineComponent::GetCurrentStateName() const } -FName UFFStateMachineComponent::GetCurrentSubStateLabel() const -{ - return CurrentSubStateLabel; -} - - void UFFStateMachineComponent::SetSubStateLabel(FName InSubStateLabel) { CurrentSubStateLabel = InSubStateLabel; diff --git a/Source/UnrealFightingFramework/State/FFStateMachineComponent.h b/Source/UnrealFightingFramework/State/FFStateMachineComponent.h index 38c990e..52b9c54 100644 --- a/Source/UnrealFightingFramework/State/FFStateMachineComponent.h +++ b/Source/UnrealFightingFramework/State/FFStateMachineComponent.h @@ -82,7 +82,15 @@ public: void GoToEntryState(); UFUNCTION(BlueprintPure) - FORCEINLINE int64 GetTicksInState() const; + FORCEINLINE int64 GetTicksInState() const { return TicksInState; } + + /** + * Returns the tick number which corresponds to when this state was entered into. + * + * The tick number represents the ticks that have elapsed since the game began. + */ + UFUNCTION(BlueprintPure) + FORCEINLINE int64 GetTickStateWasEntered() const { return TickStateWasEntered; } /** * Returns the name of the current state @@ -91,7 +99,7 @@ public: FORCEINLINE FName GetCurrentStateName() const; UFUNCTION(BlueprintPure) - FORCEINLINE FName GetCurrentSubStateLabel() const; + FORCEINLINE FName GetCurrentSubStateLabel() const { return CurrentSubStateLabel; } UFUNCTION(BlueprintCallable) void SetSubStateLabel(FName InSubStateLabel); @@ -129,6 +137,13 @@ protected: /** How many ticks have elapsed since the currently active state was entered */ int64 TicksInState; + /** + * The tick number which corresponds to when this state was entered into. + * + * The tick number represents the ticks that have elapsed since the game began. + */ + int64 TickStateWasEntered; + /** Current active state for this state machine */ UPROPERTY() UFFState* CurrentState;