// Fill out your copyright notice in the Description page of Project Settings. #include "DayNightGameStateBase.h" #include "Net/UnrealNetwork.h" #include "Engine.h" ADayNightGameStateBase::ADayNightGameStateBase() { m_TimeOfDayStart = 960; m_SkySphereName = "SkySphereBlueprint"; m_PrimarySunLightName = "LightSource"; m_SkyLightName = "SkyLight"; m_SunriseTimeMark = 6.0f; m_SunsetTimeMark = 18.0f; } void ADayNightGameStateBase::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(ADayNightGameStateBase, m_ElapsedGameMinutes); DOREPLIFETIME(ADayNightGameStateBase, m_bIsNight); } bool ADayNightGameStateBase::GetAndUpdateIsNight() { const float TimeOfDay = m_ElapsedGameMinutes - GetElapsedFullDaysInMinutes(); bool bBool = TimeOfDay > (m_SunriseTimeMark * 60) && TimeOfDay < (m_SunsetTimeMark * 60); m_bIsNight = !bBool; return m_bIsNight; } void ADayNightGameStateBase::IncrementElapsedGameMinutes(int32 time) { m_ElapsedGameMinutes = m_ElapsedGameMinutes + time; }