Skip to content

Commit

Permalink
More improvements of modifying only visible tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Apr 20, 2024
1 parent 36e6d7f commit b4e331e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ public IEnumerable<TileObject> GetTopTiles(TileObject? t1, TileObject? t2)
}
else
{
var tiles = StaticTiles[x, y]?.Where(so => IsTileVisible(so.Tile.Id));
var tiles = StaticTiles[x, y]?.Where(IsStaticVisible);
var landTile = LandTiles[x, y];
if (ShowStatics && tiles != null && tiles.Any() && !landOnly)
if (tiles != null && tiles.Any() && !landOnly)
{
yield return tiles.Last();
}
Expand Down Expand Up @@ -778,8 +778,9 @@ private bool CanDrawLand(ushort id)
return ShowNoDraw | id > 2;
}

private bool CanDrawStatic(ushort id)
private bool CanDrawStatic(StaticObject so)
{
var id = so.Tile.Id;
if (id >= TileDataLoader.Instance.StaticData.Length)
return false;

Expand Down Expand Up @@ -812,16 +813,19 @@ private bool CanDrawStatic(ushort id)
case 0x21A4: return ShowNoDraw;
}

return IsTileVisible(id);
return IsStaticVisible(so);
}

public bool IsTileVisible(ushort id)
public bool IsStaticVisible(StaticObject so)
{
if (!ShowStatics)
return false;
var id = so.Tile.Id;
if(StaticFilterEnabled)
{
return !(StaticFilterInclusive ^ StaticFilterIds.Contains(id));
}
return true;
return so.Visible;
}

private static Vector4 NonWalkableHue = HuesManager.Instance.GetRGBVector(new Color(50, 0, 0));
Expand Down Expand Up @@ -897,7 +901,7 @@ private void DrawStatic(StaticObject so, Vector4 hueOverride = default)
{
return;
}
if (!CanDrawStatic(tile.Id))
if (!CanDrawStatic(so))
return;

var landTile = LandTiles[tile.X, tile.Y];
Expand Down

0 comments on commit b4e331e

Please sign in to comment.