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

@@ -18,7 +18,8 @@ namespace Content.Server.Atmos.Commands
foreach (var gasPrototype in atmosSystem.Gases)
{
shell.WriteLine($"{gasPrototype.Name} ID: {gasPrototype.ID}");
var gasName = Loc.GetString(gasPrototype.Name);
shell.WriteLine($"{gasName} ID: {gasPrototype.ID}");
}
}
}

View File

@@ -254,7 +254,10 @@ namespace Content.Server.Atmos.EntitySystems
continue;
if (mixture != null)
gases.Add(new GasEntry(gas.Name, mixture.Moles[i], gas.Color));
{
var gasName = Loc.GetString(gas.Name);
gases.Add(new GasEntry(gasName, mixture.Moles[i], gas.Color));
}
}
return gases.ToArray();

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;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Validation;
@@ -16,10 +17,10 @@ public sealed class TileAtmosCollectionSerializer : ITypeSerializer<Dictionary<V
public Dictionary<Vector2i, TileAtmosphere> Read(ISerializationManager serializationManager, MappingDataNode node,
IDependencyCollection dependencies,
bool skipHook, ISerializationContext? context = null,
SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<Dictionary<Vector2i, TileAtmosphere>>? instanceProvider = null)
{
var data = serializationManager.Read<TileAtmosData>(node, context, skipHook);
var data = serializationManager.Read<TileAtmosData>(node, hookCtx, context);
var tiles = new Dictionary<Vector2i, TileAtmosphere>();
if (data.TilesUniqueMixes != null)
{
@@ -82,7 +83,7 @@ public sealed class TileAtmosCollectionSerializer : ITypeSerializer<Dictionary<V
[DataField("tiles")] public Dictionary<Vector2i, int>? TilesUniqueMixes;
}
public void CopyTo(ISerializationManager serializationManager, Dictionary<Vector2i, TileAtmosphere> source, ref Dictionary<Vector2i, TileAtmosphere> target, bool skipHook,
public void CopyTo(ISerializationManager serializationManager, Dictionary<Vector2i, TileAtmosphere> source, ref Dictionary<Vector2i, TileAtmosphere> target, SerializationHookContext hookCtx,
ISerializationContext? context = null)
{
target.Clear();

View File

@@ -69,40 +69,25 @@ public struct SeedChemQuantity
public class SeedData
{
#region Tracking
private string _name = String.Empty;
private string _noun = String.Empty;
private string _displayName = String.Empty;
/// <summary>
/// The name of this seed. Determines the name of seed packets.
/// </summary>
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
public string Name { get; private set; } = "";
/// <summary>
/// The noun for this type of seeds. E.g. for fungi this should probably be "spores" instead of "seeds". Also
/// used to determine the name of seed packets.
/// </summary>
[DataField("noun")]
public string Noun
{
get => _noun;
private set => _noun = Loc.GetString(value);
}
public string Noun { get; private set; } = "";
/// <summary>
/// Name displayed when examining the hydroponics tray. Describes the actual plant, not the seed itself.
/// </summary>
[DataField("displayName")]
public string DisplayName
{
get => _displayName;
private set => _displayName = Loc.GetString(value);
}
public string DisplayName { get; private set; } = "";
[DataField("mysterious")] public bool Mysterious;

View File

@@ -80,7 +80,8 @@ public sealed partial class BotanySystem : EntitySystem
if (!TryGetSeed(component, out var seed))
return;
args.PushMarkup(Loc.GetString($"seed-component-description", ("seedName", seed.DisplayName)));
var name = Loc.GetString(seed.DisplayName);
args.PushMarkup(Loc.GetString($"seed-component-description", ("seedName", name)));
args.PushMarkup(Loc.GetString($"seed-component-plant-yield-text", ("seedYield", seed.Yield)));
args.PushMarkup(Loc.GetString($"seed-component-plant-potency-text", ("seedPotency", seed.Potency)));
}
@@ -100,7 +101,9 @@ public sealed partial class BotanySystem : EntitySystem
sprite.LayerSetSprite(0, new SpriteSpecifier.Rsi(proto.PlantRsi, "seed"));
}
var val = Loc.GetString("botany-seed-packet-name", ("seedName", proto.Name), ("seedNoun", proto.Noun));
var name = Loc.GetString(proto.Name);
var noun = Loc.GetString(proto.Noun);
var val = Loc.GetString("botany-seed-packet-name", ("seedName", name), ("seedNoun", noun));
MetaData(seed).EntityName = val;
return seed;
@@ -123,7 +126,8 @@ public sealed partial class BotanySystem : EntitySystem
return Enumerable.Empty<EntityUid>();
}
_popupSystem.PopupCursor(Loc.GetString("botany-harvest-success-message", ("name", proto.DisplayName)), user, PopupType.Medium);
var name = Loc.GetString(proto.DisplayName);
_popupSystem.PopupCursor(Loc.GetString("botany-harvest-success-message", ("name", name)), user, PopupType.Medium);
return GenerateProduct(proto, Transform(user).Coordinates, yieldMod);
}

