Skip to content

Commit

Permalink
Tile flag
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Oct 15, 2024
1 parent fbe438e commit aeb5089
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Robust.Shared/Map/Tile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Robust.Shared.Map;
Expand All @@ -20,6 +21,11 @@ namespace Robust.Shared.Map;
/// </summary>
public readonly TileRenderFlag Flags;

/// <summary>
/// Tile-flags for content usage.
/// </summary>
public readonly ushort ContentFlag;

/// <summary>
/// Variant of this tile to render.
/// </summary>
Expand All @@ -41,11 +47,13 @@ namespace Robust.Shared.Map;
/// <param name="typeId">Internal type ID.</param>
/// <param name="flags">Flags used by toolbox's rendering.</param>
/// <param name="variant">The visual variant this tile is using.</param>
public Tile(int typeId, TileRenderFlag flags = 0, byte variant = 0)
/// <param name="contentFlag"><see cref="ContentFlag"/></param>
public Tile(int typeId, TileRenderFlag flags = 0, byte variant = 0, ushort contentFlag = 0)
{
TypeId = typeId;
Flags = flags;
Variant = variant;
ContentFlag = contentFlag;
}

/// <summary>
Expand Down Expand Up @@ -93,7 +101,7 @@ public bool TryFormat(
/// <inheritdoc />
public bool Equals(Tile other)
{
return TypeId == other.TypeId && Flags == other.Flags && Variant == other.Variant;
return TypeId == other.TypeId && Flags == other.Flags && Variant == other.Variant && ContentFlag == other.ContentFlag;
}

/// <inheritdoc />
Expand All @@ -112,8 +120,22 @@ public override int GetHashCode()
return (TypeId.GetHashCode() * 397) ^ Flags.GetHashCode() ^ Variant.GetHashCode();
}
}

[Pure]
public Tile WithContentFlag(ushort tileContentFlag)
{
return new Tile(typeId: TypeId, flags: Flags, variant: Variant, contentFlag: tileContentFlag);
}

[Pure]
public Tile WithVariant(byte variant)
{
return new Tile(TypeId, Flags, variant, ContentFlag);
}
}

public sealed class TileFlagLayer {}

public enum TileRenderFlag : byte
{

Expand Down

0 comments on commit aeb5089

Please sign in to comment.