minor fixes

This commit is contained in:
Arnaud Jamin
2023-10-27 10:17:25 -04:00
parent 9a1fe2a348
commit b147b4b05f
7 changed files with 45 additions and 5 deletions
@@ -130,6 +130,26 @@ void ACogEngineReplicator::Server_Spawn_Implementation(const FCogEngineSpawnEntr
#endif // !UE_BUILD_SHIPPING #endif // !UE_BUILD_SHIPPING
} }
//--------------------------------------------------------------------------------------------------------------------------
void ACogEngineReplicator::SetTimeDilation(float Value)
{
#if !UE_BUILD_SHIPPING
//-------------------------------------
// Set local time dilation right away
//-------------------------------------
TimeDilation = Value;
OnRep_TimeDilation();
//-------------------------------------
// Update server time dilation
//-------------------------------------
Server_SetTimeDilation(Value);
#endif // !UE_BUILD_SHIPPING
}
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void ACogEngineReplicator::Server_SetTimeDilation_Implementation(float Value) void ACogEngineReplicator::Server_SetTimeDilation_Implementation(float Value)
{ {
@@ -50,7 +50,7 @@ void FCogEngineWindow_TimeScale::RenderContent()
float Value = Replicator->GetTimeDilation(); float Value = Replicator->GetTimeDilation();
if (FCogWindowWidgets::MultiChoiceButtonsFloat(TimingScales, Value, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0))) if (FCogWindowWidgets::MultiChoiceButtonsFloat(TimingScales, Value, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0)))
{ {
Replicator->Server_SetTimeDilation(Value); Replicator->SetTimeDilation(Value);
} }
} }
@@ -39,8 +39,7 @@ public:
float GetTimeDilation() const { return TimeDilation; } float GetTimeDilation() const { return TimeDilation; }
UFUNCTION(Server, Reliable) void SetTimeDilation(float Value);
void Server_SetTimeDilation(float Value);
UFUNCTION(Server, Reliable) UFUNCTION(Server, Reliable)
void Server_Possess(APawn* Pawn); void Server_Possess(APawn* Pawn);
@@ -50,6 +49,9 @@ public:
protected: protected:
UFUNCTION(Server, Reliable)
void Server_SetTimeDilation(float Value);
UFUNCTION() UFUNCTION()
void OnRep_TimeDilation(); void OnRep_TimeDilation();
+16 -1
View File
@@ -1,9 +1,9 @@
#include "CogSampleBasicActor.h" #include "CogSampleBasicActor.h"
#include "GameFramework/GameStateBase.h"
#include "Net/Core/PushModel/PushModel.h" #include "Net/Core/PushModel/PushModel.h"
#include "Net/UnrealNetwork.h" #include "Net/UnrealNetwork.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
ACogSampleBasicActor::ACogSampleBasicActor(const FObjectInitializer& ObjectInitializer) ACogSampleBasicActor::ACogSampleBasicActor(const FObjectInitializer& ObjectInitializer)
{ {
@@ -22,6 +22,21 @@ void ACogSampleBasicActor::GetLifetimeReplicatedProps(TArray< FLifetimeProperty
DOREPLIFETIME_WITH_PARAMS_FAST(ACogSampleBasicActor, Creator, Params); DOREPLIFETIME_WITH_PARAMS_FAST(ACogSampleBasicActor, Creator, Params);
} }
//--------------------------------------------------------------------------------------------------------------------------
void ACogSampleBasicActor::BeginPlay()
{
//-----------------------------------------------------
// Set default creator before Super::BeginPlay()
// so component can access it inside they BeginPlay()
//-----------------------------------------------------
if (Creator == nullptr)
{
Creator = GetWorld()->GetGameState();
}
Super::BeginPlay();
}
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void ACogSampleBasicActor::SetTeam(int32 Value) void ACogSampleBasicActor::SetTeam(int32 Value)
{ {
+2
View File
@@ -20,6 +20,8 @@ public:
ACogSampleBasicActor(const FObjectInitializer& ObjectInitializer); ACogSampleBasicActor(const FObjectInitializer& ObjectInitializer);
virtual void BeginPlay();
UFUNCTION(BlueprintPure) UFUNCTION(BlueprintPure)
virtual int32 GetTeam() const override { return Team; } virtual int32 GetTeam() const override { return Team; }
+1
View File
@@ -9,6 +9,7 @@
- CogEngine: Add more info in stats tooltip (details, curves, ...) - CogEngine: Add more info in stats tooltip (details, curves, ...)
- CogEngine: Add screen settings (fullscreen, borderless, window and resolution) - CogEngine: Add screen settings (fullscreen, borderless, window and resolution)
- CogEngine: make a better widget for CheckBoxState for input shortcuts - CogEngine: make a better widget for CheckBoxState for input shortcuts
- CogEngine: save active log categories
- CogSample: Add a custom window in sample (changing the character faction) - CogSample: Add a custom window in sample (changing the character faction)
- CogSample: Create more abilities - CogSample: Create more abilities