View File

@@ -76,9 +76,10 @@ namespace Content.Server.Botany.Systems
}
else if (!component.Dead)
{
var displayName = Loc.GetString(component.Seed.DisplayName);
args.PushMarkup(Loc.GetString("plant-holder-component-something-already-growing-message",
("seedName", component.Seed.DisplayName),
("toBeForm", component.Seed.DisplayName.EndsWith('s') ? "are" : "is")));
("seedName", displayName),
("toBeForm", displayName.EndsWith('s') ? "are" : "is")));
if (component.Health <= component.Seed.Endurance / 2)
{
@@ -134,9 +135,11 @@ namespace Content.Server.Botany.Systems
if (!_botanySystem.TryGetSeed(seeds, out var seed))
return ;
var name = Loc.GetString(seed.Name);
var noun = Loc.GetString(seed.Noun);
_popupSystem.PopupCursor(Loc.GetString("plant-holder-component-plant-success-message",
("seedName", seed.Name),
("seedNoun", seed.Noun)), args.User, PopupType.Medium);
("seedName", name),
("seedNoun", noun)), args.User, PopupType.Medium);
component.Seed = seed;
component.Dead = false;
@@ -249,8 +252,9 @@ namespace Content.Server.Botany.Systems
component.Seed.Unique = false;
var seed = _botanySystem.SpawnSeedPacket(component.Seed, Transform(args.User).Coordinates);
seed.RandomOffset(0.25f);
var displayName = Loc.GetString(component.Seed.DisplayName);
_popupSystem.PopupCursor(Loc.GetString("plant-holder-component-take-sample-message",
("seedName", component.Seed.DisplayName)), args.User);
("seedName", displayName)), args.User);
component.Health -= (_random.Next(3, 5) * 10);
if (_random.Prob(0.3f))

View File

