From aa0fdfb790198d2a5b0e7453bace4d7281376971 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 11 Jan 2018 13:22:04 +0200 Subject: [PATCH] All highlighted items are rendered to the lightmap, not just the ones the player is focusing on. -> Highlighted wires and the items they are connected to now glow in the dark. Fixed LightComponent light source position not being updated if the item has no body, causing the light source to appear in a wrong position when attaching lights to walls. --- .../Source/Map/Lights/LightManager.cs | 12 +++++++++--- .../Source/Map/Lights/LightSource.cs | 2 +- .../Items/Components/Signal/LightComponent.cs | 17 ++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs index 4d230f621..0cd602cac 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs @@ -209,14 +209,20 @@ namespace Barotrauma.Lights if (Character.Controlled.FocusedItem != null) { Character.Controlled.FocusedItem.IsHighlighted = true; - Character.Controlled.FocusedItem.Draw(spriteBatch, false, true); - Character.Controlled.FocusedItem.IsHighlighted = true; } - else if (Character.Controlled.FocusedCharacter != null) + if (Character.Controlled.FocusedCharacter != null) { Character.Controlled.FocusedCharacter.Draw(spriteBatch); } + foreach (Item item in Item.ItemList) + { + if (item.IsHighlighted) + { + item.Draw(spriteBatch, false, true); + } + } + Vector2 drawPos = Character.Controlled.DrawPosition; drawPos.Y = -drawPos.Y; diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs index 824649cd8..07bd5dd0a 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs @@ -63,7 +63,7 @@ namespace Barotrauma.Lights if (position == value) return; position = value; - if (Vector2.Distance(prevCalculatedPosition, position) < 5.0f) return; + if (Vector2.DistanceSquared(prevCalculatedPosition, position) < 5.0f * 5.0f) return; NeedsHullCheck = true; NeedsRecalculation = true; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs index 9bef9f2a4..3ae29c3e9 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs @@ -128,20 +128,17 @@ namespace Barotrauma.Items.Components #if CLIENT light.ParentSub = item.Submarine; -#endif - -#if CLIENT if (item.Container != null) { light.Color = Color.Transparent; return; } + light.Position = item.Position; #endif if (item.body != null) { #if CLIENT - light.Position = item.Position; light.Rotation = item.body.Dir > 0.0f ? item.body.Rotation : item.body.Rotation - MathHelper.Pi; #endif if (!item.body.Enabled) @@ -181,19 +178,17 @@ namespace Barotrauma.Items.Components voltage = 0.0f; } - - public override bool Use(float deltaTime, Character character = null) - { - return true; - } +#if CLIENT protected override void RemoveComponentSpecific() { base.RemoveComponentSpecific(); - -#if CLIENT light.Remove(); + } #endif + public override bool Use(float deltaTime, Character character = null) + { + return true; } public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f)