From 378f6491fe1000634d8098513d36ddbcdc7a69be Mon Sep 17 00:00:00 2001 From: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:56:20 +0100 Subject: [PATCH 1/6] Markervision for all placeable entities --- .../entities/entities/ttt_base_placeable.lua | 73 ++++++++++++++++++- .../entities/entities/ttt_beacon.lua | 37 ++-------- .../entities/entities/ttt_c4/shared.lua | 68 ++++++----------- .../entities/entities/ttt_decoy.lua | 6 ++ .../entities/entities/ttt_health_station.lua | 1 + .../entities/entities/ttt_radio.lua | 36 ++------- 6 files changed, 110 insertions(+), 111 deletions(-) diff --git a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua index 28e6b13996..1317b6f785 100644 --- a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua +++ b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua @@ -14,6 +14,10 @@ ENT.isDestructible = true ENT.pickupWeaponClass = nil +-- MarkerVision related +ENT.iconMaterial = Material("vgui/ttt/tid/tid_big_role_not_known") +ENT.markerVisibility = VISIBLE_FOR_PLAYER + --- -- @realm shared function ENT:Initialize() @@ -24,6 +28,11 @@ function ENT:Initialize() if SERVER then self:PrecacheGibs() + + local mvObject = self:AddMarkerVision("ttt_base_placeable_owner") + mvObject:SetOwner(self:GetOriginator()) + mvObject:SetVisibleFor(self.markerVisibility) + mvObject:SyncToClients() end local phys = self:GetPhysicsObject() @@ -74,6 +83,12 @@ if SERVER then AccessorFunc(ENT, "hitNormal", "HitNormal", FORCE_VECTOR) AccessorFunc(ENT, "stickRotation", "StickRotation", FORCE_ANGLE) + --- + -- @realm server + function ENT:OnRemove() + self:RemoveMarkerVision("ttt_base_placeable_owner") + end + --- -- @param CTakeDamageInfo dmgInfo -- @realm server @@ -232,7 +247,7 @@ if SERVER then --- -- Hook that is called if a player uses their use key while focusing on the entity. - -- @note When overwriting this function BaseClass.UseOverwrite has to be called if + -- @note When overwriting this function BaseClass.UseOverride has to be called if -- the entity pickup system should be used. -- @param Player activator The player that used their use key -- @hook @@ -392,4 +407,58 @@ if SERVER then return true end -end +end -- SERVER + +if CLIENT then + local TryT = LANG.TryTranslation + local ParT = LANG.GetParamTranslation + + function ENT:ShouldDrawMarkerVision() + return true + end + + function ENT:CustomizeMarkerVision(mvData) end + + function ENT:GetMarkerVisionIcons(mvData) + return { self.iconMaterial } + end + + function ENT:GetMarkerVisionColors(mvData) + return { COLOR_WHITE } + end + + hook.Add("TTT2RenderMarkerVisionInfo", "HUDDrawMarkerVisionBasePlaceable", function(mvData) + local ent = mvData:GetEntity() + local mvObject = mvData:GetMarkerVisionObject() + + if + not mvObject:IsObjectFor(ent, "ttt_base_placeable_owner") + or not ent:ShouldDrawMarkerVision() + then + return + end + + local owner = ent:GetOriginator() + local nick = IsValid(owner) and owner:Nick() or "---" + + local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1) + + mvData:EnableText() + mvData:SetTitle(TryT(ent.PrintName)) + + local icons = ent:GetMarkerVisionIcons(mvData) + local colors = ent:GetMarkerVisionColors(mvData) + local size = math.min(#icons, #colors) + + for i = 1, size do + mvData:AddIcon(icons[i], colors[i]) + end + + mvData:AddDescriptionLine(ParT("marker_vision_owner", { owner = nick })) + mvData:AddDescriptionLine(ParT("marker_vision_distance", { distance = distance })) + + mvData:AddDescriptionLine(TryT(mvObject:GetVisibleForTranslationKey()), COLOR_SLATEGRAY) + + ent:CustomizeMarkerVision(mvData) + end) +end -- CLIENT diff --git a/gamemodes/terrortown/entities/entities/ttt_beacon.lua b/gamemodes/terrortown/entities/entities/ttt_beacon.lua index fa709f31a9..f320cf305c 100644 --- a/gamemodes/terrortown/entities/entities/ttt_beacon.lua +++ b/gamemodes/terrortown/entities/entities/ttt_beacon.lua @@ -25,6 +25,9 @@ ENT.pickupWeaponClass = "weapon_ttt_beacon" ENT.timeLastBeep = CurTime() ENT.lastPlysFound = {} +ENT.iconMaterial = Material("vgui/ttt/marker_vision/beacon") +ENT.markerVisibility = VISIBLE_FOR_PLAYER + local beaconDetectionRange = 135 --- @@ -42,11 +45,6 @@ function ENT:Initialize() if SERVER then self:SetUseType(SIMPLE_USE) self:NextThink(CurTime() + 1) - - local mvObject = self:AddMarkerVision("beacon_owner") - mvObject:SetOwner(ROLE_DETECTIVE) - mvObject:SetVisibleFor(VISIBLE_FOR_ROLE) - mvObject:SyncToClients() end end @@ -124,7 +122,7 @@ if SERVER then ply:RemoveMarkerVision("beacon_player") end - self:RemoveMarkerVision("beacon_owner") + BaseClass.OnRemove(self) end --- @@ -164,7 +162,7 @@ if SERVER then end --- - -- @realm server + -- @realm server -- stylua: ignore if hook.Run("TTT2BeaconDeathNotify", victim, beacon) == false then continue end @@ -203,7 +201,6 @@ if CLIENT then local baseOpacity = 35 local factorRenderDistance = 3 - local materialBeacon = Material("vgui/ttt/marker_vision/beacon") local materialPlayer = Material("vgui/ttt/tid/tid_big_role_not_known") -- handle looking at Beacon @@ -240,30 +237,6 @@ if CLIENT then tData:AddDescriptionLine(TryT("beacon_short_desc")) end) - hook.Add("TTT2RenderMarkerVisionInfo", "HUDDrawMarkerVisionBeacon", function(mvData) - local ent = mvData:GetEntity() - local mvObject = mvData:GetMarkerVisionObject() - - if not mvObject:IsObjectFor(ent, "beacon_owner") then - return - end - - local owner = ent:GetOriginator() - local nick = IsValid(owner) and owner:Nick() or "---" - - local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1) - - mvData:EnableText() - - mvData:AddIcon(materialBeacon) - mvData:SetTitle(TryT(ent.PrintName)) - - mvData:AddDescriptionLine(ParT("marker_vision_owner", { owner = nick })) - mvData:AddDescriptionLine(ParT("marker_vision_distance", { distance = distance })) - - mvData:AddDescriptionLine(TryT(mvObject:GetVisibleForTranslationKey()), COLOR_SLATEGRAY) - end) - hook.Add("TTT2RenderMarkerVisionInfo", "HUDDrawMarkerVisionBeaconPlys", function(mvData) local ent = mvData:GetEntity() local mvObject = mvData:GetMarkerVisionObject() diff --git a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua index 3e2e41be0e..f7b137b986 100644 --- a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua +++ b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua @@ -37,6 +37,9 @@ ENT.Avoidable = true ENT.isDestructible = false +ENT.iconMaterial = Material("vgui/ttt/marker_vision/c4") +ENT.markerVisibility = VISIBLE_FOR_TEAM + --- -- @accessor Entity -- @realm shared @@ -426,12 +429,6 @@ end -- Timer configuration handling if SERVER then - --- - -- @realm server - function ENT:OnRemove() - self:RemoveMarkerVision("c4_owner") - end - --- -- @param Player ply -- @realm server @@ -447,8 +444,6 @@ if SERVER then self:SetExplodeTime(0) self:SetArmed(false) - self:RemoveMarkerVision("c4_owner") - self.DisarmCausedExplosion = false end @@ -518,11 +513,6 @@ if SERVER then end events.Trigger(EVENT_C4PLANT, ply) - - local mvObject = self:AddMarkerVision("c4_owner") - mvObject:SetOwner(ply) - mvObject:SetVisibleFor(VISIBLE_FOR_TEAM) - mvObject:SyncToClients() end --- @@ -773,8 +763,6 @@ if SERVER then -- @realm server function GAMEMODE:TTTC4Destroyed(bomb, ply) end else -- CLIENT - local materialC4 = Material("vgui/ttt/marker_vision/c4") - local TryT = LANG.TryTranslation local ParT = LANG.GetParamTranslation @@ -883,35 +871,12 @@ else -- CLIENT tData:AddDescriptionLine(TryT("c4_short_desc")) end) - hook.Add("TTT2RenderMarkerVisionInfo", "HUDDrawMarkerVisionC4", function(mvData) - local ent = mvData:GetEntity() - local mvObject = mvData:GetMarkerVisionObject() - - if not mvObject:IsObjectFor(ent, "c4_owner") then - return - end - - local owner = ent:GetOriginator() - local nick = IsValid(owner) and owner:Nick() or "---" - - local time = util.SimpleTime(ent:GetExplodeTime() - CurTime(), "%02i:%02i") - local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1) - - mvData:EnableText() - - mvData:SetTitle(TryT(ent.PrintName)) - - mvData:AddDescriptionLine(ParT("marker_vision_owner", { owner = nick })) - mvData:AddDescriptionLine(ParT("c4_marker_vision_time", { time = time })) - mvData:AddDescriptionLine(ParT("marker_vision_distance", { distance = distance })) - - mvData:AddDescriptionLine(TryT(mvObject:GetVisibleForTranslationKey()), COLOR_SLATEGRAY) - + function ENT:GetMarkerVisionColors(mvData) local color = COLOR_WHITE - if mvData:GetEntityDistance() > ent:GetRadius() then + if mvData:GetEntityDistance() > self:GetRadius() then mvData:AddDescriptionLine(TryT("c4_marker_vision_safe_zone"), COLOR_GREEN) - elseif mvData:GetEntityDistance() > ent:GetRadiusInner() then + elseif mvData:GetEntityDistance() > self:GetRadiusInner() then mvData:AddDescriptionLine(TryT("c4_marker_vision_damage_zone"), COLOR_ORANGE) color = COLOR_ORANGE @@ -921,13 +886,24 @@ else -- CLIENT color = COLOR_RED end - mvData:AddIcon( - materialC4, - (mvData:IsOffScreen() or not mvData:IsOnScreenCenter()) and color - ) + if mvData:IsOffScreen() or not mvData:IsOnScreenCenter() or not self:GetArmed() then + color = COLOR_WHITE + end + + return { color } + end + + function ENT:CustomizeMarkerVision(mvData) + if not self:GetArmed() then + return + end + + local time = util.SimpleTime(self:GetExplodeTime() - CurTime(), "%02i:%02i") + + mvData:AddDescriptionLine(ParT("c4_marker_vision_time", { time = time })) mvData:SetCollapsedLine(time) - end) + end end --- diff --git a/gamemodes/terrortown/entities/entities/ttt_decoy.lua b/gamemodes/terrortown/entities/entities/ttt_decoy.lua index 129ba1ab28..58fd1a354b 100644 --- a/gamemodes/terrortown/entities/entities/ttt_decoy.lua +++ b/gamemodes/terrortown/entities/entities/ttt_decoy.lua @@ -19,6 +19,12 @@ ENT.CanHavePrints = false ENT.CanUseKey = true ENT.pickupWeaponClass = "weapon_ttt_decoy" +if CLIENT then + ENT.Icon = "vgui/ttt/icon_decoy" + ENT.PrintName = "decoy_name" + ENT.iconMaterial = Material("vgui/ttt/icon_decoy") +end + --- -- @realm shared function ENT:Initialize() diff --git a/gamemodes/terrortown/entities/entities/ttt_health_station.lua b/gamemodes/terrortown/entities/entities/ttt_health_station.lua index 8e488070bf..7e9c1f12b7 100644 --- a/gamemodes/terrortown/entities/entities/ttt_health_station.lua +++ b/gamemodes/terrortown/entities/entities/ttt_health_station.lua @@ -12,6 +12,7 @@ DEFINE_BASECLASS("ttt_base_placeable") if CLIENT then ENT.Icon = "vgui/ttt/icon_health" ENT.PrintName = "hstation_name" + ENT.iconMaterial = Material("vgui/ttt/icon_health") end ENT.Base = "ttt_base_placeable" diff --git a/gamemodes/terrortown/entities/entities/ttt_radio.lua b/gamemodes/terrortown/entities/entities/ttt_radio.lua index 3b8577c2a3..65e37611e7 100644 --- a/gamemodes/terrortown/entities/entities/ttt_radio.lua +++ b/gamemodes/terrortown/entities/entities/ttt_radio.lua @@ -27,6 +27,9 @@ ENT.pickupWeaponClass = "weapon_ttt_radio" ENT.SoundLimit = 5 ENT.SoundDelay = 0.5 +ENT.iconMaterial = Material("vgui/ttt/marker_vision/radio") +ENT.markerVisibility = VISIBLE_FOR_TEAM + --- -- @realm shared function ENT:Initialize() @@ -42,11 +45,6 @@ function ENT:Initialize() if SERVER then self:SetUseType(SIMPLE_USE) - - local mvObject = self:AddMarkerVision("radio_owner") - mvObject:SetOwner(self:GetOriginator()) - mvObject:SetVisibleFor(VISIBLE_FOR_TEAM) - mvObject:SyncToClients() end -- Register with owner @@ -107,9 +105,9 @@ function ENT:OnRemove() end client.radio = nil - else - self:RemoveMarkerVision("radio_owner") end + + BaseClass.OnRemove(self) end --- -- @param Sound snd @@ -341,30 +339,6 @@ if CLIENT then tData:SetKeyBinding("+use") tData:AddDescriptionLine(TryT("radio_short_desc")) end) - - hook.Add("TTT2RenderMarkerVisionInfo", "HUDDrawMarkerVisionRadio", function(mvData) - local ent = mvData:GetEntity() - local mvObject = mvData:GetMarkerVisionObject() - - if not mvObject:IsObjectFor(ent, "radio_owner") then - return - end - - local originator = ent:GetOriginator() - local nick = IsValid(originator) and originator:Nick() or "---" - - local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1) - - mvData:EnableText() - - mvData:SetTitle(TryT(ent.PrintName)) - mvData:AddIcon(materialRadio) - - mvData:AddDescriptionLine(ParT("marker_vision_owner", { owner = nick })) - mvData:AddDescriptionLine(ParT("marker_vision_distance", { distance = distance })) - - mvData:AddDescriptionLine(TryT(mvObject:GetVisibleForTranslationKey()), COLOR_SLATEGRAY) - end) end if SERVER then From b328784183cac67c4bc4cc759e011354d9943791 Mon Sep 17 00:00:00 2001 From: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:01:10 +0100 Subject: [PATCH 2/6] Improve naming conventions --- .../terrortown/entities/entities/ttt_base_placeable.lua | 8 ++++---- gamemodes/terrortown/entities/entities/ttt_beacon.lua | 2 +- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua | 4 ++-- gamemodes/terrortown/entities/entities/ttt_decoy.lua | 2 +- .../terrortown/entities/entities/ttt_health_station.lua | 2 +- gamemodes/terrortown/entities/entities/ttt_radio.lua | 4 +--- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua index 1317b6f785..6cee7dcecf 100644 --- a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua +++ b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua @@ -15,7 +15,7 @@ ENT.isDestructible = true ENT.pickupWeaponClass = nil -- MarkerVision related -ENT.iconMaterial = Material("vgui/ttt/tid/tid_big_role_not_known") +ENT.markerIconMaterial = Material("vgui/ttt/tid/tid_big_role_not_known") ENT.markerVisibility = VISIBLE_FOR_PLAYER --- @@ -420,10 +420,10 @@ if CLIENT then function ENT:CustomizeMarkerVision(mvData) end function ENT:GetMarkerVisionIcons(mvData) - return { self.iconMaterial } + return { self.markerIconMaterial } end - function ENT:GetMarkerVisionColors(mvData) + function ENT:GetMarkerVisionIconColors(mvData) return { COLOR_WHITE } end @@ -447,7 +447,7 @@ if CLIENT then mvData:SetTitle(TryT(ent.PrintName)) local icons = ent:GetMarkerVisionIcons(mvData) - local colors = ent:GetMarkerVisionColors(mvData) + local colors = ent:GetMarkerVisionIconColors(mvData) local size = math.min(#icons, #colors) for i = 1, size do diff --git a/gamemodes/terrortown/entities/entities/ttt_beacon.lua b/gamemodes/terrortown/entities/entities/ttt_beacon.lua index f320cf305c..8d0f7055f6 100644 --- a/gamemodes/terrortown/entities/entities/ttt_beacon.lua +++ b/gamemodes/terrortown/entities/entities/ttt_beacon.lua @@ -25,7 +25,7 @@ ENT.pickupWeaponClass = "weapon_ttt_beacon" ENT.timeLastBeep = CurTime() ENT.lastPlysFound = {} -ENT.iconMaterial = Material("vgui/ttt/marker_vision/beacon") +ENT.markerIconMaterial = Material("vgui/ttt/marker_vision/beacon") ENT.markerVisibility = VISIBLE_FOR_PLAYER local beaconDetectionRange = 135 diff --git a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua index f7b137b986..f5f8d0f28d 100644 --- a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua +++ b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua @@ -37,7 +37,7 @@ ENT.Avoidable = true ENT.isDestructible = false -ENT.iconMaterial = Material("vgui/ttt/marker_vision/c4") +ENT.markerIconMaterial = Material("vgui/ttt/marker_vision/c4") ENT.markerVisibility = VISIBLE_FOR_TEAM --- @@ -871,7 +871,7 @@ else -- CLIENT tData:AddDescriptionLine(TryT("c4_short_desc")) end) - function ENT:GetMarkerVisionColors(mvData) + function ENT:GetMarkerVisionIconColors(mvData) local color = COLOR_WHITE if mvData:GetEntityDistance() > self:GetRadius() then diff --git a/gamemodes/terrortown/entities/entities/ttt_decoy.lua b/gamemodes/terrortown/entities/entities/ttt_decoy.lua index 58fd1a354b..a5a6d424f5 100644 --- a/gamemodes/terrortown/entities/entities/ttt_decoy.lua +++ b/gamemodes/terrortown/entities/entities/ttt_decoy.lua @@ -22,7 +22,7 @@ ENT.pickupWeaponClass = "weapon_ttt_decoy" if CLIENT then ENT.Icon = "vgui/ttt/icon_decoy" ENT.PrintName = "decoy_name" - ENT.iconMaterial = Material("vgui/ttt/icon_decoy") + ENT.markerIconMaterial = Material("vgui/ttt/icon_decoy") end --- diff --git a/gamemodes/terrortown/entities/entities/ttt_health_station.lua b/gamemodes/terrortown/entities/entities/ttt_health_station.lua index 7e9c1f12b7..c44714dc4b 100644 --- a/gamemodes/terrortown/entities/entities/ttt_health_station.lua +++ b/gamemodes/terrortown/entities/entities/ttt_health_station.lua @@ -12,7 +12,7 @@ DEFINE_BASECLASS("ttt_base_placeable") if CLIENT then ENT.Icon = "vgui/ttt/icon_health" ENT.PrintName = "hstation_name" - ENT.iconMaterial = Material("vgui/ttt/icon_health") + ENT.markerIconMaterial = Material("vgui/ttt/icon_health") end ENT.Base = "ttt_base_placeable" diff --git a/gamemodes/terrortown/entities/entities/ttt_radio.lua b/gamemodes/terrortown/entities/entities/ttt_radio.lua index 65e37611e7..4047c15e98 100644 --- a/gamemodes/terrortown/entities/entities/ttt_radio.lua +++ b/gamemodes/terrortown/entities/entities/ttt_radio.lua @@ -27,7 +27,7 @@ ENT.pickupWeaponClass = "weapon_ttt_radio" ENT.SoundLimit = 5 ENT.SoundDelay = 0.5 -ENT.iconMaterial = Material("vgui/ttt/marker_vision/radio") +ENT.markerIconMaterial = Material("vgui/ttt/marker_vision/radio") ENT.markerVisibility = VISIBLE_FOR_TEAM --- @@ -303,8 +303,6 @@ function ENT:Think() end if CLIENT then - local materialRadio = Material("vgui/ttt/marker_vision/radio") - local TryT = LANG.TryTranslation local ParT = LANG.GetParamTranslation From c173abd88b4ca958d36690bb188c6144ee9b4433 Mon Sep 17 00:00:00 2001 From: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:14:20 +0100 Subject: [PATCH 3/6] Generalize owner --- .../terrortown/entities/entities/ttt_base_placeable.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua index 6cee7dcecf..eeded8a062 100644 --- a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua +++ b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua @@ -30,7 +30,7 @@ function ENT:Initialize() self:PrecacheGibs() local mvObject = self:AddMarkerVision("ttt_base_placeable_owner") - mvObject:SetOwner(self:GetOriginator()) + mvObject:SetOwner(self:GetMarkerOwner()) mvObject:SetVisibleFor(self.markerVisibility) mvObject:SyncToClients() end @@ -407,6 +407,10 @@ if SERVER then return true end + + function ENT:GetMarkerOwner() + return self:GetOriginator() + end end -- SERVER if CLIENT then From 438f755f172aecb9580ede9f2bf4af8123721e7b Mon Sep 17 00:00:00 2001 From: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:54:31 +0100 Subject: [PATCH 4/6] Add documentation --- .../entities/entities/ttt_base_placeable.lua | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua index eeded8a062..8fe54d6d4d 100644 --- a/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua +++ b/gamemodes/terrortown/entities/entities/ttt_base_placeable.lua @@ -408,6 +408,11 @@ if SERVER then return true end + --- + -- Gets the current markerOwner + -- @note Override if not the originator should own the marker + -- @return Player|Role The Player or role be marker owner + -- @realm server function ENT:GetMarkerOwner() return self:GetOriginator() end @@ -417,27 +422,46 @@ if CLIENT then local TryT = LANG.TryTranslation local ParT = LANG.GetParamTranslation - function ENT:ShouldDrawMarkerVision() + --- + -- Override to handle activation of marker overlay + -- @param MARKER_VISION_DATA mvData The @{MARKER_VISION_DATA} data object + -- @realm client + function ENT:ShouldDrawMarkerVision(mvData) return true end + --- + -- Override to customize markervision on drawcalls + -- @param MARKER_VISION_DATA mvData The @{MARKER_VISION_DATA} data object + -- @realm client function ENT:CustomizeMarkerVision(mvData) end + --- + -- Override if not the markerIconMaterial should be used + -- @param MARKER_VISION_DATA mvData The @{MARKER_VISION_DATA} data object + -- @return table Containing the icon Materials to show + -- @realm client function ENT:GetMarkerVisionIcons(mvData) return { self.markerIconMaterial } end + --- + -- Override if not the default color for the icons should be used + -- @param MARKER_VISION_DATA mvData The @{MARKER_VISION_DATA} data object + -- @return table Containing the icon colors to show + -- @realm client function ENT:GetMarkerVisionIconColors(mvData) return { COLOR_WHITE } end + -- Handle markervision for ttt_base_placeables hook.Add("TTT2RenderMarkerVisionInfo", "HUDDrawMarkerVisionBasePlaceable", function(mvData) local ent = mvData:GetEntity() local mvObject = mvData:GetMarkerVisionObject() if not mvObject:IsObjectFor(ent, "ttt_base_placeable_owner") - or not ent:ShouldDrawMarkerVision() + or not ent:ShouldDrawMarkerVision(mvData) then return end From dc42a070d79c913c566e92c4077c3b2e831104cf Mon Sep 17 00:00:00 2001 From: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:57:30 +0100 Subject: [PATCH 5/6] Add Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e466553b0..15c4c15cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel ### Added +- Added all entities inheriting from ttt_base_placeable to get markervision - Added migrations between TTT2-versions, some breaking changes could now be migrated instead - Added a new markerVision module that adds information to a specific point in space to replace the old C4 radar; it is currently used by these builtin weapons (by @TimGoll) - C4 From 9e3914e6767dc4ff921a129172a15624ebbe910a Mon Sep 17 00:00:00 2001 From: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:00:32 +0100 Subject: [PATCH 6/6] Add documentation to c4 --- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua index f5f8d0f28d..07819ddc8f 100644 --- a/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua +++ b/gamemodes/terrortown/entities/entities/ttt_c4/shared.lua @@ -871,6 +871,11 @@ else -- CLIENT tData:AddDescriptionLine(TryT("c4_short_desc")) end) + --- + -- Overriden to change colors with distance to armed c4 + -- @param MARKER_VISION_DATA mvData The @{MARKER_VISION_DATA} data object + -- @return table Containing the icon colors to show + -- @realm client function ENT:GetMarkerVisionIconColors(mvData) local color = COLOR_WHITE @@ -893,6 +898,10 @@ else -- CLIENT return { color } end + --- + -- Overriden to add time to marker + -- @param MARKER_VISION_DATA mvData The @{MARKER_VISION_DATA} data object + -- @realm client function ENT:CustomizeMarkerVision(mvData) if not self:GetArmed() then return