Misc state-handling changes (#16444)
This commit is contained in:
@@ -37,6 +37,13 @@ public abstract class ActionType : IEquatable<ActionType>, IComparable, ICloneab
|
||||
[DataField("name")]
|
||||
public string DisplayName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// This is just <see cref="DisplayName"/> with localized strings resolved and markup removed. If null, will be
|
||||
/// inferred from <see cref="DisplayName"/>. This is cached to speed up game state handling.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public string? RawName;
|
||||
|
||||
/// <summary>
|
||||
/// Description to show in UI. Accepts formatting.
|
||||
/// </summary>
|
||||
@@ -179,10 +186,11 @@ public abstract class ActionType : IEquatable<ActionType>, IComparable, ICloneab
|
||||
if (Priority != otherAction.Priority)
|
||||
return otherAction.Priority - Priority;
|
||||
|
||||
var name = FormattedMessage.RemoveMarkup(Loc.GetString(DisplayName));
|
||||
var otherName = FormattedMessage.RemoveMarkup(Loc.GetString(otherAction.DisplayName));
|
||||
if (name != otherName)
|
||||
return string.Compare(name, otherName, StringComparison.CurrentCulture);
|
||||
RawName ??= FormattedMessage.RemoveMarkup(Loc.GetString(DisplayName));
|
||||
otherAction.RawName ??= FormattedMessage.RemoveMarkup(Loc.GetString(otherAction.DisplayName));
|
||||
var cmp = string.Compare(RawName, otherAction.RawName, StringComparison.CurrentCulture);
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
|
||||
if (Provider != otherAction.Provider)
|
||||
{
|
||||
@@ -217,6 +225,7 @@ public abstract class ActionType : IEquatable<ActionType>, IComparable, ICloneab
|
||||
Icon = toClone.Icon;
|
||||
IconOn = toClone.IconOn;
|
||||
DisplayName = toClone.DisplayName;
|
||||
RawName = null;
|
||||
Description = toClone.Description;
|
||||
Provider = toClone.Provider;
|
||||
AttachedEntity = toClone.AttachedEntity;
|
||||
|
||||
@@ -22,6 +22,9 @@ public sealed class ActionsComponentState : ComponentState
|
||||
{
|
||||
public readonly List<ActionType> Actions;
|
||||
|
||||
[NonSerialized]
|
||||
public SortedSet<ActionType>? SortedActions;
|
||||
|
||||
public ActionsComponentState(List<ActionType> actions)
|
||||
{
|
||||
Actions = actions;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -37,21 +38,22 @@ namespace Content.Shared.Storage.Components
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ShowLayerData : ICloneable
|
||||
{
|
||||
public IReadOnlyList<string> QueuedEntities { get; internal set; }
|
||||
public readonly IReadOnlyList<string> QueuedEntities;
|
||||
|
||||
public ShowLayerData()
|
||||
{
|
||||
QueuedEntities = new List<string>();
|
||||
}
|
||||
|
||||
public ShowLayerData(IEnumerable<string> other)
|
||||
public ShowLayerData(IReadOnlyList<string> other)
|
||||
{
|
||||
QueuedEntities = new List<string>(other);
|
||||
QueuedEntities = other;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new ShowLayerData(QueuedEntities);
|
||||
// QueuedEntities should never be getting modified after this object is created.
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Content.Shared.Storage.EntitySystems
|
||||
/// <returns>false if <c>msg.Container.Owner</c> is not a storage, true otherwise.</returns>
|
||||
private bool TryGetLayers(ContainerModifiedMessage msg,
|
||||
ItemMapperComponent itemMapper,
|
||||
out IReadOnlyList<string> showLayers)
|
||||
out List<string> showLayers)
|
||||
{
|
||||
var containedLayers = _container.GetAllContainers(msg.Container.Owner)
|
||||
.Where(c => itemMapper.ContainerWhitelist?.Contains(c.ID) ?? true).SelectMany(cont => cont.ContainedEntities).ToArray();
|
||||
|
||||
Reference in New Issue
Block a user