Skip to content

Commit

Permalink
Option to show invisible lights
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Aug 13, 2024
1 parent 5367f07 commit e1a2f75
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CentrED/Lights/LightsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class LightsManager
public bool ColoredLights = true;
public bool AltLights = false;
public bool DarkNights = false;
public bool ShowInvisibleLights = false;
public readonly ushort VisibleLightId = 0x3EE8;
public bool ClassicUONormals = false;
public int GlobalLightLevel = 30;
public bool MaxGlobalLight => GlobalLightLevel == 30;
Expand Down
8 changes: 8 additions & 0 deletions CentrED/Map/LightObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ 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))
{
so.UpdateId(LightsManager.Instance.VisibleLightId);
}
else
{
so.UpdateId();
}
if (LightsManager.Instance.ColoredLights)
{
if (lightId > 200)
Expand Down
2 changes: 2 additions & 0 deletions CentrED/Map/StaticObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class StaticObject : TileObject
public StaticTile StaticTile;
public bool IsAnimated;
public bool IsLight;
public Rectangle RealBounds;

public StaticObject(StaticTile tile)
{
Expand Down Expand Up @@ -50,6 +51,7 @@ public void UpdateId(ushort newId)

Texture = spriteInfo.Texture;
TextureBounds = spriteInfo.UV;
RealBounds = Application.CEDGame.MapManager.Arts.GetRealArtBounds(newId);

float onePixel = Math.Max(1.0f / Texture.Width, Epsilon.value);
var texX = TextureBounds.X / (float)Texture.Width + onePixel / 2f;
Expand Down
4 changes: 4 additions & 0 deletions CentrED/UI/Windows/OptionsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ private void DrawLightOptions()
{
LightsManager.Instance.UpdateGlobalLight();
}
if(ImGui.Checkbox("Show Invisible Lights", ref LightsManager.Instance.ShowInvisibleLights))
{
CEDGame.MapManager.UpdateLights();
}
if (ImGui.Checkbox("ClassicUO Terrain Lighting", ref LightsManager.Instance.ClassicUONormals))
{
CEDGame.MapManager.Reset();
Expand Down

0 comments on commit e1a2f75

Please sign in to comment.