2025-05-14 12:43:43 +03:00
|
|
|
using Content.Shared._CP14.Skill.Prototypes;
|
2025-03-27 17:20:20 +03:00
|
|
|
using Content.Shared.Actions;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
2025-03-29 16:50:14 +03:00
|
|
|
namespace Content.Shared._CP14.Skill.Effects;
|
2025-03-27 17:20:20 +03:00
|
|
|
|
|
|
|
|
public sealed partial class AddAction : CP14SkillEffect
|
|
|
|
|
{
|
|
|
|
|
[DataField(required: true)]
|
|
|
|
|
public EntProtoId Action;
|
|
|
|
|
|
2025-03-29 16:50:14 +03:00
|
|
|
public override void AddSkill(IEntityManager entManager, EntityUid target)
|
2025-03-27 17:20:20 +03:00
|
|
|
{
|
|
|
|
|
var actionsSystem = entManager.System<SharedActionsSystem>();
|
|
|
|
|
|
|
|
|
|
actionsSystem.AddAction(target, Action);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-29 16:50:14 +03:00
|
|
|
public override void RemoveSkill(IEntityManager entManager, EntityUid target)
|
2025-03-27 17:20:20 +03:00
|
|
|
{
|
|
|
|
|
var actionsSystem = entManager.System<SharedActionsSystem>();
|
|
|
|
|
|
|
|
|
|
foreach (var (uid, _) in actionsSystem.GetActions(target))
|
|
|
|
|
{
|
|
|
|
|
if (!entManager.TryGetComponent<MetaDataComponent>(uid, out var metaData))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (metaData.EntityPrototype == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (metaData.EntityPrototype != Action)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
actionsSystem.RemoveAction(target, uid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-29 16:50:14 +03:00
|
|
|
public override string? GetName(IEntityManager entMagager, IPrototypeManager protoManager)
|
2025-03-27 17:20:20 +03:00
|
|
|
{
|
2025-03-29 16:50:14 +03:00
|
|
|
return !protoManager.TryIndex(Action, out var indexedAction) ? string.Empty : indexedAction.Name;
|
2025-03-27 17:20:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-05-14 12:43:43 +03:00
|
|
|
public override string? GetDescription(IEntityManager entMagager, IPrototypeManager protoManager, ProtoId<CP14SkillPrototype> skill)
|
2025-03-27 17:20:20 +03:00
|
|
|
{
|
2025-03-29 16:50:14 +03:00
|
|
|
return !protoManager.TryIndex(Action, out var indexedAction) ? string.Empty : indexedAction.Description;
|
2025-03-27 17:20:20 +03:00
|
|
|
}
|
|
|
|
|
}
|