Re-organize all projects (#4166)
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Shared.Preferences.Appearance
|
||||
{
|
||||
public static class HairStyles
|
||||
{
|
||||
public const string DefaultHairStyle = "HairBald";
|
||||
public const string DefaultFacialHairStyle = "FacialHairShaved";
|
||||
|
||||
public static readonly IReadOnlyList<Color> RealisticHairColors = new List<Color>
|
||||
{
|
||||
Color.Yellow,
|
||||
Color.Black,
|
||||
Color.SandyBrown,
|
||||
Color.Brown,
|
||||
Color.Wheat,
|
||||
Color.Gray
|
||||
};
|
||||
|
||||
// These comparers put the default hair style (shaved/bald) at the very top.
|
||||
// For in the hair style pickers.
|
||||
|
||||
public static readonly IComparer<SpriteAccessoryPrototype> SpriteAccessoryComparer =
|
||||
Comparer<SpriteAccessoryPrototype>.Create((a, b) =>
|
||||
{
|
||||
var cmp = -a.Priority.CompareTo(b.Priority);
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
|
||||
return string.Compare(a.Name, b.Name, StringComparison.CurrentCulture);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences.Appearance
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum HumanoidVisualLayers
|
||||
{
|
||||
Hair,
|
||||
FacialHair,
|
||||
Chest,
|
||||
Head,
|
||||
Eyes,
|
||||
RArm,
|
||||
LArm,
|
||||
RHand,
|
||||
LHand,
|
||||
RLeg,
|
||||
LLeg,
|
||||
RFoot,
|
||||
LFoot,
|
||||
Handcuffs,
|
||||
StencilMask,
|
||||
Fire,
|
||||
}
|
||||
|
||||
public static class HumanoidVisualLayersExtension
|
||||
{
|
||||
public static HumanoidVisualLayers? ToHumanoidLayer(this IBodyPart part)
|
||||
{
|
||||
return part.PartType switch
|
||||
{
|
||||
BodyPartType.Other => null,
|
||||
BodyPartType.Torso => HumanoidVisualLayers.Chest,
|
||||
BodyPartType.Head => HumanoidVisualLayers.Head,
|
||||
BodyPartType.Arm => part.Symmetry switch
|
||||
{
|
||||
BodyPartSymmetry.None => null,
|
||||
BodyPartSymmetry.Left => HumanoidVisualLayers.LArm,
|
||||
BodyPartSymmetry.Right => HumanoidVisualLayers.RArm,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
BodyPartType.Hand => part.Symmetry switch
|
||||
{
|
||||
BodyPartSymmetry.None => null,
|
||||
BodyPartSymmetry.Left => HumanoidVisualLayers.LHand,
|
||||
BodyPartSymmetry.Right => HumanoidVisualLayers.RHand,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
BodyPartType.Leg => part.Symmetry switch
|
||||
{
|
||||
BodyPartSymmetry.None => null,
|
||||
BodyPartSymmetry.Left => HumanoidVisualLayers.LLeg,
|
||||
BodyPartSymmetry.Right => HumanoidVisualLayers.RLeg,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
BodyPartType.Foot => part.Symmetry switch
|
||||
{
|
||||
BodyPartSymmetry.None => null,
|
||||
BodyPartSymmetry.Left => HumanoidVisualLayers.LFoot,
|
||||
BodyPartSymmetry.Right => HumanoidVisualLayers.RFoot,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences.Appearance
|
||||
{
|
||||
[Flags]
|
||||
[Serializable, NetSerializable]
|
||||
public enum SpriteAccessoryCategories
|
||||
{
|
||||
None = 0,
|
||||
HumanHair = 1 << 0,
|
||||
HumanFacialHair = 1 << 1,
|
||||
VoxHair = 1 << 2,
|
||||
VoxFacialHair = 1 << 3
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Preferences.Appearance
|
||||
{
|
||||
public sealed class SpriteAccessoryManager
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
private readonly Dictionary<SpriteAccessoryCategories, List<SpriteAccessoryPrototype>> _index = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_prototypeManager.PrototypesReloaded += OnPrototypesReloaded;
|
||||
|
||||
foreach (var category in Enum.GetValues<SpriteAccessoryCategories>())
|
||||
{
|
||||
_index.Add(category, new List<SpriteAccessoryPrototype>());
|
||||
}
|
||||
|
||||
foreach (var prototype in _prototypeManager.EnumeratePrototypes<SpriteAccessoryPrototype>())
|
||||
{
|
||||
AddToIndexes(prototype);
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<SpriteAccessoryPrototype> AccessoriesForCategory(SpriteAccessoryCategories categories)
|
||||
{
|
||||
return _index[categories];
|
||||
}
|
||||
|
||||
public bool IsValidAccessoryInCategory(string accessory, SpriteAccessoryCategories categories)
|
||||
{
|
||||
return _prototypeManager.TryIndex(accessory, out SpriteAccessoryPrototype? accessoryPrototype)
|
||||
&& (accessoryPrototype.Categories & categories) != 0;
|
||||
}
|
||||
|
||||
private void OnPrototypesReloaded(PrototypesReloadedEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.ByType.TryGetValue(typeof(SpriteAccessoryPrototype), out var set))
|
||||
return;
|
||||
|
||||
foreach (var list in _index.Values)
|
||||
{
|
||||
list.RemoveAll(a => set.Modified.ContainsKey(a.ID));
|
||||
}
|
||||
|
||||
foreach (var prototype in set.Modified.Values)
|
||||
{
|
||||
var accessoryPrototype = (SpriteAccessoryPrototype) prototype;
|
||||
AddToIndexes(accessoryPrototype);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddToIndexes(SpriteAccessoryPrototype accessoryPrototype)
|
||||
{
|
||||
for (var i = 0; i < sizeof(SpriteAccessoryCategories) * 8; i++)
|
||||
{
|
||||
var flag = (SpriteAccessoryCategories) (1 << i);
|
||||
if ((accessoryPrototype.Categories & flag) != 0)
|
||||
_index[flag].Add(accessoryPrototype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Preferences.Appearance
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains data for a single hair style
|
||||
/// </summary>
|
||||
[Prototype("spriteAccessory")]
|
||||
public sealed class SpriteAccessoryPrototype : IPrototype, ISerializationHooks
|
||||
{
|
||||
[DataField("id", required: true)]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField("categories", required: true)]
|
||||
public SpriteAccessoryCategories Categories { get; } = default!;
|
||||
|
||||
public string Name { get; private set; } = default!;
|
||||
|
||||
[DataField("sprite", required: true)]
|
||||
public SpriteSpecifier Sprite { get; } = default!;
|
||||
|
||||
[DataField("priority")] public int Priority { get; } = 0;
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
Name = Loc.GetString($"accessory-{ID}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.Preferences.Appearance;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public class HumanoidCharacterAppearance : ICharacterAppearance
|
||||
{
|
||||
public HumanoidCharacterAppearance(string hairStyleId,
|
||||
Color hairColor,
|
||||
string facialHairStyleId,
|
||||
Color facialHairColor,
|
||||
Color eyeColor,
|
||||
Color skinColor)
|
||||
{
|
||||
HairStyleId = hairStyleId;
|
||||
HairColor = ClampColor(hairColor);
|
||||
FacialHairStyleId = facialHairStyleId;
|
||||
FacialHairColor = ClampColor(facialHairColor);
|
||||
EyeColor = ClampColor(eyeColor);
|
||||
SkinColor = ClampColor(skinColor);
|
||||
}
|
||||
|
||||
public string HairStyleId { get; }
|
||||
public Color HairColor { get; }
|
||||
public string FacialHairStyleId { get; }
|
||||
public Color FacialHairColor { get; }
|
||||
public Color EyeColor { get; }
|
||||
public Color SkinColor { get; }
|
||||
|
||||
public HumanoidCharacterAppearance WithHairStyleName(string newName)
|
||||
{
|
||||
return new(newName, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor);
|
||||
}
|
||||
|
||||
public HumanoidCharacterAppearance WithHairColor(Color newColor)
|
||||
{
|
||||
return new(HairStyleId, newColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor);
|
||||
}
|
||||
|
||||
public HumanoidCharacterAppearance WithFacialHairStyleName(string newName)
|
||||
{
|
||||
return new(HairStyleId, HairColor, newName, FacialHairColor, EyeColor, SkinColor);
|
||||
}
|
||||
|
||||
public HumanoidCharacterAppearance WithFacialHairColor(Color newColor)
|
||||
{
|
||||
return new(HairStyleId, HairColor, FacialHairStyleId, newColor, EyeColor, SkinColor);
|
||||
}
|
||||
|
||||
public HumanoidCharacterAppearance WithEyeColor(Color newColor)
|
||||
{
|
||||
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, newColor, SkinColor);
|
||||
}
|
||||
|
||||
public HumanoidCharacterAppearance WithSkinColor(Color newColor)
|
||||
{
|
||||
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, newColor);
|
||||
}
|
||||
|
||||
public static HumanoidCharacterAppearance Default()
|
||||
{
|
||||
return new(
|
||||
HairStyles.DefaultHairStyle,
|
||||
Color.Black,
|
||||
HairStyles.DefaultFacialHairStyle,
|
||||
Color.Black,
|
||||
Color.Black,
|
||||
Color.FromHex("#C0967F")
|
||||
);
|
||||
}
|
||||
|
||||
public static HumanoidCharacterAppearance Random(Sex sex)
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var prototypes = IoCManager.Resolve<SpriteAccessoryManager>();
|
||||
var hairStyles = prototypes.AccessoriesForCategory(SpriteAccessoryCategories.HumanHair);
|
||||
var facialHairStyles = prototypes.AccessoriesForCategory(SpriteAccessoryCategories.HumanHair);
|
||||
|
||||
var newHairStyle = random.Pick(hairStyles).ID;
|
||||
|
||||
var newFacialHairStyle = sex == Sex.Female
|
||||
? HairStyles.DefaultFacialHairStyle
|
||||
: random.Pick(facialHairStyles).ID;
|
||||
|
||||
var newHairColor = random.Pick(HairStyles.RealisticHairColors);
|
||||
newHairColor = newHairColor
|
||||
.WithRed(RandomizeColor(newHairColor.R))
|
||||
.WithGreen(RandomizeColor(newHairColor.G))
|
||||
.WithBlue(RandomizeColor(newHairColor.B));
|
||||
|
||||
// TODO: Add random eye and skin color
|
||||
return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, Color.Black, Color.FromHex("#C0967F"));
|
||||
|
||||
float RandomizeColor(float channel)
|
||||
{
|
||||
return MathHelper.Clamp01(channel + random.Next(-25, 25) / 100f);
|
||||
}
|
||||
}
|
||||
|
||||
public static Color ClampColor(Color color)
|
||||
{
|
||||
return new(color.RByte, color.GByte, color.BByte);
|
||||
}
|
||||
|
||||
public static HumanoidCharacterAppearance EnsureValid(HumanoidCharacterAppearance appearance)
|
||||
{
|
||||
var mgr = IoCManager.Resolve<SpriteAccessoryManager>();
|
||||
var hairStyleId = appearance.HairStyleId;
|
||||
if (!mgr.IsValidAccessoryInCategory(hairStyleId, SpriteAccessoryCategories.HumanHair))
|
||||
{
|
||||
hairStyleId = HairStyles.DefaultHairStyle;
|
||||
}
|
||||
|
||||
var facialHairStyleId = appearance.FacialHairStyleId;
|
||||
if (!mgr.IsValidAccessoryInCategory(facialHairStyleId, SpriteAccessoryCategories.HumanFacialHair))
|
||||
{
|
||||
facialHairStyleId = HairStyles.DefaultFacialHairStyle;
|
||||
}
|
||||
|
||||
var hairColor = ClampColor(appearance.HairColor);
|
||||
var facialHairColor = ClampColor(appearance.FacialHairColor);
|
||||
var eyeColor = ClampColor(appearance.EyeColor);
|
||||
var skinColor = ClampColor(appearance.SkinColor);
|
||||
|
||||
return new HumanoidCharacterAppearance(
|
||||
hairStyleId,
|
||||
hairColor,
|
||||
facialHairStyleId,
|
||||
facialHairColor,
|
||||
eyeColor,
|
||||
skinColor);
|
||||
}
|
||||
|
||||
public bool MemberwiseEquals(ICharacterAppearance maybeOther)
|
||||
{
|
||||
if (maybeOther is not HumanoidCharacterAppearance other) return false;
|
||||
if (HairStyleId != other.HairStyleId) return false;
|
||||
if (!HairColor.Equals(other.HairColor)) return false;
|
||||
if (FacialHairStyleId != other.FacialHairStyleId) return false;
|
||||
if (!FacialHairColor.Equals(other.FacialHairColor)) return false;
|
||||
if (!EyeColor.Equals(other.EyeColor)) return false;
|
||||
if (!SkinColor.Equals(other.SkinColor)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.CharacterAppearance;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Prototypes;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
public interface ICharacterAppearance
|
||||
{
|
||||
bool MemberwiseEquals(ICharacterAppearance other);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Content.Shared.CharacterAppearance;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
|
||||
33
Content.Shared/Preferences/MsgDeleteCharacter.cs
Normal file
33
Content.Shared/Preferences/MsgDeleteCharacter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#nullable enable
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
/// <summary>
|
||||
/// The client sends this to delete a character profile.
|
||||
/// </summary>
|
||||
public class MsgDeleteCharacter : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgDeleteCharacter);
|
||||
|
||||
public MsgDeleteCharacter(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public int Slot;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
Slot = buffer.ReadInt32();
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
63
Content.Shared/Preferences/MsgPreferencesAndSettings.cs
Normal file
63
Content.Shared/Preferences/MsgPreferencesAndSettings.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#nullable enable
|
||||
using System.IO;
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
/// <summary>
|
||||
/// The server sends this before the client joins the lobby.
|
||||
/// </summary>
|
||||
public class MsgPreferencesAndSettings : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgPreferencesAndSettings);
|
||||
|
||||
public MsgPreferencesAndSettings(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public PlayerPreferences Preferences = default!;
|
||||
public GameSettings Settings = default!;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
||||
var length = buffer.ReadVariableInt32();
|
||||
using (var stream = buffer.ReadAlignedMemory(length))
|
||||
{
|
||||
serializer.DeserializeDirect(stream, out Preferences);
|
||||
}
|
||||
|
||||
length = buffer.ReadVariableInt32();
|
||||
using (var stream = buffer.ReadAlignedMemory(length))
|
||||
{
|
||||
serializer.DeserializeDirect(stream, out Settings);
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
serializer.SerializeDirect(stream, Preferences);
|
||||
buffer.WriteVariableInt32((int) stream.Length);
|
||||
stream.TryGetBuffer(out var segment);
|
||||
buffer.Write(segment);
|
||||
}
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
serializer.SerializeDirect(stream, Settings);
|
||||
buffer.WriteVariableInt32((int) stream.Length);
|
||||
stream.TryGetBuffer(out var segment);
|
||||
buffer.Write(segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Content.Shared/Preferences/MsgSelectCharacter.cs
Normal file
33
Content.Shared/Preferences/MsgSelectCharacter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#nullable enable
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
/// <summary>
|
||||
/// The client sends this to select a character slot.
|
||||
/// </summary>
|
||||
public class MsgSelectCharacter : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgSelectCharacter);
|
||||
|
||||
public MsgSelectCharacter(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public int SelectedCharacterIndex;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
SelectedCharacterIndex = buffer.ReadVariableInt32();
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.WriteVariableInt32(SelectedCharacterIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Content.Shared/Preferences/MsgUpdateCharacter.cs
Normal file
49
Content.Shared/Preferences/MsgUpdateCharacter.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
#nullable enable
|
||||
using System.IO;
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
/// <summary>
|
||||
/// The client sends this to update a character profile.
|
||||
/// </summary>
|
||||
public class MsgUpdateCharacter : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgUpdateCharacter);
|
||||
|
||||
public MsgUpdateCharacter(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public int Slot;
|
||||
public ICharacterProfile Profile = default!;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
Slot = buffer.ReadInt32();
|
||||
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
||||
var length = buffer.ReadVariableInt32();
|
||||
using var stream = buffer.ReadAlignedMemory(length);
|
||||
Profile = serializer.Deserialize<ICharacterProfile>(stream);
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(Slot);
|
||||
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
serializer.Serialize(stream, Profile);
|
||||
buffer.WriteVariableInt32((int) stream.Length);
|
||||
stream.TryGetBuffer(out var segment);
|
||||
buffer.Write(segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.Prototypes;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
public enum Sex
|
||||
{
|
||||
Male,
|
||||
Female
|
||||
}
|
||||
|
||||
public static class SexExtensions
|
||||
{
|
||||
public static DatasetPrototype FirstNames(this Sex sex, IPrototypeManager? prototypeManager = null)
|
||||
{
|
||||
prototypeManager ??= IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
switch (sex)
|
||||
{
|
||||
case Sex.Male:
|
||||
return prototypeManager.Index<DatasetPrototype>("names_first_male");
|
||||
case Sex.Female:
|
||||
return prototypeManager.Index<DatasetPrototype>("names_first_female");
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(sex), sex, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user