Refactor serialization copying to use source generators (#19412)

This commit is contained in:
DrSmugleaf
2023-08-22 18:14:33 -07:00
committed by GitHub
parent 08b43990ab
commit a88e747a0b
1737 changed files with 2532 additions and 2521 deletions

View File

@@ -4,7 +4,7 @@ namespace Content.Shared.Damage.Components;
/// Tracks whether an entity has ANY stamina damage for update purposes only.
/// </summary>
[RegisterComponent]
public sealed class ActiveStaminaComponent : Component
public sealed partial class ActiveStaminaComponent : Component
{
}

View File

@@ -4,7 +4,7 @@ using Robust.Shared.GameStates;
namespace Content.Shared.Damage.Components;
[NetworkedComponent, RegisterComponent]
public sealed class DamageContactsComponent : Component
public sealed partial class DamageContactsComponent : Component
{
/// <summary>
/// The damage done each second to those touching this entity

View File

@@ -3,6 +3,6 @@ using Robust.Shared.GameStates;
namespace Content.Shared.Damage.Components;
[RegisterComponent, NetworkedComponent]
public sealed class DamageExaminableComponent : Component
public sealed partial class DamageExaminableComponent : Component
{
}

View File

@@ -17,7 +17,7 @@ namespace Content.Shared.Damage
[RegisterComponent]
[NetworkedComponent()]
[Access(typeof(DamageableSystem), Other = AccessPermissions.ReadExecute)]
public sealed class DamageableComponent : Component
public sealed partial class DamageableComponent : Component
{
/// <summary>
/// This <see cref="DamageContainerPrototype"/> specifies what damage types are supported by this component.

View File

@@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Damage.Components;
[NetworkedComponent, RegisterComponent]
public sealed class DamagedByContactComponent : Component
public sealed partial class DamagedByContactComponent : Component
{
[DataField("nextSecond", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextSecond = TimeSpan.Zero;

View File

@@ -4,7 +4,7 @@ using Robust.Shared.GameStates;
namespace Content.Shared.Damage.Components;
[RegisterComponent, NetworkedComponent, Access(typeof(SharedGodmodeSystem))]
public sealed class GodmodeComponent : Component
public sealed partial class GodmodeComponent : Component
{
[DataField("wasMovedByPressure")]
public bool WasMovedByPressure;

View File

@@ -6,12 +6,12 @@ namespace Content.Shared.Damage.Components
// TODO It'd be nice if this could be a destructible threshold, but on the other hand,
// that doesn't really work with events at all, and
[RegisterComponent, NetworkedComponent]
public sealed class SlowOnDamageComponent : Component
public sealed partial class SlowOnDamageComponent : Component
{
/// <summary>
/// Damage -> movespeed dictionary. This is -damage-, not -health-.
/// </summary>
[DataField("speedModifierThresholds", required: true)]
public readonly Dictionary<FixedPoint2, float> SpeedModifierThresholds = default!;
public Dictionary<FixedPoint2, float> SpeedModifierThresholds = default!;
}
}

View File

@@ -7,7 +7,7 @@ namespace Content.Shared.Damage.Components;
/// Add to an entity to paralyze it whenever it reaches critical amounts of Stamina DamageType.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class StaminaComponent : Component
public sealed partial class StaminaComponent : Component
{
/// <summary>
/// Have we reached peak stamina damage and been paralyzed?

View File

@@ -6,7 +6,7 @@ namespace Content.Shared.Damage.Components;
/// Applies stamina damage when colliding with an entity.
/// </summary>
[RegisterComponent]
public sealed class StaminaDamageOnCollideComponent : Component
public sealed partial class StaminaDamageOnCollideComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("damage")]
public float Damage = 55f;

View File

@@ -3,7 +3,7 @@ using Robust.Shared.Audio;
namespace Content.Shared.Damage.Components;
[RegisterComponent]
public sealed class StaminaDamageOnHitComponent : Component
public sealed partial class StaminaDamageOnHitComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("damage")]
public float Damage = 30f;

View File

@@ -13,7 +13,7 @@ namespace Content.Shared.Damage
[DataDefinition]
[Serializable, NetSerializable]
[Virtual]
public class DamageModifierSet
public partial class DamageModifierSet
{
[DataField("coefficients", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<float, DamageTypePrototype>))]
public Dictionary<string, float> Coefficients = new();

View File

@@ -16,18 +16,18 @@ namespace Content.Shared.Damage
/// functions to apply resistance sets and supports basic math operations to modify this dictionary.
/// </remarks>
[DataDefinition]
public sealed class DamageSpecifier : IEquatable<DamageSpecifier>
public sealed partial class DamageSpecifier : IEquatable<DamageSpecifier>
{
// These exist solely so the wiki works. Please do not touch them or use them.
[JsonPropertyName("types")]
[DataField("types", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageTypePrototype>))]
[UsedImplicitly]
private readonly Dictionary<string,FixedPoint2>? _damageTypeDictionary;
private Dictionary<string,FixedPoint2>? _damageTypeDictionary;
[JsonPropertyName("groups")]
[DataField("groups", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageGroupPrototype>))]
[UsedImplicitly]
private readonly Dictionary<string, FixedPoint2>? _damageGroupDictionary;
private Dictionary<string, FixedPoint2>? _damageGroupDictionary;
/// <summary>
/// Main DamageSpecifier dictionary. Most DamageSpecifier functions exist to somehow modifying this.

View File

@@ -18,7 +18,7 @@ namespace Content.Shared.Damage.Prototypes
{
[ViewVariables]
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// List of damage groups that are supported by this container.

View File

@@ -18,6 +18,6 @@ namespace Content.Shared.Damage.Prototypes
[IdDataField] public string ID { get; } = default!;
[DataField("damageTypes", required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<DamageTypePrototype>))]
public List<string> DamageTypes { get; } = default!;
public List<string> DamageTypes { get; private set; } = default!;
}
}

View File

@@ -14,6 +14,6 @@ namespace Content.Shared.Damage.Prototypes
{
[ViewVariables]
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
}
}

View File

@@ -9,7 +9,7 @@ namespace Content.Shared.Damage.Prototypes
public sealed class DamageTypePrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// The price for each 1% damage reduction in armors

View File

@@ -9,7 +9,7 @@ namespace Content.Shared.Damage.Prototypes;
public sealed class ExaminableDamagePrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// List of damage messages IDs sorted by severity.