Refactor PacificationSystem (#18715)
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
namespace Content.Server.Traits.Assorted;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for enforcing pacifism.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class PacifistComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Content.Shared.CombatMode.Pacification;
|
||||
|
||||
namespace Content.Server.Traits.Assorted;
|
||||
|
||||
/// <summary>
|
||||
/// This handles enforced pacifism.
|
||||
/// </summary>
|
||||
public sealed class PacifistSystem : EntitySystem
|
||||
{
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var comp in EntityQuery<PacifistComponent>())
|
||||
{
|
||||
EnsureComp<PacifiedComponent>(comp.Owner); // It's a status effect so just enforce it.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ namespace Content.Shared.Alert
|
||||
Essence,
|
||||
Corporeal,
|
||||
Bleed,
|
||||
Pacified,
|
||||
Debug1,
|
||||
Debug2,
|
||||
Debug3,
|
||||
|
||||
@@ -1,52 +1,57 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Popups;
|
||||
|
||||
namespace Content.Shared.CombatMode.Pacification
|
||||
namespace Content.Shared.CombatMode.Pacification;
|
||||
|
||||
public sealed class PacificationSystem : EntitySystem
|
||||
{
|
||||
public sealed class PacificationSystem : EntitySystem
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly SharedCombatModeSystem _combatSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly SharedCombatModeSystem _combatSystem = default!;
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PacifiedComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<PacifiedComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<PacifiedComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PacifiedComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<PacifiedComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<PacifiedComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||
}
|
||||
private void OnAttackAttempt(EntityUid uid, PacifiedComponent component, AttackAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnAttackAttempt(EntityUid uid, PacifiedComponent component, AttackAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
||||
return;
|
||||
|
||||
private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
||||
return;
|
||||
if (combatMode.CanDisarm != null)
|
||||
_combatSystem.SetCanDisarm(uid, false, combatMode);
|
||||
|
||||
if (combatMode.CanDisarm != null)
|
||||
_combatSystem.SetCanDisarm(uid, false, combatMode);
|
||||
_combatSystem.SetInCombatMode(uid, false, combatMode);
|
||||
|
||||
_combatSystem.SetInCombatMode(uid, false, combatMode);
|
||||
if (combatMode.CombatToggleAction != null)
|
||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, false);
|
||||
|
||||
if (combatMode.CombatToggleAction != null)
|
||||
{
|
||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, false);
|
||||
}
|
||||
}
|
||||
_alertsSystem.ShowAlert(uid, AlertType.Pacified);
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
||||
return;
|
||||
private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
||||
return;
|
||||
|
||||
if (combatMode.CanDisarm != null)
|
||||
_combatSystem.SetCanDisarm(uid, true, combatMode);
|
||||
if (combatMode.CanDisarm != null)
|
||||
_combatSystem.SetCanDisarm(uid, true, combatMode);
|
||||
|
||||
if (combatMode.CombatToggleAction != null)
|
||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
|
||||
}
|
||||
if (combatMode.CombatToggleAction != null)
|
||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
|
||||
|
||||
_alertsSystem.ClearAlert(uid, AlertType.Pacified);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.CombatMode.Pacification
|
||||
{
|
||||
/// <summary>
|
||||
/// Status effect that disables combat mode.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class PacifiedComponent : Component
|
||||
{
|
||||
namespace Content.Shared.CombatMode.Pacification;
|
||||
|
||||
/// <summary>
|
||||
/// Status effect that disables combat mode.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(PacificationSystem))]
|
||||
public sealed class PacifiedComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,3 +86,6 @@ alerts-pulling-desc = You're pulling something. Click the alert to stop.
|
||||
|
||||
alerts-bleed-name = [color=red]Bleed[/color]
|
||||
alerts-bleed-desc = You're [color=red]bleeding[/color].
|
||||
|
||||
alerts-pacified-name = [color=green]Pacified[/color]
|
||||
alerts-pacified-desc = You're pacified; you won't be able to attack anyone directly.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- type: alertOrder
|
||||
- type: alertOrder
|
||||
# Defines ordering in alert tab, higher up = higher in tab.
|
||||
# List below can contain alert type or category, if both are present the id will take precedence.
|
||||
# If item is not in list it will go at the bottom (ties broken by alert type enum value)
|
||||
@@ -22,6 +22,7 @@
|
||||
- category: Hunger
|
||||
- category: Thirst
|
||||
- alertType: Magboots
|
||||
- alertType: Pacified
|
||||
|
||||
- type: alert
|
||||
id: LowOxygen
|
||||
@@ -323,6 +324,14 @@
|
||||
minSeverity: 0
|
||||
maxSeverity: 10
|
||||
|
||||
- type: alert
|
||||
id: Pacified
|
||||
icons:
|
||||
- sprite: /Textures/Interface/Alerts/pacified.rsi
|
||||
state: icon
|
||||
name: alerts-pacified-name
|
||||
description: alerts-pacified-desc
|
||||
|
||||
- type: alert
|
||||
id: Debug1
|
||||
icons:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- type: trait
|
||||
- type: trait
|
||||
id: Blindness
|
||||
name: trait-blindness-name
|
||||
description: trait-blindness-desc
|
||||
@@ -22,7 +22,7 @@
|
||||
id: Pacifist
|
||||
name: trait-pacifist-name
|
||||
components:
|
||||
- type: Pacifist
|
||||
- type: Pacified
|
||||
|
||||
- type: trait
|
||||
id: Paracusia
|
||||
|
||||
BIN
Resources/Textures/Interface/Alerts/pacified.rsi/icon.png
Normal file
BIN
Resources/Textures/Interface/Alerts/pacified.rsi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 311 B |
14
Resources/Textures/Interface/Alerts/pacified.rsi/meta.json
Normal file
14
Resources/Textures/Interface/Alerts/pacified.rsi/meta.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "CC-BY-SA-4.0",
|
||||
"copyright": "@Vordenburg",
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "icon"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user