diff --git a/ext/Client/Time.lua b/ext/Client/Time.lua index 25fef28..3588fb0 100644 --- a/ext/Client/Time.lua +++ b/ext/Client/Time.lua @@ -4,7 +4,7 @@ Time = class 'Time' ---@type Logger -local m_Logger = Logger("Time", false) +local m_Logger = Logger("Time", true) ---@type VisualEnvironmentHandler local m_VisualEnvironmentHandler = require("VisualEnvironmentHandler") @@ -37,7 +37,6 @@ function Time:RegisterVars() self._CurrentPreset = 1 - self._CloudSpeed = CONFIG.CLOUDS_DEFAULT_SPEED self._Sunrise = CONFIG.DN_SUN_TIMINGS[1] / 24 self._Sunset = CONFIG.DN_SUN_TIMINGS[2] / 24 end @@ -46,15 +45,16 @@ function Time:RegisterEvents() NetEvents:Subscribe('VEManager:AddTimeToClient', self, self._OnAddTime) NetEvents:Subscribe('ClientTime:Pause', self, self._OnPauseUnpause) NetEvents:Subscribe('ClientTime:Disable', self, self._OnDisable) + Events:Subscribe('VEManager:PresetsLoaded', self, self._OnPresetsLoaded) end -function Time:OnLevelLoaded() - self.m_ServerSyncEvent = NetEvents:Subscribe('TimeServer:Sync', self, self._OnServerSync) -- Server Sync +function Time:_OnPresetsLoaded() + self._SyncEvent = NetEvents:Subscribe('TimeServer:Sync', self, self._OnServerSync) -- Server Sync self:_Sync() end function Time:OnLevelDestroy() - self.m_ServerSyncEvent = NetEvents:Unsubscribe('TimeServer:Sync') -- Server Sync + self._SyncEvent:Unsubscribe() self:_Disable() end @@ -217,7 +217,7 @@ function Time:_OnAddTime(p_StartingTime, p_IsStatic, p_LengthOfDayInSeconds) if l_Object.type == l_Type and s_SunRotationY ~= nil then -- Check if night mode (moon enabled) - if s_SkyBrightness ~= nil and s_SkyBrightness <= 0.01 then + if s_SunRotationY >= 180 then s_SunRotationY = 360 - s_SunRotationY end m_Logger:Write(" - " .. tostring(l_ID) .. " (Sun: " .. tostring(s_SunRotationY) .. ")") @@ -411,8 +411,8 @@ function Time:_Run() if not m_VisualEnvironmentHandler:CheckIfExists(s_ID) then return end m_VisualEnvironmentHandler:SetVisibility(s_ID, s_Factor) - if s_Factor ~= 0 then -- TODO: Check if cloud speed works properly - m_VisualEnvironmentHandler:SetSingleValue(s_ID, 'sky', 'cloudLayer1Speed', self._CloudSpeed) + if s_Factor ~= 0 then -- hardcode for now + m_VisualEnvironmentHandler:SetSingleValue(s_ID, 'sky', 'cloudLayer1Speed', -0.0001) end end diff --git a/ext/Client/Types/VisualEnvironmentObject.lua b/ext/Client/Types/VisualEnvironmentObject.lua index 7cdf13f..99bb88b 100644 --- a/ext/Client/Types/VisualEnvironmentObject.lua +++ b/ext/Client/Types/VisualEnvironmentObject.lua @@ -24,6 +24,8 @@ function VisualEnvironmentObject:__init(p_Preset) if not p_Preset.Priority then p_Preset.Priority = 1 + elseif p_Preset.Type == 'Dynamic' then + p_Preset.Priority = 200 else p_Preset.Priority = tonumber(p_Preset.Priority) end diff --git a/ext/Client/VisualEnvironmentHandler.lua b/ext/Client/VisualEnvironmentHandler.lua index c53af5d..a8771db 100644 --- a/ext/Client/VisualEnvironmentHandler.lua +++ b/ext/Client/VisualEnvironmentHandler.lua @@ -4,7 +4,7 @@ VisualEnvironmentHandler = class 'VisualEnvironmentHandler' ---@type Logger -local m_Logger = Logger("VisualEnvironmentHandler", true) +local m_Logger = Logger("VisualEnvironmentHandler", false) ---@type EasingTransitions local m_Easing = require "__shared/Utils/Easing" @@ -377,7 +377,7 @@ function VisualEnvironmentHandler:SetSingleValue(p_ID, p_Class, p_Property, p_Va end ---@type VisualEnvironmentObject local s_Object = self._VisualEnvironmentObjects[p_ID] - s_Object.entity.state[p_Class][p_Property] = p_Value + VisualEnvironmentEntity(s_Object.entity).state[p_Class][p_Property] = p_Value VisualEnvironmentManager:SetDirty(true) end diff --git a/ext/Client/__init__.lua b/ext/Client/__init__.lua index 8d9abf9..1cfbdd5 100644 --- a/ext/Client/__init__.lua +++ b/ext/Client/__init__.lua @@ -14,6 +14,8 @@ local m_VisualEnvironmentHandler = require("VisualEnvironmentHandler") local m_RuntimeEntityHandler = require("RuntimeEntityHandler") ---@type Patches local m_Patches = require("Patches") +---@type Time +local m_Time = require("Time") --#endregion function VEManagerClient:__init() diff --git a/ext/Server/TimeServer.lua b/ext/Server/TimeServer.lua index b60a5a1..4a70430 100644 --- a/ext/Server/TimeServer.lua +++ b/ext/Server/TimeServer.lua @@ -4,7 +4,7 @@ TimeServer = class "TimeServer" ---@type Logger -local m_Logger = Logger("TimeServer", false) +local m_Logger = Logger("TimeServer", true) function TimeServer:__init() m_Logger:Write('Initializing Time-Server') @@ -37,7 +37,7 @@ function TimeServer:RegisterEvents() m_Logger:Write('Registered Events') ---@type Event - self.m_EngineUpdateEvent = Events:Subscribe('Engine:Update', self, self._OnEngineUpdate) + Events:Subscribe('Engine:Update', self, self._OnEngineUpdate) Events:Subscribe('Level:Destroy', self, self._OnLevelDestroy) Events:Subscribe('TimeServer:Enable', self, self._OnEnable) Events:Subscribe('TimeServer:Pause', self, self._OnPauseUnpause) @@ -47,7 +47,7 @@ function TimeServer:RegisterEvents() end function TimeServer:_OnLevelDestroy() - self.m_EngineUpdateEvent:Unsubscribe() + self:RegisterVars() end ---@param p_StartingTime number