fix: properly respect AllowRepeatedMorphs (#39411)
* fix: properly respect AllowRepeatedMorphs * feat: add IgnoreAllowRepeatedMorphs
This commit is contained in:
@@ -170,15 +170,18 @@ public sealed partial class PolymorphSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Polymorphs the target entity into another
|
/// Polymorphs the target entity into another.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid">The entity that will be transformed</param>
|
/// <param name="uid">The entity that will be transformed</param>
|
||||||
/// <param name="configuration">Polymorph data</param>
|
/// <param name="configuration">The new polymorph configuration</param>
|
||||||
/// <returns></returns>
|
/// <returns>The new entity, or null if the polymorph failed.</returns>
|
||||||
public EntityUid? PolymorphEntity(EntityUid uid, PolymorphConfiguration configuration)
|
public EntityUid? PolymorphEntity(EntityUid uid, PolymorphConfiguration configuration)
|
||||||
{
|
{
|
||||||
// if it's already morphed, don't allow it again with this condition active.
|
// If they're morphed, check their current config to see if they can be
|
||||||
if (!configuration.AllowRepeatedMorphs && HasComp<PolymorphedEntityComponent>(uid))
|
// morphed again
|
||||||
|
if (!configuration.IgnoreAllowRepeatedMorphs
|
||||||
|
&& TryComp<PolymorphedEntityComponent>(uid, out var currentPoly)
|
||||||
|
&& !currentPoly.Configuration.AllowRepeatedMorphs)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// If this polymorph has a cooldown, check if that amount of time has passed since the
|
// If this polymorph has a cooldown, check if that amount of time has passed since the
|
||||||
|
|||||||
@@ -112,11 +112,21 @@ public sealed partial record PolymorphConfiguration
|
|||||||
public bool RevertOnEat;
|
public bool RevertOnEat;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not an already polymorphed entity is able to be polymorphed again
|
/// If true, attempts to polymorph this polymorph will fail, unless
|
||||||
|
/// <see cref="IgnoreAllowRepeatedMorphs"/> is true on the /new/ morph.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField(serverOnly: true)]
|
[DataField(serverOnly: true)]
|
||||||
public bool AllowRepeatedMorphs;
|
public bool AllowRepeatedMorphs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, this morph will succeed even when used on an entity
|
||||||
|
/// that is already polymorphed with a configuration that has
|
||||||
|
/// <see cref="AllowRepeatedMorphs"/> set to false. Helpful for
|
||||||
|
/// smite polymorphs which should always succeed.
|
||||||
|
/// </summary>
|
||||||
|
[DataField(serverOnly: true)]
|
||||||
|
public bool IgnoreAllowRepeatedMorphs;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of time that should pass after this polymorph has ended, before a new one
|
/// The amount of time that should pass after this polymorph has ended, before a new one
|
||||||
/// can occur.
|
/// can occur.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
transferName: true
|
transferName: true
|
||||||
transferHumanoidAppearance: true
|
transferHumanoidAppearance: true
|
||||||
inventory: Transfer
|
inventory: Transfer
|
||||||
allowRepeatedMorphs: true
|
ignoreAllowRepeatedMorphs: true
|
||||||
|
|
||||||
- type: polymorph
|
- type: polymorph
|
||||||
id: AdminMonkeySmite
|
id: AdminMonkeySmite
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
entity: MobMonkey
|
entity: MobMonkey
|
||||||
forced: true
|
forced: true
|
||||||
inventory: Drop
|
inventory: Drop
|
||||||
allowRepeatedMorphs: true
|
ignoreAllowRepeatedMorphs: true
|
||||||
|
|
||||||
- type: polymorph
|
- type: polymorph
|
||||||
id: AdminBreadSmite
|
id: AdminBreadSmite
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
entity: FoodBreadPlain
|
entity: FoodBreadPlain
|
||||||
forced: true
|
forced: true
|
||||||
inventory: Drop
|
inventory: Drop
|
||||||
allowRepeatedMorphs: true
|
ignoreAllowRepeatedMorphs: true
|
||||||
|
|
||||||
- type: polymorph
|
- type: polymorph
|
||||||
id: AdminInstrumentSmite
|
id: AdminInstrumentSmite
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
entity: SuperSynthesizerInstrument
|
entity: SuperSynthesizerInstrument
|
||||||
forced: true
|
forced: true
|
||||||
inventory: Drop
|
inventory: Drop
|
||||||
allowRepeatedMorphs: true
|
ignoreAllowRepeatedMorphs: true
|
||||||
|
|
||||||
- type: polymorph
|
- type: polymorph
|
||||||
id: AdminMouseSmite
|
id: AdminMouseSmite
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
entity: MobMouse
|
entity: MobMouse
|
||||||
forced: true
|
forced: true
|
||||||
inventory: Drop
|
inventory: Drop
|
||||||
allowRepeatedMorphs: true
|
ignoreAllowRepeatedMorphs: true
|
||||||
|
|
||||||
- type: polymorph
|
- type: polymorph
|
||||||
id: AdminDisposalsSmite
|
id: AdminDisposalsSmite
|
||||||
@@ -46,4 +46,4 @@
|
|||||||
entity: DisposalUnit
|
entity: DisposalUnit
|
||||||
forced: true
|
forced: true
|
||||||
inventory: Drop
|
inventory: Drop
|
||||||
allowRepeatedMorphs: true
|
ignoreAllowRepeatedMorphs: true
|
||||||
|
|||||||
Reference in New Issue
Block a user