diff --git a/lua/entities/gmod_tardis/modules/cl_projectedlight.lua b/lua/entities/gmod_tardis/modules/cl_projectedlight.lua index dd520d19e..13099554c 100644 --- a/lua/entities/gmod_tardis/modules/cl_projectedlight.lua +++ b/lua/entities/gmod_tardis/modules/cl_projectedlight.lua @@ -28,6 +28,17 @@ function ENT:PickProjectedLightColor() pickedcolor = pickedcolor or pl.color or int_color_data.color + if pl.baselightmix > 0 and IsValid(self.interior) then + local int_base_light_color = self.interior:GetBaseLightColor() + + local mix = pl.baselightmix + pickedcolor = Color( + pickedcolor.r * (1 - mix) + int_base_light_color.r * mix, + pickedcolor.g * (1 - mix) + int_base_light_color.g * mix, + pickedcolor.b * (1 - mix) + int_base_light_color.b * mix + ) + end + return pickedcolor end diff --git a/lua/entities/gmod_tardis_interior/modules/cl_render.lua b/lua/entities/gmod_tardis_interior/modules/cl_render.lua index 32169f91c..ca0438ea7 100644 --- a/lua/entities/gmod_tardis_interior/modules/cl_render.lua +++ b/lua/entities/gmod_tardis_interior/modules/cl_render.lua @@ -9,7 +9,7 @@ local function predraw_o(self, part) render.SuppressEngineLighting(true) - local col = self:GetData("interior_base_light_color", TARDIS.color_white_vector) + local colvec = self:GetBaseLightColorVector() local parts_table = power and lo.parts or lo.parts_nopower @@ -21,7 +21,7 @@ local function predraw_o(self, part) render.ResetModelLighting(part_br, part_br, part_br) end else - render.ResetModelLighting(col[1], col[2], col[3]) + render.ResetModelLighting(colvec[1], colvec[2], colvec[3]) end --render.SetLightingMode(1) diff --git a/lua/entities/gmod_tardis_interior/modules/sh_interior_lights.lua b/lua/entities/gmod_tardis_interior/modules/sh_interior_lights.lua index 8dfaa9c68..a2851b50e 100644 --- a/lua/entities/gmod_tardis_interior/modules/sh_interior_lights.lua +++ b/lua/entities/gmod_tardis_interior/modules/sh_interior_lights.lua @@ -628,15 +628,28 @@ end -- Base light +function ENT:GetCustomBaseLightEnabled() + return self:GetData("interior_custom_base_light_enabled", false) +end + +function ENT:GetCustomBaseLightColor() + return self:GetData("interior_custom_base_light_color") +end + +function ENT:GetGetBaseLightColorVector() + return self:GetData("interior_base_light_color_vec") +end + +function ENT:GetCustomBaseLightBrightness() + return self:GetData("interior_custom_base_light_brightness") +end + + if SERVER then - function ENT:SetCustomBaseLightEnabled(enabled, color, brightness) + function ENT:SetCustomBaseLightEnabled(enabled) self:SetData("interior_custom_base_light_enabled", enabled or false, true) end - function ENT:GetCustomBaseLightEnabled() - return self:GetData("interior_custom_base_light_enabled", false) - end - function ENT:ToggleCustomBaseLightEnabled() self:SetCustomBaseLightEnabled(not self:GetCustomBaseLightEnabled()) end @@ -645,18 +658,18 @@ if SERVER then self:SetData("interior_custom_base_light_color", color, true) end - function ENT:GetCustomBaseLightColor() - return self:GetData("interior_custom_base_light_color") - end - function ENT:SetCustomBaseLightBrightness(brightness) self:SetData("interior_custom_base_light_brightness", brightness, true) end +else + function ENT:GetBaseLightColorVector() + return self:GetData("interior_base_light_color_vec", TARDIS.color_white_vector) + end - function ENT:GetCustomBaseLightBrightness() - return self:GetData("interior_custom_base_light_brightness") + function ENT:GetBaseLightColor() + return self:GetBaseLightColorVector():ToColor() end -else + ENT:AddHook("Think", "baselight", function(self) local lo = self.metadata.Interior.LightOverride if not lo then return end @@ -669,7 +682,7 @@ else local customcol = self:GetData("interior_custom_base_light_color") local custombr = self:GetData("interior_custom_base_light_brightness", normalbr) - local currentcolvec = self:GetData("interior_base_light_color") + local currentcolvec = self:GetData("interior_base_light_color_vec") local targetcolvec if self:GetData("interior_custom_base_light_enabled") and customcol then targetcolvec = customcol:ToVector() * (custombr or normalbr) @@ -680,7 +693,7 @@ else if currentcolvec == targetcolvec then return elseif not currentcolvec then - self:SetData("interior_base_light_color", targetcolvec) + self:SetData("interior_base_light_color_vec", targetcolvec) return end @@ -698,7 +711,7 @@ else local colvec = LerpVector(fraction, prevcolvec, targetcolvec) - self:SetData("interior_base_light_color", colvec) + self:SetData("interior_base_light_color_vec", colvec) self:SetData("interior_base_light_transition_fraction", fraction) end) end \ No newline at end of file diff --git a/lua/matproxy/matproxy_tardis.lua b/lua/matproxy/matproxy_tardis.lua index 47370832e..41b851f8c 100644 --- a/lua/matproxy/matproxy_tardis.lua +++ b/lua/matproxy/matproxy_tardis.lua @@ -130,7 +130,7 @@ matproxy.Add({ bind = function( self, mat, ent ) if not IsValid(ent) or not ent.TardisPart then return end - local col = ent:GetData("interior_base_light_color", TARDIS.color_white_vector) + local col = ent:GetData("interior_base_light_color_vec", TARDIS.color_white_vector) mat:SetVector(self.ResultTo, col) end }) \ No newline at end of file diff --git a/lua/tardis/interiors/base.lua b/lua/tardis/interiors/base.lua index ce216a124..b65b74778 100644 --- a/lua/tardis/interiors/base.lua +++ b/lua/tardis/interiors/base.lua @@ -87,7 +87,8 @@ T.Exterior = { --horizfov = 90, --vertical and horizontal field of view of the light. Will default to portal height and width. farz = 750, --FarZ property of the light. Determines how far the light projects.]] offset = Vector(-21,0,51.1), --Offset from box origin - texture = "effects/flashlight/square" --Texture the projected light will use. You can get these from the Lamp tool. + texture = "effects/flashlight/square", --Texture the projected light will use. You can get these from the Lamp tool. + baselightmix = 0, --How much the base light affects the projected light. 0 = none, 1 = full. }, Sounds = { Teleport = {