Changes for prototype load parallelization (#13066)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Pieter-Jan Briers
2022-12-20 23:25:34 +01:00
committed by GitHub
parent 584921b423
commit a323671984
50 changed files with 169 additions and 249 deletions

View File

@@ -16,12 +16,6 @@ namespace Content.Shared.Access
/// The player-visible name of the access level, in the ID card console and such.
/// </summary>
[DataField("name")]
public string Name
{
get => (_name is not null) ? _name : ID;
private set => _name = Loc.GetString(value);
}
private string? _name;
public string? Name { get; set; }
}
}

View File

@@ -81,7 +81,8 @@ namespace Content.Shared.Alert
if (idx == -1 && idy == -1)
{
// break ties by type value
return x.AlertType - y.AlertType;
// Must cast to int to avoid integer overflow when subtracting (enum's unsigned)
return (int)x.AlertType - (int)y.AlertType;
}
if (idx == -1) return 1;
@@ -92,7 +93,8 @@ namespace Content.Shared.Alert
if (result == 0)
{
// break ties by type value
return x.AlertType - y.AlertType;
// Must cast to int to avoid integer overflow when subtracting (enum's unsigned)
return (int)x.AlertType - (int)y.AlertType;
}
return result;

View File

@@ -1,4 +1,3 @@
using System.Globalization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
@@ -11,9 +10,6 @@ namespace Content.Shared.Alert
[Prototype("alert")]
public sealed class AlertPrototype : IPrototype, ISerializationHooks
{
private FormattedMessage _name = new ();
private FormattedMessage _description = new ();
[ViewVariables]
string IPrototype.ID => AlertType.ToString();
@@ -34,21 +30,13 @@ namespace Content.Shared.Alert
/// Name to show in tooltip window. Accepts formatting.
/// </summary>
[DataField("name")]
public FormattedMessage Name
{
get => _name;
private set => _name = FormattedMessage.FromMarkup(Loc.GetString(value.ToString()));
}
public string Name { get; private set; } = "";
/// <summary>
/// Description to show in tooltip window. Accepts formatting.
/// </summary>
[DataField("description")]
public FormattedMessage Description
{
get => _description;
private set => _description = FormattedMessage.FromMarkup(Loc.GetString(value.ToString()));
}
public string Description { get; private set; } = "";
/// <summary>
/// Category the alert belongs to. Only one alert of a given category

View File

@@ -7,14 +7,7 @@ namespace Content.Shared.Atmos.Prototypes
[Prototype("gas")]
public sealed class GasPrototype : IPrototype
{
private string _name = string.Empty;
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
[DataField("name")] public string Name { get; set; } = "";
// TODO: Control gas amount necessary for overlay to appear
// TODO: Add interfaces for gas behaviours e.g. breathing, burning

View File

@@ -5,9 +5,6 @@ namespace Content.Shared.BarSign
[Prototype("barSign")]
public sealed class BarSignPrototype : IPrototype
{
private string _description = string.Empty;
private string _name = string.Empty;
[ViewVariables]
[IdDataFieldAttribute]
public string ID { get; } = default!;
@@ -15,19 +12,8 @@ namespace Content.Shared.BarSign
[DataField("icon")] public string Icon { get; private set; } = string.Empty;
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
[DataField("description")]
public string Description
{
get => _description;
private set => _description = Loc.GetString(value);
}
[DataField("name")] public string Name { get; set; } = "";
[DataField("description")] public string Description { get; set; } = "";
[DataField("renameArea")]
public bool RenameArea { get; private set; } = true;

View File

@@ -8,14 +8,8 @@ public sealed class BodyPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
private string _name = string.Empty;
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
[DataField("root")] public string Root { get; } = string.Empty;

View File

@@ -2,6 +2,7 @@
using Content.Shared.Body.Organ;
using Content.Shared.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Sequence;
@@ -117,7 +118,7 @@ public sealed class BodyPrototypeSerializer : ITypeReader<BodyPrototype, Mapping
public BodyPrototype Read(ISerializationManager serializationManager, MappingDataNode node,
IDependencyCollection dependencies,
bool skipHook, ISerializationContext? context = null,
SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<BodyPrototype>? instanceProvider = null)
{
var id = node.Get<ValueDataNode>("id").Value;

View File

@@ -8,8 +8,6 @@ namespace Content.Shared.Construction.Prototypes
[Prototype("construction")]
public sealed class ConstructionPrototype : IPrototype
{
private string _category = string.Empty;
[DataField("conditions")] private List<IConstructionCondition> _conditions = new();
/// <summary>
@@ -54,12 +52,7 @@ namespace Content.Shared.Construction.Prototypes
[DataField("canBuildInImpassable")]
public bool CanBuildInImpassable { get; private set; }
[DataField("category")]
public string Category
{
get => _category;
private set => _category = Loc.GetString(value);
}
[DataField("category")] public string Category { get; private set; } = "";
[DataField("objectType")] public ConstructionType Type { get; private set; } = ConstructionType.Structure;

View File

@@ -1,4 +1,5 @@
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Validation;
using Robust.Shared.Serialization.TypeSerializers.Interfaces;
@@ -41,7 +42,7 @@ namespace Content.Shared.Construction.Steps
public ConstructionGraphStep Read(ISerializationManager serializationManager,
MappingDataNode node,
IDependencyCollection dependencies,
bool skipHook,
SerializationHookContext hookCtx,
ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<ConstructionGraphStep>? instanceProvider = null)
{
@@ -49,7 +50,7 @@ namespace Content.Shared.Construction.Steps
throw new ArgumentException(
"Tried to convert invalid YAML node mapping to ConstructionGraphStep!");
return (ConstructionGraphStep)serializationManager.Read(type, node, context, skipHook)!;
return (ConstructionGraphStep)serializationManager.Read(type, node, hookCtx, context)!;
}
public ValidationNode Validate(ISerializationManager serializationManager, MappingDataNode node,

View File

@@ -1,6 +1,7 @@
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Validation;
@@ -34,7 +35,7 @@ public sealed class DamageSpecifierDictionarySerializer : ITypeReader<Dictionary
}
public Dictionary<string, FixedPoint2> Read(ISerializationManager serializationManager, MappingDataNode node, IDependencyCollection dependencies,
bool skipHook, ISerializationContext? context = null, ISerializationManager.InstantiationDelegate<Dictionary<string, FixedPoint2>>? instanceProvider = null)
SerializationHookContext hookCtx, ISerializationContext? context = null, ISerializationManager.InstantiationDelegate<Dictionary<string, FixedPoint2>>? instanceProvider = null)
{
var dict = instanceProvider != null ? instanceProvider() : new();
// Add all the damage types by just copying the type dictionary (if it is not null).

View File

@@ -1,3 +1,4 @@
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
@@ -18,10 +19,10 @@ namespace Content.Shared.Decals
public DecalGridComponent.DecalGridChunkCollection Read(ISerializationManager serializationManager,
MappingDataNode node,
IDependencyCollection dependencies, bool skipHook, ISerializationContext? context = null,
IDependencyCollection dependencies, SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<DecalGridComponent.DecalGridChunkCollection>? _ = default)
{
var dictionary = serializationManager.Read<Dictionary<Vector2i, DecalChunk>>(node, context, skipHook: skipHook, notNullableOverride: true);
var dictionary = serializationManager.Read<Dictionary<Vector2i, DecalChunk>>(node, hookCtx, context, notNullableOverride: true);
var uids = new SortedSet<uint>();
var uidChunkMap = new Dictionary<uint, Vector2i>();

View File

@@ -11,18 +11,12 @@ namespace Content.Shared.Disease
[DataDefinition]
public sealed class DiseasePrototype : IPrototype, IInheritingPrototype
{
private string _name = string.Empty;
[ViewVariables]
[IdDataFieldAttribute]
public string ID { get; } = default!;
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = string.Empty;
[ParentDataFieldAttribute(typeof(AbstractPrototypeIdArraySerializer<DiseasePrototype>))]
public string[]? Parents { get; private set; }

View File

@@ -28,12 +28,7 @@ namespace Content.Shared.Maps
public ushort TileId { get; private set; }
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
[DataField("sprite")] public ResourcePath? Sprite { get; }
[DataField("isSubfloor")] public bool IsSubFloor { get; private set; }

View File

@@ -31,11 +31,7 @@ namespace Content.Shared.Materials
public string? StackId { get; } = null;
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
[DataField("color")]
public Color Color { get; } = Color.Gray;

View File

@@ -19,13 +19,7 @@ namespace Content.Shared.Research.Prototypes
/// The name this technology will have on user interfaces.
/// </summary>
[DataField("name")]
public string Name
{
get => (_name is not null) ? _name : ID;
private set => _name = Loc.GetString(value);
}
private string? _name;
public string? Name { get; private set; }
/// <summary>
/// An icon that represent this technology.
@@ -37,13 +31,7 @@ namespace Content.Shared.Research.Prototypes
/// A short description of the technology.
/// </summary>
[DataField("description")]
public string Description
{
get => (_description is not null) ? _description : "";
private set => _description = Loc.GetString(value);
}
private string? _description;
public string Description { get; private set; } = "";
/// <summary>
/// The required research points to unlock this technology.

View File

@@ -20,31 +20,19 @@ namespace Content.Shared.Roles
/// The name of this antag as displayed to players.
/// </summary>
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
/// <summary>
/// The description of this antag shown in a tooltip.
/// </summary>
[DataField("description")]
public string? Description
{
get => _description;
private set => _description = value is null ? null : Loc.GetString(value);
}
public string? Description { get; private set; }
/// <summary>
/// The antag's objective, displayed at round-start to the player.
/// </summary>
[DataField("objective")]
public string Objective
{
get => _objective;
private set => _objective = Loc.GetString(value);
}
public string Objective { get; private set; } = "";
/// <summary>
/// Whether or not the antag role is one of the bad guys.

View File

@@ -17,11 +17,7 @@ public sealed class StoreCategoryPrototype : IPrototype
public string ID { get; } = default!;
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
[DataField("priority")]
public int Priority { get; } = 0;

View File

@@ -21,21 +21,13 @@ namespace Content.Shared.Traits
/// The name of this trait.
/// </summary>
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
/// <summary>
/// The description of this trait.
/// </summary>
[DataField("description")]
public string? Description
{
get => _description;
private set => _description = value is null ? null : Loc.GetString(value);
}
public string? Description { get; private set; }
/// <summary>
/// Don't apply this trait to entities this whitelist IS NOT valid for.