Use AttackAttempt for pax (#11844)
This commit is contained in:
@@ -1,18 +1,26 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
|
|
||||||
namespace Content.Shared.CombatMode.Pacification
|
namespace Content.Shared.CombatMode.Pacification
|
||||||
{
|
{
|
||||||
public sealed class PacificationSystem : EntitySystem
|
public sealed class PacificationSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<PacifiedComponent, ComponentInit>(OnInit);
|
SubscribeLocalEvent<PacifiedComponent, ComponentStartup>(OnStartup);
|
||||||
SubscribeLocalEvent<PacifiedComponent, ComponentShutdown>(OnShutdown);
|
SubscribeLocalEvent<PacifiedComponent, ComponentShutdown>(OnShutdown);
|
||||||
|
SubscribeLocalEvent<PacifiedComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInit(EntityUid uid, PacifiedComponent component, ComponentInit args)
|
private void OnAttackAttempt(EntityUid uid, PacifiedComponent component, AttackAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args)
|
||||||
{
|
{
|
||||||
if (!TryComp<SharedCombatModeComponent>(uid, out var combatMode))
|
if (!TryComp<SharedCombatModeComponent>(uid, out var combatMode))
|
||||||
return;
|
return;
|
||||||
@@ -34,6 +42,7 @@ namespace Content.Shared.CombatMode.Pacification
|
|||||||
|
|
||||||
if (combatMode.CanDisarm != null)
|
if (combatMode.CanDisarm != null)
|
||||||
combatMode.CanDisarm = true;
|
combatMode.CanDisarm = true;
|
||||||
|
|
||||||
if (combatMode.CombatToggleAction != null)
|
if (combatMode.CombatToggleAction != null)
|
||||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
|
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,7 @@ namespace Content.Shared.CombatMode.Pacification
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class PacifiedComponent : Component
|
public sealed class PacifiedComponent : Component
|
||||||
{}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user