mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 01:57:07 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Shared.GameObjects.Components.Localization
|
|
{
|
|
/// <summary>
|
|
/// Overrides grammar attributes specified in prototypes or localization files.
|
|
/// </summary>
|
|
[RegisterComponent]
|
|
[NetworkedComponent()]
|
|
public sealed class GrammarComponent : Component
|
|
{
|
|
[ViewVariables]
|
|
[DataField("attributes")]
|
|
public Dictionary<string, string> Attributes { get; } = new();
|
|
|
|
[ViewVariables]
|
|
public Gender? Gender
|
|
{
|
|
get => Attributes.TryGetValue("gender", out var g) ? Enum.Parse<Gender>(g, true) : null;
|
|
set
|
|
{
|
|
if (value.HasValue)
|
|
Attributes["gender"] = value.Value.ToString();
|
|
else
|
|
Attributes.Remove("gender");
|
|
}
|
|
}
|
|
|
|
[ViewVariables]
|
|
public bool? ProperNoun
|
|
{
|
|
get => Attributes.TryGetValue("proper", out var g) ? bool.Parse(g) : null;
|
|
set
|
|
{
|
|
if (value.HasValue)
|
|
Attributes["proper"] = value.Value.ToString();
|
|
else
|
|
Attributes.Remove("proper");
|
|
}
|
|
}
|
|
}
|
|
}
|