Add missing DataDefinition constructors (#14603)

This commit is contained in:
Leon Friedrich
2023-03-13 12:37:24 +13:00
committed by GitHub
parent 6e4949af77
commit f0cf4e7a22
6 changed files with 45 additions and 39 deletions

View File

@@ -123,20 +123,24 @@ public sealed class FaxMachineComponent : Component
[DataDefinition]
public sealed class FaxPrintout
{
[DataField("name")]
public string Name { get; }
[DataField("name", required: true)]
public string Name { get; } = default!;
[DataField("content")]
public string Content { get; }
[DataField("content", required: true)]
public string Content { get; } = default!;
[DataField("prototypeId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string PrototypeId { get; }
[DataField("prototypeId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>), required: true)]
public string PrototypeId { get; } = default!;
[DataField("stampState")]
public string? StampState { get; }
[DataField("stampedBy")]
public List<string> StampedBy { get; }
public List<string> StampedBy { get; } = new();
private FaxPrintout()
{
}
public FaxPrintout(string content, string name, string? prototypeId, string? stampState = null, List<string>? stampedBy = null)
{

View File

@@ -84,9 +84,7 @@ namespace Content.Shared.Humanoid
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor, newMarkings);
}
public static HumanoidCharacterAppearance Default()
{
return new(
public HumanoidCharacterAppearance() : this(
HairStyles.DefaultHairStyle,
Color.Black,
HairStyles.DefaultFacialHairStyle,
@@ -94,7 +92,8 @@ namespace Content.Shared.Humanoid
Color.Black,
Humanoid.SkinColor.ValidHumanSkinTone,
new ()
);
)
{
}
public static HumanoidCharacterAppearance DefaultWithSpecies(string species)

View File

@@ -12,7 +12,11 @@ namespace Content.Shared.Humanoid.Markings
[DataField("markingColor")]
private List<Color> _markingColors = new();
private Marking(string markingId,
private Marking()
{
}
public Marking(string markingId,
List<Color> markingColors)
{
MarkingId = markingId;
@@ -45,7 +49,7 @@ namespace Content.Shared.Humanoid.Markings
/// <summary>
/// ID of the marking prototype.
/// </summary>
[DataField("markingId")]
[DataField("markingId", required: true)]
public string MarkingId { get; } = default!;
/// <summary>

View File

@@ -14,5 +14,5 @@ public sealed class HumanoidProfilePrototype : IPrototype
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayers = new();
[DataField("profile")]
public HumanoidCharacterProfile Profile { get; } = HumanoidCharacterProfile.Default();
public HumanoidCharacterProfile Profile { get; } = new();
}

View File

@@ -102,16 +102,14 @@ namespace Content.Shared.Preferences
/// Defaults to <see cref="SharedHumanoidAppearanceSystem.DefaultSpecies"/> for the species.
/// </summary>
/// <returns></returns>
public static HumanoidCharacterProfile Default()
{
return new(
public HumanoidCharacterProfile() : this(
"John Doe",
"",
SharedHumanoidAppearanceSystem.DefaultSpecies,
18,
Sex.Male,
Gender.Male,
HumanoidCharacterAppearance.Default(),
new HumanoidCharacterAppearance(),
ClothingPreference.Jumpsuit,
BackpackPreference.Backpack,
new Dictionary<string, JobPriority>
@@ -120,7 +118,8 @@ namespace Content.Shared.Preferences
},
PreferenceUnavailableMode.SpawnAsOverflow,
new List<string>(),
new List<string>());
new List<string>())
{
}
/// <summary>

View File

@@ -106,7 +106,7 @@ namespace Content.Tests.Server.Preferences
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
prototypeManager.Initialize();
prototypeManager.LoadFromStream(new StringReader(Prototypes));
await db.InitPrefsAsync(username, HumanoidCharacterProfile.Default());
await db.InitPrefsAsync(username, new HumanoidCharacterProfile());
await db.SaveCharacterSlotAsync(username, CharlieCharlieson(), 1);
await db.SaveSelectedCharacterIndexAsync(username, 1);
await db.SaveCharacterSlotAsync(username, null, 1);