mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* feat: xeno artifact debug commands * refactor: minor renaming + whitespaces * refactor: do not allocate unless needed * refactor: rename common xeno-artifact commands localization string * refactor: extract reusable parts of code, change command to work with EntityUid and not with NetEntity * refactor: renaming * refactor: make all commands toolshed * refactor: localization fix, command naming reverted to camelCase, xml-doc for new commands * refactor: make toolshed tuple actually work * refactor: remove unused code * refactor: cache for EffectPrototypes * refactor: fix unlcokNode command, remove engine copy-paste for TryParseEntity * refactor: fix localization for toolshed * refactor: remove unused dependency * refactor: caching systems for XenoArtifactCommand where possible, comments clarification, whitespacing * refactor: added readonly to SharedXenoArtifactSystem.EffectPrototypeIds * refactor: use component to detect which proto is xenoarch effect * refactor: fix missing partial for XenoArtifactCommand * refactor: fix readonly on dependencies for XenoArtifactCommand * refactor: fix missing partial for nested XenoArtifact related parsers * refactor: cleanup after merge * refactor: remove obsolete IPrototype.HasComponent call and unused using * refactor: change xenoarch commands to lowercase (as convention dictates) * refactor: XenoArtifactNodeParser and XenoArtifactTypeParser are now CustomCompletionParser (removed duplicate code) * refactor: XenoArtifactNodeParser is now CustomCompletionParser, moved custom parsers to shared/toolshed/parsers * refactor: todo for ent proto caching, moved XenoArtifactCommand to toolshed namespace * refactor: fix xenoartifact:totalresearch command * refactor: remove system caching, clean whitespaces * fix: fix localization for xenoarch commands * refactor: moved StatusEffectCompletionParser to shared, added same todo remark for cache of status effect entity prototypes. * refactor: use proxy methods in command and _entityManager.System in all parsers * refactor: mved commands and parsers into respective folders * refactor: access restriction for cached EntityPrototypeIds * refactor: todo link to issue, fixed DI in StatusEffectCompletionParser --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
141 lines
4.5 KiB
C#
141 lines
4.5 KiB
C#
using Content.Server.Administration;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.StatusEffectNew;
|
|
using Content.Shared.Toolshed.TypeParsers;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Toolshed;
|
|
|
|
namespace Content.Server.Toolshed.Commands.StatusEffects;
|
|
|
|
[ToolshedCommand, AdminCommand(AdminFlags.VarEdit)]
|
|
public sealed class StatusEffectCommand : ToolshedCommand
|
|
{
|
|
private StatusEffectsSystem? _statusEffectsSystem;
|
|
|
|
[CommandImplementation("add")]
|
|
public EntityUid? Add([PipedArgument] EntityUid input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time, float delay = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
_statusEffectsSystem.TryAddStatusEffectDuration(
|
|
input,
|
|
status,
|
|
TimeSpan.FromSeconds(time),
|
|
ZeroAsNull(delay));
|
|
|
|
return input;
|
|
}
|
|
|
|
[CommandImplementation("add")]
|
|
public IEnumerable<EntityUid> Add([PipedArgument] IEnumerable<EntityUid> input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time, float delay = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
foreach (var ent in input)
|
|
{
|
|
_statusEffectsSystem.TryAddStatusEffectDuration(
|
|
ent,
|
|
status,
|
|
TimeSpan.FromSeconds(time),
|
|
ZeroAsNull(delay));
|
|
|
|
yield return ent;
|
|
}
|
|
}
|
|
|
|
[CommandImplementation("update")]
|
|
public EntityUid? Update([PipedArgument] EntityUid input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time, float delay = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
_statusEffectsSystem.TryUpdateStatusEffectDuration(
|
|
input,
|
|
status,
|
|
ZeroAsNull(time),
|
|
ZeroAsNull(delay));
|
|
|
|
return input;
|
|
}
|
|
|
|
[CommandImplementation("update")]
|
|
public IEnumerable<EntityUid> Update([PipedArgument] IEnumerable<EntityUid> input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time, float delay = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
foreach (var ent in input)
|
|
{
|
|
_statusEffectsSystem.TryUpdateStatusEffectDuration(
|
|
ent,
|
|
status,
|
|
ZeroAsNull(time),
|
|
ZeroAsNull(delay));
|
|
|
|
yield return ent;
|
|
}
|
|
}
|
|
|
|
[CommandImplementation("set")]
|
|
public EntityUid? Set([PipedArgument] EntityUid input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time = 0, float delay = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
_statusEffectsSystem.TrySetStatusEffectDuration(
|
|
input,
|
|
status,
|
|
ZeroAsNull(time),
|
|
ZeroAsNull(delay));
|
|
|
|
return input;
|
|
}
|
|
|
|
[CommandImplementation("set")]
|
|
public IEnumerable<EntityUid> Set([PipedArgument] IEnumerable<EntityUid> input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time = 0, float delay = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
foreach (var ent in input)
|
|
{
|
|
_statusEffectsSystem.TrySetStatusEffectDuration(
|
|
ent,
|
|
status,
|
|
ZeroAsNull(time),
|
|
ZeroAsNull(delay));
|
|
|
|
yield return ent;
|
|
}
|
|
}
|
|
|
|
[CommandImplementation("remove")]
|
|
public EntityUid? Remove([PipedArgument] EntityUid input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
_statusEffectsSystem.TryRemoveTime(
|
|
input,
|
|
status,
|
|
ZeroAsNull(time));
|
|
|
|
return input;
|
|
}
|
|
|
|
[CommandImplementation("remove")]
|
|
public IEnumerable<EntityUid> Remove([PipedArgument] IEnumerable<EntityUid> input, [CommandArgument(typeof(StatusEffectCompletionParser))] EntProtoId status, float time = 0)
|
|
{
|
|
_statusEffectsSystem ??= GetSys<StatusEffectsSystem>();
|
|
|
|
foreach (var ent in input)
|
|
{
|
|
_statusEffectsSystem.TryRemoveTime(
|
|
ent,
|
|
status,
|
|
ZeroAsNull(time));
|
|
|
|
yield return ent;
|
|
}
|
|
}
|
|
|
|
private static TimeSpan? ZeroAsNull(float delay)
|
|
{
|
|
return delay == 0 ? null : TimeSpan.FromSeconds(delay);
|
|
}
|
|
}
|