diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index 5fe29dcd30e2..b7640ff98435 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -118,7 +118,10 @@ private void OnMapInit(Entity ent, ref MapInitEvent private void OnPolymorphActionEvent(Entity ent, ref PolymorphActionEvent args) { - PolymorphEntity(ent, args.Prototype.Configuration); + if (!_proto.TryIndex(args.ProtoId, out var prototype)) + return; + + PolymorphEntity(ent, prototype.Configuration); } private void OnRevertPolymorphActionEvent(Entity ent, @@ -348,7 +351,9 @@ public void CreatePolymorphAction(ProtoId id, Entity id, Entity id, Entity target) diff --git a/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs b/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs index f741c24571e5..5654c84722f7 100644 --- a/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs +++ b/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs @@ -3,8 +3,8 @@ using Content.Server.Polymorph.Systems; using Content.Shared.Administration; using Content.Shared.Polymorph; +using Robust.Shared.Prototypes; using Robust.Shared.Toolshed; -using Robust.Shared.Toolshed.TypeParsers; namespace Content.Server.Polymorph.Toolshed; @@ -15,22 +15,26 @@ namespace Content.Server.Polymorph.Toolshed; public sealed class PolymorphCommand : ToolshedCommand { private PolymorphSystem? _system; + [Dependency] private IPrototypeManager _proto = default!; [CommandImplementation] public EntityUid? Polymorph( [PipedArgument] EntityUid input, - [CommandArgument] Prototype prototype + [CommandArgument] ProtoId protoId ) { _system ??= GetSys(); - return _system.PolymorphEntity(input, prototype.Value.Configuration); + if (!_proto.TryIndex(protoId, out var prototype)) + return null; + + return _system.PolymorphEntity(input, prototype.Configuration); } [CommandImplementation] public IEnumerable Polymorph( [PipedArgument] IEnumerable input, - [CommandArgument] Prototype prototype + [CommandArgument] ProtoId protoId ) - => input.Select(x => Polymorph(x, prototype)).Where(x => x is not null).Select(x => (EntityUid)x!); + => input.Select(x => Polymorph(x, protoId)).Where(x => x is not null).Select(x => (EntityUid)x!); } diff --git a/Content.Shared/Polymorph/PolymorphActions.cs b/Content.Shared/Polymorph/PolymorphActions.cs index 0f230868f03f..13e00f55e2bb 100644 --- a/Content.Shared/Polymorph/PolymorphActions.cs +++ b/Content.Shared/Polymorph/PolymorphActions.cs @@ -1,18 +1,20 @@ using Content.Shared.Actions; +using Robust.Shared.Prototypes; namespace Content.Shared.Polymorph; public sealed partial class PolymorphActionEvent : InstantActionEvent { /// - /// The polymorph prototype containing all the information about - /// the specific polymorph. + /// The polymorph proto id, containing all the information about + /// the specific polymorph. /// - public PolymorphPrototype Prototype = default!; + [DataField] + public ProtoId? ProtoId; - public PolymorphActionEvent(PolymorphPrototype prototype) : this() + public PolymorphActionEvent(ProtoId protoId) : this() { - Prototype = prototype; + ProtoId = protoId; } }