Change Polymorph Actions to use Polymorph Proto Id (#26419)
* polymorph changes Adds poly proto ids to polymorph action event and checks for proto id when performing * nullable proto id * Replaces instances of Polymorph prototype with a proto id and tryindex * birdup --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -3,8 +3,8 @@ using Content.Server.Administration;
|
||||
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<PolymorphPrototype> prototype
|
||||
[CommandArgument] ProtoId<PolymorphPrototype> protoId
|
||||
)
|
||||
{
|
||||
_system ??= GetSys<PolymorphSystem>();
|
||||
|
||||
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<EntityUid> Polymorph(
|
||||
[PipedArgument] IEnumerable<EntityUid> input,
|
||||
[CommandArgument] Prototype<PolymorphPrototype> prototype
|
||||
[CommandArgument] ProtoId<PolymorphPrototype> 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!);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user