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

@@ -75,7 +75,7 @@ namespace Content.Client.Access.UI
var newButton = new Button var newButton = new Button
{ {
Text = accessLevel.Name, Text = GetAccessLevelName(accessLevel),
ToggleMode = true, ToggleMode = true,
}; };
AccessLevelGrid.AddChild(newButton); AccessLevelGrid.AddChild(newButton);
@@ -84,6 +84,14 @@ namespace Content.Client.Access.UI
} }
} }
private static string GetAccessLevelName(AccessLevelPrototype prototype)
{
if (prototype.Name is { } name)
return Loc.GetString(name);
return prototype.ID;
}
private void ClearAllAccess() private void ClearAllAccess()
{ {
foreach (var button in _accessButtons.Values) foreach (var button in _accessButtons.Values)

View File

@@ -39,7 +39,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
_gasData = EntitySystem.Get<AtmosphereSystem>().Gases; _gasData = EntitySystem.Get<AtmosphereSystem>().Gases;
foreach (var gas in _gasData) foreach (var gas in _gasData)
{ {
GasOptions.AddItem($"{gas.Name} ({gas.ID})"); var gasName = Loc.GetString(gas.Name);
GasOptions.AddItem($"{gasName} ({gas.ID})");
} }
GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id); GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id);

View File

@@ -39,7 +39,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
_gasData = EntitySystem.Get<AtmosphereSystem>().Gases; _gasData = EntitySystem.Get<AtmosphereSystem>().Gases;
foreach (var gas in _gasData) foreach (var gas in _gasData)
{ {
GasOptions.AddItem($"{gas.Name} ({gas.ID})"); var gasName = Loc.GetString(gas.Name);
GasOptions.AddItem($"{gasName} ({gas.ID})");
} }
GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id); GasOptions.OnItemSelected += eventArgs => GasOptions.SelectId(eventArgs.Id);

View File

@@ -85,7 +85,8 @@ namespace Content.Client.Atmos.UI
{ {
var atmos = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>(); var atmos = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>();
var gas = atmos.GetGas((Gas) cast.FilteredGas); var gas = atmos.GetGas((Gas) cast.FilteredGas);
_window.SetGasFiltered(gas.ID, gas.Name); var gasName = Loc.GetString(gas.Name);
_window.SetGasFiltered(gas.ID, gasName);
} }
else else
{ {

View File

@@ -83,7 +83,8 @@ namespace Content.Client.Atmos.UI
foreach (GasPrototype gas in gases) foreach (GasPrototype gas in gases)
{ {
GasList.Add(GetGasItem(gas.ID, gas.Name, GasList)); var gasName = Loc.GetString(gas.Name);
GasList.Add(GetGasItem(gas.ID, gasName, GasList));
} }
} }

View File