@@ -69,7 +69,7 @@ namespace Content.Server.Chemistry.Components
/// </summary>
public CancellationTokenSource? CancelToken;
private InjectorToggleMode _toggleState;
[DataField("toggleState")] private InjectorToggleMode _toggleState;
/// <summary>
/// The state of the injector. Determines it's attack behavior. Containers must have the
@@ -77,7 +77,6 @@ namespace Content.Server.Chemistry.Components
/// only ever be set to Inject
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("toggleState")]
public InjectorToggleMode ToggleState
{
get => _toggleState;

View File

@@ -1,6 +1,7 @@
using Content.Server.Storage.Components;
using Content.Shared.Storage;
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;

View File

@@ -277,9 +277,9 @@ namespace Content.Server.Cuffs.Components
{
cuff.Broken = true;
var meta = _entMan.GetComponent<MetaDataComponent>(cuffsToRemove);
meta.EntityName = cuff.BrokenName;
meta.EntityDescription = cuff.BrokenDesc;
var meta = _entMan.GetComponent<MetaDataComponent>(cuffsToRemove);
meta.EntityName = Loc.GetString(cuff.BrokenName);
meta.EntityDescription = Loc.GetString(cuff.BrokenDesc);
if (_entMan.TryGetComponent<SpriteComponent>(cuffsToRemove, out var sprite) && cuff.BrokenState != null)
{

View File

@@ -17,9 +17,6 @@ namespace Content.Server.Cuffs.Components
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
private string _brokenName = string.Empty;
private string _brokenDesc = string.Empty;
/// <summary>
/// The time it takes to apply a <see cref="CuffedComponent"/> to an entity.
/// </summary>
@@ -72,21 +69,13 @@ namespace Content.Server.Cuffs.Components
/// The iconstate used for broken handcuffs
/// </summary>
[DataField("brokenName", readOnly: true)]
public string BrokenName
{
get => _brokenName;
private set => _brokenName = Loc.GetString(value);
}
public string BrokenName { get; private set; } = "";
/// <summary>
/// The iconstate used for broken handcuffs
/// </summary>
[DataField("brokenDesc", readOnly: true)]
public string BrokenDesc
{
get => _brokenDesc;
private set => _brokenDesc = Loc.GetString(value);
}
public string BrokenDesc { get; private set; } = "";
[ViewVariables]
public bool Broken

View File

@@ -230,7 +230,8 @@ namespace Content.Server.Disease
private FormattedMessage AssembleDiseaseReport(DiseasePrototype disease)
{
FormattedMessage report = new();
report.AddMarkup(Loc.GetString("diagnoser-disease-report-name", ("disease", disease.Name)));
var diseaseName = Loc.GetString(disease.Name);
report.AddMarkup(Loc.GetString("diagnoser-disease-report-name", ("disease", diseaseName)));
report.PushNewline();
if (disease.Infectious)
@@ -355,7 +356,8 @@ namespace Content.Server.Disease
FormattedMessage contents = new();
if (args.Machine.Disease != null)
{
reportTitle = Loc.GetString("diagnoser-disease-report", ("disease", args.Machine.Disease.Name));
var diseaseName = Loc.GetString(args.Machine.Disease.Name);
reportTitle = Loc.GetString("diagnoser-disease-report", ("disease", diseaseName));
contents = AssembleDiseaseReport(args.Machine.Disease);
var known = false;

View File

@@ -761,8 +761,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
{
var spawnPoint = EntityManager.SpawnEntity(_nukeopsRuleConfig.GhostSpawnPointProto, _random.Pick(spawns));
var spawner = EnsureComp<GhostRoleMobSpawnerComponent>(spawnPoint);
spawner.RoleName = nukeOpsAntag.Name;
spawner.RoleDescription = nukeOpsAntag.Objective;
spawner.RoleName = Loc.GetString(nukeOpsAntag.Name);
spawner.RoleDescription = Loc.GetString(nukeOpsAntag.Objective);
var nukeOpSpawner = EnsureComp<NukeOperativeSpawnerComponent>(spawnPoint);
nukeOpSpawner.OperativeName = spawnDetails.Name;

View File

@@ -1,5 +1,6 @@
using Content.Server.NPC.HTN.PrimitiveTasks;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
@@ -41,7 +42,7 @@ public sealed class HTNTaskListSerializer : ITypeSerializer<List<string>, Sequen
public List<string> Read(ISerializationManager serializationManager, SequenceDataNode node,
IDependencyCollection dependencies,
bool skipHook, ISerializationContext? context = null,
SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<List<string>>? instanceProvider = null)
{
var value = instanceProvider != null ? instanceProvider() : new List<string>();

View File

@@ -1,4 +1,5 @@
using Robust.Shared.Reflection;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
@@ -47,7 +48,7 @@ public sealed class NPCBlackboardSerializer : ITypeReader<NPCBlackboard, Mapping
public NPCBlackboard Read(ISerializationManager serializationManager, MappingDataNode node,
IDependencyCollection dependencies,
bool skipHook, ISerializationContext? context = null,
SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<NPCBlackboard>? instanceProvider = null)
{
var value = instanceProvider != null ? instanceProvider() : new NPCBlackboard();
@@ -68,7 +69,7 @@ public sealed class NPCBlackboardSerializer : ITypeReader<NPCBlackboard, Mapping
if (!reflection.TryLooseGetType(typeString, out var type))
throw new NullReferenceException($"Found null type for {key}");
var bbData = serializationManager.Read(type, data.Value, context, skipHook);
var bbData = serializationManager.Read(type, data.Value, hookCtx, context);
if (bbData == null)
throw new NullReferenceException($"Found null data for {key}, expected {type}");
@@ -80,7 +81,11 @@ public sealed class NPCBlackboardSerializer : ITypeReader<NPCBlackboard, Mapping
return value;
}
public void CopyTo(ISerializationManager serializationManager, NPCBlackboard source, ref NPCBlackboard target, bool skipHook,
public void CopyTo(
ISerializationManager serializationManager,
NPCBlackboard source,
ref NPCBlackboard target,
SerializationHookContext hookCtx,
ISerializationContext? context = null)
{
target.Clear();

View File

@@ -208,11 +208,12 @@ namespace Content.Server.Pointing.EntitySystems
var tileDef = _tileDefinitionManager[tileRef?.Tile.TypeId ?? 0];
selfMessage = Loc.GetString("pointing-system-point-at-tile", ("tileName", tileDef.Name));
var name = Loc.GetString(tileDef.Name);
selfMessage = Loc.GetString("pointing-system-point-at-tile", ("tileName", name));
viewerMessage = Loc.GetString("pointing-system-other-point-at-tile", ("otherName", playerName), ("tileName", tileDef.Name));
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):user} pointed at {tileDef.Name} {(position == null ? mapCoords : position)}");
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):user} pointed at {name} {(position == null ? mapCoords : position)}");
}
_pointers[session] = _gameTiming.CurTime;

View File

@@ -14,8 +14,6 @@ namespace Content.Server.Storage.Components
[Access(typeof(SecretStashSystem))]
public sealed class SecretStashComponent : Component
{
private string _secretPartName = string.Empty;
/// <summary>
/// Max item size that can be fitted into secret stash.
/// </summary>
@@ -27,11 +25,7 @@ namespace Content.Server.Storage.Components
/// If empty string, will replace it with entity name in init.
/// </summary>
[DataField("secretPartName", readOnly: true)]
public string SecretPartName
{
get => _secretPartName;
set => _secretPartName = Loc.GetString(value);
}
public string SecretPartName { get; set; } = "";
/// <summary>
/// Container used to keep secret stash item.

View File

@@ -24,14 +24,6 @@ namespace Content.Server.Storage.EntitySystems
private void OnInit(EntityUid uid, SecretStashComponent component, ComponentInit args)
{
// set default secret part name
if (component.SecretPartName == string.Empty)
{
var meta = EntityManager.GetComponent<MetaDataComponent>(uid);
var entityName = Loc.GetString("comp-secret-stash-secret-part-name", ("name", meta.EntityName));
component.SecretPartName = entityName;
}
component.ItemContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, "stash", out _);
}
@@ -79,7 +71,7 @@ namespace Content.Server.Storage.EntitySystems
if (item.Size > component.MaxItemSize)
{
var msg = Loc.GetString("comp-secret-stash-action-hide-item-too-big",
("item", itemName), ("stash", component.SecretPartName));
("item", itemName), ("stash", GetSecretPartName(uid, component)));
_popupSystem.PopupEntity(msg, uid, userUid);
return false;
}
@@ -92,7 +84,7 @@ namespace Content.Server.Storage.EntitySystems
// all done, show success message
var successMsg = Loc.GetString("comp-secret-stash-action-hide-success",
("item", itemName), ("this", component.SecretPartName));
("item", itemName), ("this", GetSecretPartName(uid, component)));
_popupSystem.PopupEntity(successMsg, uid, userUid);
return true;
}
@@ -121,10 +113,21 @@ namespace Content.Server.Storage.EntitySystems
// show success message
var successMsg = Loc.GetString("comp-secret-stash-action-get-item-found-something",
("stash", component.SecretPartName));
("stash", GetSecretPartName(uid, component)));
_popupSystem.PopupEntity(successMsg, uid, userUid);
return true;
}
private string GetSecretPartName(EntityUid uid, SecretStashComponent stash)
{
if (stash.SecretPartName != "")
return Loc.GetString(stash.SecretPartName);
var meta = EntityManager.GetComponent<MetaDataComponent>(uid);
var entityName = Loc.GetString("comp-secret-stash-secret-part-name", ("name", meta.EntityName));
return entityName;
}
}
}

