Skip to content

Commit

Permalink
Added extra ways of tile validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Feb 22, 2024
1 parent c56431f commit b856557
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CentrED/Map/LandObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void UpdateId(ushort newId)
if (Texture == null)
{
Console.WriteLine($"No texture found for land {Tile.X},{Tile.Y},{Tile.Z}:0x{newId:X}, texmap:{useTexMap}");
Valid = false;
return;
}

Expand Down
8 changes: 4 additions & 4 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ private void DrawSelectionBuffer()
for (var y = ViewRange.Top; y < ViewRange.Bottom; y++)
{
var landTile = LandTiles[x, y];
if (landTile != null && landTile.Visible)
if (landTile != null && landTile.CanDraw)
{
DrawLand(landTile, landTile.ObjectIdColor);
}
Expand All @@ -894,7 +894,7 @@ private void DrawSelectionBuffer()
if(tiles == null) continue;
foreach (var tile in tiles)
{
if (tile.Visible)
if (tile.CanDraw)
{
DrawStatic(tile, tile.ObjectIdColor);
}
Expand Down Expand Up @@ -927,7 +927,7 @@ private void DrawLand()
for (var y = ViewRange.Top; y < ViewRange.Bottom; y++)
{
var tile = LandTiles[x, y];
if (tile != null && tile.Visible)
if (tile != null && tile.CanDraw)
{
var hueOverride = Vector4.Zero;
if (WalkableSurfaces && !TileDataLoader.Instance.LandData[tile.LandTile.Id].IsWet)
Expand Down Expand Up @@ -971,7 +971,7 @@ private void DrawStatics()
if(tiles == null) continue;
foreach (var tile in tiles)
{
if (tile.Visible)
if (tile.CanDraw)
{
var hueOverride = Vector4.Zero;
if (WalkableSurfaces && TileDataLoader.Instance.StaticData[tile.Tile.Id].IsSurface)
Expand Down
5 changes: 4 additions & 1 deletion CentrED/Map/MapObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ public static int GetNextId()

public readonly int ObjectId;
public readonly Vector4 ObjectIdColor;


public bool Visible = true;
public bool Valid = true;
public bool Visible;
public bool CanDraw => Valid && Visible;
public Texture2D Texture;
public Rectangle TextureBounds;
public MapVertex[] Vertices = new MapVertex[4];
Expand Down

0 comments on commit b856557

Please sign in to comment.