From fef1217877e09eec282ad34aa58c2783a9a92445 Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Sat, 3 Jun 2023 14:37:14 -0400 Subject: [PATCH] Reorganize plugin files and start creating some state machine classes --- .../IFESystemInterface.cpp | 9 +++++ .../UnrealFightingEngine/IFESystemInterface.h | 33 +++++++++++++++++++ Source/UnrealFightingEngine/State/FEState.cpp | 5 +++ Source/UnrealFightingEngine/State/FEState.h | 17 ++++++++++ .../State/FEStateMachineComponent.cpp | 29 ++++++++++++++++ .../State/FEStateMachineComponent.h | 26 +++++++++++++++ .../UnrealFightingEngine.Build.cs | 2 +- .../UnrealFightingEngineBPLibrary.cpp | 2 +- .../UnrealFightingEngineBPLibrary.h | 0 ...ine.cpp => UnrealFightingEngineModule.cpp} | 2 +- ...gEngine.h => UnrealFightingEngineModule.h} | 0 11 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 Source/UnrealFightingEngine/IFESystemInterface.cpp create mode 100644 Source/UnrealFightingEngine/IFESystemInterface.h create mode 100644 Source/UnrealFightingEngine/State/FEState.cpp create mode 100644 Source/UnrealFightingEngine/State/FEState.h create mode 100644 Source/UnrealFightingEngine/State/FEStateMachineComponent.cpp create mode 100644 Source/UnrealFightingEngine/State/FEStateMachineComponent.h rename Source/UnrealFightingEngine/{Private => }/UnrealFightingEngineBPLibrary.cpp (89%) rename Source/UnrealFightingEngine/{Public => }/UnrealFightingEngineBPLibrary.h (100%) rename Source/UnrealFightingEngine/{Private/UnrealFightingEngine.cpp => UnrealFightingEngineModule.cpp} (93%) rename Source/UnrealFightingEngine/{Public/UnrealFightingEngine.h => UnrealFightingEngineModule.h} (100%) diff --git a/Source/UnrealFightingEngine/IFESystemInterface.cpp b/Source/UnrealFightingEngine/IFESystemInterface.cpp new file mode 100644 index 0000000..c715879 --- /dev/null +++ b/Source/UnrealFightingEngine/IFESystemInterface.cpp @@ -0,0 +1,9 @@ +// Project Sword & Gun Copyright Kevin Poretti + + +#include "IFESystemInterface.h" + +// Add default functionality here for any IIFESystemInterface functions that are not pure virtual. +void IIFESystemInterface::FixedTick(float OneFrame) +{ +} diff --git a/Source/UnrealFightingEngine/IFESystemInterface.h b/Source/UnrealFightingEngine/IFESystemInterface.h new file mode 100644 index 0000000..78573e7 --- /dev/null +++ b/Source/UnrealFightingEngine/IFESystemInterface.h @@ -0,0 +1,33 @@ +// Project Sword & Gun Copyright Kevin Poretti + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/Interface.h" +#include "IFESystemInterface.generated.h" + +// This class does not need to be modified. +UINTERFACE(MinimalAPI) +class UIFESystemInterface : public UInterface +{ + GENERATED_BODY() +}; + +/** + * This interface defines functions that need to be implemented for any objects that are "gameplay affecting". + * + * This ensures all gameplay effecting objects can be assumed to have certain properties that enable serialization, networking and + * some form of determinism. + */ +class UNREALFIGHTINGENGINE_API IIFESystemInterface +{ + GENERATED_BODY() + +public: + /** + * Function to be called at a fixed interval/frame rate rather than using Unreal's variable Tick function + * + * @param OneFrame the time that elapses during one fixed tick + */ + virtual void FixedTick(float OneFrame); +}; diff --git a/Source/UnrealFightingEngine/State/FEState.cpp b/Source/UnrealFightingEngine/State/FEState.cpp new file mode 100644 index 0000000..7e49f67 --- /dev/null +++ b/Source/UnrealFightingEngine/State/FEState.cpp @@ -0,0 +1,5 @@ +// Project Sword & Gun Copyright Kevin Poretti + + +#include "FEState.h" + diff --git a/Source/UnrealFightingEngine/State/FEState.h b/Source/UnrealFightingEngine/State/FEState.h new file mode 100644 index 0000000..8fd888f --- /dev/null +++ b/Source/UnrealFightingEngine/State/FEState.h @@ -0,0 +1,17 @@ +// Project Sword & Gun Copyright Kevin Poretti + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/NoExportTypes.h" +#include "FEState.generated.h" + +/** + * + */ +UCLASS() +class UNREALFIGHTINGENGINE_API UFEState : public UObject +{ + GENERATED_BODY() + +}; diff --git a/Source/UnrealFightingEngine/State/FEStateMachineComponent.cpp b/Source/UnrealFightingEngine/State/FEStateMachineComponent.cpp new file mode 100644 index 0000000..85bec85 --- /dev/null +++ b/Source/UnrealFightingEngine/State/FEStateMachineComponent.cpp @@ -0,0 +1,29 @@ +// Project Sword & Gun Copyright Kevin Poretti + + +#include "FEStateMachineComponent.h" + +// Sets default values for this component's properties +UFEStateMachineComponent::UFEStateMachineComponent() +{ + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features + // off to improve performance if you don't need them. + PrimaryComponentTick.bCanEverTick = false; + + // ... +} + + +// Called when the game starts +void UFEStateMachineComponent::BeginPlay() +{ + Super::BeginPlay(); + + // ... + +} + +void UFEStateMachineComponent::FixedTick(float OneFrame) +{ +} + diff --git a/Source/UnrealFightingEngine/State/FEStateMachineComponent.h b/Source/UnrealFightingEngine/State/FEStateMachineComponent.h new file mode 100644 index 0000000..d017375 --- /dev/null +++ b/Source/UnrealFightingEngine/State/FEStateMachineComponent.h @@ -0,0 +1,26 @@ +// Project Sword & Gun Copyright Kevin Poretti + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "UnrealFightingEngine/IFESystemInterface.h" +#include "FEStateMachineComponent.generated.h" + + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class UNREALFIGHTINGENGINE_API UFEStateMachineComponent : public UActorComponent, public IIFESystemInterface +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UFEStateMachineComponent(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +public: + virtual void FixedTick(float OneFrame) override; +}; diff --git a/Source/UnrealFightingEngine/UnrealFightingEngine.Build.cs b/Source/UnrealFightingEngine/UnrealFightingEngine.Build.cs index 5015cba..4cb47fa 100644 --- a/Source/UnrealFightingEngine/UnrealFightingEngine.Build.cs +++ b/Source/UnrealFightingEngine/UnrealFightingEngine.Build.cs @@ -10,7 +10,7 @@ public class UnrealFightingEngine : ModuleRules PublicIncludePaths.AddRange( new string[] { - // ... add public include paths required here ... + "UnrealFightingEngine" } ); diff --git a/Source/UnrealFightingEngine/Private/UnrealFightingEngineBPLibrary.cpp b/Source/UnrealFightingEngine/UnrealFightingEngineBPLibrary.cpp similarity index 89% rename from Source/UnrealFightingEngine/Private/UnrealFightingEngineBPLibrary.cpp rename to Source/UnrealFightingEngine/UnrealFightingEngineBPLibrary.cpp index cca6b9c..f924e4a 100644 --- a/Source/UnrealFightingEngine/Private/UnrealFightingEngineBPLibrary.cpp +++ b/Source/UnrealFightingEngine/UnrealFightingEngineBPLibrary.cpp @@ -1,7 +1,7 @@ // Copyright Epic Games, Inc. All Rights Reserved. #include "UnrealFightingEngineBPLibrary.h" -#include "UnrealFightingEngine.h" +#include "UnrealFightingEngineModule.h" UUnrealFightingEngineBPLibrary::UUnrealFightingEngineBPLibrary(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) diff --git a/Source/UnrealFightingEngine/Public/UnrealFightingEngineBPLibrary.h b/Source/UnrealFightingEngine/UnrealFightingEngineBPLibrary.h similarity index 100% rename from Source/UnrealFightingEngine/Public/UnrealFightingEngineBPLibrary.h rename to Source/UnrealFightingEngine/UnrealFightingEngineBPLibrary.h diff --git a/Source/UnrealFightingEngine/Private/UnrealFightingEngine.cpp b/Source/UnrealFightingEngine/UnrealFightingEngineModule.cpp similarity index 93% rename from Source/UnrealFightingEngine/Private/UnrealFightingEngine.cpp rename to Source/UnrealFightingEngine/UnrealFightingEngineModule.cpp index 86106a8..fc66106 100644 --- a/Source/UnrealFightingEngine/Private/UnrealFightingEngine.cpp +++ b/Source/UnrealFightingEngine/UnrealFightingEngineModule.cpp @@ -1,6 +1,6 @@ // Copyright Epic Games, Inc. All Rights Reserved. -#include "UnrealFightingEngine.h" +#include "UnrealFightingEngineModule.h" #define LOCTEXT_NAMESPACE "FUnrealFightingEngineModule" diff --git a/Source/UnrealFightingEngine/Public/UnrealFightingEngine.h b/Source/UnrealFightingEngine/UnrealFightingEngineModule.h similarity index 100% rename from Source/UnrealFightingEngine/Public/UnrealFightingEngine.h rename to Source/UnrealFightingEngine/UnrealFightingEngineModule.h