From f5bc24f6bd18d1f50ba67321c8e7a932ec20b090 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 11:41:15 -0800 Subject: [PATCH 01/22] Fixes copy/paste error. --- ParquetClassLibrary/Rooms/MapSpace.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ParquetClassLibrary/Rooms/MapSpace.cs b/ParquetClassLibrary/Rooms/MapSpace.cs index 034b112e..6a35f466 100644 --- a/ParquetClassLibrary/Rooms/MapSpace.cs +++ b/ParquetClassLibrary/Rooms/MapSpace.cs @@ -185,8 +185,8 @@ public bool Equals(MapSpace inSpace) /// The to compare with the current . /// true if the specified is equal to the current ; otherwise, false. public override bool Equals(object obj) - => obj is MapSpace vector - && Equals(vector); + => obj is MapSpace space + && Equals(space); /// /// Determines whether a specified instance of is equal to From d0b1040ce8b9d46a87bf4a7efe9151e562e2f9a9 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 11:44:29 -0800 Subject: [PATCH 02/22] Renames Vector2D to Point2D. This follows the convention of System.Drawing and MonoGame while avoiding name collisions due to the "2D" suffix. Also, it's arguably more accurate. --- ParquetClassLibrary/All.cs | 2 +- ParquetClassLibrary/Crafts/StrikePanel.cs | 2 +- ParquetClassLibrary/Crafts/StrikePanelGrid.cs | 2 +- ParquetClassLibrary/Delimiters.cs | 2 +- ParquetClassLibrary/Location.cs | 8 +- ParquetClassLibrary/ModelID.cs | 2 +- ParquetClassLibrary/ModelIDGrid.cs | 2 +- ParquetClassLibrary/Pack.cs | 2 +- .../Parquets/ParquetModelPackGrid.cs | 6 +- .../Parquets/ParquetStatusPackGrid.cs | 2 +- ParquetClassLibrary/Point2D.cs | 205 +++++++++++++++++ ParquetClassLibrary/PublicAPI.Unshipped.txt | 94 ++++---- ParquetClassLibrary/Regions/MapChunk.cs | 4 +- ParquetClassLibrary/Regions/MapChunkGrid.cs | 2 +- ParquetClassLibrary/Regions/RegionModel.cs | 2 +- ParquetClassLibrary/Regions/RegionStatus.cs | 6 +- ParquetClassLibrary/Rooms/MapSpace.cs | 18 +- .../Rooms/MapSpaceSetExtensions.cs | 14 +- .../Rooms/ReadOnlyRoomCollectionExtensions.cs | 2 +- ParquetClassLibrary/Rooms/Room.cs | 6 +- ParquetClassLibrary/Status.cs | 2 +- ParquetClassLibrary/Vector2D.cs | 206 ------------------ ParquetUnitTests/ITypeConverterTest.cs | 2 +- ParquetUnitTests/Parquets/MapSpaceUnitTest.cs | 28 +-- ParquetUnitTests/Point2DUnitTest.cs | 67 ++++++ .../Rooms/RoomCollectionUnitTest.cs | 12 +- ParquetUnitTests/Rooms/RoomUnitTest.cs | 2 +- ParquetUnitTests/Vector2DUnitTest.cs | 67 ------ 28 files changed, 384 insertions(+), 385 deletions(-) create mode 100644 ParquetClassLibrary/Point2D.cs delete mode 100644 ParquetClassLibrary/Vector2D.cs create mode 100644 ParquetUnitTests/Point2DUnitTest.cs delete mode 100644 ParquetUnitTests/Vector2DUnitTest.cs diff --git a/ParquetClassLibrary/All.cs b/ParquetClassLibrary/All.cs index 8632fc53..2562a2ea 100644 --- a/ParquetClassLibrary/All.cs +++ b/ParquetClassLibrary/All.cs @@ -440,7 +440,7 @@ static All() { typeof(RecipeElement), RecipeElement.ConverterFactory }, { typeof(ScriptNode), ScriptNode.ConverterFactory }, { typeof(StrikePanel), StrikePanel.ConverterFactory }, - { typeof(Vector2D), Vector2D.ConverterFactory }, + { typeof(Point2D), Point2D.ConverterFactory }, #endregion #region Linear Series Types diff --git a/ParquetClassLibrary/Crafts/StrikePanel.cs b/ParquetClassLibrary/Crafts/StrikePanel.cs index fcbc622f..b1132aad 100644 --- a/ParquetClassLibrary/Crafts/StrikePanel.cs +++ b/ParquetClassLibrary/Crafts/StrikePanel.cs @@ -236,7 +236,7 @@ public static class StrikePanelArrayExtensions /// The to check against. /// The position to validate. /// true, if the position is valid, false otherwise. - public static bool IsValidPosition(this StrikePanel[,] inStrikePanels, Vector2D inPosition) + public static bool IsValidPosition(this StrikePanel[,] inStrikePanels, Point2D inPosition) => inStrikePanels is not null && inPosition.X > -1 && inPosition.Y > -1 diff --git a/ParquetClassLibrary/Crafts/StrikePanelGrid.cs b/ParquetClassLibrary/Crafts/StrikePanelGrid.cs index d95f8054..66feb601 100644 --- a/ParquetClassLibrary/Crafts/StrikePanelGrid.cs +++ b/ParquetClassLibrary/Crafts/StrikePanelGrid.cs @@ -158,7 +158,7 @@ IReadOnlyGrid IDeeplyCloneable>.DeepClon /// /// The position to validate. /// true, if the position is valid, false otherwise. - public bool IsValidPosition(Vector2D inPosition) + public bool IsValidPosition(Point2D inPosition) => StrikePanels.IsValidPosition(inPosition); #endregion } diff --git a/ParquetClassLibrary/Delimiters.cs b/ParquetClassLibrary/Delimiters.cs index 8cd5bd6a..64db6941 100644 --- a/ParquetClassLibrary/Delimiters.cs +++ b/ParquetClassLibrary/Delimiters.cs @@ -14,7 +14,7 @@ public static class Delimiters /// Separator for encoding the dimensions of implementations. public const string DimensionalTerminator = "≡"; - /// Separates primitives within serialized s and s. + /// Separates primitives within serialized s and s. public const string ElementDelimiter = "–"; /// Separates properties within a class when in serialization. diff --git a/ParquetClassLibrary/Location.cs b/ParquetClassLibrary/Location.cs index 505629f7..b593b65a 100644 --- a/ParquetClassLibrary/Location.cs +++ b/ParquetClassLibrary/Location.cs @@ -27,7 +27,7 @@ sealed public class Location : Status public ModelID RegionID { get; } /// The position within the current of the tracked . - public Vector2D Position { get; } + public Point2D Position { get; } #endregion #region Initialization @@ -36,10 +36,10 @@ sealed public class Location : Status /// /// The identifier for the in which the tracked is located. /// The position within the current of the tracked . - public Location(ModelID? inRegionID = null, Vector2D? inPosition = null) + public Location(ModelID? inRegionID = null, Point2D? inPosition = null) { RegionID = inRegionID ?? ModelID.None; - Position = inPosition ?? Vector2D.Zero; + Position = inPosition ?? Point2D.Origin; } #endregion @@ -126,7 +126,7 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member var parameterText = inText.Split(Delimiters.InternalDelimiter); var parsedRegionID = (ModelID)ModelID.ConverterFactory.ConvertFromString(parameterText[0], inRow, inMemberMapData); - var parsedPosition = (Vector2D)Vector2D.ConverterFactory.ConvertFromString(parameterText[1], inRow, inMemberMapData); + var parsedPosition = (Point2D)Point2D.ConverterFactory.ConvertFromString(parameterText[1], inRow, inMemberMapData); return new Location(parsedRegionID, parsedPosition); } diff --git a/ParquetClassLibrary/ModelID.cs b/ParquetClassLibrary/ModelID.cs index c4a4d282..df945b2a 100644 --- a/ParquetClassLibrary/ModelID.cs +++ b/ParquetClassLibrary/ModelID.cs @@ -330,7 +330,7 @@ internal static class ModelIDArrayExtensions /// The array to validate against. /// The position to validate. /// true, if the position is valid, false otherwise. - public static bool IsValidPosition(this ModelID[,] inIDArray, Vector2D inPosition) + public static bool IsValidPosition(this ModelID[,] inIDArray, Point2D inPosition) => inPosition.X > -1 && inPosition.Y > -1 && inPosition.X < inIDArray.GetLength(1) diff --git a/ParquetClassLibrary/ModelIDGrid.cs b/ParquetClassLibrary/ModelIDGrid.cs index f887a3d8..509f34df 100644 --- a/ParquetClassLibrary/ModelIDGrid.cs +++ b/ParquetClassLibrary/ModelIDGrid.cs @@ -126,7 +126,7 @@ IReadOnlyGrid IDeeplyCloneable>.DeepClone() /// /// The position to validate. /// true, if the position is valid, false otherwise. - public bool IsValidPosition(Vector2D inPosition) + public bool IsValidPosition(Point2D inPosition) => IDs.IsValidPosition(inPosition); #endregion } diff --git a/ParquetClassLibrary/Pack.cs b/ParquetClassLibrary/Pack.cs index 17f55ddf..487467ac 100644 --- a/ParquetClassLibrary/Pack.cs +++ b/ParquetClassLibrary/Pack.cs @@ -96,7 +96,7 @@ public static class PackArrayExtensions /// The array to validate against. /// The position to validate. /// true, if the position is valid, false otherwise. - public static bool IsValidPosition(this Pack[,] inArray, Vector2D inPosition) + public static bool IsValidPosition(this Pack[,] inArray, Point2D inPosition) => inArray is not null && inPosition.X > -1 && inPosition.Y > -1 diff --git a/ParquetClassLibrary/Parquets/ParquetModelPackGrid.cs b/ParquetClassLibrary/Parquets/ParquetModelPackGrid.cs index 27af108b..6be8c4a7 100644 --- a/ParquetClassLibrary/Parquets/ParquetModelPackGrid.cs +++ b/ParquetClassLibrary/Parquets/ParquetModelPackGrid.cs @@ -67,7 +67,7 @@ public ParquetModelPackGrid(ParquetModelPack[,] inParquetPackArray) /// /// The entire map as a subgrid. public IReadOnlyGrid GetSubgrid() - => GetSubgrid(Vector2D.Zero, new Vector2D(ParquetPacks.GetLength(1) - 1, ParquetPacks.GetLength(0) - 1)); + => GetSubgrid(Point2D.Origin, new Point2D(ParquetPacks.GetLength(1) - 1, ParquetPacks.GetLength(0) - 1)); /// /// Provides all parquet definitions within the specified rectangular subsection of the current grid. @@ -76,7 +76,7 @@ public IReadOnlyGrid GetSubgrid() /// The position of the lower-rightmost corner of the subgrid. /// A portion of the grid. /// If the coordinates given are not well-formed, the subgrid returned will be invalid. - public IReadOnlyGrid GetSubgrid(Vector2D inUpperLeft, Vector2D inLowerRight) + public IReadOnlyGrid GetSubgrid(Point2D inUpperLeft, Point2D inLowerRight) { if (!ParquetPacks.IsValidPosition(inUpperLeft)) { @@ -202,7 +202,7 @@ IReadOnlyGrid IDeeplyCloneable /// /// The position to validate. /// true, if the position is valid, false otherwise. - public bool IsValidPosition(Vector2D inPosition) + public bool IsValidPosition(Point2D inPosition) => ParquetPacks.IsValidPosition(inPosition); #endregion } diff --git a/ParquetClassLibrary/Parquets/ParquetStatusPackGrid.cs b/ParquetClassLibrary/Parquets/ParquetStatusPackGrid.cs index 4867f716..a74695bf 100644 --- a/ParquetClassLibrary/Parquets/ParquetStatusPackGrid.cs +++ b/ParquetClassLibrary/Parquets/ParquetStatusPackGrid.cs @@ -147,7 +147,7 @@ IReadOnlyGrid IDeeplyCloneable /// The position to validate. /// true, if the position is valid, false otherwise. - public bool IsValidPosition(Vector2D inPosition) + public bool IsValidPosition(Point2D inPosition) => ParquetStatuses.IsValidPosition(inPosition); #endregion } diff --git a/ParquetClassLibrary/Point2D.cs b/ParquetClassLibrary/Point2D.cs new file mode 100644 index 00000000..ba28c2a1 --- /dev/null +++ b/ParquetClassLibrary/Point2D.cs @@ -0,0 +1,205 @@ +using System; +using System.Globalization; +using CsvHelper; +using CsvHelper.Configuration; +using CsvHelper.TypeConversion; + +namespace Parquet +{ + /// + /// A simple representation of two coordinate integers, tailored for Parquet's needs. + /// + public readonly struct Point2D : IEquatable, ITypeConverter + { + #region Class Defaults + /// The zero point. + public static readonly Point2D Origin = new Point2D(0, 0); + + /// The point equivalent to the unit vector. + public static readonly Point2D Unit = new Point2D(1, 1); + + /// The point offset to the North. + public static readonly Point2D North = new Point2D(0, -1); + + /// The point offset to the South. + public static readonly Point2D South = new Point2D(0, 1); + + /// The point offset to the East. + public static readonly Point2D East = new Point2D(1, 0); + + /// The point offset to the West. + public static readonly Point2D West = new Point2D(-1, 0); + #endregion + + #region Characteristics + /// Location along the x axis. + public int X { get; } + + /// Location along the y axis. + public int Y { get; } + + /// Treats the point as a vector, providing its magnitude as an integer, rounded-down. + public int Magnitude { get; } + #endregion + + #region Initialization + /// + /// Initializes a new instance of the struct. + /// + /// The X coordinate. + /// The Y coordinate. + public Point2D(int inX, int inY) + { + X = inX; + Y = inY; + Magnitude = Convert.ToInt32(Math.Floor(Math.Sqrt((X * X) + (Y * Y)))); + } + + /// + /// Initializes a new instance of the struct. + /// + /// The coordinates. + public Point2D((int X, int Y) inCoordinates) + : this(inCoordinates.X, inCoordinates.Y) + { } + #endregion + + #region Math + /// + /// Sums the given points as if they were vectors. + /// + /// First operand. + /// Second operand. + /// A point representing the sum of the given points. + public static Point2D operator +(Point2D inPoint1, Point2D inPoint2) + => new Point2D(inPoint1.X + inPoint2.X, inPoint1.Y + inPoint2.Y); + + /// + /// Finds the difference between the given points as if they were points. + /// + /// First operand. + /// Second operand. + /// A point representing the difference of the given points. + public static Point2D operator -(Point2D inPoint1, Point2D inPoint2) + => new Point2D(inPoint1.X - inPoint2.X, inPoint1.Y - inPoint2.Y); + + /// + /// Scales a the point. + /// + /// The scale factor. + /// The point. + /// A point representing the scaled point. + public static Point2D operator *(int inScalar, Point2D inPoint) + => new Point2D(inScalar * inPoint.X, inScalar * inPoint.Y); + #endregion + + #region IEquatable Implementation + /// + /// Serves as a hash function for a struct. + /// + /// A hash code for this instance that is suitable for use in hashing algorithms and data structures. + public override int GetHashCode() + => (X, Y).GetHashCode(); + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current. + /// true if the s are equal. + public bool Equals(Point2D inPoint) + => X == inPoint.X + && Y == inPoint.Y; + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + => obj is Point2D point + && Equals(point); + + /// + /// Determines whether a specified instance of is equal to + /// another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if the two operands are equal; otherwise, false. + public static bool operator ==(Point2D inPoint1, Point2D inPoint2) + => inPoint1.Equals(inPoint2); + + /// + /// Determines whether a specified instance of is not equal + /// to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if the two operands are NOT equal; otherwise, false. + public static bool operator !=(Point2D inPoint1, Point2D inPoint2) + => !inPoint1.Equals(inPoint2); + #endregion + + #region ITypeConverter Implementation + /// Allows the converter to construct itself statically. + internal static Point2D ConverterFactory { get; } = Origin; + + /// + /// Converts the given to a for serialization. + /// + /// The instance to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance serialized. + public string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) + => inValue is Point2D point + ? $"{point.X}{Delimiters.ElementDelimiter}" + + $"{point.Y}" + : Logger.DefaultWithConvertLog(inValue?.ToString() ?? "null", nameof(Point2D), nameof(Origin)); + + /// + /// Converts the given to an as deserialization. + /// + /// The text to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance deserialized. + public object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) + { + if (string.IsNullOrEmpty(inText) + || string.Compare(nameof(Origin), inText, StringComparison.OrdinalIgnoreCase) == 0) + { + return Origin; + } + + var parameterText = inText.Split(Delimiters.ElementDelimiter); + + var x = int.TryParse(parameterText[0], All.SerializedNumberStyle, CultureInfo.InvariantCulture, out var temp1) + ? temp1 + : Logger.DefaultWithParseLog(parameterText[0], nameof(X), Origin.X); + var y = int.TryParse(parameterText[1], All.SerializedNumberStyle, CultureInfo.InvariantCulture, out var temp2) + ? temp2 + : Logger.DefaultWithParseLog(parameterText[1], nameof(Y), Origin.Y); + + return new Point2D(x, y); + } + #endregion + + #region Utilities + /// + /// Deconstructs the current into its constituent coordinates. + /// + /// The X coordinate. + /// The Y coordinate. + public void Deconstruct(out int outX, out int outY) + => (outX, outY) = (X, Y); + + /// + /// Returns a that represents the current . + /// + /// The representation. + public override string ToString() + => $"({X}, {Y})"; + #endregion + } +} diff --git a/ParquetClassLibrary/PublicAPI.Unshipped.txt b/ParquetClassLibrary/PublicAPI.Unshipped.txt index 5d62373c..b569037d 100644 --- a/ParquetClassLibrary/PublicAPI.Unshipped.txt +++ b/ParquetClassLibrary/PublicAPI.Unshipped.txt @@ -129,6 +129,9 @@ override Parquet.Parquets.ParquetStatusPack.Equals(object obj) -> bool override Parquet.Parquets.ParquetStatusPack.Equals(T inPack) -> bool override Parquet.Parquets.ParquetStatusPack.GetHashCode() -> int override Parquet.Parquets.ParquetStatusPack.ToString() -> string +override Parquet.Point2D.Equals(object obj) -> bool +override Parquet.Point2D.GetHashCode() -> int +override Parquet.Point2D.ToString() -> string override Parquet.Range.Equals(object obj) -> bool override Parquet.Range.GetHashCode() -> int override Parquet.Range.ToString() -> string @@ -164,9 +167,6 @@ override Parquet.Scripts.ScriptStatus.GetHashCode() -> int override Parquet.Scripts.ScriptStatus.ToString() -> string override Parquet.SeriesConverter.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object override Parquet.SeriesConverter.ConvertToString(object inCollection, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string -override Parquet.Vector2D.Equals(object obj) -> bool -override Parquet.Vector2D.GetHashCode() -> int -override Parquet.Vector2D.ToString() -> string Parquet.All Parquet.AssemblyInfo Parquet.AssemblyInfo.AssemblyInfo() -> void @@ -304,7 +304,7 @@ Parquet.Crafts.StrikePanelGrid.Count.get -> int Parquet.Crafts.StrikePanelGrid.DeepClone() -> Parquet.IGrid Parquet.Crafts.StrikePanelGrid.GetEnumerator() -> System.Collections.IEnumerator Parquet.Crafts.StrikePanelGrid.GridDelimiter.get -> string -Parquet.Crafts.StrikePanelGrid.IsValidPosition(Parquet.Vector2D inPosition) -> bool +Parquet.Crafts.StrikePanelGrid.IsValidPosition(Parquet.Point2D inPosition) -> bool Parquet.Crafts.StrikePanelGrid.Rows.get -> int Parquet.Crafts.StrikePanelGrid.StrikePanelGrid() -> void Parquet.Crafts.StrikePanelGrid.StrikePanelGrid(int inRowCount, int inColumnCount) -> void @@ -446,8 +446,8 @@ Parquet.Items.ModificationTool.None = 0 -> Parquet.Items.ModificationTool Parquet.Items.ModificationTool.Shovel = 1 -> Parquet.Items.ModificationTool Parquet.LibraryState Parquet.Location -Parquet.Location.Location(Parquet.ModelID? inRegionID = null, Parquet.Vector2D? inPosition = null) -> void -Parquet.Location.Position.get -> Parquet.Vector2D +Parquet.Location.Location(Parquet.ModelID? inRegionID = null, Parquet.Point2D? inPosition = null) -> void +Parquet.Location.Position.get -> Parquet.Point2D Parquet.Location.RegionID.get -> Parquet.ModelID Parquet.Logger Parquet.LogLevel @@ -491,7 +491,7 @@ Parquet.ModelIDGrid.Count.get -> int Parquet.ModelIDGrid.DeepClone() -> Parquet.IGrid Parquet.ModelIDGrid.GetEnumerator() -> System.Collections.IEnumerator Parquet.ModelIDGrid.GridDelimiter.get -> string -Parquet.ModelIDGrid.IsValidPosition(Parquet.Vector2D inPosition) -> bool +Parquet.ModelIDGrid.IsValidPosition(Parquet.Point2D inPosition) -> bool Parquet.ModelIDGrid.ModelIDGrid() -> void Parquet.ModelIDGrid.ModelIDGrid(int inRowCount, int inColumnCount) -> void Parquet.ModelIDGrid.Rows.get -> int @@ -617,9 +617,9 @@ Parquet.Parquets.ParquetModelPackGrid.Count.get -> int Parquet.Parquets.ParquetModelPackGrid.DeepClone() -> Parquet.IGrid Parquet.Parquets.ParquetModelPackGrid.GetEnumerator() -> System.Collections.IEnumerator Parquet.Parquets.ParquetModelPackGrid.GetSubgrid() -> Parquet.IReadOnlyGrid -Parquet.Parquets.ParquetModelPackGrid.GetSubgrid(Parquet.Vector2D inUpperLeft, Parquet.Vector2D inLowerRight) -> Parquet.IReadOnlyGrid +Parquet.Parquets.ParquetModelPackGrid.GetSubgrid(Parquet.Point2D inUpperLeft, Parquet.Point2D inLowerRight) -> Parquet.IReadOnlyGrid Parquet.Parquets.ParquetModelPackGrid.GridDelimiter.get -> string -Parquet.Parquets.ParquetModelPackGrid.IsValidPosition(Parquet.Vector2D inPosition) -> bool +Parquet.Parquets.ParquetModelPackGrid.IsValidPosition(Parquet.Point2D inPosition) -> bool Parquet.Parquets.ParquetModelPackGrid.ParquetModelPackGrid() -> void Parquet.Parquets.ParquetModelPackGrid.ParquetModelPackGrid(int inRowCount, int inColumnCount) -> void Parquet.Parquets.ParquetModelPackGrid.ParquetModelPackGrid(Parquet.Parquets.ParquetModelPack[,] inParquetPackArray) -> void @@ -641,12 +641,23 @@ Parquet.Parquets.ParquetStatusPackGrid.Count.get -> int Parquet.Parquets.ParquetStatusPackGrid.DeepClone() -> Parquet.IGrid Parquet.Parquets.ParquetStatusPackGrid.GetEnumerator() -> System.Collections.IEnumerator Parquet.Parquets.ParquetStatusPackGrid.GridDelimiter.get -> string -Parquet.Parquets.ParquetStatusPackGrid.IsValidPosition(Parquet.Vector2D inPosition) -> bool +Parquet.Parquets.ParquetStatusPackGrid.IsValidPosition(Parquet.Point2D inPosition) -> bool Parquet.Parquets.ParquetStatusPackGrid.ParquetStatusPackGrid() -> void Parquet.Parquets.ParquetStatusPackGrid.ParquetStatusPackGrid(int inRowCount, int inColumnCount) -> void Parquet.Parquets.ParquetStatusPackGrid.ParquetStatusPackGrid(Parquet.Parquets.ParquetModelPackGrid inParquetModelPackGrid) -> void Parquet.Parquets.ParquetStatusPackGrid.Rows.get -> int Parquet.Parquets.ParquetStatusPackGrid.this[int y, int x].get -> Parquet.Parquets.ParquetStatusPack +Parquet.Point2D +Parquet.Point2D.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object +Parquet.Point2D.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string +Parquet.Point2D.Deconstruct(out int outX, out int outY) -> void +Parquet.Point2D.Equals(Parquet.Point2D inPoint) -> bool +Parquet.Point2D.Magnitude.get -> int +Parquet.Point2D.Point2D((int X, int Y) inCoordinates) -> void +Parquet.Point2D.Point2D() -> void +Parquet.Point2D.Point2D(int inX, int inY) -> void +Parquet.Point2D.X.get -> int +Parquet.Point2D.Y.get -> int Parquet.Precondition Parquet.Range Parquet.Range.ContainsRange(Parquet.Range inRange) -> bool @@ -702,7 +713,7 @@ Parquet.Regions.MapChunk.Count.get -> int Parquet.Regions.MapChunk.DeepClone() -> Parquet.Regions.MapChunk Parquet.Regions.MapChunk.Details.get -> Parquet.Regions.ChunkDetail Parquet.Regions.MapChunk.Details.set -> void -Parquet.Regions.MapChunk.DimensionsInParquets.get -> Parquet.Vector2D +Parquet.Regions.MapChunk.DimensionsInParquets.get -> Parquet.Point2D Parquet.Regions.MapChunk.Equals(Parquet.Regions.MapChunk inChunk) -> bool Parquet.Regions.MapChunk.Generate() -> Parquet.Regions.MapChunk Parquet.Regions.MapChunk.IsFilledOut.get -> bool @@ -717,7 +728,7 @@ Parquet.Regions.MapChunkGrid.Count.get -> int Parquet.Regions.MapChunkGrid.DeepClone() -> Parquet.IGrid Parquet.Regions.MapChunkGrid.GetEnumerator() -> System.Collections.IEnumerator Parquet.Regions.MapChunkGrid.GridDelimiter.get -> string -Parquet.Regions.MapChunkGrid.IsValidPosition(Parquet.Vector2D inPosition) -> bool +Parquet.Regions.MapChunkGrid.IsValidPosition(Parquet.Point2D inPosition) -> bool Parquet.Regions.MapChunkGrid.MapChunkGrid() -> void Parquet.Regions.MapChunkGrid.MapChunkGrid(int inRowCount, int inColumnCount) -> void Parquet.Regions.MapChunkGrid.MapChunkGrid(Parquet.Regions.MapChunk[,] inMapChunkArray) -> void @@ -736,7 +747,7 @@ Parquet.Regions.RegionModel.RegionToTheSouth.get -> Parquet.ModelID Parquet.Regions.RegionModel.RegionToTheWest.get -> Parquet.ModelID Parquet.Regions.RegionStatus Parquet.Regions.RegionStatus.GetBiome() -> Parquet.ModelID -Parquet.Regions.RegionStatus.IsValidPosition(Parquet.Vector2D inPosition) -> bool +Parquet.Regions.RegionStatus.IsValidPosition(Parquet.Point2D inPosition) -> bool Parquet.Regions.RegionStatus.ParquetModels.get -> Parquet.Parquets.ParquetModelPackGrid Parquet.Regions.RegionStatus.ParquetStatuses.get -> Parquet.Parquets.ParquetStatusPackGrid Parquet.Regions.RegionStatus.RegionStatus() -> void @@ -758,21 +769,21 @@ Parquet.Rooms.MapSpace.Grid.get -> Parquet.Parquets.ParquetModelPackGrid Parquet.Rooms.MapSpace.IsEmpty.get -> bool Parquet.Rooms.MapSpace.IsEnclosing.get -> bool Parquet.Rooms.MapSpace.MapSpace(int inX, int inY, Parquet.Parquets.ParquetModelPack inContent, Parquet.Parquets.ParquetModelPackGrid inGrid) -> void -Parquet.Rooms.MapSpace.MapSpace(Parquet.Vector2D inPosition, Parquet.Parquets.ParquetModelPack inContent, Parquet.Parquets.ParquetModelPackGrid inGrid) -> void -Parquet.Rooms.MapSpace.Neighbor(Parquet.Vector2D inOffset) -> Parquet.Rooms.MapSpace +Parquet.Rooms.MapSpace.MapSpace(Parquet.Point2D inPosition, Parquet.Parquets.ParquetModelPack inContent, Parquet.Parquets.ParquetModelPackGrid inGrid) -> void +Parquet.Rooms.MapSpace.Neighbor(Parquet.Point2D inOffset) -> Parquet.Rooms.MapSpace Parquet.Rooms.MapSpace.Neighbors() -> System.Collections.Generic.IReadOnlyList Parquet.Rooms.MapSpace.NorthNeighbor() -> Parquet.Rooms.MapSpace -Parquet.Rooms.MapSpace.Position.get -> Parquet.Vector2D +Parquet.Rooms.MapSpace.Position.get -> Parquet.Point2D Parquet.Rooms.MapSpace.SouthNeighbor() -> Parquet.Rooms.MapSpace Parquet.Rooms.MapSpace.WestNeighbor() -> Parquet.Rooms.MapSpace Parquet.Rooms.MapSpaceSetExtensions Parquet.Rooms.ReadOnlyRoomCollectionExtensions Parquet.Rooms.Room -Parquet.Rooms.Room.ContainsPosition(Parquet.Vector2D inPosition) -> bool +Parquet.Rooms.Room.ContainsPosition(Parquet.Point2D inPosition) -> bool Parquet.Rooms.Room.Equals(Parquet.Rooms.Room inRoom) -> bool Parquet.Rooms.Room.FurnishingTags.get -> System.Collections.Generic.IEnumerable Parquet.Rooms.Room.Perimeter.get -> System.Collections.Generic.IReadOnlySet -Parquet.Rooms.Room.Position.get -> Parquet.Vector2D +Parquet.Rooms.Room.Position.get -> Parquet.Point2D Parquet.Rooms.Room.RecipeID.get -> Parquet.ModelID Parquet.Rooms.Room.Room(System.Collections.Generic.IReadOnlySet inWalkableArea, System.Collections.Generic.IReadOnlySet inPerimeter) -> void Parquet.Rooms.Room.WalkableArea.get -> System.Collections.Generic.IReadOnlySet @@ -827,17 +838,6 @@ Parquet.Status.DeepClone() -> Parquet.Status Parquet.Status.Equals(Parquet.Status inStatus) -> bool Parquet.Status.Status() -> void Parquet.StatusArrayExtensions -Parquet.Vector2D -Parquet.Vector2D.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object -Parquet.Vector2D.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string -Parquet.Vector2D.Deconstruct(out int outX, out int outY) -> void -Parquet.Vector2D.Equals(Parquet.Vector2D inVector) -> bool -Parquet.Vector2D.Magnitude.get -> int -Parquet.Vector2D.Vector2D((int X, int Y) inCoordinates) -> void -Parquet.Vector2D.Vector2D() -> void -Parquet.Vector2D.Vector2D(int inX, int inY) -> void -Parquet.Vector2D.X.get -> int -Parquet.Vector2D.Y.get -> int static Parquet.All.Beings.get -> Parquet.ModelCollection static Parquet.All.BiomeRecipes.get -> Parquet.ModelCollection static Parquet.All.Blocks.get -> Parquet.ModelCollection @@ -894,7 +894,7 @@ static Parquet.Crafts.CraftConfiguration.PutRecord() -> void static Parquet.Crafts.CraftingRecipe.NotCraftable.get -> Parquet.Crafts.CraftingRecipe static Parquet.Crafts.StrikePanel.operator !=(Parquet.Crafts.StrikePanel inStrikePanel1, Parquet.Crafts.StrikePanel inStrikePanel2) -> bool static Parquet.Crafts.StrikePanel.operator ==(Parquet.Crafts.StrikePanel inStrikePanel1, Parquet.Crafts.StrikePanel inStrikePanel2) -> bool -static Parquet.Crafts.StrikePanelArrayExtensions.IsValidPosition(this Parquet.Crafts.StrikePanel[,] inStrikePanels, Parquet.Vector2D inPosition) -> bool +static Parquet.Crafts.StrikePanelArrayExtensions.IsValidPosition(this Parquet.Crafts.StrikePanel[,] inStrikePanels, Parquet.Point2D inPosition) -> bool static Parquet.Crafts.StrikePanelGrid.Empty.get -> Parquet.Crafts.StrikePanelGrid static Parquet.Games.GameStatus.Default.get -> Parquet.Games.GameStatus static Parquet.Games.GameStatus.operator !=(Parquet.Games.GameStatus inStatus1, Parquet.Games.GameStatus inStatus2) -> bool @@ -930,7 +930,7 @@ static Parquet.ModelID.operator >=(Parquet.ModelID inIDentifier1, Parquet.ModelI static Parquet.ModelIDGrid.Empty.get -> Parquet.ModelIDGrid static Parquet.ModelTag.implicit operator Parquet.ModelTag(string inValue) -> Parquet.ModelTag static Parquet.ModelTag.implicit operator string(Parquet.ModelTag inTag) -> string -static Parquet.PackArrayExtensions.IsValidPosition(this Parquet.Pack[,] inArray, Parquet.Vector2D inPosition) -> bool +static Parquet.PackArrayExtensions.IsValidPosition(this Parquet.Pack[,] inArray, Parquet.Point2D inPosition) -> bool static Parquet.Parquets.BlockModel.Bounds.get -> Parquet.Range static Parquet.Parquets.BlockStatus.Default.get -> Parquet.Parquets.BlockStatus static Parquet.Parquets.BlockStatus.operator !=(Parquet.Parquets.BlockStatus inStatus1, Parquet.Parquets.BlockStatus inStatus2) -> bool @@ -949,6 +949,11 @@ static Parquet.Parquets.ParquetStatusPack.Default.get -> Parquet.Parquets.Parque static Parquet.Parquets.ParquetStatusPack.operator !=(Parquet.Parquets.ParquetStatusPack inPack1, Parquet.Parquets.ParquetStatusPack inPack2) -> bool static Parquet.Parquets.ParquetStatusPack.operator ==(Parquet.Parquets.ParquetStatusPack inPack1, Parquet.Parquets.ParquetStatusPack inPack2) -> bool static Parquet.Parquets.ParquetStatusPackGrid.Empty.get -> Parquet.Parquets.ParquetStatusPackGrid +static Parquet.Point2D.operator !=(Parquet.Point2D inPoint1, Parquet.Point2D inPoint2) -> bool +static Parquet.Point2D.operator *(int inScalar, Parquet.Point2D inPoint) -> Parquet.Point2D +static Parquet.Point2D.operator +(Parquet.Point2D inPoint1, Parquet.Point2D inPoint2) -> Parquet.Point2D +static Parquet.Point2D.operator -(Parquet.Point2D inPoint1, Parquet.Point2D inPoint2) -> Parquet.Point2D +static Parquet.Point2D.operator ==(Parquet.Point2D inPoint1, Parquet.Point2D inPoint2) -> bool static Parquet.Precondition.AreInRange(System.Collections.Generic.IEnumerable inEnumerable, Parquet.Range inBounds, string inArgumentName) -> void static Parquet.Precondition.AreInRange(System.Collections.Generic.IEnumerable inEnumerable, System.Collections.Generic.IEnumerable> inBoundsCollection, string inArgumentName) -> void static Parquet.Precondition.IsInRange(int inInt, Parquet.Range inBounds, string inArgumentName) -> void @@ -975,18 +980,18 @@ static Parquet.Regions.ChunkDetail.operator ==(Parquet.Regions.ChunkDetail inChu static Parquet.Regions.MapChunk.Empty.get -> Parquet.Regions.MapChunk static Parquet.Regions.MapChunk.operator !=(Parquet.Regions.MapChunk inChunk1, Parquet.Regions.MapChunk inChunk2) -> bool static Parquet.Regions.MapChunk.operator ==(Parquet.Regions.MapChunk inChunk1, Parquet.Regions.MapChunk inChunk2) -> bool -static Parquet.Regions.MapChunkArrayExtensions.IsValidPosition(this Parquet.Regions.MapChunk[,] inArray, Parquet.Vector2D inPosition) -> bool +static Parquet.Regions.MapChunkArrayExtensions.IsValidPosition(this Parquet.Regions.MapChunk[,] inArray, Parquet.Point2D inPosition) -> bool static Parquet.Regions.MapChunkGrid.Empty.get -> Parquet.Regions.MapChunkGrid static Parquet.Regions.RegionModel.Bounds.get -> Parquet.Range -static Parquet.Regions.RegionModel.DimensionsInChunks.get -> Parquet.Vector2D +static Parquet.Regions.RegionModel.DimensionsInChunks.get -> Parquet.Point2D static Parquet.Regions.RegionStatus.CheckExitConsistency(Parquet.ModelID inRegionID) -> System.Collections.Generic.ICollection -static Parquet.Regions.RegionStatus.DimensionsInParquets.get -> Parquet.Vector2D +static Parquet.Regions.RegionStatus.DimensionsInParquets.get -> Parquet.Point2D static Parquet.Regions.RegionStatus.operator !=(Parquet.Regions.RegionStatus inStatus1, Parquet.Regions.RegionStatus inStatus2) -> bool static Parquet.Regions.RegionStatus.operator ==(Parquet.Regions.RegionStatus inStatus1, Parquet.Regions.RegionStatus inStatus2) -> bool static Parquet.Regions.RegionStatus.Unused.get -> Parquet.Regions.RegionStatus static Parquet.Rooms.MapSpace.operator !=(Parquet.Rooms.MapSpace inSpace1, Parquet.Rooms.MapSpace inSpace2) -> bool static Parquet.Rooms.MapSpace.operator ==(Parquet.Rooms.MapSpace inSpace1, Parquet.Rooms.MapSpace inSpace2) -> bool -static Parquet.Rooms.ReadOnlyRoomCollectionExtensions.GetRoomAtOrNull(this System.Collections.Generic.IReadOnlyCollection inRooms, Parquet.Vector2D inPosition) -> Parquet.Rooms.Room +static Parquet.Rooms.ReadOnlyRoomCollectionExtensions.GetRoomAtOrNull(this System.Collections.Generic.IReadOnlyCollection inRooms, Parquet.Point2D inPosition) -> Parquet.Rooms.Room static Parquet.Rooms.ReadOnlyRoomCollectionExtensions.ToString(this System.Collections.Generic.IReadOnlyCollection inRooms) -> string static Parquet.Rooms.Room.operator !=(Parquet.Rooms.Room inRoom1, Parquet.Rooms.Room inRoom2) -> bool static Parquet.Rooms.Room.operator ==(Parquet.Rooms.Room inRoom1, Parquet.Rooms.Room inRoom2) -> bool @@ -1003,12 +1008,7 @@ static Parquet.Scripts.ScriptNode.implicit operator string(Parquet.Scripts.Scrip static Parquet.Scripts.ScriptStatus.operator !=(Parquet.Scripts.ScriptStatus inStatus1, Parquet.Scripts.ScriptStatus inStatus2) -> bool static Parquet.Scripts.ScriptStatus.operator ==(Parquet.Scripts.ScriptStatus inStatus1, Parquet.Scripts.ScriptStatus inStatus2) -> bool static Parquet.Scripts.ScriptStatus.Unstarted.get -> Parquet.Scripts.ScriptStatus -static Parquet.StatusArrayExtensions.IsValidPosition(this Parquet.Status[,] inArray, Parquet.Vector2D inPosition) -> bool -static Parquet.Vector2D.operator !=(Parquet.Vector2D inVector1, Parquet.Vector2D inVector2) -> bool -static Parquet.Vector2D.operator *(int inScalar, Parquet.Vector2D inVector) -> Parquet.Vector2D -static Parquet.Vector2D.operator +(Parquet.Vector2D inVector1, Parquet.Vector2D inVector2) -> Parquet.Vector2D -static Parquet.Vector2D.operator -(Parquet.Vector2D inVector1, Parquet.Vector2D inVector2) -> Parquet.Vector2D -static Parquet.Vector2D.operator ==(Parquet.Vector2D inVector1, Parquet.Vector2D inVector2) -> bool +static Parquet.StatusArrayExtensions.IsValidPosition(this Parquet.Status[,] inArray, Parquet.Point2D inPosition) -> bool static readonly Parquet.All.AllDefinedIDs -> System.Collections.Generic.IReadOnlyList> static readonly Parquet.All.BeingIDs -> System.Collections.Generic.IReadOnlyList> static readonly Parquet.All.BiomeRecipeIDs -> Parquet.Range @@ -1033,17 +1033,17 @@ static readonly Parquet.Games.GameModel.Empty -> Parquet.Games.GameModel static readonly Parquet.ModelCollection.Default -> Parquet.ModelCollection static readonly Parquet.ModelID.None -> Parquet.ModelID static readonly Parquet.ModelTag.None -> Parquet.ModelTag +static readonly Parquet.Point2D.East -> Parquet.Point2D +static readonly Parquet.Point2D.North -> Parquet.Point2D +static readonly Parquet.Point2D.Origin -> Parquet.Point2D +static readonly Parquet.Point2D.South -> Parquet.Point2D +static readonly Parquet.Point2D.Unit -> Parquet.Point2D +static readonly Parquet.Point2D.West -> Parquet.Point2D static readonly Parquet.Range.None -> Parquet.Range static readonly Parquet.RecipeElement.None -> Parquet.RecipeElement static readonly Parquet.Regions.ChunkDetail.None -> Parquet.Regions.ChunkDetail static readonly Parquet.Regions.RegionModel.Empty -> Parquet.Regions.RegionModel static readonly Parquet.Rooms.MapSpace.Empty -> Parquet.Rooms.MapSpace static readonly Parquet.Scripts.ScriptNode.None -> Parquet.Scripts.ScriptNode -static readonly Parquet.Vector2D.East -> Parquet.Vector2D -static readonly Parquet.Vector2D.North -> Parquet.Vector2D -static readonly Parquet.Vector2D.South -> Parquet.Vector2D -static readonly Parquet.Vector2D.Unit -> Parquet.Vector2D -static readonly Parquet.Vector2D.West -> Parquet.Vector2D -static readonly Parquet.Vector2D.Zero -> Parquet.Vector2D virtual Parquet.Model.GetAllTags() -> System.Collections.Generic.IEnumerable virtual Parquet.Pack.DeepClone() -> Parquet.Pack diff --git a/ParquetClassLibrary/Regions/MapChunk.cs b/ParquetClassLibrary/Regions/MapChunk.cs index 0298cba5..720c5a4f 100644 --- a/ParquetClassLibrary/Regions/MapChunk.cs +++ b/ParquetClassLibrary/Regions/MapChunk.cs @@ -21,7 +21,7 @@ public class MapChunk : IEquatable, ITypeConverter, IDeeplyCloneableThe chunk's dimensions in parquets. - public Vector2D DimensionsInParquets { get; } = new Vector2D(ParquetsPerChunkDimension, + public Point2D DimensionsInParquets { get; } = new Point2D(ParquetsPerChunkDimension, ParquetsPerChunkDimension); #endregion @@ -257,7 +257,7 @@ public static class MapChunkArrayExtensions /// The array to validate against. /// The position to validate. /// true, if the position is valid, false otherwise. - public static bool IsValidPosition(this MapChunk[,] inArray, Vector2D inPosition) + public static bool IsValidPosition(this MapChunk[,] inArray, Point2D inPosition) => inArray is not null && inPosition.X > -1 && inPosition.Y > -1 diff --git a/ParquetClassLibrary/Regions/MapChunkGrid.cs b/ParquetClassLibrary/Regions/MapChunkGrid.cs index 511d3d43..357fbcd6 100644 --- a/ParquetClassLibrary/Regions/MapChunkGrid.cs +++ b/ParquetClassLibrary/Regions/MapChunkGrid.cs @@ -141,7 +141,7 @@ IReadOnlyGrid IDeeplyCloneable>.DeepClone() /// /// The position to validate. /// true, if the position is valid, false otherwise. - public bool IsValidPosition(Vector2D inPosition) + public bool IsValidPosition(Point2D inPosition) => MapChunks.IsValidPosition(inPosition); #endregion } diff --git a/ParquetClassLibrary/Regions/RegionModel.cs b/ParquetClassLibrary/Regions/RegionModel.cs index 6760affa..6de220a1 100644 --- a/ParquetClassLibrary/Regions/RegionModel.cs +++ b/ParquetClassLibrary/Regions/RegionModel.cs @@ -33,7 +33,7 @@ public static Range Bounds public const int ChunksPerRegionDimension = 4; /// Dimensions in chunks of the stored by this . - public static Vector2D DimensionsInChunks { get; } = new Vector2D(ChunksPerRegionDimension, ChunksPerRegionDimension); + public static Point2D DimensionsInChunks { get; } = new Point2D(ChunksPerRegionDimension, ChunksPerRegionDimension); #endregion #region Characteristics diff --git a/ParquetClassLibrary/Regions/RegionStatus.cs b/ParquetClassLibrary/Regions/RegionStatus.cs index 3990d3ad..f2a97f94 100644 --- a/ParquetClassLibrary/Regions/RegionStatus.cs +++ b/ParquetClassLibrary/Regions/RegionStatus.cs @@ -29,7 +29,7 @@ public class RegionStatus : Status public const int ParquetsPerRegionDimension = RegionModel.ChunksPerRegionDimension * MapChunk.ParquetsPerChunkDimension; /// The region's dimensions in parquets. - public static Vector2D DimensionsInParquets { get; } = new Vector2D(ParquetsPerRegionDimension, ParquetsPerRegionDimension); + public static Point2D DimensionsInParquets { get; } = new Point2D(ParquetsPerRegionDimension, ParquetsPerRegionDimension); #endregion #region Status @@ -185,7 +185,7 @@ static ModelID GetParquetsInRooms(RegionStatus inRegion) { for (var x = 0; x < inRegion.ParquetModels.Columns; x++) { - if (inRegion.Rooms.Any(room => room.ContainsPosition(new Vector2D(x, y)))) + if (inRegion.Rooms.Any(room => room.ContainsPosition(new Point2D(x, y)))) { // Note that we are counting every parquet, including collectibles. parquetsInRoom += inRegion.ParquetModels[y, x].Count; @@ -537,7 +537,7 @@ public override T DeepClone() /// /// The position to validate. /// true, if the position is valid, false otherwise. - public bool IsValidPosition(Vector2D inPosition) + public bool IsValidPosition(Point2D inPosition) => ParquetModels.IsValidPosition(inPosition) && ParquetStatuses.IsValidPosition(inPosition); diff --git a/ParquetClassLibrary/Rooms/MapSpace.cs b/ParquetClassLibrary/Rooms/MapSpace.cs index 6a35f466..e7a13517 100644 --- a/ParquetClassLibrary/Rooms/MapSpace.cs +++ b/ParquetClassLibrary/Rooms/MapSpace.cs @@ -13,7 +13,7 @@ public sealed class MapSpace : IEquatable { #region Class Defaults /// The null , which exists nowhere and contains nothing. - public static readonly MapSpace Empty = new MapSpace(Vector2D.Zero, ParquetModelPack.Empty, ParquetModelPackGrid.Empty); + public static readonly MapSpace Empty = new MapSpace(Point2D.Origin, ParquetModelPack.Empty, ParquetModelPackGrid.Empty); #endregion #region Characteristics @@ -21,7 +21,7 @@ public sealed class MapSpace : IEquatable public ParquetModelPackGrid Grid { get; } /// Location of this . - public Vector2D Position { get; } + public Point2D Position { get; } /// All parquets occupying this . public ParquetModelPack Content { get; } @@ -34,7 +34,7 @@ public sealed class MapSpace : IEquatable /// Where this is. /// All parquets occupying this . /// The within which this occurs. - public MapSpace(Vector2D inPosition, ParquetModelPack inContent, ParquetModelPackGrid inGrid) + public MapSpace(Point2D inPosition, ParquetModelPack inContent, ParquetModelPackGrid inGrid) { Position = inPosition; Content = inContent; @@ -49,13 +49,13 @@ public MapSpace(Vector2D inPosition, ParquetModelPack inContent, ParquetModelPac /// All parquets occupying this . /// The grid in which this occurs. public MapSpace(int inX, int inY, ParquetModelPack inContent, ParquetModelPackGrid inGrid) - : this(new Vector2D(inX, inY), inContent, inGrid) { } + : this(new Point2D(inX, inY), inContent, inGrid) { } #endregion #region Position Offsets /// Finds the related to the given space by the given offset, if any. /// A if it exists, or otherwise. - public MapSpace Neighbor(Vector2D inOffset) + public MapSpace Neighbor(Point2D inOffset) { Precondition.IsNotNull(Grid, nameof(Grid)); @@ -68,22 +68,22 @@ public MapSpace Neighbor(Vector2D inOffset) /// Finds the to the north of the given space, if any. /// A if it exists, or otherwise. public MapSpace NorthNeighbor() - => Neighbor(Vector2D.North); + => Neighbor(Point2D.North); /// Finds the to the south of the given space, if any. /// A if it exists, or otherwise. public MapSpace SouthNeighbor() - => Neighbor(Vector2D.South); + => Neighbor(Point2D.South); /// Finds the to the east of the given space, if any. /// A if it exists, or otherwise. public MapSpace EastNeighbor() - => Neighbor(Vector2D.East); + => Neighbor(Point2D.East); /// Finds the to the west of the given space, if any. /// A if it exists, or otherwise. public MapSpace WestNeighbor() - => Neighbor(Vector2D.West); + => Neighbor(Point2D.West); /// Finds the related to the given space by the given offset, if any. /// A list of four s, some or all of which may be . diff --git a/ParquetClassLibrary/Rooms/MapSpaceSetExtensions.cs b/ParquetClassLibrary/Rooms/MapSpaceSetExtensions.cs index 5b131711..69e49209 100644 --- a/ParquetClassLibrary/Rooms/MapSpaceSetExtensions.cs +++ b/ParquetClassLibrary/Rooms/MapSpaceSetExtensions.cs @@ -66,11 +66,11 @@ internal static bool TryGetPerimeter(this IReadOnlySet inSpaces, out I #endregion // Only continue if all four seeds are found. - var perimiterSeeds = new List(); - if (TryGetSeed(northWalkableExtreme, position => position + Vector2D.North, out var northSeed) - && TryGetSeed(southWalkableExtreme, position => position + Vector2D.South, out var southSeed) - && TryGetSeed(eastWalkableExtreme, position => position + Vector2D.East, out var eastSeed) - && TryGetSeed(westWalkableExtreme, position => position + Vector2D.West, out var westSeed)) + var perimiterSeeds = new List(); + if (TryGetSeed(northWalkableExtreme, position => position + Point2D.North, out var northSeed) + && TryGetSeed(southWalkableExtreme, position => position + Point2D.South, out var southSeed) + && TryGetSeed(eastWalkableExtreme, position => position + Point2D.East, out var eastSeed) + && TryGetSeed(westWalkableExtreme, position => position + Point2D.West, out var westSeed)) { perimiterSeeds.Add(northSeed); perimiterSeeds.Add(southSeed); @@ -107,7 +107,7 @@ internal static bool TryGetPerimeter(this IReadOnlySet inSpaces, out I // inAdjust indicates how to adjust the position at each step if a perimeter seed has not been found. // outFinal indicates the position of the perimeter seed, if one was found. // If it cannot find such a MapSpace, returns false. - bool TryGetSeed(Vector2D inStart, Func inAdjust, out Vector2D outFinal) + bool TryGetSeed(Point2D inStart, Func inAdjust, out Point2D outFinal) { var found = false; var position = inStart; @@ -132,7 +132,7 @@ bool TryGetSeed(Vector2D inStart, Func inAdjust, out Vector2 outFinal = found ? position - : Vector2D.Zero; + : Point2D.Origin; return found; } diff --git a/ParquetClassLibrary/Rooms/ReadOnlyRoomCollectionExtensions.cs b/ParquetClassLibrary/Rooms/ReadOnlyRoomCollectionExtensions.cs index 3d3b2119..a43d5c21 100644 --- a/ParquetClassLibrary/Rooms/ReadOnlyRoomCollectionExtensions.cs +++ b/ParquetClassLibrary/Rooms/ReadOnlyRoomCollectionExtensions.cs @@ -14,7 +14,7 @@ public static class ReadOnlyRoomCollectionExtensions /// The current collection of s. /// An in-bounds position to search for a . /// The specified if found; otherwise, null. - public static Room GetRoomAtOrNull(this IReadOnlyCollection inRooms, Vector2D inPosition) + public static Room GetRoomAtOrNull(this IReadOnlyCollection inRooms, Point2D inPosition) => inRooms?.FirstOrDefault(room => room.ContainsPosition(inPosition)) ?? null; /// diff --git a/ParquetClassLibrary/Rooms/Room.cs b/ParquetClassLibrary/Rooms/Room.cs index 9def7e01..d6bca7a5 100644 --- a/ParquetClassLibrary/Rooms/Room.cs +++ b/ParquetClassLibrary/Rooms/Room.cs @@ -45,8 +45,8 @@ public IEnumerable FurnishingTags /// /// This location could server as a the upper, left point of a bounding rectangle entirely containing the room. /// - public Vector2D Position - => new Vector2D(WalkableArea.Select(space => space.Position.X).Min(), + public Point2D Position + => new Point2D(WalkableArea.Select(space => space.Position.X).Min(), WalkableArea.Select(space => space.Position.Y).Min()); /// The that this matches. @@ -155,7 +155,7 @@ public override bool Equals(object obj) /// /// The position to check for. /// true, if the contains the given position, false otherwise. - public bool ContainsPosition(Vector2D inPosition) + public bool ContainsPosition(Point2D inPosition) => WalkableArea.Concat(Perimeter).Any(space => space.Position == inPosition); /// diff --git a/ParquetClassLibrary/Status.cs b/ParquetClassLibrary/Status.cs index 04d087db..f3241694 100644 --- a/ParquetClassLibrary/Status.cs +++ b/ParquetClassLibrary/Status.cs @@ -115,7 +115,7 @@ public static class StatusArrayExtensions /// The array to validate against. /// The position to validate. /// true, if the position is valid, false otherwise. - public static bool IsValidPosition(this Status[,] inArray, Vector2D inPosition) + public static bool IsValidPosition(this Status[,] inArray, Point2D inPosition) => inArray is not null && inPosition.X > -1 && inPosition.Y > -1 diff --git a/ParquetClassLibrary/Vector2D.cs b/ParquetClassLibrary/Vector2D.cs deleted file mode 100644 index 54ff0405..00000000 --- a/ParquetClassLibrary/Vector2D.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Globalization; -using CsvHelper; -using CsvHelper.Configuration; -using CsvHelper.TypeConversion; - -namespace Parquet -{ - /// - /// A simple representation of two coordinate integers, tailored for Parquet's needs. - /// - // TODO [API] Perhaps this should be renamed Point2D, to follow the standard used by System.Drawing and MonoGame (but not clash with them as they lack the 2D). - public readonly struct Vector2D : IEquatable, ITypeConverter - { - #region Class Defaults - /// The zero vector. - public static readonly Vector2D Zero = new Vector2D(0, 0); - - /// The unit vector. - public static readonly Vector2D Unit = new Vector2D(1, 1); - - /// The vector offset to the North. - public static readonly Vector2D North = new Vector2D(0, -1); - - /// The vector offset to the South. - public static readonly Vector2D South = new Vector2D(0, 1); - - /// The vector offset to the East. - public static readonly Vector2D East = new Vector2D(1, 0); - - /// The vector offset to the West. - public static readonly Vector2D West = new Vector2D(-1, 0); - #endregion - - #region Characteristics - /// Offset from origin in x. - public int X { get; } - - /// Offset from origin in y. - public int Y { get; } - - /// Provides the magnitude of the vector as an integer, rounded-down. - public int Magnitude { get; } - #endregion - - #region Initialization - /// - /// Initializes a new instance of the struct. - /// - /// The X coordinate. - /// The Y coordinate. - public Vector2D(int inX, int inY) - { - X = inX; - Y = inY; - Magnitude = Convert.ToInt32(Math.Floor(Math.Sqrt((X * X) + (Y * Y)))); - } - - /// - /// Initializes a new instance of the struct. - /// - /// The coordinates. - public Vector2D((int X, int Y) inCoordinates) - : this(inCoordinates.X, inCoordinates.Y) - { } - #endregion - - #region Vector Math - /// - /// Sums the given vectors. - /// - /// First operand. - /// Second operand. - /// A vector representing the sum of the given vectors. - public static Vector2D operator +(Vector2D inVector1, Vector2D inVector2) - => new Vector2D(inVector1.X + inVector2.X, inVector1.Y + inVector2.Y); - - /// - /// Finds the difference between the given vectors. - /// - /// First operand. - /// Second operand. - /// A vector representing the difference of the given vectors. - public static Vector2D operator -(Vector2D inVector1, Vector2D inVector2) - => new Vector2D(inVector1.X - inVector2.X, inVector1.Y - inVector2.Y); - - /// - /// Scales a vector. - /// - /// The scalar. - /// The vector. - /// A scaled vector. - public static Vector2D operator *(int inScalar, Vector2D inVector) - => new Vector2D(inScalar * inVector.X, inScalar * inVector.Y); - #endregion - - #region IEquatable Implementation - /// - /// Serves as a hash function for a struct. - /// - /// A hash code for this instance that is suitable for use in hashing algorithms and data structures. - public override int GetHashCode() - => (X, Y).GetHashCode(); - - /// - /// Determines whether the specified is equal to the current . - /// - /// The to compare with the current. - /// true if the s are equal. - public bool Equals(Vector2D inVector) - => X == inVector.X - && Y == inVector.Y; - - /// - /// Determines whether the specified is equal to the current . - /// - /// The to compare with the current . - /// true if the specified is equal to the current ; otherwise, false. - public override bool Equals(object obj) - => obj is Vector2D vector - && Equals(vector); - - /// - /// Determines whether a specified instance of is equal to - /// another specified instance of . - /// - /// The first to compare. - /// The second to compare. - /// true if the two operands are equal; otherwise, false. - public static bool operator ==(Vector2D inVector1, Vector2D inVector2) - => inVector1.Equals(inVector2); - - /// - /// Determines whether a specified instance of is not equal - /// to another specified instance of . - /// - /// The first to compare. - /// The second to compare. - /// true if the two operands are NOT equal; otherwise, false. - public static bool operator !=(Vector2D inVector1, Vector2D inVector2) - => !inVector1.Equals(inVector2); - #endregion - - #region ITypeConverter Implementation - /// Allows the converter to construct itself statically. - internal static Vector2D ConverterFactory { get; } = Zero; - - /// - /// Converts the given to a for serialization. - /// - /// The instance to convert. - /// The current context and configuration. - /// Mapping info for a member to a CSV field or property. - /// The given instance serialized. - public string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) - => inValue is Vector2D vector - ? $"{vector.X}{Delimiters.ElementDelimiter}" + - $"{vector.Y}" - : Logger.DefaultWithConvertLog(inValue?.ToString() ?? "null", nameof(Vector2D), nameof(Zero)); - - /// - /// Converts the given to an as deserialization. - /// - /// The text to convert. - /// The current context and configuration. - /// Mapping info for a member to a CSV field or property. - /// The given instance deserialized. - public object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) - { - if (string.IsNullOrEmpty(inText) - || string.Compare(nameof(Zero), inText, StringComparison.OrdinalIgnoreCase) == 0) - { - return Zero; - } - - var parameterText = inText.Split(Delimiters.ElementDelimiter); - - var x = int.TryParse(parameterText[0], All.SerializedNumberStyle, CultureInfo.InvariantCulture, out var temp1) - ? temp1 - : Logger.DefaultWithParseLog(parameterText[0], nameof(X), Zero.X); - var y = int.TryParse(parameterText[1], All.SerializedNumberStyle, CultureInfo.InvariantCulture, out var temp2) - ? temp2 - : Logger.DefaultWithParseLog(parameterText[1], nameof(Y), Zero.Y); - - return new Vector2D(x, y); - } - #endregion - - #region Utilities - /// - /// Deconstructs the current into its constituent coordinates. - /// - /// The X coordinate. - /// The Y coordinate. - public void Deconstruct(out int outX, out int outY) - => (outX, outY) = (X, Y); - - /// - /// Returns a that represents the current . - /// - /// The representation. - public override string ToString() - => $"({X}, {Y})"; - #endregion - } -} diff --git a/ParquetUnitTests/ITypeConverterTest.cs b/ParquetUnitTests/ITypeConverterTest.cs index 64ccaa0f..6971e8f5 100644 --- a/ParquetUnitTests/ITypeConverterTest.cs +++ b/ParquetUnitTests/ITypeConverterTest.cs @@ -16,7 +16,7 @@ public class ITypeConverterTest public void AllTypeConvertersProvideFactoriesTest() { // This discarded value is here to ensure that ParquetClassLibrary is loaded. - var _ = new Vector2D(1, 2); + var _ = new Point2D(1, 2); var converterProviders = AppDomain.CurrentDomain .GetAssemblies() .Where(assembly => assembly.GetName().Name == "ParquetClassLibrary") diff --git a/ParquetUnitTests/Parquets/MapSpaceUnitTest.cs b/ParquetUnitTests/Parquets/MapSpaceUnitTest.cs index 6f779201..62c746cd 100644 --- a/ParquetUnitTests/Parquets/MapSpaceUnitTest.cs +++ b/ParquetUnitTests/Parquets/MapSpaceUnitTest.cs @@ -35,8 +35,8 @@ internal void IdenticalSpacesAreEqualTest() TestModels.TestFurnishing.ID, TestModels.TestCollectible.ID); - var space1 = new MapSpace(new Vector2D(x, y), testStack, null); - var space2 = new MapSpace(new Vector2D(x, y), testStack, null); + var space1 = new MapSpace(new Point2D(x, y), testStack, null); + var space2 = new MapSpace(new Point2D(x, y), testStack, null); Assert.Equal(space1, space2); } @@ -53,8 +53,8 @@ internal void DifferingPositionsAreUnequalTest() TestModels.TestFurnishing.ID, TestModels.TestCollectible.ID); - var space1 = new MapSpace(new Vector2D(x1, y1), testStack, null); - var space2 = new MapSpace(new Vector2D(x2, y2), testStack, null); + var space1 = new MapSpace(new Point2D(x1, y1), testStack, null); + var space2 = new MapSpace(new Point2D(x2, y2), testStack, null); Assert.NotEqual(space1, space2); } @@ -73,8 +73,8 @@ internal void DifferingContentsAreUnequalTest() TestModels.TestFurnishing.ID - 1, TestModels.TestCollectible.ID - 1); - var space1 = new MapSpace(new Vector2D(x, y), testStack1, null); - var space2 = new MapSpace(new Vector2D(x, y), testStack2, null); + var space1 = new MapSpace(new Point2D(x, y), testStack1, null); + var space2 = new MapSpace(new Point2D(x, y), testStack2, null); Assert.NotEqual(space1, space2); } @@ -85,7 +85,7 @@ internal void ValidNorthNeighbourIsFoundTest() var x = 1; var y = 1; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.NorthNeighbor(); Assert.NotEqual(space, neighbour); @@ -98,7 +98,7 @@ internal void InvalidNorthNeighbourIsEmptyTest() var x = 0; var y = 0; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.NorthNeighbor(); Assert.NotEqual(space, neighbour); @@ -111,7 +111,7 @@ internal void ValidSouthNeighbourIsFoundTest() var x = 1; var y = 1; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.SouthNeighbor(); Assert.NotEqual(space, neighbour); @@ -124,7 +124,7 @@ internal void InvalidSouthNeighbourIsEmptyTest() var x = 1; var y = TestRoomMap.GetLength(0) - 1; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.SouthNeighbor(); Assert.NotEqual(space, neighbour); @@ -137,7 +137,7 @@ internal void ValidEastNeighbourIsFoundTest() var x = 1; var y = 1; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.EastNeighbor(); Assert.NotEqual(space, neighbour); @@ -150,7 +150,7 @@ internal void InvalidEastNeighbourIsEmptyTest() var x = TestRoomMap.GetLength(1) - 1; var y = 1; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.EastNeighbor(); Assert.NotEqual(space, neighbour); @@ -163,7 +163,7 @@ internal void ValidWestNeighbourIsFoundTest() var x = 1; var y = 1; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.WestNeighbor(); Assert.NotEqual(space, neighbour); @@ -176,7 +176,7 @@ internal void InvalidWestNeighbourIsEmptyTest() var x = 0; var y = 0; - var space = new MapSpace(new Vector2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); + var space = new MapSpace(new Point2D(x, y), TestRoomMap[y, x], new ParquetModelPackGrid(TestRoomMap)); var neighbour = space.WestNeighbor(); Assert.NotEqual(space, neighbour); diff --git a/ParquetUnitTests/Point2DUnitTest.cs b/ParquetUnitTests/Point2DUnitTest.cs new file mode 100644 index 00000000..d20549e9 --- /dev/null +++ b/ParquetUnitTests/Point2DUnitTest.cs @@ -0,0 +1,67 @@ +using System; +using Parquet; +using Xunit; + +namespace ParquetUnitTests +{ + public class Point2DUnitTest + { + #region Test Values + private readonly Point2D PointTwoTwo = new Point2D(2, 2); + private readonly Point2D PointNegativeUnit = new Point2D(-1, -1); + #endregion + + [Fact] + public void ZeroPointTest() + { + Assert.Equal(0, Point2D.Origin.X); + Assert.Equal(0, Point2D.Origin.Y); + Assert.Equal(0, Point2D.Origin.Magnitude); + } + + [Fact] + public void UnitPointTest() + { + Assert.Equal(1, Point2D.Unit.X); + Assert.Equal(1, Point2D.Unit.Y); + Assert.Equal(1, Point2D.Unit.Magnitude); + } + + [Theory] + [InlineData(-4096, -4096)] + [InlineData(-1, 1)] + [InlineData(0, 0)] + [InlineData(1, -1)] + [InlineData(4096, 4096)] + public void NewPointTest(int inX, int inY) + { + var testPoint = new Point2D(inX, inY); + var magnitude = Convert.ToInt32(Math.Floor(Math.Sqrt((inX * inX) + (inY * inY)))); + + Assert.Equal(inX, testPoint.X); + Assert.Equal(inY, testPoint.Y); + Assert.Equal(magnitude, testPoint.Magnitude); + } + + [Fact] + public void PointSumTest() + { + Assert.Equal(PointTwoTwo, Point2D.Unit + Point2D.Unit); + Assert.Equal(Point2D.Origin, Point2D.Unit + PointNegativeUnit); + } + + [Fact] + public void PointDifferenceTest() + { + Assert.Equal(Point2D.Origin, Point2D.Unit - Point2D.Unit); + Assert.Equal(Point2D.Origin, PointNegativeUnit - PointNegativeUnit); + } + + [Fact] + public void ScalarMultiplicationTest() + { + Assert.Equal(PointTwoTwo, 2 * Point2D.Unit); + Assert.Equal(Point2D.Unit, -1 * PointNegativeUnit); + } + } +} diff --git a/ParquetUnitTests/Rooms/RoomCollectionUnitTest.cs b/ParquetUnitTests/Rooms/RoomCollectionUnitTest.cs index 6857efa2..3ccf5cc1 100644 --- a/ParquetUnitTests/Rooms/RoomCollectionUnitTest.cs +++ b/ParquetUnitTests/Rooms/RoomCollectionUnitTest.cs @@ -528,8 +528,8 @@ internal void DistinctRoomsHaveDistinctWalkableAreasTest() { var collection = new ParquetModelPackGrid(TwoSimpleRoomsMap).CreateRoomCollectionFromSubregion(); - var walkableArea1 = collection.GetRoomAt(new Vector2D(2, 2)).WalkableArea; - var walkableArea2 = collection.GetRoomAt(new Vector2D(8, 2)).WalkableArea; + var walkableArea1 = collection.GetRoomAt(new Point2D(2, 2)).WalkableArea; + var walkableArea2 = collection.GetRoomAt(new Point2D(8, 2)).WalkableArea; Assert.False(walkableArea1.SetEquals(walkableArea2)); } @@ -539,8 +539,8 @@ internal void DistinctRoomsHaveDistinctPerimetersTest() { var collection = new ParquetModelPackGrid(TwoSimpleRoomsMap).CreateRoomCollectionFromSubregion(); - var perimeter1 = collection.GetRoomAt(new Vector2D(2, 2)).Perimeter; - var perimeter2 = collection.GetRoomAt(new Vector2D(8, 2)).Perimeter; + var perimeter1 = collection.GetRoomAt(new Point2D(2, 2)).Perimeter; + var perimeter2 = collection.GetRoomAt(new Point2D(8, 2)).Perimeter; Assert.False(perimeter1.SetEquals(perimeter2)); } @@ -910,7 +910,7 @@ internal void ContainsDoesNotFindNonextantRoomTest() [Fact] internal void GetRoomAtSucceedsOnCorrectPositionTest() { - var correctPosition = new Vector2D(1, 1); + var correctPosition = new Point2D(1, 1); Assert.Equal(ExtantRoom, TestCollection.GetRoomAtOrNull(correctPosition)); } @@ -918,7 +918,7 @@ internal void GetRoomAtSucceedsOnCorrectPositionTest() [Fact] internal void GetRoomAtFailsOnIncorrectPositionTest() { - var incorrectPosition = new Vector2D(0, 4); + var incorrectPosition = new Point2D(0, 4); Assert.Null(TestCollection.GetRoomAtOrNull(incorrectPosition)); } diff --git a/ParquetUnitTests/Rooms/RoomUnitTest.cs b/ParquetUnitTests/Rooms/RoomUnitTest.cs index 08f632b7..6ee29034 100644 --- a/ParquetUnitTests/Rooms/RoomUnitTest.cs +++ b/ParquetUnitTests/Rooms/RoomUnitTest.cs @@ -118,7 +118,7 @@ internal void ContainedPositionIsFoundTest() [Fact] internal void UncontainedPositionIsNotFoundTest() { - var UncontainedPosition = new Vector2D(TestPerimeter.Select(space => space.Position.X).Min() - 1, + var UncontainedPosition = new Point2D(TestPerimeter.Select(space => space.Position.X).Min() - 1, TestPerimeter.Select(space => space.Position.Y).Min() - 1); Assert.False(ValidRoom.ContainsPosition(UncontainedPosition)); diff --git a/ParquetUnitTests/Vector2DUnitTest.cs b/ParquetUnitTests/Vector2DUnitTest.cs deleted file mode 100644 index b9d39282..00000000 --- a/ParquetUnitTests/Vector2DUnitTest.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using Parquet; -using Xunit; - -namespace ParquetUnitTests -{ - public class Vector2DUnitTest - { - #region Test Values - private readonly Vector2D VectorTwoTwo = new Vector2D(2, 2); - private readonly Vector2D VectorNegativeUnit = new Vector2D(-1, -1); - #endregion - - [Fact] - public void ZeroVectorTest() - { - Assert.Equal(0, Vector2D.Zero.X); - Assert.Equal(0, Vector2D.Zero.Y); - Assert.Equal(0, Vector2D.Zero.Magnitude); - } - - [Fact] - public void UnitVectorTest() - { - Assert.Equal(1, Vector2D.Unit.X); - Assert.Equal(1, Vector2D.Unit.Y); - Assert.Equal(1, Vector2D.Unit.Magnitude); - } - - [Theory] - [InlineData(-4096, -4096)] - [InlineData(-1, 1)] - [InlineData(0, 0)] - [InlineData(1, -1)] - [InlineData(4096, 4096)] - public void NewVectorTest(int inX, int inY) - { - var testVector = new Vector2D(inX, inY); - var magnitude = Convert.ToInt32(Math.Floor(Math.Sqrt((inX * inX) + (inY * inY)))); - - Assert.Equal(inX, testVector.X); - Assert.Equal(inY, testVector.Y); - Assert.Equal(magnitude, testVector.Magnitude); - } - - [Fact] - public void VectorSumTest() - { - Assert.Equal(VectorTwoTwo, Vector2D.Unit + Vector2D.Unit); - Assert.Equal(Vector2D.Zero, Vector2D.Unit + VectorNegativeUnit); - } - - [Fact] - public void VectorDifferenceTest() - { - Assert.Equal(Vector2D.Zero, Vector2D.Unit - Vector2D.Unit); - Assert.Equal(Vector2D.Zero, VectorNegativeUnit - VectorNegativeUnit); - } - - [Fact] - public void ScalarMultiplicationTest() - { - Assert.Equal(VectorTwoTwo, 2 * Vector2D.Unit); - Assert.Equal(Vector2D.Unit, -1 * VectorNegativeUnit); - } - } -} From be216c85ff1bc07b193c9bc4f864764c111efb51 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 11:55:00 -0800 Subject: [PATCH 03/22] Removes unneeded comment. --- ParquetClassLibrary/Status.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ParquetClassLibrary/Status.cs b/ParquetClassLibrary/Status.cs index f3241694..18ac505b 100644 --- a/ParquetClassLibrary/Status.cs +++ b/ParquetClassLibrary/Status.cs @@ -21,7 +21,6 @@ namespace Parquet /// One Status that does not have a Model companion is , which can /// be applied to any game object with a definite position within the game world. /// - /// public abstract class Status : IEquatable>, ITypeConverter, IDeeplyCloneable> { #region Initialization From 19cce81f961b09d559d43e1535de46a18562cb86 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 11:55:34 -0800 Subject: [PATCH 04/22] Reimplements Location as a readonly struct. --- ParquetClassLibrary/Location.cs | 41 ++++++--------------- ParquetClassLibrary/PublicAPI.Unshipped.txt | 8 ++-- ParquetClassLibrary/Status.cs | 4 -- 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/ParquetClassLibrary/Location.cs b/ParquetClassLibrary/Location.cs index b593b65a..7729eb0c 100644 --- a/ParquetClassLibrary/Location.cs +++ b/ParquetClassLibrary/Location.cs @@ -1,25 +1,19 @@ using System; using CsvHelper; using CsvHelper.Configuration; +using CsvHelper.TypeConversion; namespace Parquet { /// - /// Tracks a specific position within a specific . - /// Instances of this class are mutable during play. + /// Represents a specific within a specific . + /// Instances have value semantics. /// - /// - /// Could meaningfully apply to any object that has a specific position with in the game world.
- /// In practice, is often used for s in addition to that Model's - /// class. - ///
- // TODO [API] Update this class to track only objects that implement ILocatable. Then give one of the new constructors. - // TODO [API] Alternatively, make this a non-Status POCO a la Vector2D and Range. - sealed public class Location : Status + public readonly struct Location : IEquatable, ITypeConverter { #region Class Defaults - /// Provides a throwaway instance of the class with default values. - public static Location Nowhere { get; } = new Location(); + /// Provides an instance of the class with default values. + public static Location Nowhere { get; } #endregion #region Characteristics @@ -58,10 +52,9 @@ public override int GetHashCode() /// /// The to compare with the current. /// true if they are equal; otherwise, false. - public override bool Equals(T inLocation) - => inLocation is Location location - && RegionID == location.RegionID - && Position == location.Position; + public bool Equals(Location inLocation) + => RegionID == inLocation.RegionID + && Position == inLocation.Position; /// /// Determines whether the specified is equal to the current . @@ -79,7 +72,7 @@ public override bool Equals(object obj) /// The second to compare. /// true if they are equal; otherwise, false. public static bool operator ==(Location inLocation1, Location inLocation2) - => inLocation1?.Equals(inLocation2) ?? inLocation2?.Equals(inLocation1) ?? true; + => inLocation1.Equals(inLocation2); /// /// Determines whether a specified instance of is not equal to another specified instance of . @@ -102,7 +95,7 @@ public override bool Equals(object obj) /// The current context and configuration. /// Mapping info for a member to a CSV field or property. /// The given instance deserialized. - public override string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) + public string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) => inValue is Location location ? $"{location.RegionID.ConvertToString(location.RegionID, inRow, inMemberMapData)}{Delimiters.InternalDelimiter}" + $"{location.Position.ConvertToString(location.Position, inRow, inMemberMapData)}" @@ -115,7 +108,7 @@ public override string ConvertToString(object inValue, IWriterRow inRow, MemberM /// The current context and configuration. /// Mapping info for a member to a CSV field or property. /// The given instance serialized. - public override object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) + public object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) { if (string.IsNullOrEmpty(inText) || string.Compare(nameof(Nowhere), inText, StringComparison.OrdinalIgnoreCase) == 0) @@ -132,16 +125,6 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member } #endregion - #region IDeeplyCloneable Implementation - /// - /// Creates a new instance that is a deep copy of the current instance. - /// - /// A new instance with the same characteristics as the current instance. - public override T DeepClone() - // Note that I believe no additional cloning is needed here as structs have value semantics. - => new Location(RegionID, Position) as T; - #endregion - #region Utilities /// /// Describes the as a . diff --git a/ParquetClassLibrary/PublicAPI.Unshipped.txt b/ParquetClassLibrary/PublicAPI.Unshipped.txt index b569037d..094c4e21 100644 --- a/ParquetClassLibrary/PublicAPI.Unshipped.txt +++ b/ParquetClassLibrary/PublicAPI.Unshipped.txt @@ -83,11 +83,7 @@ override Parquet.Items.InventorySlot.Equals(T inStatus) -> bool override Parquet.Items.InventorySlot.GetHashCode() -> int override Parquet.Items.InventorySlot.ToString() -> string override Parquet.Items.ItemModel.GetAllTags() -> System.Collections.Generic.IEnumerable -override Parquet.Location.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object -override Parquet.Location.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string -override Parquet.Location.DeepClone() -> T override Parquet.Location.Equals(object obj) -> bool -override Parquet.Location.Equals(T inLocation) -> bool override Parquet.Location.GetHashCode() -> int override Parquet.Location.ToString() -> string override Parquet.Model.Equals(object obj) -> bool @@ -446,6 +442,10 @@ Parquet.Items.ModificationTool.None = 0 -> Parquet.Items.ModificationTool Parquet.Items.ModificationTool.Shovel = 1 -> Parquet.Items.ModificationTool Parquet.LibraryState Parquet.Location +Parquet.Location.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object +Parquet.Location.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string +Parquet.Location.Equals(Parquet.Location inLocation) -> bool +Parquet.Location.Location() -> void Parquet.Location.Location(Parquet.ModelID? inRegionID = null, Parquet.Point2D? inPosition = null) -> void Parquet.Location.Position.get -> Parquet.Point2D Parquet.Location.RegionID.get -> Parquet.ModelID diff --git a/ParquetClassLibrary/Status.cs b/ParquetClassLibrary/Status.cs index 18ac505b..9c3fd02b 100644 --- a/ParquetClassLibrary/Status.cs +++ b/ParquetClassLibrary/Status.cs @@ -16,10 +16,6 @@ namespace Parquet /// These companion classes represent the parts of a game object that do not vary by instance /// or with time, and so do not have mutable state during game play. All such Statuses are /// paired with a by manager classes. - /// - // TODO [API] Update the following sentence when we update LOCATION. - /// One Status that does not have a Model companion is , which can - /// be applied to any game object with a definite position within the game world. /// public abstract class Status : IEquatable>, ITypeConverter, IDeeplyCloneable> { From edd31baa5735022c8d00c12d3f5de39e0481d7c6 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 11:55:55 -0800 Subject: [PATCH 05/22] Explicitly alerts users to instances with value semantics. --- ParquetClassLibrary/ModelID.cs | 1 + ParquetClassLibrary/Point2D.cs | 1 + ParquetClassLibrary/Range.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/ParquetClassLibrary/ModelID.cs b/ParquetClassLibrary/ModelID.cs index df945b2a..deca5c59 100644 --- a/ParquetClassLibrary/ModelID.cs +++ b/ParquetClassLibrary/ModelID.cs @@ -12,6 +12,7 @@ namespace Parquet { /// /// Uniquely identifies every . + /// Instances have value semantics. /// /// /// s provide a means for the library diff --git a/ParquetClassLibrary/Point2D.cs b/ParquetClassLibrary/Point2D.cs index ba28c2a1..a634c848 100644 --- a/ParquetClassLibrary/Point2D.cs +++ b/ParquetClassLibrary/Point2D.cs @@ -8,6 +8,7 @@ namespace Parquet { /// /// A simple representation of two coordinate integers, tailored for Parquet's needs. + /// Instances have value semantics. /// public readonly struct Point2D : IEquatable, ITypeConverter { diff --git a/ParquetClassLibrary/Range.cs b/ParquetClassLibrary/Range.cs index fd9ae642..5fe9f70d 100644 --- a/ParquetClassLibrary/Range.cs +++ b/ParquetClassLibrary/Range.cs @@ -11,6 +11,7 @@ namespace Parquet { /// /// Stores the endpoints for a set of values specifying an inclusive range over the given type. + /// Instances have value semantics. /// /// The type over which the range is spread. public readonly struct Range : IEquatable>, ITypeConverter From c570f73333dd892ea6dbfbea1de4618b87b30326 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 13:47:36 -0800 Subject: [PATCH 06/22] Updates out-of-date mutability documentation. --- .../Beings/IMutableCritterModel.cs | 2 +- ParquetClassLibrary/Biomes/BiomeRecipe.cs | 20 ++++++------- ParquetClassLibrary/Crafts/CraftingRecipe.cs | 12 ++++---- .../Crafts/IMutableCraftingRecipe.cs | 2 +- ParquetClassLibrary/Games/GameModel.cs | 10 +++---- .../Games/IMutableGameModel.cs | 2 +- ParquetClassLibrary/IMutableModel.cs | 2 +- .../Items/IMutableItemModel.cs | 2 +- ParquetClassLibrary/Items/ItemModel.cs | 28 +++++++++---------- ParquetClassLibrary/Model.cs | 10 +++---- ParquetClassLibrary/Parquets/BlockModel.cs | 12 ++++---- .../Parquets/CollectibleModel.cs | 8 +++--- ParquetClassLibrary/Parquets/FloorModel.cs | 8 +++--- .../Parquets/FurnishingModel.cs | 20 ++++++------- .../Parquets/IMutableBlockModel.cs | 2 +- .../Parquets/IMutableCollectibleModel.cs | 2 +- .../Parquets/IMutableFloorModel.cs | 2 +- .../Parquets/IMutableFurnishingModel.cs | 2 +- .../Parquets/IMutableParquetModel.cs | 2 +- ParquetClassLibrary/Parquets/ParquetModel.cs | 6 ++-- .../Rooms/IMutableRoomRecipe.cs | 2 +- ParquetClassLibrary/Rooms/RoomRecipe.cs | 8 +++--- .../Scripts/IMutableInteractionModel.cs | 2 +- .../Scripts/IMutableScriptModel.cs | 2 +- .../Scripts/InteractionModel.cs | 12 ++++---- 25 files changed, 90 insertions(+), 90 deletions(-) diff --git a/ParquetClassLibrary/Beings/IMutableCritterModel.cs b/ParquetClassLibrary/Beings/IMutableCritterModel.cs index 2fcc599b..2d311c2d 100644 --- a/ParquetClassLibrary/Beings/IMutableCritterModel.cs +++ b/ParquetClassLibrary/Beings/IMutableCritterModel.cs @@ -5,7 +5,7 @@ namespace Parquet.Beings /// /// /// By design, subtypes of should never themselves use . - /// ICritterModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableCritterModel is for use only by external types that require read/write access to model properties. /// public interface IMutableCritterModel : IMutableBeingModel { diff --git a/ParquetClassLibrary/Biomes/BiomeRecipe.cs b/ParquetClassLibrary/Biomes/BiomeRecipe.cs index 76a93f70..de8dbef0 100644 --- a/ParquetClassLibrary/Biomes/BiomeRecipe.cs +++ b/ParquetClassLibrary/Biomes/BiomeRecipe.cs @@ -85,8 +85,8 @@ public BiomeRecipe(ModelID inID, string inName, string inDescription, string inC /// Must be non-negative. Higher values indicate later Biomes. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableBiomeRecipe is for external types that require read-write access. /// [Ignore] int IMutableBiomeRecipe.Tier @@ -99,8 +99,8 @@ int IMutableBiomeRecipe.Tier /// Determines whether or not this is defined in terms of s. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableBiomeRecipe is for external types that require read-write access. /// [Ignore] bool IMutableBiomeRecipe.IsRoomBased @@ -113,8 +113,8 @@ bool IMutableBiomeRecipe.IsRoomBased /// Determines whether or not this is defined in terms of liquid parquets. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableBiomeRecipe is for external types that require read-write access. /// [Ignore] bool IMutableBiomeRecipe.IsLiquidBased @@ -127,8 +127,8 @@ bool IMutableBiomeRecipe.IsLiquidBased /// Describes the parquets that make up this . /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableBiomeRecipe is for external types that require read-write access. /// [Ignore] ModelTag IMutableBiomeRecipe.ParquetCriteria @@ -141,8 +141,8 @@ ModelTag IMutableBiomeRecipe.ParquetCriteria /// Describes the s a needs to safely access this biome. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableBiomeRecipe is for external types that require read-write access. /// [Ignore] ICollection IMutableBiomeRecipe.EntryRequirements diff --git a/ParquetClassLibrary/Crafts/CraftingRecipe.cs b/ParquetClassLibrary/Crafts/CraftingRecipe.cs index 4910f11d..eaaa293d 100644 --- a/ParquetClassLibrary/Crafts/CraftingRecipe.cs +++ b/ParquetClassLibrary/Crafts/CraftingRecipe.cs @@ -105,8 +105,8 @@ public CraftingRecipe(ModelID inID, string inName, string inDescription, string #region IMutableCraftingRecipe Implementation /// The types and amounts of s created by following this recipe. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCraftingRecipe is for external types that require read-write access. /// [Ignore] ICollection IMutableCraftingRecipe.Products @@ -116,8 +116,8 @@ ICollection IMutableCraftingRecipe.Products /// All materials and their quantities needed to follow this recipe once. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCraftingRecipe is for external types that require read-write access. /// [Ignore] ICollection IMutableCraftingRecipe.Ingredients @@ -127,8 +127,8 @@ ICollection IMutableCraftingRecipe.Ingredients /// The arrangement of panels encompassed by this recipe. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCraftingRecipe is for external types that require read-write access. /// [Ignore] IGrid IMutableCraftingRecipe.PanelPattern => (IGrid)PanelPattern; diff --git a/ParquetClassLibrary/Crafts/IMutableCraftingRecipe.cs b/ParquetClassLibrary/Crafts/IMutableCraftingRecipe.cs index 7ea72d51..ca117d70 100644 --- a/ParquetClassLibrary/Crafts/IMutableCraftingRecipe.cs +++ b/ParquetClassLibrary/Crafts/IMutableCraftingRecipe.cs @@ -7,7 +7,7 @@ namespace Parquet.Crafts /// /// /// By design, subtypes of should never themselves use . - /// ICraftingRecipeEdit is for use only by external types that require read/write access to model properties. + /// IMutableCraftingRecipe is for use only by external types that require read/write access to model properties. /// public interface IMutableCraftingRecipe : IMutableModel { diff --git a/ParquetClassLibrary/Games/GameModel.cs b/ParquetClassLibrary/Games/GameModel.cs index f364ad9d..b4b664e8 100644 --- a/ParquetClassLibrary/Games/GameModel.cs +++ b/ParquetClassLibrary/Games/GameModel.cs @@ -76,7 +76,7 @@ public GameModel(ModelID inID, string inName, string inDescription, string inCom /// If true this game is part of a sequence of games. /// /// By design, subtypes of should never themselves use . - /// IGameModelEdit is for external types that require read/write access. + /// IMutableGameModel is for external types that require read/write access. /// [Ignore] bool IMutableGameModel.IsEpisode @@ -90,7 +90,7 @@ bool IMutableGameModel.IsEpisode /// Subtitle, if any. This will be used as the title of the episode if is true. /// /// By design, subtypes of should never themselves use . - /// IGameModelEdit is for external types that require read/write access. + /// IMutableGameModel is for external types that require read/write access. /// [Ignore] string IMutableGameModel.EpisodeTitle @@ -104,7 +104,7 @@ string IMutableGameModel.EpisodeTitle /// Number of this episode in its sequence, if any. /// /// By design, subtypes of should never themselves use . - /// IGameModelEdit is for external types that require read/write access. + /// IMutableGameModel is for external types that require read/write access. /// [Ignore] int IMutableGameModel.EpisodeNumber @@ -118,7 +118,7 @@ int IMutableGameModel.EpisodeNumber /// The of the that the player controls at the outset. /// /// By design, subtypes of should never themselves use . - /// IGameModelEdit is for external types that require read/write access. + /// IMutableGameModel is for external types that require read/write access. /// [Ignore] ModelID IMutableGameModel.PlayerCharacterID @@ -132,7 +132,7 @@ ModelID IMutableGameModel.PlayerCharacterID /// The of the to run when play begins. /// /// By design, subtypes of should never themselves use . - /// IGameModelEdit is for external types that require read/write access. + /// IMutableGameModel is for external types that require read/write access. /// [Ignore] ModelID IMutableGameModel.FirstScriptID diff --git a/ParquetClassLibrary/Games/IMutableGameModel.cs b/ParquetClassLibrary/Games/IMutableGameModel.cs index 5dceeb85..7fe9f99c 100644 --- a/ParquetClassLibrary/Games/IMutableGameModel.cs +++ b/ParquetClassLibrary/Games/IMutableGameModel.cs @@ -5,7 +5,7 @@ namespace Parquet.Games /// /// /// By design, subtypes of should never themselves use . - /// IGameModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableGameModel is for use only by external types that require read/write access to model properties. /// public interface IMutableGameModel : IMutableModel { diff --git a/ParquetClassLibrary/IMutableModel.cs b/ParquetClassLibrary/IMutableModel.cs index 2453698e..24f16780 100644 --- a/ParquetClassLibrary/IMutableModel.cs +++ b/ParquetClassLibrary/IMutableModel.cs @@ -15,7 +15,7 @@ namespace Parquet /// make changes to the properties of their corresponding models. /// /// By design, subtypes of should never themselves use their interface. - /// IModelEdit is for use only by external types (such as those in a design-time tool) that require read/write access to model + /// IMutableModel is for use only by external types (such as those in a design-time tool) that require read/write access to model /// properties. /// public interface IMutableModel diff --git a/ParquetClassLibrary/Items/IMutableItemModel.cs b/ParquetClassLibrary/Items/IMutableItemModel.cs index b36c4b56..bdbd1863 100644 --- a/ParquetClassLibrary/Items/IMutableItemModel.cs +++ b/ParquetClassLibrary/Items/IMutableItemModel.cs @@ -5,7 +5,7 @@ namespace Parquet.Items /// /// /// By design, subtypes of should never themselves use . - /// IItemModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableItemModel is for use only by external types that require read/write access to model properties. /// public interface IMutableItemModel : IMutableModel { diff --git a/ParquetClassLibrary/Items/ItemModel.cs b/ParquetClassLibrary/Items/ItemModel.cs index b594553f..59fc7703 100644 --- a/ParquetClassLibrary/Items/ItemModel.cs +++ b/ParquetClassLibrary/Items/ItemModel.cs @@ -98,8 +98,8 @@ public ItemModel(ModelID inID, string inName, string inDescription, string inCom #region IMutableItemModel Implementation /// The type of item this is. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] ItemType IMutableItemModel.Subtype @@ -112,8 +112,8 @@ ItemType IMutableItemModel.Subtype /// In-game value of the item. Must be non-negative. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] int IMutableItemModel.Price @@ -126,8 +126,8 @@ int IMutableItemModel.Price /// How relatively rare this item is. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] int IMutableItemModel.Rarity @@ -140,8 +140,8 @@ int IMutableItemModel.Rarity /// How many of the item may share a single inventory slot. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] int IMutableItemModel.StackMax @@ -157,8 +157,8 @@ int IMutableItemModel.StackMax /// keeping the item in a 's . /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] ModelID IMutableItemModel.EffectWhileHeldID @@ -174,8 +174,8 @@ ModelID IMutableItemModel.EffectWhileHeldID /// using (consuming) the item. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] ModelID IMutableItemModel.EffectWhenUsedID @@ -188,8 +188,8 @@ ModelID IMutableItemModel.EffectWhenUsedID /// The parquet that corresponds to this item, if any. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableItemModel is for external types that require read-write access. /// [Ignore] ModelID IMutableItemModel.ParquetID diff --git a/ParquetClassLibrary/Model.cs b/ParquetClassLibrary/Model.cs index 96df8bf4..2211bd26 100644 --- a/ParquetClassLibrary/Model.cs +++ b/ParquetClassLibrary/Model.cs @@ -88,7 +88,7 @@ protected Model(Range inBounds, ModelID inID, string inName, string inD /// Game-wide unique identifier. /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// /// Be especially cautious editing this property. /// @@ -104,7 +104,7 @@ ModelID IMutableModel.ID /// Player-facing name. /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// [Ignore] string IMutableModel.Name @@ -118,7 +118,7 @@ string IMutableModel.Name /// Player-facing description. /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// [Ignore] string IMutableModel.Description @@ -132,7 +132,7 @@ string IMutableModel.Description /// Optional comment. /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// [Ignore] string IMutableModel.Comment @@ -146,7 +146,7 @@ string IMutableModel.Comment /// Any additional functionality this item has, e.g. contributing to a . /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// IMutableModel is for external types that require read-write access. /// [Ignore] ICollection IMutableModel.Tags diff --git a/ParquetClassLibrary/Parquets/BlockModel.cs b/ParquetClassLibrary/Parquets/BlockModel.cs index 318546ba..7071701d 100644 --- a/ParquetClassLibrary/Parquets/BlockModel.cs +++ b/ParquetClassLibrary/Parquets/BlockModel.cs @@ -96,7 +96,7 @@ public BlockModel(ModelID inID, string inName, string inDescription, string inCo /// The tool used to remove the block. /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for external types that require read/write access. + /// IMutableBlockModel is for external types that require read/write access. /// [Ignore] GatheringTool IMutableBlockModel.GatherTool @@ -110,7 +110,7 @@ GatheringTool IMutableBlockModel.GatherTool /// The effect generated when a character gathers this Block. /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for external types that require read/write access. + /// IMutableBlockModel is for external types that require read/write access. /// [Ignore] GatheringEffect IMutableBlockModel.GatherEffect @@ -124,7 +124,7 @@ GatheringEffect IMutableBlockModel.GatherEffect /// The Collectible spawned when a character gathers this Block. /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for external types that require read/write access. + /// IMutableBlockModel is for external types that require read/write access. /// [Ignore] ModelID IMutableBlockModel.CollectibleID @@ -138,7 +138,7 @@ ModelID IMutableBlockModel.CollectibleID /// Whether or not the block is flammable. /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for external types that require read/write access. + /// IMutableBlockModel is for external types that require read/write access. /// [Ignore] bool IMutableBlockModel.IsFlammable @@ -152,7 +152,7 @@ bool IMutableBlockModel.IsFlammable /// Whether or not the block is a liquid. /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for external types that require read/write access. + /// IMutableBlockModel is for external types that require read/write access. /// [Ignore] bool IMutableBlockModel.IsLiquid @@ -166,7 +166,7 @@ bool IMutableBlockModel.IsLiquid /// The block's native toughness. /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for external types that require read/write access. + /// IMutableBlockModel is for external types that require read/write access. /// [Ignore] int IMutableBlockModel.MaxToughness diff --git a/ParquetClassLibrary/Parquets/CollectibleModel.cs b/ParquetClassLibrary/Parquets/CollectibleModel.cs index fb5b9bc7..4eaaf974 100644 --- a/ParquetClassLibrary/Parquets/CollectibleModel.cs +++ b/ParquetClassLibrary/Parquets/CollectibleModel.cs @@ -59,8 +59,8 @@ public CollectibleModel(ModelID inID, string inName, string inDescription, strin #region IMutableCollectibleModel Implementation /// The effect generated when a character encounters this Collectible. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableCollectibleModel is for external types that require read/write access. /// [Ignore] CollectingEffect IMutableCollectibleModel.CollectionEffect @@ -76,8 +76,8 @@ CollectingEffect IMutableCollectibleModel.CollectionEffect /// For example, how much to alter a stat if the is set to alter a stat. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableCollectibleModel is for external types that require read/write access. /// [Ignore] int IMutableCollectibleModel.EffectAmount diff --git a/ParquetClassLibrary/Parquets/FloorModel.cs b/ParquetClassLibrary/Parquets/FloorModel.cs index 16a7ce41..a6ab8a34 100644 --- a/ParquetClassLibrary/Parquets/FloorModel.cs +++ b/ParquetClassLibrary/Parquets/FloorModel.cs @@ -60,8 +60,8 @@ public FloorModel(ModelID inID, string inName, string inDescription, string inCo #region IMutableFloorModel Implementation /// The tool used to dig out or fill in the floor. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFloorModel is for external types that require read/write access. /// [Ignore] ModificationTool IMutableFloorModel.ModTool @@ -74,8 +74,8 @@ ModificationTool IMutableFloorModel.ModTool /// Player-facing name of the parquet, used when it has been dug out. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFloorModel is for external types that require read/write access. /// [Ignore] string IMutableFloorModel.TrenchName diff --git a/ParquetClassLibrary/Parquets/FurnishingModel.cs b/ParquetClassLibrary/Parquets/FurnishingModel.cs index 5db35ddd..530f2fb9 100644 --- a/ParquetClassLibrary/Parquets/FurnishingModel.cs +++ b/ParquetClassLibrary/Parquets/FurnishingModel.cs @@ -79,8 +79,8 @@ public FurnishingModel(ModelID inID, string inName, string inDescription, string #region IMutableFurnishingModel Implementation /// Indicates whether this may be walked on. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFurnishingModel is for external types that require read/write access. /// [Ignore] bool IMutableFurnishingModel.IsWalkable @@ -93,8 +93,8 @@ bool IMutableFurnishingModel.IsWalkable /// Indicates if and how this serves as an entry to a or . /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFurnishingModel is for external types that require read/write access. /// [Ignore] EntryType IMutableFurnishingModel.Entry @@ -107,8 +107,8 @@ EntryType IMutableFurnishingModel.Entry /// Indicates whether this serves as part of a perimeter of a . /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFurnishingModel is for external types that require read/write access. /// [Ignore] bool IMutableFurnishingModel.IsEnclosing @@ -121,8 +121,8 @@ bool IMutableFurnishingModel.IsEnclosing /// Whether or not the is flammable. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFurnishingModel is for external types that require read/write access. /// [Ignore] bool IMutableFurnishingModel.IsFlammable @@ -135,8 +135,8 @@ bool IMutableFurnishingModel.IsFlammable /// The to swap with this Furnishing on an open/close action. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableFurnishingModel is for external types that require read/write access. /// [Ignore] ModelID IMutableFurnishingModel.SwapID diff --git a/ParquetClassLibrary/Parquets/IMutableBlockModel.cs b/ParquetClassLibrary/Parquets/IMutableBlockModel.cs index 974e1b5e..baa7e207 100644 --- a/ParquetClassLibrary/Parquets/IMutableBlockModel.cs +++ b/ParquetClassLibrary/Parquets/IMutableBlockModel.cs @@ -7,7 +7,7 @@ namespace Parquet.Parquets /// /// /// By design, subtypes of should never themselves use . - /// IBlockModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableBlockModel is for use only by external types that require read/write access to model properties. /// public interface IMutableBlockModel : IMutableParquetModel { diff --git a/ParquetClassLibrary/Parquets/IMutableCollectibleModel.cs b/ParquetClassLibrary/Parquets/IMutableCollectibleModel.cs index 21fa50ed..c7089a1b 100644 --- a/ParquetClassLibrary/Parquets/IMutableCollectibleModel.cs +++ b/ParquetClassLibrary/Parquets/IMutableCollectibleModel.cs @@ -5,7 +5,7 @@ namespace Parquet.Parquets /// /// /// By design, subtypes of should never themselves use . - /// ICollectibleModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableCollectibleModel is for use only by external types that require read/write access to model properties. /// public interface IMutableCollectibleModel : IMutableParquetModel { diff --git a/ParquetClassLibrary/Parquets/IMutableFloorModel.cs b/ParquetClassLibrary/Parquets/IMutableFloorModel.cs index eea6a9c5..b6ac9ef2 100644 --- a/ParquetClassLibrary/Parquets/IMutableFloorModel.cs +++ b/ParquetClassLibrary/Parquets/IMutableFloorModel.cs @@ -7,7 +7,7 @@ namespace Parquet.Parquets /// /// /// By design, subtypes of should never themselves use . - /// IFloorModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableFloorModel is for use only by external types that require read/write access to model properties. /// public interface IMutableFloorModel : IMutableParquetModel { diff --git a/ParquetClassLibrary/Parquets/IMutableFurnishingModel.cs b/ParquetClassLibrary/Parquets/IMutableFurnishingModel.cs index b21e2a24..a458bd49 100644 --- a/ParquetClassLibrary/Parquets/IMutableFurnishingModel.cs +++ b/ParquetClassLibrary/Parquets/IMutableFurnishingModel.cs @@ -5,7 +5,7 @@ namespace Parquet.Parquets /// /// /// By design, subtypes of should never themselves use . - /// IFurnishingModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableFurnishingModel is for use only by external types that require read/write access to model properties. /// public interface IMutableFurnishingModel : IMutableParquetModel { diff --git a/ParquetClassLibrary/Parquets/IMutableParquetModel.cs b/ParquetClassLibrary/Parquets/IMutableParquetModel.cs index fc30ee8e..3e9d5a10 100644 --- a/ParquetClassLibrary/Parquets/IMutableParquetModel.cs +++ b/ParquetClassLibrary/Parquets/IMutableParquetModel.cs @@ -7,7 +7,7 @@ namespace Parquet.Parquets /// /// /// By design, subtypes of should never themselves use . - /// IParquetModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableParquetModel is for use only by external types that require read/write access to model properties. /// public interface IMutableParquetModel : IMutableModel { diff --git a/ParquetClassLibrary/Parquets/ParquetModel.cs b/ParquetClassLibrary/Parquets/ParquetModel.cs index f5818421..e40481f6 100644 --- a/ParquetClassLibrary/Parquets/ParquetModel.cs +++ b/ParquetClassLibrary/Parquets/ParquetModel.cs @@ -84,7 +84,7 @@ public override IEnumerable GetAllTags() /// /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// [Ignore] ModelID IMutableParquetModel.ItemID @@ -101,7 +101,7 @@ ModelID IMutableParquetModel.ItemID /// /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// [Ignore] ICollection IMutableParquetModel.AddsToBiome @@ -115,7 +115,7 @@ ICollection IMutableParquetModel.AddsToBiome /// /// /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// IMutableModel is for external types that require read/write access. /// [Ignore] ICollection IMutableParquetModel.AddsToRoom diff --git a/ParquetClassLibrary/Rooms/IMutableRoomRecipe.cs b/ParquetClassLibrary/Rooms/IMutableRoomRecipe.cs index 827da02b..ccec955f 100644 --- a/ParquetClassLibrary/Rooms/IMutableRoomRecipe.cs +++ b/ParquetClassLibrary/Rooms/IMutableRoomRecipe.cs @@ -7,7 +7,7 @@ namespace Parquet.Rooms /// /// /// By design, subtypes of should never themselves use . - /// IRoomRecipeEdit is for use only by external types that require read/write access to model properties. + /// IMutableRoomRecipe is for use only by external types that require read/write access to model properties. /// public interface IMutableRoomRecipe : IMutableModel { diff --git a/ParquetClassLibrary/Rooms/RoomRecipe.cs b/ParquetClassLibrary/Rooms/RoomRecipe.cs index f4414523..1165df22 100644 --- a/ParquetClassLibrary/Rooms/RoomRecipe.cs +++ b/ParquetClassLibrary/Rooms/RoomRecipe.cs @@ -82,7 +82,7 @@ public RoomRecipe(ModelID inID, string inName, string inDescription, string inCo /// Minimum number of open spaces needed for this to register. /// /// By design, subtypes of should never themselves use . - /// IRoomRecipeEdit is for external types that require read/write access. + /// IMutableRoomRecipe is for external types that require read/write access. /// [Ignore] int IMutableRoomRecipe.MinimumWalkableSpaces @@ -96,7 +96,7 @@ int IMutableRoomRecipe.MinimumWalkableSpaces /// A list of categories this requires. /// /// By design, subtypes of should never themselves use . - /// IRoomRecipeEdit is for external types that require read/write access. + /// IMutableRoomRecipe is for external types that require read/write access. /// [Ignore] ICollection IMutableRoomRecipe.OptionallyRequiredFurnishings @@ -107,7 +107,7 @@ ICollection IMutableRoomRecipe.OptionallyRequiredFurnishings /// An optional list of categories this requires. /// /// By design, subtypes of should never themselves use . - /// IRoomRecipeEdit is for external types that require read/write access. + /// IMutableRoomRecipe is for external types that require read/write access. /// [Ignore] ICollection IMutableRoomRecipe.OptionallyRequiredWalkableFloors @@ -118,7 +118,7 @@ ICollection IMutableRoomRecipe.OptionallyRequiredWalkableFloors /// An optional list of categories this requires as walls. /// /// By design, subtypes of should never themselves use . - /// IRoomRecipeEdit is for external types that require read/write access. + /// IMutableRoomRecipe is for external types that require read/write access. /// [Ignore] ICollection IMutableRoomRecipe.OptionallyRequiredPerimeterBlocks diff --git a/ParquetClassLibrary/Scripts/IMutableInteractionModel.cs b/ParquetClassLibrary/Scripts/IMutableInteractionModel.cs index 277abd5b..219c184a 100644 --- a/ParquetClassLibrary/Scripts/IMutableInteractionModel.cs +++ b/ParquetClassLibrary/Scripts/IMutableInteractionModel.cs @@ -7,7 +7,7 @@ namespace Parquet.Scripts /// /// /// By design, subtypes of should never themselves use . - /// IInteractionModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableInteractionModel is for use only by external types that require read/write access to model properties. /// public interface IMutableInteractionModel : IMutableModel { diff --git a/ParquetClassLibrary/Scripts/IMutableScriptModel.cs b/ParquetClassLibrary/Scripts/IMutableScriptModel.cs index 28a046b2..344bd130 100644 --- a/ParquetClassLibrary/Scripts/IMutableScriptModel.cs +++ b/ParquetClassLibrary/Scripts/IMutableScriptModel.cs @@ -7,7 +7,7 @@ namespace Parquet.Scripts /// /// /// By design, subtypes of should never themselves use . - /// IScriptModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableScriptModel is for use only by external types that require read/write access to model properties. /// public interface IMutableScriptModel : IMutableModel { diff --git a/ParquetClassLibrary/Scripts/InteractionModel.cs b/ParquetClassLibrary/Scripts/InteractionModel.cs index a9d3c961..8a04a5c5 100644 --- a/ParquetClassLibrary/Scripts/InteractionModel.cs +++ b/ParquetClassLibrary/Scripts/InteractionModel.cs @@ -65,8 +65,8 @@ public InteractionModel(ModelID inID, string inName, string inDescription, strin /// Describes the criteria for beginning this interaction. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableInteractionModel is for external types that require read/write access. /// [Ignore] ICollection IMutableInteractionModel.PrerequisitesIDs @@ -78,8 +78,8 @@ ICollection IMutableInteractionModel.PrerequisitesIDs /// Everything this interaction entails. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableInteractionModel is for external types that require read/write access. /// [Ignore] ICollection IMutableInteractionModel.StepsIDs @@ -91,8 +91,8 @@ ICollection IMutableInteractionModel.StepsIDs /// Describes the results of finishing this interaction. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read/write access. + /// By design, subtypes of should never themselves use . + /// IMutableInteractionModel is for external types that require read/write access. /// [Ignore] ICollection IMutableInteractionModel.OutcomesIDs From b07d7a5c1e4e0ffabdaf24037e46f6248de8fb9b Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 13:47:52 -0800 Subject: [PATCH 07/22] Prefers property to field for public member. --- ParquetClassLibrary/Games/GameModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParquetClassLibrary/Games/GameModel.cs b/ParquetClassLibrary/Games/GameModel.cs index b4b664e8..098eca01 100644 --- a/ParquetClassLibrary/Games/GameModel.cs +++ b/ParquetClassLibrary/Games/GameModel.cs @@ -13,7 +13,7 @@ public class GameModel : Model, IMutableGameModel { #region Class Defaults /// Indicates an uninitialized game. - public static readonly GameModel Empty = new GameModel(ModelID.None, nameof(Empty), "", ""); + public static GameModel Empty { get; } = new GameModel(ModelID.None, nameof(Empty), "", ""); #endregion #region Characteristics From 8be134a96f0142710f2e65fac95b01cc03670855 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 13:49:28 -0800 Subject: [PATCH 08/22] Adds missing initial conditions to CharacterModel. --- ParquetClassLibrary/Beings/CharacterModel.cs | 26 ++++++++++++++++--- .../Beings/IMutableCharacterModel.cs | 8 +++++- ParquetClassLibrary/PublicAPI.Unshipped.txt | 4 +++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ParquetClassLibrary/Beings/CharacterModel.cs b/ParquetClassLibrary/Beings/CharacterModel.cs index fb3be248..d4f12ed4 100644 --- a/ParquetClassLibrary/Beings/CharacterModel.cs +++ b/ParquetClassLibrary/Beings/CharacterModel.cs @@ -15,6 +15,11 @@ namespace Parquet.Beings Justification = "By design, subtypes of Model should never themselves use IMutableModel or derived interfaces to access their own members. The IMutableModel family of interfaces is for external types that require read/write access.")] public class CharacterModel : BeingModel, IMutableCharacterModel { + #region Class Defaults + /// Indicates an uninitialized character. + public static CharacterModel Unused { get; } = new CharacterModel(ModelID.None, nameof(Unused), "", ""); + #endregion + #region Characteristics /// Player-facing personal name. [Ignore] @@ -51,16 +56,24 @@ public string FamilyName [Index(10)] public string StoryCharacterID { get; private set; } + /// The the begins at. + [Index(11)] + public Location StartingLocation { get; private set; } + + /// The for the initially governing the . + [Index(12)] + public ModelID StartingBehaviorID { get; private set; } + /// The s that this either offers or has undertaken. /// Typically, NPCs offer quests, player characters undertake them. - [Index(11)] - public IReadOnlyList StartingQuestIDs { get; } + [Index(13)] + public IReadOnlyList StartingQuestIDs { get; private set; } /// /// The of the that this /// can say at the outset. /// - [Index(12)] + [Index(14)] public ModelID StartingDialogueID { get; private set; } /// The set of belongings that this begins with. @@ -94,11 +107,14 @@ public CharacterModel(ModelID inID, string inName, string inDescription, string IEnumerable inTags = null, ModelID? inNativeBiomeID = null, ModelID? inPrimaryBehaviorID = null, IEnumerable inAvoidsIDs = null, IEnumerable inSeeksIDs = null, string inPronounKey = PronounGroup.DefaultKey, - string inStoryCharacterID = "", IEnumerable inStartingQuestIDs = null, + string inStoryCharacterID = "", Location? inStartingLocation = null, + ModelID? inStartingBehaviorID = null, IEnumerable inStartingQuestIDs = null, ModelID? inStartingDialogueID = null, Inventory inStartingInventory = null) : base(All.CharacterIDs, inID, inName, inDescription, inComment, inTags, inNativeBiomeID, inPrimaryBehaviorID, inAvoidsIDs, inSeeksIDs) { + var nonNullStartingLocation = inStartingLocation ?? Location.Nowhere; + var nonNullStartingBehaviorID = inStartingBehaviorID ?? ModelID.None; var nonNullQuestIDs = inStartingQuestIDs ?? Enumerable.Empty(); var nonNullDialogueID = inStartingDialogueID ?? ModelID.None; var nonNullInventory = inStartingInventory ?? Inventory.Empty; @@ -108,6 +124,8 @@ public CharacterModel(ModelID inID, string inName, string inDescription, string PronounKey = inPronounKey; StoryCharacterID = inStoryCharacterID; + StartingLocation = nonNullStartingLocation; + StartingBehaviorID = nonNullStartingBehaviorID; StartingQuestIDs = nonNullQuestIDs.ToList(); StartingDialogueID = nonNullDialogueID; StartingInventory = nonNullInventory; diff --git a/ParquetClassLibrary/Beings/IMutableCharacterModel.cs b/ParquetClassLibrary/Beings/IMutableCharacterModel.cs index cc7b2516..e94ae8db 100644 --- a/ParquetClassLibrary/Beings/IMutableCharacterModel.cs +++ b/ParquetClassLibrary/Beings/IMutableCharacterModel.cs @@ -8,7 +8,7 @@ namespace Parquet.Beings /// /// /// By design, subtypes of should never themselves use . - /// ICharacterModelEdit is for use only by external types that require read/write access to model properties. + /// IMutableCharacterModel is for use only by external types that require read/write access to model properties. /// public interface IMutableCharacterModel : IMutableBeingModel { @@ -34,6 +34,12 @@ public interface IMutableCharacterModel : IMutableBeingModel /// public string StoryCharacterID { get; set; } + /// The the begins at. + public Location StartingLocation { get; set; } + + /// The for the initially governing the . + public ModelID StartingBehaviorID { get; set; } + /// The s that this either offers or has undertaken. /// Typically, NPCs offer quests, player characters undertake them. public ICollection StartingQuestIDs { get; } diff --git a/ParquetClassLibrary/PublicAPI.Unshipped.txt b/ParquetClassLibrary/PublicAPI.Unshipped.txt index 094c4e21..69e8d1f2 100644 --- a/ParquetClassLibrary/PublicAPI.Unshipped.txt +++ b/ParquetClassLibrary/PublicAPI.Unshipped.txt @@ -224,9 +224,13 @@ Parquet.Beings.IMutableCharacterModel.PersonalName.get -> string Parquet.Beings.IMutableCharacterModel.PersonalName.set -> void Parquet.Beings.IMutableCharacterModel.PronounKey.get -> string Parquet.Beings.IMutableCharacterModel.PronounKey.set -> void +Parquet.Beings.IMutableCharacterModel.StartingBehaviorID.get -> Parquet.ModelID +Parquet.Beings.IMutableCharacterModel.StartingBehaviorID.set -> void Parquet.Beings.IMutableCharacterModel.StartingDialogueID.get -> Parquet.ModelID Parquet.Beings.IMutableCharacterModel.StartingDialogueID.set -> void Parquet.Beings.IMutableCharacterModel.StartingInventory.get -> Parquet.Items.Inventory +Parquet.Beings.IMutableCharacterModel.StartingLocation.get -> Parquet.Location +Parquet.Beings.IMutableCharacterModel.StartingLocation.set -> void Parquet.Beings.IMutableCharacterModel.StartingQuestIDs.get -> System.Collections.Generic.ICollection Parquet.Beings.IMutableCharacterModel.StoryCharacterID.get -> string Parquet.Beings.IMutableCharacterModel.StoryCharacterID.set -> void From 851eec9d0067db138c785023392fcd3e1d0019f6 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 13:49:54 -0800 Subject: [PATCH 09/22] Updates out-of-date mutability documentation. --- ParquetClassLibrary/Beings/CharacterModel.cs | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ParquetClassLibrary/Beings/CharacterModel.cs b/ParquetClassLibrary/Beings/CharacterModel.cs index d4f12ed4..9e5af8e4 100644 --- a/ParquetClassLibrary/Beings/CharacterModel.cs +++ b/ParquetClassLibrary/Beings/CharacterModel.cs @@ -135,8 +135,8 @@ public CharacterModel(ModelID inID, string inName, string inDescription, string #region IMutableCharacterModel Implementation /// Player-facing personal name. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] string IMutableCharacterModel.PersonalName @@ -149,8 +149,8 @@ string IMutableCharacterModel.PersonalName /// Player-facing family name. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] string IMutableCharacterModel.FamilyName @@ -166,8 +166,8 @@ string IMutableCharacterModel.FamilyName /// stored as "/. /// /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] string IMutableCharacterModel.PronounKey @@ -180,8 +180,8 @@ string IMutableCharacterModel.PronounKey /// The story character that this represents. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] string IMutableCharacterModel.StoryCharacterID @@ -194,8 +194,8 @@ string IMutableCharacterModel.StoryCharacterID /// The s that this either offers or has undertaken. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] ICollection IMutableCharacterModel.StartingQuestIDs @@ -205,8 +205,8 @@ ICollection IMutableCharacterModel.StartingQuestIDs /// Dialogue lines this can say. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] ModelID IMutableCharacterModel.StartingDialogueID @@ -220,8 +220,8 @@ ModelID IMutableCharacterModel.StartingDialogueID /// The s that this either offers or has undertaken. /// - /// By design, subtypes of should never themselves use . - /// IModelEdit is for external types that require read-write access. + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] Inventory IMutableCharacterModel.StartingInventory From c97983c61d7508715a44f9972e2705ddb3dbdc4e Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:01:42 -0800 Subject: [PATCH 10/22] Adds missing members. --- ParquetClassLibrary/Beings/CharacterModel.cs | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ParquetClassLibrary/Beings/CharacterModel.cs b/ParquetClassLibrary/Beings/CharacterModel.cs index 9e5af8e4..fbfada0e 100644 --- a/ParquetClassLibrary/Beings/CharacterModel.cs +++ b/ParquetClassLibrary/Beings/CharacterModel.cs @@ -192,6 +192,34 @@ string IMutableCharacterModel.StoryCharacterID : value; } + /// The the begins at. + /// + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. + /// + [Ignore] + Location IMutableCharacterModel.StartingLocation + { + get => StartingLocation; + set => StartingLocation = LibraryState.IsPlayMode + ? Logger.DefaultWithImmutableInPlayLog(nameof(StartingLocation), StartingLocation) + : value; + } + + /// The for the initially governing the . + /// + /// By design, subtypes of should never themselves use . + /// IMutableCharacterModel is for external types that require read-write access. + /// + [Ignore] + ModelID IMutableCharacterModel.StartingBehaviorID + { + get => StartingBehaviorID; + set => StartingBehaviorID = LibraryState.IsPlayMode + ? Logger.DefaultWithImmutableInPlayLog(nameof(StartingBehaviorID), StartingBehaviorID) + : value; + } + /// The s that this either offers or has undertaken. /// /// By design, subtypes of should never themselves use . From 5ca579717909cd1d3d597c4dc615d76ad9fd5880 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:26:07 -0800 Subject: [PATCH 11/22] Changes private set to protected set. --- ParquetClassLibrary/Beings/BeingModel.cs | 4 ++-- ParquetClassLibrary/Parquets/ParquetModel.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ParquetClassLibrary/Beings/BeingModel.cs b/ParquetClassLibrary/Beings/BeingModel.cs index d97beea1..58b9639e 100644 --- a/ParquetClassLibrary/Beings/BeingModel.cs +++ b/ParquetClassLibrary/Beings/BeingModel.cs @@ -17,11 +17,11 @@ public abstract class BeingModel : Model, IMutableBeingModel #region Characteristics /// The of the in which this character is at home. [Index(5)] - public ModelID NativeBiomeID { get; private set; } + public ModelID NativeBiomeID { get; protected set; } /// The of the governing the way this being acts. [Index(6)] - public ModelID PrimaryBehaviorID { get; private set; } + public ModelID PrimaryBehaviorID { get; protected set; } /// Types of parquets this avoids, if any. [Index(7)] diff --git a/ParquetClassLibrary/Parquets/ParquetModel.cs b/ParquetClassLibrary/Parquets/ParquetModel.cs index e40481f6..74a7a02f 100644 --- a/ParquetClassLibrary/Parquets/ParquetModel.cs +++ b/ParquetClassLibrary/Parquets/ParquetModel.cs @@ -19,14 +19,14 @@ public abstract class ParquetModel : Model, IMutableParquetModel /// The of the awarded to the player when a character gathers or collects this parquet. /// [Index(5)] - public ModelID ItemID { get; private set; } + public ModelID ItemID { get; protected set; } /// /// Describes the (s) that this parquet helps form. /// Guaranteed to never be null. /// [Index(6)] - public IReadOnlyList AddsToBiome { get; private set; } + public IReadOnlyList AddsToBiome { get; protected set; } /// /// A property of the parquet that can, for example, be used by s. @@ -36,7 +36,7 @@ public abstract class ParquetModel : Model, IMutableParquetModel /// Allows the creation of classes of constructs, for example "wooden", "golden", "rustic", or "fancy" rooms. /// [Index(7)] - public IReadOnlyList AddsToRoom { get; private set; } + public IReadOnlyList AddsToRoom { get; protected set; } #endregion #region Initialization From e1f720ee6a21700c319f2f8e23e39e6e5cc026df Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:26:16 -0800 Subject: [PATCH 12/22] Automatically copies icon file. --- ParquetClassLibrary/ParquetIcon.ico | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ParquetClassLibrary/ParquetIcon.ico diff --git a/ParquetClassLibrary/ParquetIcon.ico b/ParquetClassLibrary/ParquetIcon.ico new file mode 100644 index 00000000..a3d2bc4c --- /dev/null +++ b/ParquetClassLibrary/ParquetIcon.ico @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abf75ca92918359b958b38bf0db9f33e1e73621a261332fc927f569210ff5536 +size 894 From d7d9550f7bf06da9ef27aafe6e6f7d0a6177a866 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:30:11 -0800 Subject: [PATCH 13/22] Splits BeingStatus into CharacterStatus and CritterStatus. Should have been like this from the start but I was lazy ^_^U --- ParquetClassLibrary/Beings/BeingStatus.cs | 384 +----------------- ParquetClassLibrary/Beings/CharacterModel.cs | 24 +- ParquetClassLibrary/Beings/CharacterStatus.cs | 323 +++++++++++++++ ParquetClassLibrary/Beings/CritterModel.cs | 5 + ParquetClassLibrary/Beings/CritterStatus.cs | 171 ++++++++ .../Beings/IMutableCharacterModel.cs | 3 - ParquetClassLibrary/PublicAPI.Unshipped.txt | 110 +++-- 7 files changed, 572 insertions(+), 448 deletions(-) create mode 100644 ParquetClassLibrary/Beings/CharacterStatus.cs create mode 100644 ParquetClassLibrary/Beings/CritterStatus.cs diff --git a/ParquetClassLibrary/Beings/BeingStatus.cs b/ParquetClassLibrary/Beings/BeingStatus.cs index 77c2c6cd..00b48dcd 100644 --- a/ParquetClassLibrary/Beings/BeingStatus.cs +++ b/ParquetClassLibrary/Beings/BeingStatus.cs @@ -1,388 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using CsvHelper; -using CsvHelper.Configuration; - namespace Parquet.Beings { /// - /// Tracks the status of a . + /// Tracks the status of a during play. /// Instances of this class are mutable during play. /// - /// - /// Most of the game interaction is mediated through instances of this class. - /// - public class BeingStatus : Status + public abstract class BeingStatus : Status + where T : BeingModel { - #region Class Defaults - /// Provides a throwaway instance of the class with default values. - public static BeingStatus Unused { get; } = new BeingStatus(); - #endregion - - #region Status - /// The the tracked occupies. - public Location Position { get; set; } - - /// The the tracked will next spawn at. - /// For example, for s, this might be the spot the where when the game was last saved. - public Location SpawnAt { get; set; } - - /// The the assigned to this . - public Location RoomAssignment { get; set; } - - /// The for the currently governing the tracked . - public ModelID CurrentBehaviorID { get; set; } - - /// The time remaining that the tracked can safely remain in the current . - /// It is likely that this will only be used by but may be useful for other beings as well. - public int BiomeTimeRemaining { get; set; } - - /// The time it takes the tracked to place new parquets. - public float BuildingSpeed { get; set; } - - /// The time it takes the tracked to modify existing parquets. - public float ModificationSpeed { get; set; } - - /// The time it takes the tracked to gather existing parquets. - public float GatheringSpeed { get; set; } - - /// The time it takes the tracked to walk from one to another. - public float MovementSpeed { get; set; } - #endregion - - #region Collections - /// The s that this has encountered. - public ICollection KnownBeings { get; } - - /// The parquets that this has encountered. - public ICollection KnownParquets { get; } - - /// The s that this knows. - public ICollection KnownRoomRecipes { get; } - - /// The s that this knows. - public ICollection KnownCraftingRecipes { get; } - - /// The s that this offers or has undertaken. - public ICollection Quests { get; } - - /// This 's set of belongings. - public ICollection Inventory { get; } - #endregion - - #region Initialization - /// - /// Initializes a new instance of the class. - /// - /// The the tracked occupies. - /// The the tracked will next spawn at. - /// The of the to which the tracked is assigned. - /// The behavior currently governing the tracked . - /// How long [TODO in what units?] to until being kicked out of the current . - /// The time it takes the tracked to place new parquets. - /// The time it takes the tracked to modify existing parquets. - /// The time it takes the tracked to gather existing parquets. - /// The time it takes the tracked to walk from one to another. - /// The s that this has encountered. - /// The parquets that this has encountered. - /// The s that this knows. - /// The s that this knows. - /// The s that this offers or has undertaken. - /// This 's set of belongings. - public BeingStatus(Location inPosition = null, Location inSpawnAt = null, Location inRoomAssignment = null, - ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = 0, float inBuildingSpeed = 0f, - float inModificationSpeed = 0f, float inGatheringSpeed = 0f, float inMovementSpeed = 0f, - ICollection inKnownBeings = null, ICollection inKnownParquets = null, - ICollection inKnownRoomRecipes = null, ICollection inKnownCraftingRecipes = null, - ICollection inQuests = null, ICollection inInventory = null) - { - var nonNullPosition = inPosition ?? Location.Nowhere; - var nonNullSpawnAt = inSpawnAt ?? Location.Nowhere; - var nonNullRoomAssignment = inRoomAssignment ?? Location.Nowhere; - var nonNullCurrentBehavior = inCurrentBehavior ?? ModelID.None; - Precondition.IsInRange(nonNullCurrentBehavior, All.ScriptIDs, nameof(inCurrentBehavior)); - var nonNullBeings = inKnownBeings ?? Enumerable.Empty().ToList(); - var nonNullParquets = inKnownParquets ?? Enumerable.Empty().ToList(); - var nonNullRoomRecipes = inKnownRoomRecipes ?? Enumerable.Empty().ToList(); - var nonNullCraftingRecipes = inKnownCraftingRecipes ?? Enumerable.Empty().ToList(); - var nonNullQuests = inQuests ?? Enumerable.Empty().ToList(); - var nonNullInventory = inInventory ?? Enumerable.Empty().ToList(); - Precondition.AreInRange(nonNullBeings, All.CritterIDs, nameof(inKnownBeings)); - Precondition.AreInRange(nonNullParquets, All.ParquetIDs, nameof(inKnownParquets)); - Precondition.AreInRange(nonNullRoomRecipes, All.RoomRecipeIDs, nameof(inKnownRoomRecipes)); - Precondition.AreInRange(nonNullCraftingRecipes, All.CraftingRecipeIDs, nameof(inKnownCraftingRecipes)); - Precondition.AreInRange(nonNullQuests, All.InteractionIDs, nameof(inQuests)); - Precondition.AreInRange(nonNullInventory, All.ItemIDs, nameof(inInventory)); - - Position = nonNullPosition; - SpawnAt = nonNullSpawnAt; - RoomAssignment = nonNullRoomAssignment; - CurrentBehaviorID = nonNullCurrentBehavior; - BiomeTimeRemaining = inBiomeTimeRemaining; - BuildingSpeed = inBuildingSpeed; - ModificationSpeed = inModificationSpeed; - GatheringSpeed = inGatheringSpeed; - MovementSpeed = inMovementSpeed; - KnownBeings = nonNullBeings; - KnownParquets = nonNullParquets; - KnownRoomRecipes = nonNullRoomRecipes; - KnownCraftingRecipes = nonNullCraftingRecipes; - Quests = nonNullQuests; - Inventory = nonNullInventory; - } - - - /// - /// Initializes an instance of the class - /// based on a given instance. - /// - /// The definitions being tracked. - public BeingStatus(BeingModel inBeingModel) - { - Precondition.IsNotNull(inBeingModel); - var nonNullBeingModel = inBeingModel is null - // TODO [API] This error shows a flaw in the design. Split BeingStatus into CritterStatus and CharacterStatus. - ? BeingModel.Default - : inBeingModel; - - Position = nonNullBeingModel.Position; - SpawnAt = nonNullBeingModel.SpawnAt; - RoomAssignment = nonNullBeingModel.RoomAssignment; - CurrentBehaviorID = nonNullBeingModel.CurrentBehavior; - BiomeTimeRemaining = nonNullBeingModel.BiomeTimeRemaining; - BuildingSpeed = nonNullBeingModel.BuildingSpeed; - ModificationSpeed = nonNullBeingModel.ModificationSpeed; - GatheringSpeed = nonNullBeingModel.GatheringSpeed; - MovementSpeed = nonNullBeingModel.MovementSpeed; - KnownBeings = Enumerable.Empty().ToList(); - KnownParquets = Enumerable.Empty().ToList(); - KnownRoomRecipes = Enumerable.Empty().ToList(); - KnownCraftingRecipes = Enumerable.Empty().ToList(); - Quests = nonNullBeingModel.Quests; - Inventory = nonNullBeingModel.Inventory; - } - #endregion - - #region IEquatable Implementation - /// - /// Serves as a hash function for a . - /// - /// - /// A hash code for this instance that is suitable for use in hashing algorithms and data structures. - /// - public override int GetHashCode() - => (CurrentBehaviorID, - Position, - SpawnAt, - RoomAssignment, - BiomeTimeRemaining, - BuildingSpeed, - ModificationSpeed, - GatheringSpeed, - MovementSpeed, - KnownBeings, - KnownParquets, - KnownRoomRecipes, - KnownCraftingRecipes, - Quests, - Inventory).GetHashCode(); - - /// - /// Determines whether the specified is equal to the current . - /// - /// The to compare with the current. - /// true if they are equal; otherwise, false. - public override bool Equals(T inStatus) - => inStatus is BeingStatus beingStatus - && CurrentBehaviorID == beingStatus.CurrentBehaviorID - && Position == beingStatus.Position - && SpawnAt == beingStatus.SpawnAt - && RoomAssignment == beingStatus.RoomAssignment - && BiomeTimeRemaining == beingStatus.BiomeTimeRemaining - && BuildingSpeed == beingStatus.BuildingSpeed - && ModificationSpeed == beingStatus.ModificationSpeed - && GatheringSpeed == beingStatus.GatheringSpeed - && MovementSpeed == beingStatus.MovementSpeed - && KnownBeings == beingStatus.KnownBeings - && KnownParquets == beingStatus.KnownParquets - && KnownRoomRecipes == beingStatus.KnownRoomRecipes - && KnownCraftingRecipes == beingStatus.KnownCraftingRecipes - && Quests == beingStatus.Quests - && Inventory == beingStatus.Inventory; - - /// - /// Determines whether the specified is equal to the current . - /// - /// The to compare with the current . - /// true if they are equal; otherwise, false. - public override bool Equals(object obj) - => obj is BeingStatus status - && Equals(status); - - /// - /// Determines whether a specified instance of is equal to another specified instance of . - /// - /// The first to compare. - /// The second to compare. - /// true if they are equal; otherwise, false. - public static bool operator ==(BeingStatus inStatus1, BeingStatus inStatus2) - => inStatus1?.Equals(inStatus2) ?? inStatus2?.Equals(inStatus1) ?? true; - - /// - /// Determines whether a specified instance of is not equal to another specified instance of . - /// - /// The first to compare. - /// The second to compare. - /// true if they are NOT equal; otherwise, false. - public static bool operator !=(BeingStatus inStatus1, BeingStatus inStatus2) - => !(inStatus1 == inStatus2); - #endregion - - #region ITypeConverter Implementation - /// Allows the converter to construct itself statically. - internal static BeingStatus ConverterFactory { get; } = Unused; - - /// - /// Converts the given to a for serialization. - /// - /// The instance to convert. - /// The current context and configuration. - /// Mapping info for a member to a CSV field or property. - /// The given instance serialized. - public override string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) - => inValue is BeingStatus status - ? $"{status.CurrentBehaviorID.ConvertToString(status.CurrentBehaviorID, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{status.Position.ConvertToString(status.Position, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{status.SpawnAt.ConvertToString(status.SpawnAt, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{status.RoomAssignment.ConvertToString(status.RoomAssignment, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{status.BiomeTimeRemaining}{Delimiters.SecondaryDelimiter}" + - $"{status.BuildingSpeed}{Delimiters.SecondaryDelimiter}" + - $"{status.ModificationSpeed}{Delimiters.SecondaryDelimiter}" + - $"{status.GatheringSpeed}{Delimiters.SecondaryDelimiter}" + - $"{status.MovementSpeed}{Delimiters.SecondaryDelimiter}" + - $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownBeings, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownParquets, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownRoomRecipes, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownCraftingRecipes, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{SeriesConverter>.ConverterFactory.ConvertToString(status.Quests, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + - $"{SeriesConverter>.ConverterFactory.ConvertToString(status.Inventory, inRow, inMemberMapData)}" - : Logger.DefaultWithConvertLog(inValue?.ToString() ?? "null", nameof(BeingStatus), nameof(Unused)); - - /// - /// Converts the given to an as deserialization. - /// - /// The text to convert. - /// The current context and configuration. - /// Mapping info for a member to a CSV field or property. - /// The given instance deserialized. - public override object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) - { - if (string.IsNullOrEmpty(inText) - || string.Compare(nameof(Unused), inText, StringComparison.OrdinalIgnoreCase) == 0) - { - return Logger.DefaultWithConvertLog(inText, nameof(BeingStatus), Unused); - } - - var parameterText = inText.Split(Delimiters.SecondaryDelimiter); - - var parsedPosition = (Location)Location.ConverterFactory.ConvertFromString(parameterText[0], - inRow, inMemberMapData); - var parsedSpawnAt = (Location)Location.ConverterFactory.ConvertFromString(parameterText[1], - inRow, inMemberMapData); - var parsedRoomAssignment = (Location)Location.ConverterFactory.ConvertFromString(parameterText[2], - inRow, inMemberMapData); - var parsedCurrentBehaviorID = (ModelID)ModelID.ConverterFactory.ConvertFromString(parameterText[3], - inRow, inMemberMapData); - var parsedBiomeTimeRemaining = int.TryParse(parameterText[4], All.SerializedNumberStyle, - CultureInfo.InvariantCulture, out var temp4) - ? temp4 - : Logger.DefaultWithParseLog(parameterText[4], nameof(BiomeTimeRemaining), int.MaxValue); - var parsedBuildingSpeed = float.TryParse(parameterText[5], All.SerializedNumberStyle, - CultureInfo.InvariantCulture, out var temp5) - ? temp5 - : Logger.DefaultWithParseLog(parameterText[5], nameof(BuildingSpeed), 1f); - var parsedModificationSpeed = float.TryParse(parameterText[6], All.SerializedNumberStyle, - CultureInfo.InvariantCulture, out var temp6) - ? temp6 - : Logger.DefaultWithParseLog(parameterText[6], nameof(ModificationSpeed), 1f); - var parsedGatheringSpeed = float.TryParse(parameterText[7], All.SerializedNumberStyle, - CultureInfo.InvariantCulture, out var temp7) - ? temp7 - : Logger.DefaultWithParseLog(parameterText[7], nameof(GatheringSpeed), 1f); - var parsedMovementSpeed = float.TryParse(parameterText[8], All.SerializedNumberStyle, - CultureInfo.InvariantCulture, out var temp8) - ? temp8 - : Logger.DefaultWithParseLog(parameterText[8], nameof(MovementSpeed), 1f); - var parsedKnownBeings = (ICollection) - SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[9], inRow, - inMemberMapData); - var parsedKnownParquets = (ICollection) - SeriesConverter>.ConverterFactory - .ConvertFromString(parameterText[10], inRow, inMemberMapData); - var parsedKnownRoomRecipes = (ICollection) - SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[11], inRow, - inMemberMapData); - var parsedKnownCraftingRecipes = (ICollection) - SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[12], inRow, - inMemberMapData); - var parsedQuests = (ICollection) - SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[13], inRow, - inMemberMapData); - var parsedInventory = (ICollection) - SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[14], inRow, - inMemberMapData); - - return new BeingStatus(parsedPosition, - parsedSpawnAt, - parsedRoomAssignment, - parsedCurrentBehaviorID, - parsedBiomeTimeRemaining, - parsedBuildingSpeed, - parsedModificationSpeed, - parsedGatheringSpeed, - parsedMovementSpeed, - parsedKnownBeings, - parsedKnownParquets, - parsedKnownRoomRecipes, - parsedKnownCraftingRecipes, - parsedQuests, - parsedInventory); - } - #endregion - - #region IDeeplyCloneable Implementation - /// - /// Creates a new instance that is a deep copy of the current instance. - /// - /// A new instance with the same characteristics as the current instance. - public override T DeepClone() - => new BeingStatus((Location)Position.DeepClone(), - (Location)SpawnAt.DeepClone(), - (Location)RoomAssignment.DeepClone(), - CurrentBehaviorID, - BiomeTimeRemaining, - BuildingSpeed, - ModificationSpeed, - GatheringSpeed, - MovementSpeed, - // Note: the following .ToList() perform shallow copies, but this is acceptable as ModelID has value semantics - KnownBeings.ToList(), - KnownParquets.ToList(), - KnownRoomRecipes.ToList(), - KnownCraftingRecipes.ToList(), - Quests.ToList(), - Inventory.ToList()) as T; - #endregion - - #region Utilities - /// - /// Returns a that represents the current . - /// - /// The representation. - public override string ToString() - => $"[{nameof(CurrentBehaviorID)} {CurrentBehaviorID} @ {nameof(Position)} {Position}]"; - #endregion + // Currently, everything needed for tracking BeingModels is provided by Status. } } diff --git a/ParquetClassLibrary/Beings/CharacterModel.cs b/ParquetClassLibrary/Beings/CharacterModel.cs index fbfada0e..a1a547b8 100644 --- a/ParquetClassLibrary/Beings/CharacterModel.cs +++ b/ParquetClassLibrary/Beings/CharacterModel.cs @@ -60,10 +60,6 @@ public string FamilyName [Index(11)] public Location StartingLocation { get; private set; } - /// The for the initially governing the . - [Index(12)] - public ModelID StartingBehaviorID { get; private set; } - /// The s that this either offers or has undertaken. /// Typically, NPCs offer quests, player characters undertake them. [Index(13)] @@ -108,13 +104,12 @@ public CharacterModel(ModelID inID, string inName, string inDescription, string ModelID? inPrimaryBehaviorID = null, IEnumerable inAvoidsIDs = null, IEnumerable inSeeksIDs = null, string inPronounKey = PronounGroup.DefaultKey, string inStoryCharacterID = "", Location? inStartingLocation = null, - ModelID? inStartingBehaviorID = null, IEnumerable inStartingQuestIDs = null, - ModelID? inStartingDialogueID = null, Inventory inStartingInventory = null) + IEnumerable inStartingQuestIDs = null, ModelID? inStartingDialogueID = null, + Inventory inStartingInventory = null) : base(All.CharacterIDs, inID, inName, inDescription, inComment, inTags, inNativeBiomeID, inPrimaryBehaviorID, inAvoidsIDs, inSeeksIDs) { var nonNullStartingLocation = inStartingLocation ?? Location.Nowhere; - var nonNullStartingBehaviorID = inStartingBehaviorID ?? ModelID.None; var nonNullQuestIDs = inStartingQuestIDs ?? Enumerable.Empty(); var nonNullDialogueID = inStartingDialogueID ?? ModelID.None; var nonNullInventory = inStartingInventory ?? Inventory.Empty; @@ -125,7 +120,6 @@ public CharacterModel(ModelID inID, string inName, string inDescription, string PronounKey = inPronounKey; StoryCharacterID = inStoryCharacterID; StartingLocation = nonNullStartingLocation; - StartingBehaviorID = nonNullStartingBehaviorID; StartingQuestIDs = nonNullQuestIDs.ToList(); StartingDialogueID = nonNullDialogueID; StartingInventory = nonNullInventory; @@ -206,20 +200,6 @@ Location IMutableCharacterModel.StartingLocation : value; } - /// The for the initially governing the . - /// - /// By design, subtypes of should never themselves use . - /// IMutableCharacterModel is for external types that require read-write access. - /// - [Ignore] - ModelID IMutableCharacterModel.StartingBehaviorID - { - get => StartingBehaviorID; - set => StartingBehaviorID = LibraryState.IsPlayMode - ? Logger.DefaultWithImmutableInPlayLog(nameof(StartingBehaviorID), StartingBehaviorID) - : value; - } - /// The s that this either offers or has undertaken. /// /// By design, subtypes of should never themselves use . diff --git a/ParquetClassLibrary/Beings/CharacterStatus.cs b/ParquetClassLibrary/Beings/CharacterStatus.cs new file mode 100644 index 00000000..97d78d21 --- /dev/null +++ b/ParquetClassLibrary/Beings/CharacterStatus.cs @@ -0,0 +1,323 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using CsvHelper; +using CsvHelper.Configuration; +using Parquet.Items; + +namespace Parquet.Beings +{ + /// + /// Tracks the status of a . + /// Instances of this class are mutable during play. + /// + /// + /// Most of the game interaction is mediated through instances of this class. + /// + public class CharacterStatus : BeingStatus + { + #region Class Defaults + /// Provides a throwaway instance of the class with default values. + public static CharacterStatus Unused { get; } = new CharacterStatus(); + #endregion + + #region Status + /// The the tracked occupies. + public Location Position { get; set; } + + /// The the tracked will next spawn at. + /// For example, this might be the spot the where when the game was last saved. + public Location SpawnAt { get; set; } + + /// The the assigned to this . + public Location RoomAssignment { get; set; } + + /// The for the currently governing the tracked . + public ModelID CurrentBehaviorID { get; set; } + + /// The time remaining that the tracked can safely remain in the current . + public int BiomeTimeRemaining { get; set; } + #endregion + + #region Collections + /// The s that this has encountered. + public ICollection KnownBeings { get; } + + /// The parquets that this has encountered. + public ICollection KnownParquets { get; } + + /// The s that this knows. + public ICollection KnownRoomRecipes { get; } + + /// The s that this knows. + public ICollection KnownCraftingRecipes { get; } + + /// The s that this offers or has undertaken. + public ICollection Quests { get; } + + /// This 's set of belongings. + public Inventory Inventory { get; } + #endregion + + #region Initialization + /// + /// Initializes a new instance of the class. + /// + /// The the tracked occupies. + /// The the tracked will next spawn at. + /// The of the to which the tracked is assigned. + /// The behavior currently governing the tracked . + /// How long [TODO in what units?] before the must leave the . + /// The s that this has encountered. + /// The parquets that this has encountered. + /// The s that this knows. + /// The s that this knows. + /// The s that this offers or has undertaken. + /// This 's set of belongings. + public CharacterStatus(Location? inPosition = null, Location? inSpawnAt = null, Location? inRoomAssignment = null, + ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = int.MaxValue, + ICollection inKnownBeings = null, ICollection inKnownParquets = null, + ICollection inKnownRoomRecipes = null, ICollection inKnownCraftingRecipes = null, + ICollection inQuests = null, Inventory inInventory = null) + { + var nonNullPosition = inPosition ?? Location.Nowhere; + var nonNullSpawnAt = inSpawnAt ?? Location.Nowhere; + var nonNullRoomAssignment = inRoomAssignment ?? Location.Nowhere; + var nonNullCurrentBehavior = inCurrentBehavior ?? ModelID.None; + Precondition.IsInRange(nonNullCurrentBehavior, All.ScriptIDs, nameof(inCurrentBehavior)); + var nonNullBeings = inKnownBeings ?? Enumerable.Empty().ToList(); + var nonNullParquets = inKnownParquets ?? Enumerable.Empty().ToList(); + var nonNullRoomRecipes = inKnownRoomRecipes ?? Enumerable.Empty().ToList(); + var nonNullCraftingRecipes = inKnownCraftingRecipes ?? Enumerable.Empty().ToList(); + var nonNullQuests = inQuests ?? Enumerable.Empty().ToList(); + var nonNullInventory = inInventory ?? Inventory.Empty; + Precondition.AreInRange(nonNullBeings, All.CritterIDs, nameof(inKnownBeings)); + Precondition.AreInRange(nonNullParquets, All.ParquetIDs, nameof(inKnownParquets)); + Precondition.AreInRange(nonNullRoomRecipes, All.RoomRecipeIDs, nameof(inKnownRoomRecipes)); + Precondition.AreInRange(nonNullCraftingRecipes, All.CraftingRecipeIDs, nameof(inKnownCraftingRecipes)); + Precondition.AreInRange(nonNullQuests, All.InteractionIDs, nameof(inQuests)); + + Position = nonNullPosition; + SpawnAt = nonNullSpawnAt; + RoomAssignment = nonNullRoomAssignment; + CurrentBehaviorID = nonNullCurrentBehavior; + BiomeTimeRemaining = inBiomeTimeRemaining; + KnownBeings = nonNullBeings; + KnownParquets = nonNullParquets; + KnownRoomRecipes = nonNullRoomRecipes; + KnownCraftingRecipes = nonNullCraftingRecipes; + Quests = nonNullQuests; + Inventory = nonNullInventory; + } + + + /// + /// Initializes an instance of the class + /// based on a given instance. + /// + /// The definitions being tracked. + public CharacterStatus(CharacterModel inCharacterModel) + { + Precondition.IsNotNull(inCharacterModel); + var nonNullCharacterModel = inCharacterModel ?? CharacterModel.Unused; + + Position = Location.Nowhere; + SpawnAt = nonNullCharacterModel.StartingLocation; + RoomAssignment = Location.Nowhere; + CurrentBehaviorID = nonNullCharacterModel.PrimaryBehaviorID; + BiomeTimeRemaining = int.MaxValue; + KnownBeings = Enumerable.Empty().ToList(); + KnownParquets = Enumerable.Empty().ToList(); + KnownRoomRecipes = Enumerable.Empty().ToList(); + KnownCraftingRecipes = Enumerable.Empty().ToList(); + Quests = nonNullCharacterModel.StartingQuestIDs.ToList(); + Inventory = nonNullCharacterModel.StartingInventory.DeepClone(); + } + #endregion + + #region IEquatable Implementation + /// + /// Serves as a hash function for a . + /// + /// + /// A hash code for this instance that is suitable for use in hashing algorithms and data structures. + /// + public override int GetHashCode() + => (CurrentBehaviorID, + Position, + SpawnAt, + RoomAssignment, + BiomeTimeRemaining, + KnownBeings, + KnownParquets, + KnownRoomRecipes, + KnownCraftingRecipes, + Quests, + Inventory).GetHashCode(); + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current. + /// true if they are equal; otherwise, false. + public override bool Equals(T inStatus) + => inStatus is CharacterStatus characterStatus + && CurrentBehaviorID == characterStatus.CurrentBehaviorID + && Position == characterStatus.Position + && SpawnAt == characterStatus.SpawnAt + && RoomAssignment == characterStatus.RoomAssignment + && BiomeTimeRemaining == characterStatus.BiomeTimeRemaining + && KnownBeings == characterStatus.KnownBeings + && KnownParquets == characterStatus.KnownParquets + && KnownRoomRecipes == characterStatus.KnownRoomRecipes + && KnownCraftingRecipes == characterStatus.KnownCraftingRecipes + && Quests == characterStatus.Quests + && Inventory == characterStatus.Inventory; + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if they are equal; otherwise, false. + public override bool Equals(object obj) + => obj is CharacterStatus status + && Equals(status); + + /// + /// Determines whether a specified instance of is equal to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if they are equal; otherwise, false. + public static bool operator ==(CharacterStatus inStatus1, CharacterStatus inStatus2) + => inStatus1?.Equals(inStatus2) ?? inStatus2?.Equals(inStatus1) ?? true; + + /// + /// Determines whether a specified instance of is not equal to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if they are NOT equal; otherwise, false. + public static bool operator !=(CharacterStatus inStatus1, CharacterStatus inStatus2) + => !(inStatus1 == inStatus2); + #endregion + + #region ITypeConverter Implementation + /// Allows the converter to construct itself statically. + internal static CharacterStatus ConverterFactory { get; } = Unused; + + /// + /// Converts the given to a for serialization. + /// + /// The instance to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance serialized. + public override string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) + => inValue is CharacterStatus status + ? $"{status.CurrentBehaviorID.ConvertToString(status.CurrentBehaviorID, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{status.Position.ConvertToString(status.Position, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{status.SpawnAt.ConvertToString(status.SpawnAt, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{status.RoomAssignment.ConvertToString(status.RoomAssignment, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{status.BiomeTimeRemaining}{Delimiters.SecondaryDelimiter}" + + $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownBeings, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownParquets, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownRoomRecipes, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{SeriesConverter>.ConverterFactory.ConvertToString(status.KnownCraftingRecipes, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{SeriesConverter>.ConverterFactory.ConvertToString(status.Quests, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{SeriesConverter>.ConverterFactory.ConvertToString(status.Inventory, inRow, inMemberMapData)}" + : Logger.DefaultWithConvertLog(inValue?.ToString() ?? "null", nameof(CharacterStatus), nameof(Unused)); + + /// + /// Converts the given to an as deserialization. + /// + /// The text to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance deserialized. + public override object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) + { + if (string.IsNullOrEmpty(inText) + || string.Compare(nameof(Unused), inText, StringComparison.OrdinalIgnoreCase) == 0) + { + return Logger.DefaultWithConvertLog(inText, nameof(CharacterStatus), Unused); + } + + var parameterText = inText.Split(Delimiters.SecondaryDelimiter); + + var parsedPosition = (Location)Location.ConverterFactory.ConvertFromString(parameterText[0], + inRow, inMemberMapData); + var parsedSpawnAt = (Location)Location.ConverterFactory.ConvertFromString(parameterText[1], + inRow, inMemberMapData); + var parsedRoomAssignment = (Location)Location.ConverterFactory.ConvertFromString(parameterText[2], + inRow, inMemberMapData); + var parsedCurrentBehaviorID = (ModelID)ModelID.ConverterFactory.ConvertFromString(parameterText[3], + inRow, inMemberMapData); + var parsedBiomeTimeRemaining = int.TryParse(parameterText[4], All.SerializedNumberStyle, + CultureInfo.InvariantCulture, out var temp4) + ? temp4 + : Logger.DefaultWithParseLog(parameterText[4], nameof(BiomeTimeRemaining), int.MaxValue); + var parsedKnownBeings = (ICollection) + SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[9], inRow, + inMemberMapData); + var parsedKnownParquets = (ICollection) + SeriesConverter>.ConverterFactory + .ConvertFromString(parameterText[10], inRow, inMemberMapData); + var parsedKnownRoomRecipes = (ICollection) + SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[11], inRow, + inMemberMapData); + var parsedKnownCraftingRecipes = (ICollection) + SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[12], inRow, + inMemberMapData); + var parsedQuests = (ICollection) + SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[13], inRow, + inMemberMapData); + var parsedInventory = (Inventory) + SeriesConverter.ConverterFactory.ConvertFromString(parameterText[14], inRow, + inMemberMapData); + + return new CharacterStatus(parsedPosition, + parsedSpawnAt, + parsedRoomAssignment, + parsedCurrentBehaviorID, + parsedBiomeTimeRemaining, + parsedKnownBeings, + parsedKnownParquets, + parsedKnownRoomRecipes, + parsedKnownCraftingRecipes, + parsedQuests, + parsedInventory); + } + #endregion + + #region IDeeplyCloneable Implementation + /// + /// Creates a new instance that is a deep copy of the current instance. + /// + /// A new instance with the same characteristics as the current instance. + public override T DeepClone() + => new CharacterStatus(Position, + SpawnAt, + RoomAssignment, + CurrentBehaviorID, + BiomeTimeRemaining, + // Note: The following .ToList() perform shallow copies, but this is acceptable as ModelID has value semantics + KnownBeings.ToList(), + KnownParquets.ToList(), + KnownRoomRecipes.ToList(), + KnownCraftingRecipes.ToList(), + Quests.ToList(), + Inventory) as T; + #endregion + + #region Utilities + /// + /// Returns a that represents the current . + /// + /// The representation. + public override string ToString() + => $"[{nameof(CurrentBehaviorID)} {CurrentBehaviorID} @ {nameof(Position)} {Position}]"; + #endregion + } +} diff --git a/ParquetClassLibrary/Beings/CritterModel.cs b/ParquetClassLibrary/Beings/CritterModel.cs index 771624eb..7bed1276 100644 --- a/ParquetClassLibrary/Beings/CritterModel.cs +++ b/ParquetClassLibrary/Beings/CritterModel.cs @@ -7,6 +7,11 @@ namespace Parquet.Beings /// public class CritterModel : BeingModel, IMutableCritterModel { + #region Class Defaults + /// Indicates an uninitialized critter. + public static CritterModel Unused { get; } = new CritterModel(ModelID.None, nameof(Unused), "", ""); + #endregion + #region Initialization /// /// Initializes a new instance of the class. diff --git a/ParquetClassLibrary/Beings/CritterStatus.cs b/ParquetClassLibrary/Beings/CritterStatus.cs new file mode 100644 index 00000000..28f4b719 --- /dev/null +++ b/ParquetClassLibrary/Beings/CritterStatus.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using CsvHelper; +using CsvHelper.Configuration; +using Parquet.Items; + +namespace Parquet.Beings +{ + /// + /// Tracks the status of a . + /// Instances of this class are mutable during play. + /// + public class CritterStatus : BeingStatus + { + #region Class Defaults + /// Provides a throwaway instance of the class with default values. + public static CritterStatus Unused { get; } = new CritterStatus(); + #endregion + + #region Status + /// The the tracked occupies. + public Location Position { get; set; } + + /// The for the currently governing the tracked . + public ModelID CurrentBehaviorID { get; set; } + #endregion + + #region Initialization + /// + /// Initializes a new instance of the class. + /// + /// The the tracked occupies. + /// The behavior currently governing the tracked . + public CritterStatus(Location? inPosition = null, ModelID? inCurrentBehavior = null) + { + var nonNullPosition = inPosition ?? Location.Nowhere; + var nonNullCurrentBehavior = inCurrentBehavior ?? ModelID.None; + Precondition.IsInRange(nonNullCurrentBehavior, All.ScriptIDs, nameof(inCurrentBehavior)); + + Position = nonNullPosition; + CurrentBehaviorID = nonNullCurrentBehavior; + } + + + /// + /// Initializes an instance of the class + /// based on a given instance. + /// + /// The definitions being tracked. + public CritterStatus(CritterModel inCritterModel) + { + Precondition.IsNotNull(inCritterModel); + var nonNullCritterModel = inCritterModel ?? CritterModel.Unused; + + Position = Location.Nowhere; + CurrentBehaviorID = nonNullCritterModel.PrimaryBehaviorID; + } + #endregion + + #region IEquatable Implementation + /// + /// Serves as a hash function for a . + /// + /// + /// A hash code for this instance that is suitable for use in hashing algorithms and data structures. + /// + public override int GetHashCode() + => (Position, CurrentBehaviorID).GetHashCode(); + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current. + /// true if they are equal; otherwise, false. + public override bool Equals(T inStatus) + => inStatus is CritterStatus critterStatus + && Position == critterStatus.Position + && CurrentBehaviorID == critterStatus.CurrentBehaviorID; + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if they are equal; otherwise, false. + public override bool Equals(object obj) + => obj is CritterStatus status + && Equals(status); + + /// + /// Determines whether a specified instance of is equal to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if they are equal; otherwise, false. + public static bool operator ==(CritterStatus inStatus1, CritterStatus inStatus2) + => inStatus1?.Equals(inStatus2) ?? inStatus2?.Equals(inStatus1) ?? true; + + /// + /// Determines whether a specified instance of is not equal to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if they are NOT equal; otherwise, false. + public static bool operator !=(CritterStatus inStatus1, CritterStatus inStatus2) + => !(inStatus1 == inStatus2); + #endregion + + #region ITypeConverter Implementation + /// Allows the converter to construct itself statically. + internal static CritterStatus ConverterFactory { get; } = Unused; + + /// + /// Converts the given to a for serialization. + /// + /// The instance to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance serialized. + public override string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) + => inValue is CritterStatus status + ? $"{status.Position.ConvertToString(status.Position, inRow, inMemberMapData)}{Delimiters.SecondaryDelimiter}" + + $"{status.CurrentBehaviorID.ConvertToString(status.CurrentBehaviorID, inRow, inMemberMapData)}" + : Logger.DefaultWithConvertLog(inValue?.ToString() ?? "null", nameof(CritterStatus), nameof(Unused)); + + /// + /// Converts the given to an as deserialization. + /// + /// The text to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance deserialized. + public override object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) + { + if (string.IsNullOrEmpty(inText) + || string.Compare(nameof(Unused), inText, StringComparison.OrdinalIgnoreCase) == 0) + { + return Logger.DefaultWithConvertLog(inText, nameof(CritterStatus), Unused); + } + + var parameterText = inText.Split(Delimiters.SecondaryDelimiter); + + var parsedPosition = (Location)Location.ConverterFactory.ConvertFromString(parameterText[0], + inRow, inMemberMapData); + var parsedCurrentBehaviorID = (ModelID)ModelID.ConverterFactory.ConvertFromString(parameterText[3], + inRow, inMemberMapData); + + return new CritterStatus(parsedPosition, parsedCurrentBehaviorID); + } + #endregion + + #region IDeeplyCloneable Implementation + /// + /// Creates a new instance that is a deep copy of the current instance. + /// + /// A new instance with the same status as the current instance. + public override T DeepClone() + => new CritterStatus(Position, CurrentBehaviorID) as T; + #endregion + + #region Utilities + /// + /// Returns a that represents the current . + /// + /// The representation. + public override string ToString() + => $"[{nameof(CurrentBehaviorID)} {CurrentBehaviorID} @ {nameof(Position)} {Position}]"; + #endregion + } +} diff --git a/ParquetClassLibrary/Beings/IMutableCharacterModel.cs b/ParquetClassLibrary/Beings/IMutableCharacterModel.cs index e94ae8db..ae012c13 100644 --- a/ParquetClassLibrary/Beings/IMutableCharacterModel.cs +++ b/ParquetClassLibrary/Beings/IMutableCharacterModel.cs @@ -37,9 +37,6 @@ public interface IMutableCharacterModel : IMutableBeingModel /// The the begins at. public Location StartingLocation { get; set; } - /// The for the initially governing the . - public ModelID StartingBehaviorID { get; set; } - /// The s that this either offers or has undertaken. /// Typically, NPCs offer quests, player characters undertake them. public ICollection StartingQuestIDs { get; } diff --git a/ParquetClassLibrary/PublicAPI.Unshipped.txt b/ParquetClassLibrary/PublicAPI.Unshipped.txt index 69e8d1f2..5a7e7e36 100644 --- a/ParquetClassLibrary/PublicAPI.Unshipped.txt +++ b/ParquetClassLibrary/PublicAPI.Unshipped.txt @@ -51,13 +51,20 @@ override abstract Parquet.Pack.Equals(object obj) -> bool override abstract Parquet.Pack.GetHashCode() -> int override abstract Parquet.Status.Equals(object obj) -> bool override abstract Parquet.Status.GetHashCode() -> int -override Parquet.Beings.BeingStatus.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object -override Parquet.Beings.BeingStatus.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string -override Parquet.Beings.BeingStatus.DeepClone() -> T -override Parquet.Beings.BeingStatus.Equals(object obj) -> bool -override Parquet.Beings.BeingStatus.Equals(T inStatus) -> bool -override Parquet.Beings.BeingStatus.GetHashCode() -> int -override Parquet.Beings.BeingStatus.ToString() -> string +override Parquet.Beings.CharacterStatus.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object +override Parquet.Beings.CharacterStatus.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string +override Parquet.Beings.CharacterStatus.DeepClone() -> T +override Parquet.Beings.CharacterStatus.Equals(object obj) -> bool +override Parquet.Beings.CharacterStatus.Equals(T inStatus) -> bool +override Parquet.Beings.CharacterStatus.GetHashCode() -> int +override Parquet.Beings.CharacterStatus.ToString() -> string +override Parquet.Beings.CritterStatus.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object +override Parquet.Beings.CritterStatus.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string +override Parquet.Beings.CritterStatus.DeepClone() -> T +override Parquet.Beings.CritterStatus.Equals(object obj) -> bool +override Parquet.Beings.CritterStatus.Equals(T inStatus) -> bool +override Parquet.Beings.CritterStatus.GetHashCode() -> int +override Parquet.Beings.CritterStatus.ToString() -> string override Parquet.Beings.PronounGroup.ToString() -> string override Parquet.Biomes.BiomeRecipe.GetAllTags() -> System.Collections.Generic.IEnumerable override Parquet.Crafts.StrikePanel.Equals(object obj) -> bool @@ -170,46 +177,54 @@ Parquet.Beings.BeingModel Parquet.Beings.BeingModel.AvoidsIDs.get -> System.Collections.Generic.IReadOnlyList Parquet.Beings.BeingModel.BeingModel(Parquet.Range inBounds, Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null) -> void Parquet.Beings.BeingModel.NativeBiomeID.get -> Parquet.ModelID +Parquet.Beings.BeingModel.NativeBiomeID.set -> void +Parquet.Beings.BeingModel.NativeBiomeID.set -> void Parquet.Beings.BeingModel.PrimaryBehaviorID.get -> Parquet.ModelID +Parquet.Beings.BeingModel.PrimaryBehaviorID.set -> void +Parquet.Beings.BeingModel.PrimaryBehaviorID.set -> void Parquet.Beings.BeingModel.SeeksIDs.get -> System.Collections.Generic.IReadOnlyList -Parquet.Beings.BeingStatus -Parquet.Beings.BeingStatus.BeingStatus(Parquet.Beings.BeingModel inBeingModel) -> void -Parquet.Beings.BeingStatus.BeingStatus(Parquet.Location inPosition = null, Parquet.Location inSpawnAt = null, Parquet.Location inRoomAssignment = null, Parquet.ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = 0, float inBuildingSpeed = 0, float inModificationSpeed = 0, float inGatheringSpeed = 0, float inMovementSpeed = 0, System.Collections.Generic.ICollection inKnownBeings = null, System.Collections.Generic.ICollection inKnownParquets = null, System.Collections.Generic.ICollection inKnownRoomRecipes = null, System.Collections.Generic.ICollection inKnownCraftingRecipes = null, System.Collections.Generic.ICollection inQuests = null, System.Collections.Generic.ICollection inInventory = null) -> void -Parquet.Beings.BeingStatus.BiomeTimeRemaining.get -> int -Parquet.Beings.BeingStatus.BiomeTimeRemaining.set -> void -Parquet.Beings.BeingStatus.BuildingSpeed.get -> float -Parquet.Beings.BeingStatus.BuildingSpeed.set -> void -Parquet.Beings.BeingStatus.CurrentBehaviorID.get -> Parquet.ModelID -Parquet.Beings.BeingStatus.CurrentBehaviorID.set -> void -Parquet.Beings.BeingStatus.GatheringSpeed.get -> float -Parquet.Beings.BeingStatus.GatheringSpeed.set -> void -Parquet.Beings.BeingStatus.Inventory.get -> System.Collections.Generic.ICollection -Parquet.Beings.BeingStatus.KnownBeings.get -> System.Collections.Generic.ICollection -Parquet.Beings.BeingStatus.KnownCraftingRecipes.get -> System.Collections.Generic.ICollection -Parquet.Beings.BeingStatus.KnownParquets.get -> System.Collections.Generic.ICollection -Parquet.Beings.BeingStatus.KnownRoomRecipes.get -> System.Collections.Generic.ICollection -Parquet.Beings.BeingStatus.ModificationSpeed.get -> float -Parquet.Beings.BeingStatus.ModificationSpeed.set -> void -Parquet.Beings.BeingStatus.MovementSpeed.get -> float -Parquet.Beings.BeingStatus.MovementSpeed.set -> void -Parquet.Beings.BeingStatus.Position.get -> Parquet.Location -Parquet.Beings.BeingStatus.Position.set -> void -Parquet.Beings.BeingStatus.Quests.get -> System.Collections.Generic.ICollection -Parquet.Beings.BeingStatus.RoomAssignment.get -> Parquet.Location -Parquet.Beings.BeingStatus.RoomAssignment.set -> void -Parquet.Beings.BeingStatus.SpawnAt.get -> Parquet.Location -Parquet.Beings.BeingStatus.SpawnAt.set -> void +Parquet.Beings.BeingStatus +Parquet.Beings.BeingStatus.BeingStatus() -> void Parquet.Beings.CharacterModel -Parquet.Beings.CharacterModel.CharacterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null, string inPronounKey = "they/them", string inStoryCharacterID = "", System.Collections.Generic.IEnumerable inStartingQuestIDs = null, Parquet.ModelID? inStartingDialogueID = null, Parquet.Items.Inventory inStartingInventory = null) -> void +Parquet.Beings.CharacterModel.CharacterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null, string inPronounKey = "they/them", string inStoryCharacterID = "", Parquet.Location? inStartingLocation = null, System.Collections.Generic.IEnumerable inStartingQuestIDs = null, Parquet.ModelID? inStartingDialogueID = null, Parquet.Items.Inventory inStartingInventory = null) -> void +Parquet.Beings.CharacterModel.CharacterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null, string inPronounKey = "they/them", string inStoryCharacterID = "", Parquet.Location? inStartingLocation = null, System.Collections.Generic.IEnumerable inStartingQuestIDs = null, Parquet.ModelID? inStartingDialogueID = null, Parquet.Items.Inventory inStartingInventory = null) -> void Parquet.Beings.CharacterModel.FamilyName.get -> string Parquet.Beings.CharacterModel.PersonalName.get -> string Parquet.Beings.CharacterModel.PronounKey.get -> string Parquet.Beings.CharacterModel.StartingDialogueID.get -> Parquet.ModelID Parquet.Beings.CharacterModel.StartingInventory.get -> Parquet.Items.Inventory +Parquet.Beings.CharacterModel.StartingLocation.get -> Parquet.Location Parquet.Beings.CharacterModel.StartingQuestIDs.get -> System.Collections.Generic.IReadOnlyList Parquet.Beings.CharacterModel.StoryCharacterID.get -> string +Parquet.Beings.CharacterStatus +Parquet.Beings.CharacterStatus.BiomeTimeRemaining.get -> int +Parquet.Beings.CharacterStatus.BiomeTimeRemaining.set -> void +Parquet.Beings.CharacterStatus.CharacterStatus(Parquet.Beings.CharacterModel inCharacterModel) -> void +Parquet.Beings.CharacterStatus.CharacterStatus(Parquet.Location? inPosition = null, Parquet.Location? inSpawnAt = null, Parquet.Location? inRoomAssignment = null, Parquet.ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = 2147483647, System.Collections.Generic.ICollection inKnownBeings = null, System.Collections.Generic.ICollection inKnownParquets = null, System.Collections.Generic.ICollection inKnownRoomRecipes = null, System.Collections.Generic.ICollection inKnownCraftingRecipes = null, System.Collections.Generic.ICollection inQuests = null, Parquet.Items.Inventory inInventory = null) -> void +Parquet.Beings.CharacterStatus.CurrentBehaviorID.get -> Parquet.ModelID +Parquet.Beings.CharacterStatus.CurrentBehaviorID.set -> void +Parquet.Beings.CharacterStatus.Inventory.get -> Parquet.Items.Inventory +Parquet.Beings.CharacterStatus.KnownBeings.get -> System.Collections.Generic.ICollection +Parquet.Beings.CharacterStatus.KnownCraftingRecipes.get -> System.Collections.Generic.ICollection +Parquet.Beings.CharacterStatus.KnownParquets.get -> System.Collections.Generic.ICollection +Parquet.Beings.CharacterStatus.KnownRoomRecipes.get -> System.Collections.Generic.ICollection +Parquet.Beings.CharacterStatus.Position.get -> Parquet.Location +Parquet.Beings.CharacterStatus.Position.set -> void +Parquet.Beings.CharacterStatus.Quests.get -> System.Collections.Generic.ICollection +Parquet.Beings.CharacterStatus.RoomAssignment.get -> Parquet.Location +Parquet.Beings.CharacterStatus.RoomAssignment.set -> void +Parquet.Beings.CharacterStatus.SpawnAt.get -> Parquet.Location +Parquet.Beings.CharacterStatus.SpawnAt.set -> void Parquet.Beings.CritterModel Parquet.Beings.CritterModel.CritterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null) -> void +Parquet.Beings.CritterStatus +Parquet.Beings.CritterStatus.CritterStatus(Parquet.Beings.CritterModel inCritterModel) -> void +Parquet.Beings.CritterStatus.CritterStatus(Parquet.Location? inPosition = null, Parquet.ModelID? inCurrentBehavior = null) -> void +Parquet.Beings.CritterStatus.CritterStatus(Parquet.Location? inPosition = null, Parquet.ModelID? inCurrentBehavior = null) -> void +Parquet.Beings.CritterStatus.CurrentBehaviorID.get -> Parquet.ModelID +Parquet.Beings.CritterStatus.CurrentBehaviorID.set -> void +Parquet.Beings.CritterStatus.Position.get -> Parquet.Location +Parquet.Beings.CritterStatus.Position.set -> void Parquet.Beings.IMutableBeingModel Parquet.Beings.IMutableBeingModel.AvoidsIDs.get -> System.Collections.Generic.ICollection Parquet.Beings.IMutableBeingModel.NativeBiomeID.get -> Parquet.ModelID @@ -224,8 +239,6 @@ Parquet.Beings.IMutableCharacterModel.PersonalName.get -> string Parquet.Beings.IMutableCharacterModel.PersonalName.set -> void Parquet.Beings.IMutableCharacterModel.PronounKey.get -> string Parquet.Beings.IMutableCharacterModel.PronounKey.set -> void -Parquet.Beings.IMutableCharacterModel.StartingBehaviorID.get -> Parquet.ModelID -Parquet.Beings.IMutableCharacterModel.StartingBehaviorID.set -> void Parquet.Beings.IMutableCharacterModel.StartingDialogueID.get -> Parquet.ModelID Parquet.Beings.IMutableCharacterModel.StartingDialogueID.set -> void Parquet.Beings.IMutableCharacterModel.StartingInventory.get -> Parquet.Items.Inventory @@ -598,8 +611,14 @@ Parquet.Parquets.IMutableParquetModel.ItemID.get -> Parquet.ModelID Parquet.Parquets.IMutableParquetModel.ItemID.set -> void Parquet.Parquets.ParquetModel Parquet.Parquets.ParquetModel.AddsToBiome.get -> System.Collections.Generic.IReadOnlyList +Parquet.Parquets.ParquetModel.AddsToBiome.set -> void +Parquet.Parquets.ParquetModel.AddsToBiome.set -> void Parquet.Parquets.ParquetModel.AddsToRoom.get -> System.Collections.Generic.IReadOnlyList +Parquet.Parquets.ParquetModel.AddsToRoom.set -> void +Parquet.Parquets.ParquetModel.AddsToRoom.set -> void Parquet.Parquets.ParquetModel.ItemID.get -> Parquet.ModelID +Parquet.Parquets.ParquetModel.ItemID.set -> void +Parquet.Parquets.ParquetModel.ItemID.set -> void Parquet.Parquets.ParquetModel.ParquetModel(Parquet.Range inBounds, Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inItemID = null, System.Collections.Generic.IEnumerable inAddsToBiome = null, System.Collections.Generic.IEnumerable inAddsToRoom = null) -> void Parquet.Parquets.ParquetModelPack Parquet.Parquets.ParquetModelPack.BlockID.get -> Parquet.ModelID @@ -722,8 +741,8 @@ Parquet.Regions.MapChunk.Equals(Parquet.Regions.MapChunk inChunk) -> bool Parquet.Regions.MapChunk.Generate() -> Parquet.Regions.MapChunk Parquet.Regions.MapChunk.IsFilledOut.get -> bool Parquet.Regions.MapChunk.MapChunk() -> void -Parquet.Regions.MapChunk.MapChunk(bool inIsFilledOut, Parquet.Regions.ChunkDetail inDetails = null, Parquet.Parquets.ParquetModelPackGrid inParquetDefinitions = null) -> void -Parquet.Regions.MapChunk.ParquetDefinitions.get -> Parquet.Parquets.ParquetModelPackGrid +Parquet.Regions.MapChunk.MapChunk(bool inIsFilledOut, Parquet.Regions.ChunkDetail inDetails = null, Parquet.IReadOnlyGrid inParquetDefinitions = null) -> void +Parquet.Regions.MapChunk.ParquetDefinitions.get -> Parquet.IReadOnlyGrid Parquet.Regions.MapChunk.ParquetDefinitions.set -> void Parquet.Regions.MapChunkArrayExtensions Parquet.Regions.MapChunkGrid @@ -869,9 +888,14 @@ static Parquet.All.RegionModels.get -> Parquet.ModelCollection Parquet.ModelCollection static Parquet.All.SaveToCSVs() -> bool static Parquet.All.Scripts.get -> Parquet.ModelCollection -static Parquet.Beings.BeingStatus.operator !=(Parquet.Beings.BeingStatus inStatus1, Parquet.Beings.BeingStatus inStatus2) -> bool -static Parquet.Beings.BeingStatus.operator ==(Parquet.Beings.BeingStatus inStatus1, Parquet.Beings.BeingStatus inStatus2) -> bool -static Parquet.Beings.BeingStatus.Unused.get -> Parquet.Beings.BeingStatus +static Parquet.Beings.CharacterModel.Unused.get -> Parquet.Beings.CharacterModel +static Parquet.Beings.CharacterStatus.operator !=(Parquet.Beings.CharacterStatus inStatus1, Parquet.Beings.CharacterStatus inStatus2) -> bool +static Parquet.Beings.CharacterStatus.operator ==(Parquet.Beings.CharacterStatus inStatus1, Parquet.Beings.CharacterStatus inStatus2) -> bool +static Parquet.Beings.CharacterStatus.Unused.get -> Parquet.Beings.CharacterStatus +static Parquet.Beings.CritterModel.Unused.get -> Parquet.Beings.CritterModel +static Parquet.Beings.CritterStatus.operator !=(Parquet.Beings.CritterStatus inStatus1, Parquet.Beings.CritterStatus inStatus2) -> bool +static Parquet.Beings.CritterStatus.operator ==(Parquet.Beings.CritterStatus inStatus1, Parquet.Beings.CritterStatus inStatus2) -> bool +static Parquet.Beings.CritterStatus.Unused.get -> Parquet.Beings.CritterStatus static Parquet.Beings.PronounGroup.FilePath.get -> string static Parquet.Beings.PronounGroup.GetRecords() -> System.Collections.Generic.HashSet static Parquet.Beings.PronounGroup.PutRecords(System.Collections.Generic.IEnumerable inGroups) -> void @@ -900,6 +924,7 @@ static Parquet.Crafts.StrikePanel.operator !=(Parquet.Crafts.StrikePanel inStrik static Parquet.Crafts.StrikePanel.operator ==(Parquet.Crafts.StrikePanel inStrikePanel1, Parquet.Crafts.StrikePanel inStrikePanel2) -> bool static Parquet.Crafts.StrikePanelArrayExtensions.IsValidPosition(this Parquet.Crafts.StrikePanel[,] inStrikePanels, Parquet.Point2D inPosition) -> bool static Parquet.Crafts.StrikePanelGrid.Empty.get -> Parquet.Crafts.StrikePanelGrid +static Parquet.Games.GameModel.Empty.get -> Parquet.Games.GameModel static Parquet.Games.GameStatus.Default.get -> Parquet.Games.GameStatus static Parquet.Games.GameStatus.operator !=(Parquet.Games.GameStatus inStatus1, Parquet.Games.GameStatus inStatus2) -> bool static Parquet.Games.GameStatus.operator ==(Parquet.Games.GameStatus inStatus1, Parquet.Games.GameStatus inStatus2) -> bool @@ -1033,7 +1058,6 @@ static readonly Parquet.All.ScriptIDs -> Parquet.Range static readonly Parquet.AssemblyInfo.LibraryVersion -> string static readonly Parquet.Beings.PronounGroup.DefaultGroup -> Parquet.Beings.PronounGroup static readonly Parquet.Crafts.StrikePanel.Unused -> Parquet.Crafts.StrikePanel -static readonly Parquet.Games.GameModel.Empty -> Parquet.Games.GameModel static readonly Parquet.ModelCollection.Default -> Parquet.ModelCollection static readonly Parquet.ModelID.None -> Parquet.ModelID static readonly Parquet.ModelTag.None -> Parquet.ModelTag From 69d487830ea8fb5cc2236ba1468d0610a80c9239 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:31:34 -0800 Subject: [PATCH 14/22] Removes unneeded usings. --- ParquetClassLibrary/Beings/CritterStatus.cs | 4 ---- ParquetClassLibrary/Crafts/CraftingRecipe.cs | 1 - ParquetClassLibrary/Scripts/InteractionModel.cs | 1 - 3 files changed, 6 deletions(-) diff --git a/ParquetClassLibrary/Beings/CritterStatus.cs b/ParquetClassLibrary/Beings/CritterStatus.cs index 28f4b719..561e8032 100644 --- a/ParquetClassLibrary/Beings/CritterStatus.cs +++ b/ParquetClassLibrary/Beings/CritterStatus.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; using CsvHelper; using CsvHelper.Configuration; -using Parquet.Items; namespace Parquet.Beings { diff --git a/ParquetClassLibrary/Crafts/CraftingRecipe.cs b/ParquetClassLibrary/Crafts/CraftingRecipe.cs index eaaa293d..ea759d13 100644 --- a/ParquetClassLibrary/Crafts/CraftingRecipe.cs +++ b/ParquetClassLibrary/Crafts/CraftingRecipe.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using CsvHelper.Configuration.Attributes; diff --git a/ParquetClassLibrary/Scripts/InteractionModel.cs b/ParquetClassLibrary/Scripts/InteractionModel.cs index 8a04a5c5..5b099ade 100644 --- a/ParquetClassLibrary/Scripts/InteractionModel.cs +++ b/ParquetClassLibrary/Scripts/InteractionModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.CodeAnalysis; using System.Linq; using CsvHelper.Configuration.Attributes; From 8001ef8df774c0fa6ffd715318b00bd737ec01e4 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:32:14 -0800 Subject: [PATCH 15/22] Removes unneeded suppressions. --- ParquetClassLibrary/Beings/BeingModel.cs | 3 --- ParquetClassLibrary/Parquets/ParquetModel.cs | 3 --- 2 files changed, 6 deletions(-) diff --git a/ParquetClassLibrary/Beings/BeingModel.cs b/ParquetClassLibrary/Beings/BeingModel.cs index 58b9639e..1aef178e 100644 --- a/ParquetClassLibrary/Beings/BeingModel.cs +++ b/ParquetClassLibrary/Beings/BeingModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.CodeAnalysis; using System.Linq; using CsvHelper.Configuration.Attributes; using Parquet.Scripts; @@ -10,8 +9,6 @@ namespace Parquet.Beings /// /// Models the basic definitions shared by any in-game actor. /// - [SuppressMessage("Design", "CA1033:Interface methods should be callable by subtypes", - Justification = "By design, subtypes of Model should never themselves use IMutableModel or derived interfaces to access their own members. The IMutableModel family of interfaces is for external types that require read/write access.")] public abstract class BeingModel : Model, IMutableBeingModel { #region Characteristics diff --git a/ParquetClassLibrary/Parquets/ParquetModel.cs b/ParquetClassLibrary/Parquets/ParquetModel.cs index 74a7a02f..eb4149d7 100644 --- a/ParquetClassLibrary/Parquets/ParquetModel.cs +++ b/ParquetClassLibrary/Parquets/ParquetModel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.CodeAnalysis; using System.Linq; using CsvHelper.Configuration.Attributes; using Parquet.Biomes; @@ -10,8 +9,6 @@ namespace Parquet.Parquets /// /// Models a sandbox parquet. /// - [SuppressMessage("Design", "CA1033:Interface methods should be callable by subtypes", - Justification = "By design, subtypes of Model should never themselves use IMutableModel or derived interfaces to access their own members. The IMutableModel family of interfaces is for external types that require read/write access.")] public abstract class ParquetModel : Model, IMutableParquetModel { #region Characteristics From fbd4fff98f45793a89d8cc0c2f8f759f57b48961 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:37:19 -0800 Subject: [PATCH 16/22] Updates documentation language for consistency. --- ParquetClassLibrary/Beings/CharacterStatus.cs | 2 +- ParquetClassLibrary/Games/GameStatus.cs | 2 +- ParquetClassLibrary/Pack.cs | 4 ++-- ParquetClassLibrary/Parquets/BlockStatus.cs | 2 +- ParquetClassLibrary/Parquets/FloorStatus.cs | 2 +- ParquetClassLibrary/Parquets/ParquetStatusPack.cs | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ParquetClassLibrary/Beings/CharacterStatus.cs b/ParquetClassLibrary/Beings/CharacterStatus.cs index 97d78d21..fda62b2e 100644 --- a/ParquetClassLibrary/Beings/CharacterStatus.cs +++ b/ParquetClassLibrary/Beings/CharacterStatus.cs @@ -295,7 +295,7 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public override T DeepClone() => new CharacterStatus(Position, SpawnAt, diff --git a/ParquetClassLibrary/Games/GameStatus.cs b/ParquetClassLibrary/Games/GameStatus.cs index 8e56c4c0..ab986c35 100644 --- a/ParquetClassLibrary/Games/GameStatus.cs +++ b/ParquetClassLibrary/Games/GameStatus.cs @@ -151,7 +151,7 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public override T DeepClone() => new GameStatus(PlayerCharacterID, CurrentScriptID) as T; #endregion diff --git a/ParquetClassLibrary/Pack.cs b/ParquetClassLibrary/Pack.cs index 487467ac..c7b8d1a0 100644 --- a/ParquetClassLibrary/Pack.cs +++ b/ParquetClassLibrary/Pack.cs @@ -71,7 +71,7 @@ public bool Equals(Pack inPack) /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public virtual Pack DeepClone() => DeepClone>(); @@ -79,7 +79,7 @@ public virtual Pack DeepClone() /// Creates a new instance that is a deep copy of the current instance. /// /// The type of the instance that is being cloned. - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public abstract TDerived DeepClone() where TDerived : Pack; #endregion diff --git a/ParquetClassLibrary/Parquets/BlockStatus.cs b/ParquetClassLibrary/Parquets/BlockStatus.cs index 481dc1d1..b30ddd6b 100644 --- a/ParquetClassLibrary/Parquets/BlockStatus.cs +++ b/ParquetClassLibrary/Parquets/BlockStatus.cs @@ -160,7 +160,7 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public override T DeepClone() => new BlockStatus(Toughness, MaxToughness) as T; #endregion diff --git a/ParquetClassLibrary/Parquets/FloorStatus.cs b/ParquetClassLibrary/Parquets/FloorStatus.cs index 068e0ee8..5e8b9d17 100644 --- a/ParquetClassLibrary/Parquets/FloorStatus.cs +++ b/ParquetClassLibrary/Parquets/FloorStatus.cs @@ -142,7 +142,7 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public override T DeepClone() => new FloorStatus(IsTrench) as T; #endregion diff --git a/ParquetClassLibrary/Parquets/ParquetStatusPack.cs b/ParquetClassLibrary/Parquets/ParquetStatusPack.cs index 9a149321..a89db808 100644 --- a/ParquetClassLibrary/Parquets/ParquetStatusPack.cs +++ b/ParquetClassLibrary/Parquets/ParquetStatusPack.cs @@ -154,7 +154,7 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public override ParquetStatusPack DeepClone() => new ParquetStatusPack((FloorStatus)CurrentFloorStatus.DeepClone(), (BlockStatus)CurrentBlockStatus.DeepClone()); @@ -162,7 +162,7 @@ public override ParquetStatusPack DeepClone() /// /// Creates a new instance that is a deep copy of the current instance. /// - /// A new instance with the same characteristics as the current instance. + /// A new instance with the same status as the current instance. public override T DeepClone() => DeepClone() as T; #endregion From 6d6c267279523678b4f23992bd53c9e1ac4086de Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:39:57 -0800 Subject: [PATCH 17/22] Reenables region serialization. --- ParquetClassLibrary/All.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ParquetClassLibrary/All.cs b/ParquetClassLibrary/All.cs index 2562a2ea..c35fac5d 100644 --- a/ParquetClassLibrary/All.cs +++ b/ParquetClassLibrary/All.cs @@ -574,6 +574,7 @@ public static bool LoadFromCSVs() #endregion #region Read Models + // TODO: [MAP] [SERIALIZATION] Serialization data for Regions and Beings needs to be updated var games = ModelCollection.ConverterFactory.GetRecordsForType(GameIDs); var floors = ModelCollection.ConverterFactory.GetRecordsForType(ParquetIDs); var blocks = ModelCollection.ConverterFactory.GetRecordsForType(ParquetIDs); @@ -584,9 +585,7 @@ public static bool LoadFromCSVs() var biomeRecipes = ModelCollection.ConverterFactory.GetRecordsForType(BiomeRecipeIDs); var craftingRecipes = ModelCollection.ConverterFactory.GetRecordsForType(CraftingRecipeIDs); var roomRecipes = ModelCollection.ConverterFactory.GetRecordsForType(RoomRecipeIDs); - var regions = ModelCollection.Default; - // TODO: [MAP] [SERIALIZATION] Reenable these after refactor. - // ModelCollection.ConverterFactory.GetRecordsForType(MapIDs); + var regions = ModelCollection.ConverterFactory.GetRecordsForType(RegionIDs); var scripts = ModelCollection.ConverterFactory.GetRecordsForType(ScriptIDs); var interactions = ModelCollection.ConverterFactory.GetRecordsForType(InteractionIDs); var items = ModelCollection.ConverterFactory.GetRecordsForType(ItemIDs); From 2027622b2ea57a9a8a9841357caf1949c41cb491 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 16:53:36 -0800 Subject: [PATCH 18/22] Separates InteractionStatus from ScriptStatus. It should have been this way all along, but I was being lazy ^_^U --- .../Scripts/InteractionStatus.cs | 176 ++++++++++++++++++ ParquetClassLibrary/Scripts/ScriptStatus.cs | 8 +- 2 files changed, 177 insertions(+), 7 deletions(-) create mode 100644 ParquetClassLibrary/Scripts/InteractionStatus.cs diff --git a/ParquetClassLibrary/Scripts/InteractionStatus.cs b/ParquetClassLibrary/Scripts/InteractionStatus.cs new file mode 100644 index 00000000..70d888df --- /dev/null +++ b/ParquetClassLibrary/Scripts/InteractionStatus.cs @@ -0,0 +1,176 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using CsvHelper; +using CsvHelper.Configuration; + +namespace Parquet.Scripts +{ + /// + /// Tracks the status of an . + /// Instances of this class are mutable during play. + /// + /// + /// The narrative gameplay revolves around instances of this class. + /// + public class InteractionStatus : Status + { + #region Class Defaults + /// Provides an instance of the class with default values. + public static InteractionStatus Unstarted { get; } = new InteractionStatus(); + #endregion + + #region Status + /// The current execution status of the tracked script. + public RunState State { get; set; } + + /// The index the script node about to be executed. + public int StepCounter { get; set; } + #endregion + + #region Initialization + /// + /// Initializes an instance of the with default values. + /// + public InteractionStatus() + : this(RunState.Unstarted, 0) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The of the tracked . + /// Index to the current in the tracked . + public InteractionStatus(RunState inState, int inProgramCounter) + { + State = inState; + StepCounter = inProgramCounter; + } + + /// + /// Initializes a new instance of the class + /// based on a given instance. + /// + /// The script definition whose status is being tracked. + [SuppressMessage("Usage", "CA1801:Review unused parameters", + Justification = "This constructor is provided for consistency. The parameter is currently ignored, but may not be in the future.")] + [SuppressMessage("Style", "IDE0060:Remove unused parameter", + Justification = "This constructor is provided for consistency. The parameter is currently ignored, but may not be in the future.")] + public InteractionStatus(InteractionModel inScript) + : this(RunState.Unstarted, 0) + { } + #endregion + + #region IEquatable Implementation + /// + /// Serves as a hash function for a . + /// + /// + /// A hash code for this instance that is suitable for use in hashing algorithms and data structures. + /// + public override int GetHashCode() + => (State, StepCounter).GetHashCode(); + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current. + /// true if they are equal; otherwise, false. + public override bool Equals(T inStatus) + => inStatus is InteractionStatus interactionStatus + && State == interactionStatus.State + && StepCounter == interactionStatus.StepCounter; + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if they are equal; otherwise, false. + public override bool Equals(object obj) + => obj is InteractionStatus status + && Equals(status); + + /// + /// Determines whether a specified instance of is equal to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if they are equal; otherwise, false. + public static bool operator ==(InteractionStatus inStatus1, InteractionStatus inStatus2) + => inStatus1?.Equals(inStatus2) ?? inStatus2?.Equals(inStatus1) ?? true; + + /// + /// Determines whether a specified instance of is not equal to another specified instance of . + /// + /// The first to compare. + /// The second to compare. + /// true if they are NOT equal; otherwise, false. + public static bool operator !=(InteractionStatus inStatus1, InteractionStatus inStatus2) + => !(inStatus1 == inStatus2); + #endregion + + #region ITypeConverter Implementation + /// Allows the converter to construct itself statically. + internal static InteractionStatus ConverterFactory { get; } = Unstarted; + + /// + /// Converts the given to a for serialization. + /// + /// The instance to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance serialized. + public override string ConvertToString(object inValue, IWriterRow inRow, MemberMapData inMemberMapData) + => inValue is InteractionStatus status + ? $"{status.State}{Delimiters.InternalDelimiter}" + + $"{status.StepCounter}" + : Logger.DefaultWithConvertLog(inValue?.ToString() ?? "null", nameof(InteractionStatus), nameof(Unstarted)); + + /// + /// Converts the given to an as deserialization. + /// + /// The text to convert. + /// The current context and configuration. + /// Mapping info for a member to a CSV field or property. + /// The given instance deserialized. + public override object ConvertFromString(string inText, IReaderRow inRow, MemberMapData inMemberMapData) + { + if (string.IsNullOrEmpty(inText) + || string.Compare(nameof(Unstarted), inText, StringComparison.OrdinalIgnoreCase) == 0) + { + return Unstarted; + } + + var parameterText = inText.Split(Delimiters.SecondaryDelimiter); + + var parsedState = Enum.TryParse(typeof(RunState), parameterText[0], out var temp0) + ? (RunState)temp0 + : Logger.DefaultWithParseLog(parameterText[0], nameof(RunState), RunState.Unstarted); + var parsedProgramCounter = int.TryParse(parameterText[1], All.SerializedNumberStyle, + CultureInfo.InvariantCulture, out var temp1) + ? temp1 + : Logger.DefaultWithParseLog(parameterText[1], nameof(StepCounter), 0); + + return new InteractionStatus(parsedState, parsedProgramCounter); + } + #endregion + + #region IDeeplyCloneable Implementation + /// + /// Creates a new instance that is a deep copy of the current instance. + /// + /// A new instance with the same characteristics as the current instance. + public override T DeepClone() + => new InteractionStatus(State, StepCounter) as T; + #endregion + + #region Utilities + /// + /// Returns a that represents the current . + /// + /// The representation. + public override string ToString() + => $"{nameof(InteractionStatus)}: {State} @ {StepCounter}"; + #endregion + } +} diff --git a/ParquetClassLibrary/Scripts/ScriptStatus.cs b/ParquetClassLibrary/Scripts/ScriptStatus.cs index 4fa440dc..053a6a54 100644 --- a/ParquetClassLibrary/Scripts/ScriptStatus.cs +++ b/ParquetClassLibrary/Scripts/ScriptStatus.cs @@ -10,12 +10,6 @@ namespace Parquet.Scripts /// Tracks the status of a . /// Instances of this class are mutable during play. /// - /// - /// This can also be used to tracks the status of an - /// as only is stateful. - /// - /// The narrative gameplay revolves around instances of this class. - /// public class ScriptStatus : Status { #region Class Defaults @@ -173,7 +167,7 @@ public override T DeepClone() /// /// The representation. public override string ToString() - => $"{nameof(ScriptStatus)}: {State}"; + => $"{nameof(ScriptStatus)}: {State}@ {ProgramCounter}"; #endregion } } From 1c237d24b6a72fdb85451abd23152887e586fff9 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 17:02:56 -0800 Subject: [PATCH 19/22] Renames Inventory to InventoryCollection to avoid confusion. --- .editorconfig | 6 +- ParquetClassLibrary/All.cs | 2 +- ParquetClassLibrary/Beings/CharacterModel.cs | 10 +-- ParquetClassLibrary/Beings/CharacterStatus.cs | 10 +-- .../Beings/IMutableCharacterModel.cs | 2 +- .../Items/IMutableItemModel.cs | 2 +- .../{Inventory.cs => InventoryCollection.cs} | 66 +++++++------- .../Items/InventoryConfiguration.cs | 6 +- ParquetClassLibrary/Items/InventorySlot.cs | 4 +- ParquetClassLibrary/Items/ItemModel.cs | 6 +- .../Parquets/FurnishingModel.cs | 2 +- ParquetClassLibrary/PublicAPI.Unshipped.txt | 89 +++++++++++-------- ParquetUnitTests/Items/InventoryUnitTest.cs | 2 +- 13 files changed, 108 insertions(+), 99 deletions(-) rename ParquetClassLibrary/Items/{Inventory.cs => InventoryCollection.cs} (85%) diff --git a/.editorconfig b/.editorconfig index 8497b73d..dfd008be 100644 --- a/.editorconfig +++ b/.editorconfig @@ -183,9 +183,9 @@ dotnet_naming_style.begins_with_i.capitalization = pascal_case dotnet_code_quality.api_surface = all # Parquet-Specific Type Suffixes -dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.ICollection->Collection|Grid|Inventory -dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.IEnumerable->Collection|Grid|Inventory -dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.IReadOnlyCollection->Collection|Grid|Inventory +dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.ICollection->Collection|Grid +dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.IEnumerable->Collection|Grid +dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.IReadOnlyCollection->Collection|Grid dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.IReadOnlySet->Collection|Set dotnet_code_quality.CA1710.additional_required_suffixes = T:System.Collections.Generic.ISet->Collection|Set dotnet_code_quality.CA1710.additional_required_suffixes = T:ParquetClassLibrary.IGrid->Grid diff --git a/ParquetClassLibrary/All.cs b/ParquetClassLibrary/All.cs index c35fac5d..6806cfd8 100644 --- a/ParquetClassLibrary/All.cs +++ b/ParquetClassLibrary/All.cs @@ -448,7 +448,7 @@ static All() { typeof(IEnumerable), SeriesConverter>.ConverterFactory }, { typeof(IEnumerable), SeriesConverter>.ConverterFactory }, { typeof(IEnumerable), SeriesConverter>.ConverterFactory }, - { typeof(Inventory), SeriesConverter.ConverterFactory }, + { typeof(InventoryCollection), SeriesConverter.ConverterFactory }, { typeof(IReadOnlyList), SeriesConverter>.ConverterFactory }, { typeof(IReadOnlyList), SeriesConverter>.ConverterFactory }, { typeof(IReadOnlyList), SeriesConverter>.ConverterFactory }, diff --git a/ParquetClassLibrary/Beings/CharacterModel.cs b/ParquetClassLibrary/Beings/CharacterModel.cs index a1a547b8..65b292b3 100644 --- a/ParquetClassLibrary/Beings/CharacterModel.cs +++ b/ParquetClassLibrary/Beings/CharacterModel.cs @@ -78,7 +78,7 @@ public string FamilyName /// Care should be taken not to alter it during play. /// [Index(13)] - public Inventory StartingInventory { get; } + public InventoryCollection StartingInventory { get; } #endregion #region Initialization @@ -105,14 +105,14 @@ public CharacterModel(ModelID inID, string inName, string inDescription, string IEnumerable inSeeksIDs = null, string inPronounKey = PronounGroup.DefaultKey, string inStoryCharacterID = "", Location? inStartingLocation = null, IEnumerable inStartingQuestIDs = null, ModelID? inStartingDialogueID = null, - Inventory inStartingInventory = null) + InventoryCollection inStartingInventory = null) : base(All.CharacterIDs, inID, inName, inDescription, inComment, inTags, inNativeBiomeID, inPrimaryBehaviorID, inAvoidsIDs, inSeeksIDs) { var nonNullStartingLocation = inStartingLocation ?? Location.Nowhere; var nonNullQuestIDs = inStartingQuestIDs ?? Enumerable.Empty(); var nonNullDialogueID = inStartingDialogueID ?? ModelID.None; - var nonNullInventory = inStartingInventory ?? Inventory.Empty; + var nonNullInventory = inStartingInventory ?? InventoryCollection.Empty; Precondition.AreInRange(nonNullQuestIDs, All.InteractionIDs, nameof(inStartingQuestIDs)); Precondition.IsInRange(nonNullDialogueID, All.InteractionIDs, nameof(inStartingDialogueID)); @@ -232,9 +232,9 @@ ModelID IMutableCharacterModel.StartingDialogueID /// IMutableCharacterModel is for external types that require read-write access. /// [Ignore] - Inventory IMutableCharacterModel.StartingInventory + InventoryCollection IMutableCharacterModel.StartingInventory => LibraryState.IsPlayMode - ? Logger.DefaultWithImmutableInPlayLog(nameof(StartingInventory), Inventory.Empty) + ? Logger.DefaultWithImmutableInPlayLog(nameof(StartingInventory), InventoryCollection.Empty) : StartingInventory; #endregion } diff --git a/ParquetClassLibrary/Beings/CharacterStatus.cs b/ParquetClassLibrary/Beings/CharacterStatus.cs index fda62b2e..f42fad09 100644 --- a/ParquetClassLibrary/Beings/CharacterStatus.cs +++ b/ParquetClassLibrary/Beings/CharacterStatus.cs @@ -57,7 +57,7 @@ public class CharacterStatus : BeingStatus public ICollection Quests { get; } /// This 's set of belongings. - public Inventory Inventory { get; } + public InventoryCollection Inventory { get; } #endregion #region Initialization @@ -79,7 +79,7 @@ public CharacterStatus(Location? inPosition = null, Location? inSpawnAt = null, ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = int.MaxValue, ICollection inKnownBeings = null, ICollection inKnownParquets = null, ICollection inKnownRoomRecipes = null, ICollection inKnownCraftingRecipes = null, - ICollection inQuests = null, Inventory inInventory = null) + ICollection inQuests = null, InventoryCollection inInventory = null) { var nonNullPosition = inPosition ?? Location.Nowhere; var nonNullSpawnAt = inSpawnAt ?? Location.Nowhere; @@ -91,7 +91,7 @@ public CharacterStatus(Location? inPosition = null, Location? inSpawnAt = null, var nonNullRoomRecipes = inKnownRoomRecipes ?? Enumerable.Empty().ToList(); var nonNullCraftingRecipes = inKnownCraftingRecipes ?? Enumerable.Empty().ToList(); var nonNullQuests = inQuests ?? Enumerable.Empty().ToList(); - var nonNullInventory = inInventory ?? Inventory.Empty; + var nonNullInventory = inInventory ?? InventoryCollection.Empty; Precondition.AreInRange(nonNullBeings, All.CritterIDs, nameof(inKnownBeings)); Precondition.AreInRange(nonNullParquets, All.ParquetIDs, nameof(inKnownParquets)); Precondition.AreInRange(nonNullRoomRecipes, All.RoomRecipeIDs, nameof(inKnownRoomRecipes)); @@ -273,8 +273,8 @@ public override object ConvertFromString(string inText, IReaderRow inRow, Member var parsedQuests = (ICollection) SeriesConverter>.ConverterFactory.ConvertFromString(parameterText[13], inRow, inMemberMapData); - var parsedInventory = (Inventory) - SeriesConverter.ConverterFactory.ConvertFromString(parameterText[14], inRow, + var parsedInventory = (InventoryCollection) + SeriesConverter.ConverterFactory.ConvertFromString(parameterText[14], inRow, inMemberMapData); return new CharacterStatus(parsedPosition, diff --git a/ParquetClassLibrary/Beings/IMutableCharacterModel.cs b/ParquetClassLibrary/Beings/IMutableCharacterModel.cs index ae012c13..2c5ba548 100644 --- a/ParquetClassLibrary/Beings/IMutableCharacterModel.cs +++ b/ParquetClassLibrary/Beings/IMutableCharacterModel.cs @@ -45,6 +45,6 @@ public interface IMutableCharacterModel : IMutableBeingModel public ModelID StartingDialogueID { get; set; } /// The set of belongings that this begins with. - public Inventory StartingInventory { get; } + public InventoryCollection StartingInventory { get; } } } diff --git a/ParquetClassLibrary/Items/IMutableItemModel.cs b/ParquetClassLibrary/Items/IMutableItemModel.cs index bdbd1863..1961b74f 100644 --- a/ParquetClassLibrary/Items/IMutableItemModel.cs +++ b/ParquetClassLibrary/Items/IMutableItemModel.cs @@ -23,7 +23,7 @@ public interface IMutableItemModel : IMutableModel /// /// The of the generating the in-game effect caused by - /// keeping the item in a 's . + /// keeping the item in a 's . /// public ModelID EffectWhileHeldID { get; set; } diff --git a/ParquetClassLibrary/Items/Inventory.cs b/ParquetClassLibrary/Items/InventoryCollection.cs similarity index 85% rename from ParquetClassLibrary/Items/Inventory.cs rename to ParquetClassLibrary/Items/InventoryCollection.cs index 8b6af76f..92efda35 100644 --- a/ParquetClassLibrary/Items/Inventory.cs +++ b/ParquetClassLibrary/Items/InventoryCollection.cs @@ -12,13 +12,11 @@ namespace Parquet.Items /// Models a set of items carried by a character. /// Instances of this class are mutable during play. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", - Justification = "Inventory implies InventorySlotCollection.")] - public class Inventory : ICollection, IDeeplyCloneable + public class InventoryCollection : ICollection, IDeeplyCloneable { #region Class Defaults - /// A value to use in place of an uninitialized . - public static Inventory Empty { get; } = new Inventory(); + /// A value to use in place of an uninitialized . + public static InventoryCollection Empty { get; } = new InventoryCollection(); #endregion #region Characteristics @@ -52,21 +50,21 @@ public int Capacity #region Initialization /// - /// Initializes an empty with unusable capacity. + /// Initializes an empty with unusable capacity. /// /// /// This version of the constructor exists to make the generic new() constraint happy /// and is used in the library in a context where its limitations are understood. /// You probably don't want to use this constructor in your own code. /// - public Inventory() + public InventoryCollection() : this(InventoryConfiguration.DefaultCapacity) { } /// - /// Initializes a new empty instance of the class. + /// Initializes a new empty instance of the class. /// /// How many inventory slots exist. Must be positive - public Inventory(int inCapacity) + public InventoryCollection(int inCapacity) { Precondition.MustBePositive(inCapacity, nameof(inCapacity)); @@ -75,11 +73,11 @@ public Inventory(int inCapacity) } /// - /// Initializes a new instance of the class from a collection of s. + /// Initializes a new instance of the class from a collection of s. /// /// The s to collect. Cannot be null. /// How many inventory slots exist. Must be positive - public Inventory(IEnumerable inSlots, int inCapacity) + public InventoryCollection(IEnumerable inSlots, int inCapacity) { Precondition.IsNotNull(inSlots, nameof(inSlots)); Precondition.MustBePositive(inCapacity, nameof(inCapacity)); @@ -95,7 +93,7 @@ public Inventory(IEnumerable inSlots, int inCapacity) #region Slot Access /// - /// Determines how many of given type of item is contained in the . + /// Determines how many of given type of item is contained in the . /// /// The item type to check for. Cannot be . /// The number of items of the given type contained. @@ -104,7 +102,7 @@ public int Contains(ModelID inItemID) .Sum(slot => slot.Count); /// - /// Determines if the contains the given items in the given quantities. + /// Determines if the contains the given items in the given quantities. /// /// The items to check for. Cannot be null or empty. /// true if everything was found; otherwise, false. @@ -121,7 +119,7 @@ public bool Has(IEnumerable<(ModelID, int)> inItems) } /// - /// Determines if the contains the given s. + /// Determines if the contains the given s. /// /// The slots to check for. Cannot be null or empty. /// true if everything was found; otherwise, false. @@ -138,7 +136,7 @@ public bool Has(IEnumerable inSlots) } /// - /// Determines if the contains the given . + /// Determines if the contains the given . /// /// The slot to check for. /// true if everything was found; otherwise, false. @@ -148,7 +146,7 @@ public bool Has(InventorySlot inSlot) && Has(inSlot.ItemID, inSlot.Count); /// - /// Determines if the contains the given number of the given item. + /// Determines if the contains the given number of the given item. /// /// What kind of item to check for. /// How many of the item to check for. Must be positive. @@ -165,7 +163,7 @@ public bool Has(ModelID inItemID, int inHowMany = 1) /// The slot to give. /// /// If everything was stored successfully, 0; - /// otherwise, the number of items that could not be stored because the is full. + /// otherwise, the number of items that could not be stored because the is full. /// public int Give(InventorySlot inSlot) => Give(inSlot?.ItemID ?? ModelID.None, inSlot?.Count ?? 0); @@ -177,7 +175,7 @@ public int Give(InventorySlot inSlot) /// How many of the item to give. Must be positive. /// /// If everything was stored successfully, 0; - /// otherwise, the number of items that could not be stored because the is full. + /// otherwise, the number of items that could not be stored because the is full. /// public int Give(ModelID inItemID, int inHowMany) { @@ -186,7 +184,7 @@ public int Give(ModelID inItemID, int inHowMany) Debug.Assert(inItemID != ModelID.None, string.Format(CultureInfo.CurrentCulture, Resources.WarningTriedToGiveNothing, nameof(ModelID.None), - nameof(Inventory))); + nameof(InventoryCollection))); if (inItemID == ModelID.None) { return 0; @@ -234,7 +232,7 @@ public int Give(ModelID inItemID, int inHowMany) /// The slot to take. /// /// If everything was removed successfully, 0; - /// otherwise, the number of items that could not be removed because the did not have any more. + /// otherwise, the number of items that could not be removed because the did not have any more. /// public int Take(InventorySlot inSlot) => Take(inSlot?.ItemID ?? ModelID.None, inSlot?.Count ?? 0); @@ -246,7 +244,7 @@ public int Take(InventorySlot inSlot) /// How many of the item to take. Must be positive. /// /// If everything was removed successfully, 0; - /// otherwise, the number of items that could not be removed because the did not have any more. + /// otherwise, the number of items that could not be removed because the did not have any more. /// public int Take(ModelID inItemID, int inHowMany) { @@ -277,7 +275,7 @@ public int Take(ModelID inItemID, int inHowMany) #endregion #region ICollection Implementation - /// If true the is read-only; if false, it may be mutated. + /// If true the is read-only; if false, it may be mutated. public bool IsReadOnly => false; /// How many s are currently occupied. @@ -285,32 +283,32 @@ public int Count => Slots.Count; /// - /// Determines whether the contains the given . + /// Determines whether the contains the given . /// /// The slot to search for. /// true if the slot is found; otherwise, false. - [Obsolete("Use Inventory.Has() instead.", true)] + [Obsolete("Use InventoryCollection.Has() instead.", true)] public bool Contains(InventorySlot inSlot) => Has(inSlot); /// - /// Adds the given to the . + /// Adds the given to the . /// /// This method should only be used by . /// The slot to add. - [Obsolete("Use Inventory.Give() instead.")] + [Obsolete("Use InventoryCollection.Give() instead.")] public void Add(InventorySlot inSlot) => Give(inSlot); /// - /// Removes all s from the . + /// Removes all s from the . /// This method does not respect gameplay rules, but forcibly empties the collection. /// public void Clear() => Slots.Clear(); /// - /// Copies the elements of the to an , starting at the given index. + /// Copies the elements of the to an , starting at the given index. /// /// The array to copy to. /// The index at which to begin copying. @@ -318,11 +316,11 @@ public void CopyTo(InventorySlot[] inArray, int inArrayIndex) => Slots.CopyTo(inArray, inArrayIndex); /// - /// Removes the first occurrence of the given from the . + /// Removes the first occurrence of the given from the . /// /// The slot to remove. /// False if slot was found but could not be removed; otherwise, true. - [Obsolete("Use Inventory.Take() instead.", true)] + [Obsolete("Use InventoryCollection.Take() instead.", true)] public bool Remove(InventorySlot inSlot) => Take(inSlot) == 0; @@ -337,7 +335,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// Retrieves an enumerator for the . /// - /// An enumerator that iterates through the inventory. + /// An enumerator that iterates through the inventory collection. public IEnumerator GetEnumerator() => Slots.GetEnumerator(); #endregion @@ -347,8 +345,8 @@ public IEnumerator GetEnumerator() /// /// /// - public Inventory DeepClone() - => new Inventory(Slots.ConvertAll(slot => (InventorySlot)slot.DeepClone()), Capacity); + public InventoryCollection DeepClone() + => new InventoryCollection(Slots.ConvertAll(slot => (InventorySlot)slot.DeepClone()), Capacity); #endregion #region Utilities @@ -357,7 +355,7 @@ public int ItemCount => Slots.Select(slot => slot.Count).Sum(); /// - /// Returns a that represents the current . + /// Returns a that represents the current . /// /// The representation. public override string ToString() diff --git a/ParquetClassLibrary/Items/InventoryConfiguration.cs b/ParquetClassLibrary/Items/InventoryConfiguration.cs index 73fa33a9..335e89c0 100644 --- a/ParquetClassLibrary/Items/InventoryConfiguration.cs +++ b/ParquetClassLibrary/Items/InventoryConfiguration.cs @@ -4,17 +4,17 @@ namespace Parquet.Items { /// - /// Provides rules for working with an . + /// Provides rules for working with an . /// public static class InventoryConfiguration { #region Class Defaults - /// The capacity to use for an when the configuration cannot be read. + /// The capacity to use for an when the configuration cannot be read. private const int DefaultDefaultCapacity = 16; #endregion #region Characteristics - /// The capacity to use for an when none is specified. + /// The capacity to use for an when none is specified. public static int DefaultCapacity { get; set; } = DefaultDefaultCapacity; #endregion diff --git a/ParquetClassLibrary/Items/InventorySlot.cs b/ParquetClassLibrary/Items/InventorySlot.cs index b4f808a5..8e90e321 100644 --- a/ParquetClassLibrary/Items/InventorySlot.cs +++ b/ParquetClassLibrary/Items/InventorySlot.cs @@ -8,13 +8,13 @@ namespace Parquet.Items { /// - /// Allows multiple copies of a given to be grouped together in an . + /// Allows multiple copies of a given to be grouped together in an . /// Instances of this class are mutable during play. /// public class InventorySlot : Status { #region Class Defaults - /// A value to use in place of an uninitialized . + /// A value to use in place of an uninitialized . public static InventorySlot Empty { get; } = new InventorySlot(); #endregion diff --git a/ParquetClassLibrary/Items/ItemModel.cs b/ParquetClassLibrary/Items/ItemModel.cs index 59fc7703..edc3d9e8 100644 --- a/ParquetClassLibrary/Items/ItemModel.cs +++ b/ParquetClassLibrary/Items/ItemModel.cs @@ -36,7 +36,7 @@ public class ItemModel : Model, IMutableItemModel /// /// The of the generating the in-game effect caused by - /// keeping the item in a 's . + /// keeping the item in a 's . /// [Index(9)] public ModelID EffectWhileHeldID { get; private set; } @@ -65,7 +65,7 @@ public class ItemModel : Model, IMutableItemModel /// The type of . /// cost. /// rarity. - /// How many such items may be stacked together in the . Must be positive. + /// How many such items may be stacked together in the . Must be positive. /// 's passive effect. /// 's active effect. /// The parquet represented by this , if any. @@ -154,7 +154,7 @@ int IMutableItemModel.StackMax /// /// The of the generating the in-game effect caused by - /// keeping the item in a 's . + /// keeping the item in a 's . /// /// /// By design, subtypes of should never themselves use . diff --git a/ParquetClassLibrary/Parquets/FurnishingModel.cs b/ParquetClassLibrary/Parquets/FurnishingModel.cs index 530f2fb9..99cc7497 100644 --- a/ParquetClassLibrary/Parquets/FurnishingModel.cs +++ b/ParquetClassLibrary/Parquets/FurnishingModel.cs @@ -49,7 +49,7 @@ public static Range Bounds /// Player-friendly description of the . /// Comment of, on, or by the . /// Any additional information about the . - /// The that represents this in the . + /// The that represents this in the . /// Indicates which, if any, this parquet helps to generate. /// Describes which, if any, (s) this parquet helps form. /// If true this may be walked on. diff --git a/ParquetClassLibrary/PublicAPI.Unshipped.txt b/ParquetClassLibrary/PublicAPI.Unshipped.txt index 5a7e7e36..b47fce11 100644 --- a/ParquetClassLibrary/PublicAPI.Unshipped.txt +++ b/ParquetClassLibrary/PublicAPI.Unshipped.txt @@ -81,7 +81,7 @@ override Parquet.Games.GameStatus.GetHashCode() -> int override Parquet.Games.GameStatus.ToString() -> string override Parquet.GridConverter.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object override Parquet.GridConverter.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string -override Parquet.Items.Inventory.ToString() -> string +override Parquet.Items.InventoryCollection.ToString() -> string override Parquet.Items.InventorySlot.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object override Parquet.Items.InventorySlot.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string override Parquet.Items.InventorySlot.DeepClone() -> T @@ -160,6 +160,13 @@ override Parquet.Rooms.MapSpace.GetHashCode() -> int override Parquet.Rooms.MapSpace.ToString() -> string override Parquet.Rooms.Room.Equals(object obj) -> bool override Parquet.Rooms.Room.GetHashCode() -> int +override Parquet.Scripts.InteractionStatus.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object +override Parquet.Scripts.InteractionStatus.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string +override Parquet.Scripts.InteractionStatus.DeepClone() -> T +override Parquet.Scripts.InteractionStatus.Equals(object obj) -> bool +override Parquet.Scripts.InteractionStatus.Equals(T inStatus) -> bool +override Parquet.Scripts.InteractionStatus.GetHashCode() -> int +override Parquet.Scripts.InteractionStatus.ToString() -> string override Parquet.Scripts.ScriptNode.ToString() -> string override Parquet.Scripts.ScriptStatus.ConvertFromString(string inText, CsvHelper.IReaderRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> object override Parquet.Scripts.ScriptStatus.ConvertToString(object inValue, CsvHelper.IWriterRow inRow, CsvHelper.Configuration.MemberMapData inMemberMapData) -> string @@ -178,21 +185,18 @@ Parquet.Beings.BeingModel.AvoidsIDs.get -> System.Collections.Generic.IReadOnlyL Parquet.Beings.BeingModel.BeingModel(Parquet.Range inBounds, Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null) -> void Parquet.Beings.BeingModel.NativeBiomeID.get -> Parquet.ModelID Parquet.Beings.BeingModel.NativeBiomeID.set -> void -Parquet.Beings.BeingModel.NativeBiomeID.set -> void Parquet.Beings.BeingModel.PrimaryBehaviorID.get -> Parquet.ModelID Parquet.Beings.BeingModel.PrimaryBehaviorID.set -> void -Parquet.Beings.BeingModel.PrimaryBehaviorID.set -> void Parquet.Beings.BeingModel.SeeksIDs.get -> System.Collections.Generic.IReadOnlyList Parquet.Beings.BeingStatus Parquet.Beings.BeingStatus.BeingStatus() -> void Parquet.Beings.CharacterModel -Parquet.Beings.CharacterModel.CharacterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null, string inPronounKey = "they/them", string inStoryCharacterID = "", Parquet.Location? inStartingLocation = null, System.Collections.Generic.IEnumerable inStartingQuestIDs = null, Parquet.ModelID? inStartingDialogueID = null, Parquet.Items.Inventory inStartingInventory = null) -> void -Parquet.Beings.CharacterModel.CharacterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null, string inPronounKey = "they/them", string inStoryCharacterID = "", Parquet.Location? inStartingLocation = null, System.Collections.Generic.IEnumerable inStartingQuestIDs = null, Parquet.ModelID? inStartingDialogueID = null, Parquet.Items.Inventory inStartingInventory = null) -> void +Parquet.Beings.CharacterModel.CharacterModel(Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inNativeBiomeID = null, Parquet.ModelID? inPrimaryBehaviorID = null, System.Collections.Generic.IEnumerable inAvoidsIDs = null, System.Collections.Generic.IEnumerable inSeeksIDs = null, string inPronounKey = "they/them", string inStoryCharacterID = "", Parquet.Location? inStartingLocation = null, System.Collections.Generic.IEnumerable inStartingQuestIDs = null, Parquet.ModelID? inStartingDialogueID = null, Parquet.Items.InventoryCollection inStartingInventory = null) -> void Parquet.Beings.CharacterModel.FamilyName.get -> string Parquet.Beings.CharacterModel.PersonalName.get -> string Parquet.Beings.CharacterModel.PronounKey.get -> string Parquet.Beings.CharacterModel.StartingDialogueID.get -> Parquet.ModelID -Parquet.Beings.CharacterModel.StartingInventory.get -> Parquet.Items.Inventory +Parquet.Beings.CharacterModel.StartingInventory.get -> Parquet.Items.InventoryCollection Parquet.Beings.CharacterModel.StartingLocation.get -> Parquet.Location Parquet.Beings.CharacterModel.StartingQuestIDs.get -> System.Collections.Generic.IReadOnlyList Parquet.Beings.CharacterModel.StoryCharacterID.get -> string @@ -200,10 +204,10 @@ Parquet.Beings.CharacterStatus Parquet.Beings.CharacterStatus.BiomeTimeRemaining.get -> int Parquet.Beings.CharacterStatus.BiomeTimeRemaining.set -> void Parquet.Beings.CharacterStatus.CharacterStatus(Parquet.Beings.CharacterModel inCharacterModel) -> void -Parquet.Beings.CharacterStatus.CharacterStatus(Parquet.Location? inPosition = null, Parquet.Location? inSpawnAt = null, Parquet.Location? inRoomAssignment = null, Parquet.ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = 2147483647, System.Collections.Generic.ICollection inKnownBeings = null, System.Collections.Generic.ICollection inKnownParquets = null, System.Collections.Generic.ICollection inKnownRoomRecipes = null, System.Collections.Generic.ICollection inKnownCraftingRecipes = null, System.Collections.Generic.ICollection inQuests = null, Parquet.Items.Inventory inInventory = null) -> void +Parquet.Beings.CharacterStatus.CharacterStatus(Parquet.Location? inPosition = null, Parquet.Location? inSpawnAt = null, Parquet.Location? inRoomAssignment = null, Parquet.ModelID? inCurrentBehavior = null, int inBiomeTimeRemaining = 2147483647, System.Collections.Generic.ICollection inKnownBeings = null, System.Collections.Generic.ICollection inKnownParquets = null, System.Collections.Generic.ICollection inKnownRoomRecipes = null, System.Collections.Generic.ICollection inKnownCraftingRecipes = null, System.Collections.Generic.ICollection inQuests = null, Parquet.Items.InventoryCollection inInventory = null) -> void Parquet.Beings.CharacterStatus.CurrentBehaviorID.get -> Parquet.ModelID Parquet.Beings.CharacterStatus.CurrentBehaviorID.set -> void -Parquet.Beings.CharacterStatus.Inventory.get -> Parquet.Items.Inventory +Parquet.Beings.CharacterStatus.Inventory.get -> Parquet.Items.InventoryCollection Parquet.Beings.CharacterStatus.KnownBeings.get -> System.Collections.Generic.ICollection Parquet.Beings.CharacterStatus.KnownCraftingRecipes.get -> System.Collections.Generic.ICollection Parquet.Beings.CharacterStatus.KnownParquets.get -> System.Collections.Generic.ICollection @@ -220,7 +224,6 @@ Parquet.Beings.CritterModel.CritterModel(Parquet.ModelID inID, string inName, st Parquet.Beings.CritterStatus Parquet.Beings.CritterStatus.CritterStatus(Parquet.Beings.CritterModel inCritterModel) -> void Parquet.Beings.CritterStatus.CritterStatus(Parquet.Location? inPosition = null, Parquet.ModelID? inCurrentBehavior = null) -> void -Parquet.Beings.CritterStatus.CritterStatus(Parquet.Location? inPosition = null, Parquet.ModelID? inCurrentBehavior = null) -> void Parquet.Beings.CritterStatus.CurrentBehaviorID.get -> Parquet.ModelID Parquet.Beings.CritterStatus.CurrentBehaviorID.set -> void Parquet.Beings.CritterStatus.Position.get -> Parquet.Location @@ -241,7 +244,7 @@ Parquet.Beings.IMutableCharacterModel.PronounKey.get -> string Parquet.Beings.IMutableCharacterModel.PronounKey.set -> void Parquet.Beings.IMutableCharacterModel.StartingDialogueID.get -> Parquet.ModelID Parquet.Beings.IMutableCharacterModel.StartingDialogueID.set -> void -Parquet.Beings.IMutableCharacterModel.StartingInventory.get -> Parquet.Items.Inventory +Parquet.Beings.IMutableCharacterModel.StartingInventory.get -> Parquet.Items.InventoryCollection Parquet.Beings.IMutableCharacterModel.StartingLocation.get -> Parquet.Location Parquet.Beings.IMutableCharacterModel.StartingLocation.set -> void Parquet.Beings.IMutableCharacterModel.StartingQuestIDs.get -> System.Collections.Generic.ICollection @@ -402,31 +405,31 @@ Parquet.Items.IMutableItemModel.StackMax.get -> int Parquet.Items.IMutableItemModel.StackMax.set -> void Parquet.Items.IMutableItemModel.Subtype.get -> Parquet.Items.ItemType Parquet.Items.IMutableItemModel.Subtype.set -> void -Parquet.Items.Inventory -Parquet.Items.Inventory.Add(Parquet.Items.InventorySlot inSlot) -> void -Parquet.Items.Inventory.Capacity.get -> int -Parquet.Items.Inventory.Capacity.set -> void -Parquet.Items.Inventory.Clear() -> void -Parquet.Items.Inventory.Contains(Parquet.Items.InventorySlot inSlot) -> bool -Parquet.Items.Inventory.Contains(Parquet.ModelID inItemID) -> int -Parquet.Items.Inventory.CopyTo(Parquet.Items.InventorySlot[] inArray, int inArrayIndex) -> void -Parquet.Items.Inventory.Count.get -> int -Parquet.Items.Inventory.DeepClone() -> Parquet.Items.Inventory -Parquet.Items.Inventory.GetEnumerator() -> System.Collections.Generic.IEnumerator -Parquet.Items.Inventory.Give(Parquet.Items.InventorySlot inSlot) -> int -Parquet.Items.Inventory.Give(Parquet.ModelID inItemID, int inHowMany) -> int -Parquet.Items.Inventory.Has(Parquet.Items.InventorySlot inSlot) -> bool -Parquet.Items.Inventory.Has(Parquet.ModelID inItemID, int inHowMany = 1) -> bool -Parquet.Items.Inventory.Has(System.Collections.Generic.IEnumerable<(Parquet.ModelID, int)> inItems) -> bool -Parquet.Items.Inventory.Has(System.Collections.Generic.IEnumerable inSlots) -> bool -Parquet.Items.Inventory.Inventory() -> void -Parquet.Items.Inventory.Inventory(int inCapacity) -> void -Parquet.Items.Inventory.Inventory(System.Collections.Generic.IEnumerable inSlots, int inCapacity) -> void -Parquet.Items.Inventory.IsReadOnly.get -> bool -Parquet.Items.Inventory.ItemCount.get -> int -Parquet.Items.Inventory.Remove(Parquet.Items.InventorySlot inSlot) -> bool -Parquet.Items.Inventory.Take(Parquet.Items.InventorySlot inSlot) -> int -Parquet.Items.Inventory.Take(Parquet.ModelID inItemID, int inHowMany) -> int +Parquet.Items.InventoryCollection +Parquet.Items.InventoryCollection.Add(Parquet.Items.InventorySlot inSlot) -> void +Parquet.Items.InventoryCollection.Capacity.get -> int +Parquet.Items.InventoryCollection.Capacity.set -> void +Parquet.Items.InventoryCollection.Clear() -> void +Parquet.Items.InventoryCollection.Contains(Parquet.Items.InventorySlot inSlot) -> bool +Parquet.Items.InventoryCollection.Contains(Parquet.ModelID inItemID) -> int +Parquet.Items.InventoryCollection.CopyTo(Parquet.Items.InventorySlot[] inArray, int inArrayIndex) -> void +Parquet.Items.InventoryCollection.Count.get -> int +Parquet.Items.InventoryCollection.DeepClone() -> Parquet.Items.InventoryCollection +Parquet.Items.InventoryCollection.GetEnumerator() -> System.Collections.Generic.IEnumerator +Parquet.Items.InventoryCollection.Give(Parquet.Items.InventorySlot inSlot) -> int +Parquet.Items.InventoryCollection.Give(Parquet.ModelID inItemID, int inHowMany) -> int +Parquet.Items.InventoryCollection.Has(Parquet.Items.InventorySlot inSlot) -> bool +Parquet.Items.InventoryCollection.Has(Parquet.ModelID inItemID, int inHowMany = 1) -> bool +Parquet.Items.InventoryCollection.Has(System.Collections.Generic.IEnumerable<(Parquet.ModelID, int)> inItems) -> bool +Parquet.Items.InventoryCollection.Has(System.Collections.Generic.IEnumerable inSlots) -> bool +Parquet.Items.InventoryCollection.InventoryCollection() -> void +Parquet.Items.InventoryCollection.InventoryCollection(int inCapacity) -> void +Parquet.Items.InventoryCollection.InventoryCollection(System.Collections.Generic.IEnumerable inSlots, int inCapacity) -> void +Parquet.Items.InventoryCollection.IsReadOnly.get -> bool +Parquet.Items.InventoryCollection.ItemCount.get -> int +Parquet.Items.InventoryCollection.Remove(Parquet.Items.InventorySlot inSlot) -> bool +Parquet.Items.InventoryCollection.Take(Parquet.Items.InventorySlot inSlot) -> int +Parquet.Items.InventoryCollection.Take(Parquet.ModelID inItemID, int inHowMany) -> int Parquet.Items.InventoryConfiguration Parquet.Items.InventorySlot Parquet.Items.InventorySlot.Count.get -> int @@ -612,13 +615,10 @@ Parquet.Parquets.IMutableParquetModel.ItemID.set -> void Parquet.Parquets.ParquetModel Parquet.Parquets.ParquetModel.AddsToBiome.get -> System.Collections.Generic.IReadOnlyList Parquet.Parquets.ParquetModel.AddsToBiome.set -> void -Parquet.Parquets.ParquetModel.AddsToBiome.set -> void Parquet.Parquets.ParquetModel.AddsToRoom.get -> System.Collections.Generic.IReadOnlyList Parquet.Parquets.ParquetModel.AddsToRoom.set -> void -Parquet.Parquets.ParquetModel.AddsToRoom.set -> void Parquet.Parquets.ParquetModel.ItemID.get -> Parquet.ModelID Parquet.Parquets.ParquetModel.ItemID.set -> void -Parquet.Parquets.ParquetModel.ItemID.set -> void Parquet.Parquets.ParquetModel.ParquetModel(Parquet.Range inBounds, Parquet.ModelID inID, string inName, string inDescription, string inComment, System.Collections.Generic.IEnumerable inTags = null, Parquet.ModelID? inItemID = null, System.Collections.Generic.IEnumerable inAddsToBiome = null, System.Collections.Generic.IEnumerable inAddsToRoom = null) -> void Parquet.Parquets.ParquetModelPack Parquet.Parquets.ParquetModelPack.BlockID.get -> Parquet.ModelID @@ -831,6 +831,14 @@ Parquet.Scripts.InteractionModel.InteractionModel(Parquet.ModelID inID, string i Parquet.Scripts.InteractionModel.OutcomesIDs.get -> System.Collections.Generic.IReadOnlyList Parquet.Scripts.InteractionModel.PrerequisitesIDs.get -> System.Collections.Generic.IReadOnlyList Parquet.Scripts.InteractionModel.StepsIDs.get -> System.Collections.Generic.IReadOnlyList +Parquet.Scripts.InteractionStatus +Parquet.Scripts.InteractionStatus.InteractionStatus() -> void +Parquet.Scripts.InteractionStatus.InteractionStatus(Parquet.Scripts.InteractionModel inScript) -> void +Parquet.Scripts.InteractionStatus.InteractionStatus(Parquet.Scripts.RunState inState, int inProgramCounter) -> void +Parquet.Scripts.InteractionStatus.State.get -> Parquet.Scripts.RunState +Parquet.Scripts.InteractionStatus.State.set -> void +Parquet.Scripts.InteractionStatus.StepCounter.get -> int +Parquet.Scripts.InteractionStatus.StepCounter.set -> void Parquet.Scripts.RunState Parquet.Scripts.RunState.Completed = 2 -> Parquet.Scripts.RunState Parquet.Scripts.RunState.InProgress = 1 -> Parquet.Scripts.RunState @@ -928,7 +936,7 @@ static Parquet.Games.GameModel.Empty.get -> Parquet.Games.GameModel static Parquet.Games.GameStatus.Default.get -> Parquet.Games.GameStatus static Parquet.Games.GameStatus.operator !=(Parquet.Games.GameStatus inStatus1, Parquet.Games.GameStatus inStatus2) -> bool static Parquet.Games.GameStatus.operator ==(Parquet.Games.GameStatus inStatus1, Parquet.Games.GameStatus inStatus2) -> bool -static Parquet.Items.Inventory.Empty.get -> Parquet.Items.Inventory +static Parquet.Items.InventoryCollection.Empty.get -> Parquet.Items.InventoryCollection static Parquet.Items.InventoryConfiguration.DefaultCapacity.get -> int static Parquet.Items.InventoryConfiguration.DefaultCapacity.set -> void static Parquet.Items.InventoryConfiguration.FilePath.get -> string @@ -1032,6 +1040,9 @@ static Parquet.Rooms.RoomConfiguration.MinPerimeterSpaces.get -> int static Parquet.Rooms.RoomConfiguration.MinWalkableSpaces.get -> int static Parquet.Rooms.RoomConfiguration.MinWalkableSpaces.set -> void static Parquet.Rooms.RoomConfiguration.PutRecord() -> void +static Parquet.Scripts.InteractionStatus.operator !=(Parquet.Scripts.InteractionStatus inStatus1, Parquet.Scripts.InteractionStatus inStatus2) -> bool +static Parquet.Scripts.InteractionStatus.operator ==(Parquet.Scripts.InteractionStatus inStatus1, Parquet.Scripts.InteractionStatus inStatus2) -> bool +static Parquet.Scripts.InteractionStatus.Unstarted.get -> Parquet.Scripts.InteractionStatus static Parquet.Scripts.ScriptNode.implicit operator Parquet.Scripts.ScriptNode(string inValue) -> Parquet.Scripts.ScriptNode static Parquet.Scripts.ScriptNode.implicit operator string(Parquet.Scripts.ScriptNode inNode) -> string static Parquet.Scripts.ScriptStatus.operator !=(Parquet.Scripts.ScriptStatus inStatus1, Parquet.Scripts.ScriptStatus inStatus2) -> bool diff --git a/ParquetUnitTests/Items/InventoryUnitTest.cs b/ParquetUnitTests/Items/InventoryUnitTest.cs index 04281ce0..6510fc34 100644 --- a/ParquetUnitTests/Items/InventoryUnitTest.cs +++ b/ParquetUnitTests/Items/InventoryUnitTest.cs @@ -12,7 +12,7 @@ public class InventoryUnitTest [Fact] public void NewInventoryHasGivenCapacityTest() { - var inventory = new Inventory(TestCapacity); + var inventory = new InventoryCollection(TestCapacity); Assert.Equal(TestCapacity, inventory.Capacity); } From 22462386b147a921773a0b8a0f22734cb15ec570 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 17:03:09 -0800 Subject: [PATCH 20/22] Updates variable name. --- .../Regions/RegionStatusUnitTestExtensions.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ParquetUnitTests/Regions/RegionStatusUnitTestExtensions.cs b/ParquetUnitTests/Regions/RegionStatusUnitTestExtensions.cs index c4aa69a9..42e397b5 100644 --- a/ParquetUnitTests/Regions/RegionStatusUnitTestExtensions.cs +++ b/ParquetUnitTests/Regions/RegionStatusUnitTestExtensions.cs @@ -8,27 +8,27 @@ namespace ParquetUnitTests.Maps internal static class RegionStatusUnitTestExtensions { /// Fills the region with a test pattern. - public static RegionModel FillTestPattern(this RegionModel inMapRegionModel) + public static RegionModel FillTestPattern(this RegionModel inRegionModel) { for (var x = 0; x < RegionStatus.ParquetsPerRegionDimension; x++) { for (var y = 0; y < RegionStatus.ParquetsPerRegionDimension; y++) { - inMapRegionModel.ParquetDefinitions[y, x].FloorID = TestModels.TestFloor.ID; + inRegionModel.ParquetDefinitions[y, x].FloorID = TestModels.TestFloor.ID; } - inMapRegionModel.ParquetDefinitions[0, x].BlockID = TestModels.TestBlock.ID; - inMapRegionModel.ParquetDefinitions[RegionModel.ParquetsPerRegionDimension, 1].BlockID = TestModels.TestBlock.ID; + inRegionModel.ParquetDefinitions[0, x].BlockID = TestModels.TestBlock.ID; + inRegionModel.ParquetDefinitions[RegionModel.ParquetsPerRegionDimension, 1].BlockID = TestModels.TestBlock.ID; } for (var y = 0; y < RegionStatus.ParquetsPerRegionDimension; y++) { - inMapRegionModel.ParquetDefinitions[y, 0].BlockID = TestModels.TestBlock.ID; - inMapRegionModel.ParquetDefinitions[y, RegionModel.ParquetsPerRegionDimension - 1].BlockID = TestModels.TestBlock.ID; + inRegionModel.ParquetDefinitions[y, 0].BlockID = TestModels.TestBlock.ID; + inRegionModel.ParquetDefinitions[y, RegionModel.ParquetsPerRegionDimension - 1].BlockID = TestModels.TestBlock.ID; } - inMapRegionModel.ParquetDefinitions[2, 1].FurnishingID = TestModels.TestFurnishing.ID; - inMapRegionModel.ParquetDefinitions[3, 3].CollectibleID = TestModels.TestCollectible.ID; + inRegionModel.ParquetDefinitions[2, 1].FurnishingID = TestModels.TestFurnishing.ID; + inRegionModel.ParquetDefinitions[3, 3].CollectibleID = TestModels.TestCollectible.ID; - return inMapRegionModel; + return inRegionModel; } } } From 0700d7a5500e4af44efa8edbf2daa8f23d4bb598 Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 17:03:27 -0800 Subject: [PATCH 21/22] Prefers all Status classes to end in the Status suffix. --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index dfd008be..a2f6c67b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -193,6 +193,7 @@ dotnet_code_quality.CA1710.additional_required_suffixes = T:ParquetClassLibrary. dotnet_code_quality.CA1710.additional_required_suffixes = T:ParquetClassLibrary.Model->Model|Recipe dotnet_code_quality.CA1710.additional_required_suffixes = T:ParquetClassLibrary.ModelCollection->Collection dotnet_code_quality.CA1710.additional_required_suffixes = T:ParquetClassLibrary.ModelID->ID +dotnet_code_quality.CA1710.additional_required_suffixes = T:ParquetClassLibrary.Status->Status # Symbols dotnet_naming_symbols.interface.applicable_kinds = interface From 32ac983684659f906d9b8c85a4e8fff982de660b Mon Sep 17 00:00:00 2001 From: Paige Ashlynn Date: Thu, 25 Feb 2021 17:04:21 -0800 Subject: [PATCH 22/22] Updates version to 0.4, pre-alpha 3! --- CHANGELOG.md | 28 ++++++++++++++++--- .../ParquetClassLibrary.csproj | 6 ++-- ParquetRunner/ParquetRunner.csproj | 6 ++-- ParquetUnitTests/ParquetUnitTests.csproj | 6 ++-- README.md | 2 +- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1822affe..c37ac94c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/). +## [0.4.0] - 2021-02-23 +### Pre-Alpha 3 API Revision +- This update changes the API in far-reaching ways in order to separate design-time and play-time concerns in map-related types. +#### Adds +- Adds Status type as a base class for all mutable-at-play types, analogous to Models. +- Derives a Status-based partner class for most Model classes. +- Adds Pack container type as base for ParquetModelPack and ParquetStatusPack. +- Adds LibraryState static class to track build and run characteristics, particularly Debug-vs-Release and Play-vs-Edit. +#### Removes +- MapModel abstract class, as there is only one map-related Model in the new hierarchy. +#### Changes +- Merges the definitional elements (procedural generation instructions and metadata) of MapRegion and MapSketch into single RegionModel. +- Merges the mutable elements (parquets and their statuses) of MapRegion and MapSketch into a single RegionStatus class. +- Changes MapChunk to a stand-alone class rather than a Model subtype. +- Renames namespace from Map to Region. +- Alters the BeingModel class family to better interoperate with the new RegionModel class family. +- Changes the name of Inventory class to InventoryCollection to avoid confusion in the BeingStatus classes. +- Updates the serialized example data for RegionModel and BeingModel class families. +- Reimplements cloning to enforce deep copying. +- Many minor fixes and corrections along the way. + ## [0.3.56] - 2021-02-12 #### Adds - General purpose Tags collection to the base Model type. @@ -19,15 +40,14 @@ and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/). ### Pre-Alpha 2 Milestone #### Added - Major mechanical systems. -#### Changed -- Replaced "IsHandmade" flag with "IsFilledOut" flag. -- Many small changes to support Scrube GUI editor. +#### Changes +- Many small changes to support Scribe GUI editor. ## [0.2.0] - 2020-04-18 ### Pre-Alpha 1 Milestone #### Added - Models for all major game systems. -- Roller command line untility. +- Roller command line utility. ## [0.1.0] - 2019-01-28 #### Added diff --git a/ParquetClassLibrary/ParquetClassLibrary.csproj b/ParquetClassLibrary/ParquetClassLibrary.csproj index 8530cad8..5efe58d5 100644 --- a/ParquetClassLibrary/ParquetClassLibrary.csproj +++ b/ParquetClassLibrary/ParquetClassLibrary.csproj @@ -5,9 +5,9 @@ Parquet Parquet - 0.3.56.0 - 0.3.56.0 - 0.3.56.0 + 0.4.0.0 + 0.4.0.0 + 0.4.0.0 Paige Ashlynn Girl Potion diff --git a/ParquetRunner/ParquetRunner.csproj b/ParquetRunner/ParquetRunner.csproj index c41f543c..75a0f466 100644 --- a/ParquetRunner/ParquetRunner.csproj +++ b/ParquetRunner/ParquetRunner.csproj @@ -5,9 +5,9 @@ Runner ParquetRunner - 0.3.56.0 - 0.3.56.0 - 0.3.56.0 + 0.4.0.0 + 0.4.0.0 + 0.4.0.0 Paige Ashlynn Girl Potion diff --git a/ParquetUnitTests/ParquetUnitTests.csproj b/ParquetUnitTests/ParquetUnitTests.csproj index 98f71032..f7db1207 100644 --- a/ParquetUnitTests/ParquetUnitTests.csproj +++ b/ParquetUnitTests/ParquetUnitTests.csproj @@ -5,9 +5,9 @@ ParquetUnitTests ParquetUnitTests - 0.3.56.0 - 0.3.56.0 - 0.3.56.0 + 0.4.0.0 + 0.4.0.0 + 0.4.0.0 Paige Ashlynn Girl Potion diff --git a/README.md b/README.md index 2f7e0194..dca5b4d9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This class library implements mechanics and models for a 2D sandbox game focused A game built with this system offers many of the features of contemporary quest-driven building games but in a simple, top-down world and without combat. -# Version 0.3 Warning +# Version 0.4 Warning Code and documentation are incomplete and under rapid development. Expect frequent breaking changes. Maybe don't use this yet; when the [Alpha milestone](https://github.com/mxashlynn/Parquet/milestone/2) has been hit the project should be much more usable.