diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.dll b/Project/Binaries/Win64/UnrealEditor-Gasa.dll index a0926e6..db39942 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.dll and b/Project/Binaries/Win64/UnrealEditor-Gasa.dll differ diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb index b319266..3e7d6be 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb and b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb differ diff --git a/Project/Source/Gasa/Characters/GasaCharacter.cpp b/Project/Source/Gasa/Characters/GasaCharacter.cpp index 8cd2c98..f02ddf6 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.cpp +++ b/Project/Source/Gasa/Characters/GasaCharacter.cpp @@ -43,11 +43,31 @@ AGasaCharacter::AGasaCharacter() { AbilitySystem = CreateDefaultSubobject("Ability System"); AbilitySystem->SetIsReplicated(true); + AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Minimal); Attributes = CreateDefaultSubobject("Attributes"); } } +#pragma region Pawn +void AGasaCharacter::PossessedBy(AController* NewController) +{ + Super::PossessedBy(NewController); + + if (bAutoAbilitySystem) + { + // TODO(Ed): Do we need to do this for enemies? + AbilitySystem->InitAbilityActorInfo(this, this); + } +} + +void AGasaCharacter::OnRep_PlayerState() +{ + Super::OnRep_PlayerState(); +} +#pragma endregion Pawn + +#pragma region Actor void AGasaCharacter::BeginPlay() { Super::BeginPlay(); @@ -96,3 +116,4 @@ void AGasaCharacter::Tick(float DeltaSeconds) break; } } +#pragma endregion Actor diff --git a/Project/Source/Gasa/Characters/GasaCharacter.h b/Project/Source/Gasa/Characters/GasaCharacter.h index 7e8a345..6a71200 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.h +++ b/Project/Source/Gasa/Characters/GasaCharacter.h @@ -4,6 +4,7 @@ #include "GameFramework/Character.h" #include "GasaCommon.h" +#include "Game/GasaPlayerState.h" #include "GasaCharacter.generated.h" @@ -57,10 +58,18 @@ public: AGasaCharacter(); + FORCEINLINE AGasaPlayerState* GetGasaPlayerState() { return GetPlayerState(); } + #pragma region IAbilitySystem FORCEINLINE UAttributeSet* GetAttributes() { return Attributes; } FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystem; } #pragma endregion IAbilitySystem + +#pragma region Pawn + void PossessedBy(AController* NewController) override; + + void OnRep_PlayerState() override; +#pragma endregion Pawn #pragma region Actor void BeginPlay() override; diff --git a/Project/Source/Gasa/Characters/PlayerCharacter.cpp b/Project/Source/Gasa/Characters/PlayerCharacter.cpp index afe9dbe..84a393b 100644 --- a/Project/Source/Gasa/Characters/PlayerCharacter.cpp +++ b/Project/Source/Gasa/Characters/PlayerCharacter.cpp @@ -1,8 +1,23 @@ #include "PlayerCharacter.h" +#include "AbilitySystemComponent.h" + APlayerCharacter::APlayerCharacter() { PrimaryActorTick.bCanEverTick = true; bAutoAbilitySystem = false; } + +void APlayerCharacter::OnRep_PlayerState() +{ + Super::OnRep_PlayerState(); + + AGasaPlayerState* PS = GetGasaPlayerState(); + // Client setup ability system + { + AbilitySystem = PS->AbilitySystem; + Attributes = PS->Attributes; + AbilitySystem->InitAbilityActorInfo(PS, this); + } +} diff --git a/Project/Source/Gasa/Characters/PlayerCharacter.h b/Project/Source/Gasa/Characters/PlayerCharacter.h index d55880e..6b99be5 100644 --- a/Project/Source/Gasa/Characters/PlayerCharacter.h +++ b/Project/Source/Gasa/Characters/PlayerCharacter.h @@ -10,5 +10,9 @@ class GASA_API APlayerCharacter : public AGasaCharacter GENERATED_BODY() public: - APlayerCharacter(); + APlayerCharacter(); + +#pragma region Pawn + void OnRep_PlayerState() override; +#pragma endregion Pawn }; diff --git a/Project/Source/Gasa/Game/GasaPlayerController.cpp b/Project/Source/Gasa/Game/GasaPlayerController.cpp index 5bde786..4f5c1d5 100644 --- a/Project/Source/Gasa/Game/GasaPlayerController.cpp +++ b/Project/Source/Gasa/Game/GasaPlayerController.cpp @@ -1,8 +1,10 @@ #include "GasaPlayerController.h" +#include "AbilitySystemComponent.h" #include "Engine/LocalPlayer.h" #include "EnhancedInputComponent.h" #include "EnhancedInputSubsystems.h" +#include "GasaPlayerState.h" #include "Actors/CameraMount.h" #include "Camera/CameraComponent.h" #include "Characters/GasaCharacter.h" @@ -67,6 +69,15 @@ void AGasaPlayerController::OnPossess(APawn* InPawn) Super::OnPossess(InPawn); Cam->AttachToActor(InPawn, FAttachmentTransformRules::KeepRelativeTransform); + + AGasaPlayerState* PS = GetPlayerState(); + AGasaCharacter* character = Cast(InPawn); + // Net Owner setup ability system + { + character->AbilitySystem = PS->AbilitySystem; + character->Attributes = PS->Attributes; + character->AbilitySystem->InitAbilityActorInfo(PS, character); + } } void AGasaPlayerController::OnUnPossess() diff --git a/Project/Source/Gasa/Game/GasaPlayerController.h b/Project/Source/Gasa/Game/GasaPlayerController.h index 5628f30..05cfd29 100644 --- a/Project/Source/Gasa/Game/GasaPlayerController.h +++ b/Project/Source/Gasa/Game/GasaPlayerController.h @@ -1,11 +1,11 @@ #pragma once #include "GasaCommon.h" +#include "GasaPlayerState.h" #include "GameFramework/PlayerController.h" #include "GasaPlayerController.generated.h" - UCLASS(Blueprintable) class GASA_API AGasaPlayerController : public APlayerController { @@ -48,11 +48,16 @@ public: UPROPERTY(EditAnywhere, Category="Input") TObjectPtr IA_Move; + + void Move(FInputActionValue const& ActionValue); #pragma endregion Input AGasaPlayerController(); - void Move(FInputActionValue const& ActionValue); + AGasaPlayerState* GetPlayerState() + { + return Cast( PlayerState ); + } #pragma region PlayerController void OnPossess(APawn* InPawn) override; diff --git a/Project/Source/Gasa/Game/GasaPlayerState.cpp b/Project/Source/Gasa/Game/GasaPlayerState.cpp index d131754..a862ca7 100644 --- a/Project/Source/Gasa/Game/GasaPlayerState.cpp +++ b/Project/Source/Gasa/Game/GasaPlayerState.cpp @@ -6,6 +6,7 @@ AGasaPlayerState::AGasaPlayerState() { AbilitySystem = CreateDefaultSubobject("Ability System"); AbilitySystem->SetIsReplicated(true); + AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Mixed); Attributes = CreateDefaultSubobject("Attributes"); diff --git a/Project/Source/Gasa/Game/GasaPlayerState.h b/Project/Source/Gasa/Game/GasaPlayerState.h index a6553de..23adb22 100644 --- a/Project/Source/Gasa/Game/GasaPlayerState.h +++ b/Project/Source/Gasa/Game/GasaPlayerState.h @@ -31,4 +31,8 @@ public: FORCEINLINE UAttributeSet* GetAttributes() { return Attributes; } FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystem; } #pragma endregion IAbilitySystem + +#pragma region + +#pragma endregion }; diff --git a/Project/Source/Gasa/GasaCommon.h b/Project/Source/Gasa/GasaCommon.h index 9433325..1a93f75 100644 --- a/Project/Source/Gasa/GasaCommon.h +++ b/Project/Source/Gasa/GasaCommon.h @@ -8,6 +8,10 @@ #define internal static #define local_persist static +#pragma region Math +#define m_pow2( value ) (value * value) +#pragma endregion Math + #pragma region Engine Forwards struct FInputActionValue; @@ -130,3 +134,22 @@ namespace Gasa #define GASA_Verbose(Message) UE_LOG( Gasa, Verbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() ); #define GASA_VeryVerbose(Message) UE_LOG( Gasa, VeryVerbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() ); #pragma endregion Logging + +#pragma region Timing +namespace Gasa +{ + constexpr float _24Hz = .042f; + constexpr float _30Hz = .033f; + constexpr float _42Hz = .024f; + constexpr float _45Hz = .022f; + constexpr float _50Hz = .020f; + constexpr float _60Hz = .016f; + constexpr float _72Hz = .014f; + constexpr float _80Hz = .013f; + constexpr float _90Hz = .011f; + constexpr float _100Hz = .010f; + constexpr float _120Hz = .083f; + constexpr float _240Hz = .004f; + constexpr float _480Hz = .002f; +} +#pragma endregion Timing \ No newline at end of file diff --git a/Project/Source/Gasa/GasaLibrary.cpp b/Project/Source/Gasa/GasaLibrary.cpp index 1731534..351a251 100644 --- a/Project/Source/Gasa/GasaLibrary.cpp +++ b/Project/Source/Gasa/GasaLibrary.cpp @@ -86,5 +86,5 @@ float UGasaLib::printToScreenDuration = 10.0f; #pragma region Timing // Protected -float UGasaLib::timingRate_Std = UGasaLib::_60Hz; +float UGasaLib::timingRate_Std = Gasa::_60Hz; #pragma endregion Timing diff --git a/Project/Source/Gasa/GasaLibrary.h b/Project/Source/Gasa/GasaLibrary.h index 204c5e6..9dee172 100644 --- a/Project/Source/Gasa/GasaLibrary.h +++ b/Project/Source/Gasa/GasaLibrary.h @@ -45,65 +45,51 @@ public: #pragma region Timing public: - static constexpr float _24Hz = .042f; - static constexpr float _30Hz = .033f; - static constexpr float _42Hz = .024f; - static constexpr float _45Hz = .022f; - static constexpr float _50Hz = .020f; - static constexpr float _60Hz = .016f; - static constexpr float _72Hz = .014f; - static constexpr float _80Hz = .013f; - static constexpr float _90Hz = .011f; - static constexpr float _100Hz = .010f; - static constexpr float _120Hz = .083f; - static constexpr float _240Hz = .004f; - static constexpr float _480Hz = .002f; - // Constant Rates UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "24 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_24Hz () { return _24Hz; } + static FORCEINLINE float BP_Clock_24Hz () { return Gasa::_24Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "30 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_30Hz () { return _30Hz; } + static FORCEINLINE float BP_Clock_30Hz () { return Gasa::_30Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "42 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_42Hz () { return _42Hz; } + static FORCEINLINE float BP_Clock_42Hz () { return Gasa::_42Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "50 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_50Hz () { return _50Hz; } + static FORCEINLINE float BP_Clock_50Hz () { return Gasa::_50Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "60 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_60Hz () { return _60Hz; } + static FORCEINLINE float BP_Clock_60Hz () { return Gasa::_60Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "72 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_72Hz () { return _72Hz; } + static FORCEINLINE float BP_Clock_72Hz () { return Gasa::_72Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "80 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_80Hz () { return _80Hz; } + static FORCEINLINE float BP_Clock_80Hz () { return Gasa::_80Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "90 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_90Hz () { return _90Hz; } + static FORCEINLINE float BP_Clock_90Hz () { return Gasa::_90Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "100 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_100Hz() { return _100Hz; } + static FORCEINLINE float BP_Clock_100Hz() { return Gasa::_100Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "120 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_120Hz() { return _120Hz; } + static FORCEINLINE float BP_Clock_120Hz() { return Gasa::_120Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "240 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BP_Clock_240Hz() { return _240Hz; } + static FORCEINLINE float BP_Clock_240Hz() { return Gasa::_240Hz; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "480 Hz", CallableWithoutWorldContext)) - static FORCEINLINE float BPClock_480Hz() { return _480Hz; } + static FORCEINLINE float BPClock_480Hz() { return Gasa::_480Hz; } // Standard Timing UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "Time Rate", CallableWithoutWorldContext)) static FORCEINLINE float GetStd_Timerate () { return timingRate_Std; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "Quarter Time Rate", CallableWithoutWorldContext)) - static FORCEINLINE float GetStd_Timerate_Quarter() { return timingRate_Std / 4.0f; } + static FORCEINLINE float GetStd_Timerate_Quarter() { return timingRate_Std * 0.25f; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "Half Time Rate", CallableWithoutWorldContext)) - static FORCEINLINE float GetStd_Timerate_Half () { return timingRate_Std / 2.0f; } + static FORCEINLINE float GetStd_Timerate_Half () { return timingRate_Std * 0.5f; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "2X Time Rate", CallableWithoutWorldContext)) static FORCEINLINE float GetStd_Timerate_2X () { return timingRate_Std * 2.0f; } UFUNCTION(BlueprintPure, Category = "Timing", Meta = (DisplayName = "4X Time Rate", CallableWithoutWorldContext)) - static FORCEINLINE float GetStd_Timerate_4X () { return timingRate_Std * 2.0f; } + static FORCEINLINE float GetStd_Timerate_4X () { return timingRate_Std * 4.0f; } UFUNCTION(BlueprintCallable, Category = "Timing", Meta = (DisplayName = "Set Time Rate")) static void SetStd_Timerate(float _rateDesired) { // Not the best check.. if inconsistency arises, use the a rigorous one. - if (_rateDesired >= _24Hz) + if (_rateDesired >= Gasa::_24Hz) { timingRate_Std = _rateDesired; } diff --git a/Project/Source/Gasa/Networking/GasaNetLibrary.cpp b/Project/Source/Gasa/Networking/GasaNetLibrary.cpp new file mode 100644 index 0000000..169c801 --- /dev/null +++ b/Project/Source/Gasa/Networking/GasaNetLibrary.cpp @@ -0,0 +1,2 @@ +#include "GasaNetLibrary.h" + diff --git a/Project/Source/Gasa/Networking/GasaNetLibrary.h b/Project/Source/Gasa/Networking/GasaNetLibrary.h new file mode 100644 index 0000000..c7773a4 --- /dev/null +++ b/Project/Source/Gasa/Networking/GasaNetLibrary.h @@ -0,0 +1,15 @@ +#pragma once + + +namespace Gasa +{ + constexpr float NetCullDist_Default = 225000000.0f; + constexpr float NetCullDist_Immediate = 250.0f * 250.0f; + constexpr float NetCullDist_VerClose = 1000.0f * 1000.0f; + constexpr float NetCullDist_Close = 3500.0f * 3500.0f; + constexpr float NetCullDist_Medium = 5000.0f * 5000.0f; + constexpr float NetCullDist_Distant = 7000.0f * 7000.0f; + constexpr float NetCullDist_Far = 8500.0f * 8500.0f; + constexpr float NetCullDist_VeryFar = 10000.0f * 10000.0f; + constexpr float NetCullDist_VisualMax = 15000.0f * 15000.0f; +}