Cleanups PolymorphSystem/Components/Prototypes (#23721)

* Cleanups PolymorphSystem

* forgot this

* Nah

* Fix test

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
AJCM-git
2024-02-01 08:17:02 -04:00
committed by GitHub
parent c0227bcb3b
commit b8f0ed3975
17 changed files with 714 additions and 724 deletions

View File

@@ -9,6 +9,11 @@ public sealed partial class PolymorphActionEvent : InstantActionEvent
/// the specific polymorph.
/// </summary>
public PolymorphPrototype Prototype = default!;
public PolymorphActionEvent(PolymorphPrototype prototype) : this()
{
Prototype = prototype;
}
}
public sealed partial class RevertPolymorphActionEvent : InstantActionEvent

View File

@@ -1,116 +1,125 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
namespace Content.Shared.Polymorph
namespace Content.Shared.Polymorph;
/// <summary>
/// Polymorphs generally describe any type of transformation that can be applied to an entity.
/// </summary>
[Prototype]
[DataDefinition]
public sealed partial class PolymorphPrototype : IPrototype, IInheritingPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = default!;
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<PolymorphPrototype>))]
public string[]? Parents { get; private set; }
[NeverPushInheritance]
[AbstractDataField]
public bool Abstract { get; private set; }
[DataField(required: true, serverOnly: true)]
public PolymorphConfiguration Configuration = new();
}
/// <summary>
/// Defines information about the polymorph
/// </summary>
[DataDefinition]
public sealed partial record PolymorphConfiguration
{
/// <summary>
/// Polymorphs generally describe any type of transformation that can be applied to an entity.
/// What entity the polymorph will turn the target into
/// must be in here because it makes no sense if it isn't
/// </summary>
[Prototype("polymorph")]
[DataDefinition]
public sealed partial class PolymorphPrototype : IPrototype, IInheritingPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = default!;
[DataField(required: true, serverOnly: true)]
public EntProtoId Entity;
[DataField("name")]
public string Name { get; private set; } = string.Empty;
/// <summary>
/// The delay between the polymorph's uses in seconds
/// Slightly weird as of right now.
/// </summary>
[DataField(serverOnly: true)]
public int Delay = 60;
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<PolymorphPrototype>))]
public string[]? Parents { get; private set; }
/// <summary>
/// The duration of the transformation in seconds
/// can be null if there is not one
/// </summary>
[DataField(serverOnly: true)]
public int? Duration;
[NeverPushInheritance]
[AbstractDataFieldAttribute]
public bool Abstract { get; private set; }
/// <summary>
/// whether or not the target can transform as will
/// set to true for things like polymorph spells and curses
/// </summary>
[DataField(serverOnly: true)]
public bool Forced;
/// <summary>
/// What entity the polymorph will turn the target into
/// must be in here because it makes no sense if it isn't
/// </summary>
[DataField("entity", required: true, serverOnly: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Entity = string.Empty;
/// <summary>
/// Whether or not the entity transfers its damage between forms.
/// </summary>
[DataField(serverOnly: true)]
public bool TransferDamage = true;
/// <summary>
/// The delay between the polymorph's uses in seconds
/// Slightly weird as of right now.
/// </summary>
[DataField("delay", serverOnly: true)]
public int Delay = 60;
/// <summary>
/// Whether or not the entity transfers its name between forms.
/// </summary>
[DataField(serverOnly: true)]
public bool TransferName;
/// <summary>
/// The duration of the transformation in seconds
/// can be null if there is not one
/// </summary>
[DataField("duration", serverOnly: true)]
public int? Duration = null;
/// <summary>
/// Whether or not the entity transfers its hair, skin color, hair color, etc.
/// </summary>
[DataField(serverOnly: true)]
public bool TransferHumanoidAppearance;
/// <summary>
/// whether or not the target can transform as will
/// set to true for things like polymorph spells and curses
/// </summary>
[DataField("forced", serverOnly: true)]
public bool Forced = false;
/// <summary>
/// Whether or not the entity transfers its inventory and equipment between forms.
/// </summary>
[DataField(serverOnly: true)]
public PolymorphInventoryChange Inventory = PolymorphInventoryChange.None;
/// <summary>
/// Whether or not the entity transfers its damage between forms.
/// </summary>
[DataField("transferDamage", serverOnly: true)]
public bool TransferDamage = true;
/// <summary>
/// Whether or not the polymorph reverts when the entity goes into crit.
/// </summary>
[DataField(serverOnly: true)]
public bool RevertOnCrit = true;
/// <summary>
/// Whether or not the entity transfers its name between forms.
/// </summary>
[DataField("transferName", serverOnly: true)]
public bool TransferName = false;
/// <summary>
/// Whether or not the polymorph reverts when the entity dies.
/// </summary>
[DataField(serverOnly: true)]
public bool RevertOnDeath = true;
/// <summary>
/// Whether or not the entity transfers its hair, skin color, hair color, etc.
/// </summary>
[DataField("transferHumanoidAppearance", serverOnly: true)]
public bool TransferHumanoidAppearance = false;
/// <summary>
/// Whether or not the polymorph reverts when the entity is eaten or fully sliced.
/// </summary>
[DataField(serverOnly: true)]
public bool RevertOnEat;
/// <summary>
/// Whether or not the entity transfers its inventory and equipment between forms.
/// </summary>
[DataField("inventory", serverOnly: true)]
public PolymorphInventoryChange Inventory = PolymorphInventoryChange.None;
/// <summary>
/// Whether or not an already polymorphed entity is able to be polymorphed again
/// </summary>
[DataField(serverOnly: true)]
public bool AllowRepeatedMorphs;
/// <summary>
/// Whether or not the polymorph reverts when the entity goes into crit.
/// </summary>
[DataField("revertOnCrit", serverOnly: true)]
public bool RevertOnCrit = true;
/// <summary>
/// Whether or not the polymorph reverts when the entity dies.
/// </summary>
[DataField("revertOnDeath", serverOnly: true)]
public bool RevertOnDeath = true;
/// <summary>
/// Whether or not the polymorph reverts when the entity is eaten or fully sliced.
/// </summary>
[DataField("revertOnEat", serverOnly: true)]
public bool RevertOnEat = false;
[DataField("allowRepeatedMorphs", serverOnly: true)]
public bool AllowRepeatedMorphs = false;
/// <summary>
/// The amount of time that should pass after this polymorph has ended, before a new one
/// can occur.
/// </summary>
[DataField("cooldown", serverOnly: true)]
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan Cooldown = TimeSpan.Zero;
}
public enum PolymorphInventoryChange : byte
{
None,
Drop,
Transfer,
}
/// <summary>
/// The amount of time that should pass after this polymorph has ended, before a new one
/// can occur.
/// </summary>
[DataField(serverOnly: true)]
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan Cooldown = TimeSpan.Zero;
}
public enum PolymorphInventoryChange : byte
{
None,
Drop,
Transfer,
}