Struct Tile
Represents a two-character tile on the map. Each tile consists of a left and right character.
Inherited Members
Namespace: ExplorerGame.Core
Assembly: explorer-game.dll
Syntax
public struct Tile
Constructors
| Edit this page View SourceTile(char, char)
Initializes a new Tile with the specified left and right characters.
Declaration
public Tile(char left, char right)
Parameters
| Type | Name | Description |
|---|---|---|
| char | left | The left character. |
| char | right | The right character. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when either character is not allowed. |
Tile(string)
Creates a tile from a 2-character string. Throws if string length is not exactly 2.
Declaration
public Tile(string str)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str |
Properties
| Edit this page View SourceLeft
Gets or sets the left character of the two-character tile.
Declaration
public char Left { get; set; }
Property Value
| Type | Description |
|---|---|
| char |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the value is not an allowed character. |
Right
Gets or sets the right character of the two-character tile.
Declaration
public char Right { get; set; }
Property Value
| Type | Description |
|---|---|
| char |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the value is not an allowed character. |
Methods
| Edit this page View SourceDeserialize(JObject?)
Deserializes a Tile from a Newtonsoft.Json.Linq.JObject.
Declaration
public static Tile? Deserialize(JObject? jobj)
Parameters
| Type | Name | Description |
|---|---|---|
| JObject | jobj | The JSON object to read from, or |
Returns
| Type | Description |
|---|---|
| Tile? | The deserialized tile, or |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the JSON object does not contain the required |
Equals(object?)
Determines whether this instance and a specified object, which must also be a Tile, have the same left and right characters.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
| Edit this page View SourceGetHashCode()
Returns a hash code for this tile.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer hash code. |
Overrides
| Edit this page View SourceSerialize(Tile?)
Serializes a nullable Tile to a Newtonsoft.Json.Linq.JObject.
Declaration
public static JObject? Serialize(Tile? tile)
Parameters
| Type | Name | Description |
|---|---|---|
| Tile? | tile | The tile to serialize, or |
Returns
| Type | Description |
|---|---|
| JObject | A Newtonsoft.Json.Linq.JObject with the tile data, or |
ToString()
Returns the two-character string that represents this tile.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A two-character string. |
Overrides
Operators
| Edit this page View Sourceoperator ==(Tile, Tile)
Determines whether two tiles are the same.
Declaration
public static bool operator ==(Tile a, Tile b)
Parameters
| Type | Name | Description |
|---|---|---|
| Tile | a | The first tile. |
| Tile | b | The second tile. |
Returns
| Type | Description |
|---|---|
| bool |
|
implicit operator Tile(string)
Implicit conversion from string to tile. Allows easy construction from string literals.
Declaration
public static implicit operator Tile(string str)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str |
Returns
| Type | Description |
|---|---|
| Tile |
operator !=(Tile, Tile)
Determines whether two tiles differ.
Declaration
public static bool operator !=(Tile a, Tile b)
Parameters
| Type | Name | Description |
|---|---|---|
| Tile | a | The first tile. |
| Tile | b | The second tile. |
Returns
| Type | Description |
|---|---|
| bool |
|