Fix ItemMapper whitelist mispredict when inserting or removing items (#29461)
* Fix ItemMapper whitelist mispredict when inserting or removing items Makes the ItemMapper MapLayerData available on client so that the client can predict whether an inserted/removed item changes the visibility of a sprite layer. * review --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -17,21 +17,21 @@ namespace Content.Shared.Storage.Components
|
|||||||
{
|
{
|
||||||
public string Layer = string.Empty;
|
public string Layer = string.Empty;
|
||||||
|
|
||||||
[DataField("whitelist", required: true, serverOnly: true)]
|
[DataField(required: true)]
|
||||||
public EntityWhitelist ServerWhitelist { get; set; } = new();
|
public EntityWhitelist? Whitelist { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimal amount of entities that are valid for whitelist.
|
/// Minimal amount of entities that are valid for whitelist.
|
||||||
/// If it's smaller than minimal amount, layer will be hidden.
|
/// If it's smaller than minimal amount, layer will be hidden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("minCount")]
|
[DataField]
|
||||||
public int MinCount = 1;
|
public int MinCount = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Max amount of entities that are valid for whitelist.
|
/// Max amount of entities that are valid for whitelist.
|
||||||
/// If it's bigger than max amount, layer will be hidden.
|
/// If it's bigger than max amount, layer will be hidden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("maxCount")]
|
[DataField]
|
||||||
public int MaxCount = int.MaxValue;
|
public int MaxCount = int.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace Content.Shared.Storage.EntitySystems
|
|||||||
var list = new List<string>();
|
var list = new List<string>();
|
||||||
foreach (var mapLayerData in itemMapper.MapLayers.Values)
|
foreach (var mapLayerData in itemMapper.MapLayers.Values)
|
||||||
{
|
{
|
||||||
var count = containedLayers.Count(ent => _whitelistSystem.IsWhitelistPass(mapLayerData.ServerWhitelist, ent));
|
var count = containedLayers.Count(ent => _whitelistSystem.IsWhitelistPass(mapLayerData.Whitelist, ent));
|
||||||
if (count >= mapLayerData.MinCount && count <= mapLayerData.MaxCount)
|
if (count >= mapLayerData.MinCount && count <= mapLayerData.MaxCount)
|
||||||
{
|
{
|
||||||
list.Add(mapLayerData.Layer);
|
list.Add(mapLayerData.Layer);
|
||||||
|
|||||||
Reference in New Issue
Block a user