store system prototype modification oversight (#10801)

This commit is contained in:
Nemanja
2022-08-25 09:40:35 -04:00
committed by GitHub
parent 2d5823c3d8
commit 0e5e3b46c4
2 changed files with 27 additions and 2 deletions

View File

@@ -26,7 +26,9 @@ public sealed partial class StoreSystem : EntitySystem
var allData = new HashSet<ListingData>();
foreach (var listing in allListings)
allData.Add(listing);
{
allData.Add((ListingData) listing.Clone());
}
return allData;
}

View File

@@ -17,7 +17,7 @@ namespace Content.Shared.Store;
/// </summary>
[Serializable, NetSerializable]
[Virtual, DataDefinition]
public class ListingData : IEquatable<ListingData>
public class ListingData : IEquatable<ListingData>, ICloneable
{
/// <summary>
/// The name of the listing. If empty, uses the entity's name (if present)
@@ -116,6 +116,29 @@ public class ListingData : IEquatable<ListingData>
return true;
}
/// <summary>
/// Creates a unique instance of a listing. ALWAWYS USE THIS WHEN ENUMERATING LISTING PROTOTYPES
/// DON'T BE DUMB AND MODIFY THE PROTOTYPES
/// </summary>
/// <returns>A unique copy of the listing data.</returns>
public object Clone()
{
return new ListingData
{
Name = Name,
Description = Description,
Categories = Categories,
Cost = Cost,
Conditions = Conditions,
Icon = Icon,
Priority = Priority,
ProductEntity = ProductEntity,
ProductAction = ProductAction,
ProductEvent = ProductEvent,
PurchaseAmount = PurchaseAmount,
};
}
}
//<inheritdoc>