From ec72dab82134ccce5c3e4dfb0459fb20507cdb53 Mon Sep 17 00:00:00 2001 From: kaczy Date: Tue, 13 Aug 2024 12:20:40 +0200 Subject: [PATCH] Lights fix --- CentrED/Map/LightObject.cs | 10 ++++++---- CentrED/Map/MapManager.cs | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CentrED/Map/LightObject.cs b/CentrED/Map/LightObject.cs index f6a6ba7..c13b5e3 100644 --- a/CentrED/Map/LightObject.cs +++ b/CentrED/Map/LightObject.cs @@ -57,7 +57,7 @@ public void Update() var tiledata = TileDataLoader.Instance.StaticData[staticTile.Id]; lightId = tiledata.Layer; } - if (LightsManager.Instance.ShowInvisibleLights && (so.RealBounds.Width <= 0 || so.RealBounds.Height <= 0)) + if (LightsManager.Instance.ShowInvisibleLights && (so.RealBounds.Width < 0 || so.RealBounds.Height < 0)) { so.UpdateId(LightsManager.Instance.VisibleLightId); } @@ -108,9 +108,11 @@ public void Update() { Vertices[i].Hue = hue; } - - var posX = staticTile.X * TileObject.TILE_SIZE - so.TextureBounds.Height / 4f; - var posY = staticTile.Y * TileObject.TILE_SIZE - so.TextureBounds.Height / 4f; + + //Don't use so.TextureBounds as it can have different graphic ie. invisible light source + var tileSpriteInfo = Application.CEDGame.MapManager.Arts.GetArt(so.StaticTile.Id); + var posX = staticTile.X * TileObject.TILE_SIZE - tileSpriteInfo.UV.Height / 4f; + var posY = staticTile.Y * TileObject.TILE_SIZE - tileSpriteInfo.UV.Height / 4f; var posZ = staticTile.Z * TileObject.TILE_Z_SCALE; //Handle FlatView var sqrt2 = (float)Math.Sqrt(2); diff --git a/CentrED/Map/MapManager.cs b/CentrED/Map/MapManager.cs index 076709d..8cbd598 100644 --- a/CentrED/Map/MapManager.cs +++ b/CentrED/Map/MapManager.cs @@ -752,6 +752,7 @@ public void Reset() StaticTiles = new List[Client.Width * 8, Client.Height * 8]; GhostLandTiles.Clear(); GhostStaticTiles.Clear(); + LightTiles.Clear(); AllTiles.Clear(); ViewRange = Rectangle.Empty; Client.ResizeCache(0);