Move global update items to its own game loop update function. Damage numbers now update on the overworld map menu.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/57/head
Nic0Nic0Nii 8 months ago
parent bcbe2150ee
commit 23f17ec459
  1. 84
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h

@ -361,29 +361,7 @@ bool AiL::OnUserCreate(){
}
bool AiL::OnUserUpdate(float fElapsedTime){
levelTime+=fElapsedTime;
SteamAPI_RunCallbacks();
STEAMINPUT(
ActivateActionSetForAllControllers(Input::ingameControlsHandle);
Input::UpdateSteamInput();
)
if(GetMousePos()!=lastMousePos){
lastMouseMovement=0.f;
lastMousePos=GetMousePos();
}else lastMouseMovement+=fElapsedTime;
vignetteDisplayTime=std::max(0.f,vignetteDisplayTime-fElapsedTime);
if(Audio::Engine().IsPlaying(GetPlayer()->cooldownSoundInstance)){
Audio::Engine().SetVolume(GetPlayer()->cooldownSoundInstance,Audio::GetCalculatedSFXVolume("Audio.Casting Sound Volume"_F/100.f));
}
if(!GamePaused()){
GameState::STATE->OnUserUpdate(this);
}else{
ClearTimedOutGarbage();
}
GlobalGameUpdates();
LoadingScreen::Update();
InputListener::Update();
Tutorial::Update();
@ -1659,20 +1637,6 @@ void AiL::RenderWorld(float fElapsedTime){
for(std::vector<std::shared_ptr<DamageNumber>>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){
DamageNumber*dn=(*it).get();
if(dn->pauseTime>0){
dn->pauseTime-=fElapsedTime;
} else{
dn->lifeTime+=fElapsedTime;
if(dn->lifeTime<=1){
if(dn->lifeTime<DamageNumber::MOVE_UP_TIME){
if(dn->invertedDirection){
dn->pos.y+=dn->riseSpd*fElapsedTime;
}else{
dn->pos.y-=dn->riseSpd*fElapsedTime;
}
}
}
}
#define NumberScalesWithDamage true
#define NormalNumber false
@ -3948,3 +3912,49 @@ const float AiL::GetEncounterDuration()const{
void AiL::ShowDamageVignetteOverlay(){
vignetteDisplayTime="Interface.Vignette Appearance Time"_F+"Interface.Vignette Fadeout Time"_F;
}
void AiL::GlobalGameUpdates(){
levelTime+=fElapsedTime;
SteamAPI_RunCallbacks();
STEAMINPUT(
ActivateActionSetForAllControllers(Input::ingameControlsHandle);
Input::UpdateSteamInput();
)
#pragma region Damage Numbers update
for(std::vector<std::shared_ptr<DamageNumber>>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){
DamageNumber*dn=(*it).get();
if(dn->pauseTime>0){
dn->pauseTime-=fElapsedTime;
} else{
dn->lifeTime+=fElapsedTime;
if(dn->lifeTime<=1){
if(dn->lifeTime<DamageNumber::MOVE_UP_TIME){
if(dn->invertedDirection){
dn->pos.y+=dn->riseSpd*fElapsedTime;
}else{
dn->pos.y-=dn->riseSpd*fElapsedTime;
}
}
}
}
}
#pragma endregion
if(GetMousePos()!=lastMousePos){
lastMouseMovement=0.f;
lastMousePos=GetMousePos();
}else lastMouseMovement+=fElapsedTime;
vignetteDisplayTime=std::max(0.f,vignetteDisplayTime-fElapsedTime);
if(Audio::Engine().IsPlaying(GetPlayer()->cooldownSoundInstance)){
Audio::Engine().SetVolume(GetPlayer()->cooldownSoundInstance,Audio::GetCalculatedSFXVolume("Audio.Casting Sound Volume"_F/100.f));
}
if(!GamePaused()){
GameState::STATE->OnUserUpdate(this);
}else{
ClearTimedOutGarbage();
}
}

@ -321,6 +321,7 @@ public:
void ActivateActionSetForAllControllers(InputActionSetHandle_t actionSetHandle);
const float GetEncounterDuration()const;
void ShowDamageVignetteOverlay();
void GlobalGameUpdates();
struct TileGroupData{
vi2d tilePos;

Loading…
Cancel
Save