View File

@@ -10,12 +10,12 @@ namespace Content.Server.Suspicion.Roles
public SuspicionInnocentRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
{
Prototype = antagPrototype;
Name = antagPrototype.Name;
Name = Loc.GetString(antagPrototype.Name);
Antagonist = antagPrototype.Antagonist;
}
public override string Name { get; }
public string Objective => Prototype.Objective;
public string Objective => Loc.GetString(Prototype.Objective);
public override bool Antagonist { get; }
public override void Greet()

View File

@@ -11,12 +11,12 @@ namespace Content.Server.Suspicion.Roles
public SuspicionTraitorRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
{
Prototype = antagPrototype;
Name = antagPrototype.Name;
Name = Loc.GetString(antagPrototype.Name);
Antagonist = antagPrototype.Antagonist;
}
public override string Name { get; }
public string Objective => Prototype.Objective;
public string Objective => Loc.GetString(Prototype.Objective);
public override bool Antagonist { get; }
public void GreetSuspicion(List<SuspicionTraitorRole> traitors, IChatManager chatMgr)

View File

@@ -11,7 +11,7 @@ namespace Content.Server.Traitor
public TraitorRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
{
Prototype = antagPrototype;
Name = antagPrototype.Name;
Name = Loc.GetString(antagPrototype.Name);
Antagonist = antagPrototype.Antagonist;
}