@@ -154,7 +154,7 @@ namespace Content.Client.Construction.UI
continue; continue;
} }
if (!string.IsNullOrEmpty(category) && category != Loc.GetString("construction-category-all")) if (!string.IsNullOrEmpty(category) && category != "construction-category-all")
{ {
if (recipe.Category != category) if (recipe.Category != category)
continue; continue;
@@ -178,7 +178,7 @@ namespace Content.Client.Construction.UI
var uniqueCategories = new HashSet<string>(); var uniqueCategories = new HashSet<string>();
// hard-coded to show all recipes // hard-coded to show all recipes
uniqueCategories.Add(Loc.GetString("construction-category-all")); uniqueCategories.Add("construction-category-all");
foreach (var prototype in _prototypeManager.EnumeratePrototypes<ConstructionPrototype>()) foreach (var prototype in _prototypeManager.EnumeratePrototypes<ConstructionPrototype>())
{ {
@@ -190,13 +190,13 @@ namespace Content.Client.Construction.UI
_constructionView.Category.Clear(); _constructionView.Category.Clear();
var array = uniqueCategories.ToArray(); var array = uniqueCategories.OrderBy(Loc.GetString).ToArray();
Array.Sort(array); Array.Sort(array);
for (var i = 0; i < array.Length; i++) for (var i = 0; i < array.Length; i++)
{ {
var category = array[i]; var category = array[i];
_constructionView.Category.AddItem(category, i); _constructionView.Category.AddItem(Loc.GetString(category), i);
} }
_constructionView.Categories = array; _constructionView.Categories = array;

View File

@@ -72,13 +72,10 @@ public sealed partial class LatheMenu : DefaultWindow
{ {
if (!_prototypeManager.TryIndex(id, out MaterialPrototype? material)) if (!_prototypeManager.TryIndex(id, out MaterialPrototype? material))
continue; continue;
var name = Loc.GetString(material.Name);
if (amount > 0) var mat = Loc.GetString("lathe-menu-material-display",
{ ("material", name), ("amount", amount));
var mat = Loc.GetString("lathe-menu-material-display", Materials.AddItem(mat, _spriteSystem.Frame0(material.Icon), false);
("material", material.Name), ("amount", amount));
Materials.AddItem(mat, _spriteSystem.Frame0(material.Icon), false);
}
} }
if (Materials.Count == 0) if (Materials.Count == 0)
@@ -140,7 +137,7 @@ public sealed partial class LatheMenu : DefaultWindow
sb.Append(adjustedAmount); sb.Append(adjustedAmount);
sb.Append(' '); sb.Append(' ');
sb.Append(proto.Name); sb.Append(Loc.GetString(proto.Name));
} }
var icon = _spriteSystem.Frame0(prototype.Icon); var icon = _spriteSystem.Frame0(prototype.Icon);

View File

@@ -86,7 +86,7 @@ public sealed partial class MappingSystem : EntitySystem
{ {
CheckCanInteract = false, CheckCanInteract = false,
Event = actionEvent, Event = actionEvent,
DisplayName = tileDef.Name, DisplayName = Loc.GetString(tileDef.Name),
Icon = tileIcon Icon = tileIcon
}; };

View File

@@ -470,7 +470,7 @@ namespace Content.Client.Preferences.UI
_antagPreferences = new List<AntagPreferenceSelector>(); _antagPreferences = new List<AntagPreferenceSelector>();
foreach (var antag in prototypeManager.EnumeratePrototypes<AntagPrototype>().OrderBy(a => a.Name)) foreach (var antag in prototypeManager.EnumeratePrototypes<AntagPrototype>().OrderBy(a => Loc.GetString(a.Name)))
{ {
if (!antag.SetPreference) if (!antag.SetPreference)
{ {
@@ -492,7 +492,7 @@ namespace Content.Client.Preferences.UI
#region Traits #region Traits
var traits = prototypeManager.EnumeratePrototypes<TraitPrototype>().OrderBy(t => t.Name).ToList(); var traits = prototypeManager.EnumeratePrototypes<TraitPrototype>().OrderBy(t => Loc.GetString(t.Name)).ToList();
_traitPreferences = new List<TraitPreferenceSelector>(); _traitPreferences = new List<TraitPreferenceSelector>();
_tabContainer.SetTabTitle(3, Loc.GetString("humanoid-profile-editor-traits-tab")); _tabContainer.SetTabTitle(3, Loc.GetString("humanoid-profile-editor-traits-tab"));
@@ -1238,12 +1238,12 @@ namespace Content.Client.Preferences.UI
{ {
Antag = antag; Antag = antag;
_checkBox = new CheckBox {Text = $"{antag.Name}"}; _checkBox = new CheckBox {Text = Loc.GetString(antag.Name)};
_checkBox.OnToggled += OnCheckBoxToggled; _checkBox.OnToggled += OnCheckBoxToggled;
if (antag.Description != null) if (antag.Description != null)
{ {
_checkBox.ToolTip = antag.Description; _checkBox.ToolTip = Loc.GetString(antag.Description);
_checkBox.TooltipDelay = 0.2f; _checkBox.TooltipDelay = 0.2f;
} }
@@ -1280,12 +1280,12 @@ namespace Content.Client.Preferences.UI
{ {
Trait = trait; Trait = trait;
_checkBox = new CheckBox {Text = $"{trait.Name}"}; _checkBox = new CheckBox {Text = Loc.GetString(trait.Name)};
_checkBox.OnToggled += OnCheckBoxToggled; _checkBox.OnToggled += OnCheckBoxToggled;
if (trait.Description != null) if (trait.Description is { } desc)
{ {
_checkBox.ToolTip = trait.Description; _checkBox.ToolTip = Loc.GetString(desc);
_checkBox.TooltipDelay = 0.2f; _checkBox.TooltipDelay = 0.2f;
} }

View File

@@ -113,24 +113,33 @@ namespace Content.Client.Research.UI
// For now, we retrieve all technologies. In the future, this should be changed. // For now, we retrieve all technologies. In the future, this should be changed.
foreach (var tech in prototypeMan.EnumeratePrototypes<TechnologyPrototype>()) foreach (var tech in prototypeMan.EnumeratePrototypes<TechnologyPrototype>())
{ {
var techName = GetTechName(tech);
if (Owner.IsTechnologyUnlocked(tech)) if (Owner.IsTechnologyUnlocked(tech))
{ {
UnlockedTechnologies.AddItem(tech.Name, tech.Icon.Frame0()); UnlockedTechnologies.AddItem(techName, tech.Icon.Frame0());
_unlockedTechnologyPrototypes.Add(tech); _unlockedTechnologyPrototypes.Add(tech);
} }
else if (Owner.CanUnlockTechnology(tech)) else if (Owner.CanUnlockTechnology(tech))
{ {
UnlockableTechnologies.AddItem(tech.Name, tech.Icon.Frame0()); UnlockableTechnologies.AddItem(techName, tech.Icon.Frame0());
_unlockableTechnologyPrototypes.Add(tech); _unlockableTechnologyPrototypes.Add(tech);
} }
else else
{ {
FutureTechnologies.AddItem(tech.Name, tech.Icon.Frame0()); FutureTechnologies.AddItem(techName, tech.Icon.Frame0());
_futureTechnologyPrototypes.Add(tech); _futureTechnologyPrototypes.Add(tech);
} }
} }
} }
private string GetTechName(TechnologyPrototype prototype)
{
if (prototype.Name is { } name)
return Loc.GetString(name);
return prototype.ID;
}
/// <summary> /// <summary>
/// Fills the selected technology controls with details. /// Fills the selected technology controls with details.
/// </summary> /// </summary>
@@ -145,8 +154,9 @@ namespace Content.Client.Research.UI
} }
TechnologyIcon.Texture = TechnologySelected.Icon.Frame0(); TechnologyIcon.Texture = TechnologySelected.Icon.Frame0();
TechnologyName.Text = TechnologySelected.Name; TechnologyName.Text = GetTechName(TechnologySelected);
TechnologyDescription.Text = TechnologySelected.Description + $"\n{TechnologySelected.RequiredPoints} " + Loc.GetString("research-console-menu-research-points-text" ,("points", Owner.Points)).ToLowerInvariant(); var desc = Loc.GetString(TechnologySelected.Description);
TechnologyDescription.Text = desc + $"\n{TechnologySelected.RequiredPoints} " + Loc.GetString("research-console-menu-research-points-text" ,("points", Owner.Points)).ToLowerInvariant();
TechnologyRequirements.Text = Loc.GetString("research-console-tech-requirements-none"); TechnologyRequirements.Text = Loc.GetString("research-console-tech-requirements-none");
var prototypeMan = IoCManager.Resolve<IPrototypeManager>(); var prototypeMan = IoCManager.Resolve<IPrototypeManager>();
@@ -155,10 +165,11 @@ namespace Content.Client.Research.UI
{ {
var requiredId = TechnologySelected.RequiredTechnologies[i]; var requiredId = TechnologySelected.RequiredTechnologies[i];
if (!prototypeMan.TryIndex(requiredId, out TechnologyPrototype? prototype)) continue; if (!prototypeMan.TryIndex(requiredId, out TechnologyPrototype? prototype)) continue;
var protoName = GetTechName(prototype);
if (i == 0) if (i == 0)
TechnologyRequirements.Text = Loc.GetString("research-console-tech-requirements-prototype-name", ("prototypeName", prototype.Name)); TechnologyRequirements.Text = Loc.GetString("research-console-tech-requirements-prototype-name", ("prototypeName", protoName));
else else
TechnologyRequirements.Text += $", {prototype.Name}"; TechnologyRequirements.Text += $", {protoName}";
} }
} }

View File

@@ -4,6 +4,7 @@ using Content.Shared.Alert;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Client.UserInterface.Systems.Alerts.Controls namespace Content.Client.UserInterface.Systems.Alerts.Controls
{ {
@@ -65,7 +66,9 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
private Control SupplyTooltip(Control? sender) private Control SupplyTooltip(Control? sender)
{ {
return new ActionAlertTooltip(Alert.Name, Alert.Description) {Cooldown = Cooldown}; var msg = FormattedMessage.FromMarkup(Loc.GetString(Alert.Name));
var desc = FormattedMessage.FromMarkup(Loc.GetString(Alert.Description));
return new ActionAlertTooltip(msg, desc) {Cooldown = Cooldown};
} }
/// <summary> /// <summary>

View File

@@ -11,6 +11,7 @@ using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown; using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
@@ -240,7 +241,7 @@ public sealed class PrototypeSaveTest
EntityUid ITypeReader<EntityUid, ValueDataNode>.Read(ISerializationManager serializationManager, EntityUid ITypeReader<EntityUid, ValueDataNode>.Read(ISerializationManager serializationManager,
ValueDataNode node, ValueDataNode node,
IDependencyCollection dependencies, IDependencyCollection dependencies,
bool skipHook, SerializationHookContext hookCtx,
ISerializationContext? context, ISerializationManager.InstantiationDelegate<EntityUid>? instanceProvider = null) ISerializationContext? context, ISerializationManager.InstantiationDelegate<EntityUid>? instanceProvider = null)
{ {
return EntityUid.Invalid; return EntityUid.Invalid;

View File

@@ -18,7 +18,8 @@ namespace Content.Server.Atmos.Commands
foreach (var gasPrototype in atmosSystem.Gases) 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; continue;
if (mixture != null) 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(); 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;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Validation; 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, public Dictionary<Vector2i, TileAtmosphere> Read(ISerializationManager serializationManager, MappingDataNode node,
IDependencyCollection dependencies, IDependencyCollection dependencies,
bool skipHook, ISerializationContext? context = null, SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<Dictionary<Vector2i, TileAtmosphere>>? instanceProvider = 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>(); var tiles = new Dictionary<Vector2i, TileAtmosphere>();
if (data.TilesUniqueMixes != null) if (data.TilesUniqueMixes != null)
{ {
@@ -82,7 +83,7 @@ public sealed class TileAtmosCollectionSerializer : ITypeSerializer<Dictionary<V
[DataField("tiles")] public Dictionary<Vector2i, int>? TilesUniqueMixes; [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) ISerializationContext? context = null)
{ {
target.Clear(); target.Clear();

View File

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

View File

@@ -80,7 +80,8 @@ public sealed partial class BotanySystem : EntitySystem
if (!TryGetSeed(component, out var seed)) if (!TryGetSeed(component, out var seed))
return; 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-yield-text", ("seedYield", seed.Yield)));
args.PushMarkup(Loc.GetString($"seed-component-plant-potency-text", ("seedPotency", seed.Potency))); 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")); 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; MetaData(seed).EntityName = val;
return seed; return seed;
@@ -123,7 +126,8 @@ public sealed partial class BotanySystem : EntitySystem
return Enumerable.Empty<EntityUid>(); 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); return GenerateProduct(proto, Transform(user).Coordinates, yieldMod);
} }

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Shared.Storage; using Content.Shared.Storage;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Sequence; using Robust.Shared.Serialization.Markdown.Sequence;

View File

@@ -277,9 +277,9 @@ namespace Content.Server.Cuffs.Components
{ {
cuff.Broken = true; cuff.Broken = true;
var meta = _entMan.GetComponent<MetaDataComponent>(cuffsToRemove); var meta = _entMan.GetComponent<MetaDataComponent>(cuffsToRemove);
meta.EntityName = cuff.BrokenName; meta.EntityName = Loc.GetString(cuff.BrokenName);
meta.EntityDescription = cuff.BrokenDesc; meta.EntityDescription = Loc.GetString(cuff.BrokenDesc);
if (_entMan.TryGetComponent<SpriteComponent>(cuffsToRemove, out var sprite) && cuff.BrokenState != null) 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 IEntityManager _entities = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!;
private string _brokenName = string.Empty;
private string _brokenDesc = string.Empty;
/// <summary> /// <summary>
/// The time it takes to apply a <see cref="CuffedComponent"/> to an entity. /// The time it takes to apply a <see cref="CuffedComponent"/> to an entity.
/// </summary> /// </summary>
@@ -72,21 +69,13 @@ namespace Content.Server.Cuffs.Components
/// The iconstate used for broken handcuffs /// The iconstate used for broken handcuffs
/// </summary> /// </summary>
[DataField("brokenName", readOnly: true)] [DataField("brokenName", readOnly: true)]
public string BrokenName public string BrokenName { get; private set; } = "";
{
get => _brokenName;
private set => _brokenName = Loc.GetString(value);
}
/// <summary> /// <summary>
/// The iconstate used for broken handcuffs /// The iconstate used for broken handcuffs
/// </summary> /// </summary>
[DataField("brokenDesc", readOnly: true)] [DataField("brokenDesc", readOnly: true)]
public string BrokenDesc public string BrokenDesc { get; private set; } = "";
{
get => _brokenDesc;
private set => _brokenDesc = Loc.GetString(value);
}
[ViewVariables] [ViewVariables]
public bool Broken public bool Broken

View File

@@ -230,7 +230,8 @@ namespace Content.Server.Disease
private FormattedMessage AssembleDiseaseReport(DiseasePrototype disease) private FormattedMessage AssembleDiseaseReport(DiseasePrototype disease)
{ {
FormattedMessage report = new(); 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(); report.PushNewline();
if (disease.Infectious) if (disease.Infectious)
@@ -355,7 +356,8 @@ namespace Content.Server.Disease
FormattedMessage contents = new(); FormattedMessage contents = new();
if (args.Machine.Disease != null) 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); contents = AssembleDiseaseReport(args.Machine.Disease);
var known = false; var known = false;

View File

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

View File

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

View File

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

View File

@@ -208,11 +208,12 @@ namespace Content.Server.Pointing.EntitySystems
var tileDef = _tileDefinitionManager[tileRef?.Tile.TypeId ?? 0]; 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)); 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; _pointers[session] = _gameTiming.CurTime;

View File

@@ -14,8 +14,6 @@ namespace Content.Server.Storage.Components
[Access(typeof(SecretStashSystem))] [Access(typeof(SecretStashSystem))]
public sealed class SecretStashComponent : Component public sealed class SecretStashComponent : Component
{ {
private string _secretPartName = string.Empty;
/// <summary> /// <summary>
/// Max item size that can be fitted into secret stash. /// Max item size that can be fitted into secret stash.
/// </summary> /// </summary>
@@ -27,11 +25,7 @@ namespace Content.Server.Storage.Components
/// If empty string, will replace it with entity name in init. /// If empty string, will replace it with entity name in init.
/// </summary> /// </summary>
[DataField("secretPartName", readOnly: true)] [DataField("secretPartName", readOnly: true)]
public string SecretPartName public string SecretPartName { get; set; } = "";
{
get => _secretPartName;
set => _secretPartName = Loc.GetString(value);
}
/// <summary> /// <summary>
/// Container used to keep secret stash item. /// 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) 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 _); component.ItemContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, "stash", out _);
} }
@@ -79,7 +71,7 @@ namespace Content.Server.Storage.EntitySystems
if (item.Size > component.MaxItemSize) if (item.Size > component.MaxItemSize)
{ {
var msg = Loc.GetString("comp-secret-stash-action-hide-item-too-big", 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); _popupSystem.PopupEntity(msg, uid, userUid);
return false; return false;
} }
@@ -92,7 +84,7 @@ namespace Content.Server.Storage.EntitySystems
// all done, show success message // all done, show success message
var successMsg = Loc.GetString("comp-secret-stash-action-hide-success", 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); _popupSystem.PopupEntity(successMsg, uid, userUid);
return true; return true;
} }
@@ -121,10 +113,21 @@ namespace Content.Server.Storage.EntitySystems
// show success message // show success message
var successMsg = Loc.GetString("comp-secret-stash-action-get-item-found-something", var successMsg = Loc.GetString("comp-secret-stash-action-get-item-found-something",
("stash", component.SecretPartName)); ("stash", GetSecretPartName(uid, component)));
_popupSystem.PopupEntity(successMsg, uid, userUid); _popupSystem.PopupEntity(successMsg, uid, userUid);
return true; 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) public SuspicionInnocentRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind)
{ {
Prototype = antagPrototype; Prototype = antagPrototype;
Name = antagPrototype.Name; Name = Loc.GetString(antagPrototype.Name);
Antagonist = antagPrototype.Antagonist; Antagonist = antagPrototype.Antagonist;
} }
public override string Name { get; } public override string Name { get; }
public string Objective => Prototype.Objective; public string Objective => Loc.GetString(Prototype.Objective);
public override bool Antagonist { get; } public override bool Antagonist { get; }
public override void Greet() public override void Greet()

View File

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

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. /// The player-visible name of the access level, in the ID card console and such.
/// </summary> /// </summary>
[DataField("name")] [DataField("name")]
public string Name public string? Name { get; set; }
{
get => (_name is not null) ? _name : ID;
private set => _name = Loc.GetString(value);
}
private string? _name;
} }
} }

View File

@@ -81,7 +81,8 @@ namespace Content.Shared.Alert
if (idx == -1 && idy == -1) if (idx == -1 && idy == -1)
{ {
// break ties by type value // 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; if (idx == -1) return 1;
@@ -92,7 +93,8 @@ namespace Content.Shared.Alert
if (result == 0) if (result == 0)
{ {
// break ties by type value // 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; return result;

View File

@@ -1,4 +1,3 @@
using System.Globalization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -11,9 +10,6 @@ namespace Content.Shared.Alert
[Prototype("alert")] [Prototype("alert")]
public sealed class AlertPrototype : IPrototype, ISerializationHooks public sealed class AlertPrototype : IPrototype, ISerializationHooks
{ {
private FormattedMessage _name = new ();
private FormattedMessage _description = new ();
[ViewVariables] [ViewVariables]
string IPrototype.ID => AlertType.ToString(); string IPrototype.ID => AlertType.ToString();
@@ -34,21 +30,13 @@ namespace Content.Shared.Alert
/// Name to show in tooltip window. Accepts formatting. /// Name to show in tooltip window. Accepts formatting.
/// </summary> /// </summary>
[DataField("name")] [DataField("name")]
public FormattedMessage Name public string Name { get; private set; } = "";
{
get => _name;
private set => _name = FormattedMessage.FromMarkup(Loc.GetString(value.ToString()));
}
/// <summary> /// <summary>
/// Description to show in tooltip window. Accepts formatting. /// Description to show in tooltip window. Accepts formatting.
/// </summary> /// </summary>
[DataField("description")] [DataField("description")]
public FormattedMessage Description public string Description { get; private set; } = "";
{
get => _description;
private set => _description = FormattedMessage.FromMarkup(Loc.GetString(value.ToString()));
}
/// <summary> /// <summary>
/// Category the alert belongs to. Only one alert of a given category /// 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")] [Prototype("gas")]
public sealed class GasPrototype : IPrototype public sealed class GasPrototype : IPrototype
{ {
private string _name = string.Empty; [DataField("name")] public string Name { get; set; } = "";
[DataField("name")]
public string Name
{
get => _name;
private set => _name = Loc.GetString(value);
}
// TODO: Control gas amount necessary for overlay to appear // TODO: Control gas amount necessary for overlay to appear
// TODO: Add interfaces for gas behaviours e.g. breathing, burning // TODO: Add interfaces for gas behaviours e.g. breathing, burning

View File

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

View File

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

View File

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

View File

@@ -8,8 +8,6 @@ namespace Content.Shared.Construction.Prototypes
[Prototype("construction")] [Prototype("construction")]
public sealed class ConstructionPrototype : IPrototype public sealed class ConstructionPrototype : IPrototype
{ {
private string _category = string.Empty;
[DataField("conditions")] private List<IConstructionCondition> _conditions = new(); [DataField("conditions")] private List<IConstructionCondition> _conditions = new();
/// <summary> /// <summary>
@@ -54,12 +52,7 @@ namespace Content.Shared.Construction.Prototypes
[DataField("canBuildInImpassable")] [DataField("canBuildInImpassable")]
public bool CanBuildInImpassable { get; private set; } public bool CanBuildInImpassable { get; private set; }
[DataField("category")] [DataField("category")] public string Category { get; private set; } = "";
public string Category
{
get => _category;
private set => _category = Loc.GetString(value);
}
[DataField("objectType")] public ConstructionType Type { get; private set; } = ConstructionType.Structure; [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.Mapping;
using Robust.Shared.Serialization.Markdown.Validation; using Robust.Shared.Serialization.Markdown.Validation;
using Robust.Shared.Serialization.TypeSerializers.Interfaces; using Robust.Shared.Serialization.TypeSerializers.Interfaces;
@@ -41,7 +42,7 @@ namespace Content.Shared.Construction.Steps
public ConstructionGraphStep Read(ISerializationManager serializationManager, public ConstructionGraphStep Read(ISerializationManager serializationManager,
MappingDataNode node, MappingDataNode node,
IDependencyCollection dependencies, IDependencyCollection dependencies,
bool skipHook, SerializationHookContext hookCtx,
ISerializationContext? context = null, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<ConstructionGraphStep>? instanceProvider = null) ISerializationManager.InstantiationDelegate<ConstructionGraphStep>? instanceProvider = null)
{ {
@@ -49,7 +50,7 @@ namespace Content.Shared.Construction.Steps
throw new ArgumentException( throw new ArgumentException(
"Tried to convert invalid YAML node mapping to ConstructionGraphStep!"); "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, public ValidationNode Validate(ISerializationManager serializationManager, MappingDataNode node,

View File

@@ -1,6 +1,7 @@
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Validation; 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, 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(); var dict = instanceProvider != null ? instanceProvider() : new();
// Add all the damage types by just copying the type dictionary (if it is not null). // 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.Manager;
using Robust.Shared.Serialization.Markdown; using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
@@ -18,10 +19,10 @@ namespace Content.Shared.Decals
public DecalGridComponent.DecalGridChunkCollection Read(ISerializationManager serializationManager, public DecalGridComponent.DecalGridChunkCollection Read(ISerializationManager serializationManager,
MappingDataNode node, MappingDataNode node,
IDependencyCollection dependencies, bool skipHook, ISerializationContext? context = null, IDependencyCollection dependencies, SerializationHookContext hookCtx, ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<DecalGridComponent.DecalGridChunkCollection>? _ = default) 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 uids = new SortedSet<uint>();
var uidChunkMap = new Dictionary<uint, Vector2i>(); var uidChunkMap = new Dictionary<uint, Vector2i>();

View File

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

View File

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

View File

@@ -31,11 +31,7 @@ namespace Content.Shared.Materials
public string? StackId { get; } = null; public string? StackId { get; } = null;
[DataField("name")] [DataField("name")]
public string Name public string Name { get; private set; } = "";
{
get => _name;
private set => _name = Loc.GetString(value);
}
[DataField("color")] [DataField("color")]
public Color Color { get; } = Color.Gray; 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. /// The name this technology will have on user interfaces.
/// </summary> /// </summary>
[DataField("name")] [DataField("name")]
public string Name public string? Name { get; private set; }
{
get => (_name is not null) ? _name : ID;
private set => _name = Loc.GetString(value);
}
private string? _name;
/// <summary> /// <summary>
/// An icon that represent this technology. /// An icon that represent this technology.
@@ -37,13 +31,7 @@ namespace Content.Shared.Research.Prototypes
/// A short description of the technology. /// A short description of the technology.
/// </summary> /// </summary>
[DataField("description")] [DataField("description")]
public string Description public string Description { get; private set; } = "";
{
get => (_description is not null) ? _description : "";
private set => _description = Loc.GetString(value);
}
private string? _description;
/// <summary> /// <summary>
/// The required research points to unlock this technology. /// 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. /// The name of this antag as displayed to players.
/// </summary> /// </summary>
[DataField("name")] [DataField("name")]
public string Name public string Name { get; private set; } = "";
{
get => _name;
private set => _name = Loc.GetString(value);
}
/// <summary> /// <summary>
/// The description of this antag shown in a tooltip. /// The description of this antag shown in a tooltip.
/// </summary> /// </summary>
[DataField("description")] [DataField("description")]
public string? Description public string? Description { get; private set; }
{
get => _description;
private set => _description = value is null ? null : Loc.GetString(value);
}
/// <summary> /// <summary>
/// The antag's objective, displayed at round-start to the player. /// The antag's objective, displayed at round-start to the player.
/// </summary> /// </summary>
[DataField("objective")] [DataField("objective")]
public string Objective public string Objective { get; private set; } = "";
{
get => _objective;
private set => _objective = Loc.GetString(value);
}
/// <summary> /// <summary>
/// Whether or not the antag role is one of the bad guys. /// 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!; public string ID { get; } = default!;
[DataField("name")] [DataField("name")]
public string Name public string Name { get; private set; } = "";
{
get => _name;
private set => _name = Loc.GetString(value);
}
[DataField("priority")] [DataField("priority")]
public int Priority { get; } = 0; public int Priority { get; } = 0;

View File

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