Browse Source
- Marked the location of @Latelinks for refactoring/searchability - Added the concept of GameplayTime, a time which can be paused and played. Gameplay code should use this instead of world time - Math macros no longer have semicolons, making them useful in for loops etc. - I had to comment out std::cout calls in Logging.cpp because Unreal gets upset when those are executed - Added several build systems and debug options to get both a full debug Unreal Editor and standalone game client working and convenient to use - Added SetEntitySpeeds() to the MovementManager interface. The idea is that if things die their speeds can be set to zero. This will likely be replaced with something cleaner - Added the ability to interface with EntityComponentManager with a single UnsubscribeEntities function instead of a whole ComponentManager derived class. This is proving to be a somewhat dumb idea. I still need to figure out this whole interfacemaster

19 changed files with 286 additions and 49 deletions
@ -1,5 +1,5 @@ |
|||
#pragma once |
|||
|
|||
#define CLAMP(value, min, max) if (value > max) value = max; else if (value < min) value = min; |
|||
#define MIN(a, b) a <= b ? a : b; |
|||
#define MAX(a, b) a >= b ? a : b; |
|||
#define MIN(a, b) (a <= b ? a : b) |
|||
#define MAX(a, b) (a >= b ? a : b) |
@ -0,0 +1,60 @@ |
|||
#include "Time.hpp" |
|||
|
|||
namespace gv |
|||
{ |
|||
struct GameplayTimeManager |
|||
{ |
|||
// The difference between gameplay time and world time. This makes sure gameplay time stays
|
|||
// ignorant of pausing
|
|||
float GameplayTimeWorldTimeDelta; |
|||
|
|||
bool IsPlaying; |
|||
float PausedAtWorldTime; |
|||
}; |
|||
|
|||
static GameplayTimeManager s_GameplayTimeManager; |
|||
|
|||
float GetGameplayTime() |
|||
{ |
|||
if (s_GameplayTimeManager.IsPlaying) |
|||
{ |
|||
return GetWorldTime() - s_GameplayTimeManager.GameplayTimeWorldTimeDelta; |
|||
} |
|||
else |
|||
{ |
|||
// If we're paused, we want to return the same time regardless of world time
|
|||
return s_GameplayTimeManager.PausedAtWorldTime - |
|||
s_GameplayTimeManager.GameplayTimeWorldTimeDelta; |
|||
} |
|||
} |
|||
|
|||
bool GameIsPlaying() |
|||
{ |
|||
return s_GameplayTimeManager.IsPlaying; |
|||
} |
|||
|
|||
void GameSetPlaying(bool shouldPlay) |
|||
{ |
|||
// Pausing
|
|||
if (!shouldPlay && s_GameplayTimeManager.IsPlaying) |
|||
{ |
|||
s_GameplayTimeManager.PausedAtWorldTime = GetWorldTime(); |
|||
} |
|||
// Resuming
|
|||
else if (shouldPlay && !s_GameplayTimeManager.IsPlaying) |
|||
{ |
|||
float thisPauseTimeDelta = |
|||
GetWorldTime() - s_GameplayTimeManager.GameplayTimeWorldTimeDelta; |
|||
s_GameplayTimeManager.GameplayTimeWorldTimeDelta += thisPauseTimeDelta; |
|||
} |
|||
|
|||
s_GameplayTimeManager.IsPlaying = shouldPlay; |
|||
} |
|||
|
|||
void ResetGameplayTime() |
|||
{ |
|||
s_GameplayTimeManager.GameplayTimeWorldTimeDelta = 0.f; |
|||
s_GameplayTimeManager.IsPlaying = true; |
|||
s_GameplayTimeManager.PausedAtWorldTime = 0.f; |
|||
} |
|||
} |
Loading…
Reference in new issue