Refactor PacificationSystem (#18715)

This commit is contained in:
Vordenburg
2023-08-05 17:27:12 -04:00
committed by GitHub
parent 42ed9dd550
commit 28fe9d9f33
10 changed files with 80 additions and 75 deletions

View File

@@ -1,10 +0,0 @@
namespace Content.Server.Traits.Assorted;
/// <summary>
/// This is used for enforcing pacifism.
/// </summary>
[RegisterComponent]
public sealed class PacifistComponent : Component
{
}

View File

@@ -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.
}
}
}

View File

@@ -39,6 +39,7 @@ namespace Content.Shared.Alert
Essence, Essence,
Corporeal, Corporeal,
Bleed, Bleed,
Pacified,
Debug1, Debug1,
Debug2, Debug2,
Debug3, Debug3,

View File

@@ -1,12 +1,16 @@
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Alert;
using Content.Shared.Interaction.Events; 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 SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedCombatModeSystem _combatSystem = default!; [Dependency] private readonly SharedCombatModeSystem _combatSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -32,9 +36,9 @@ namespace Content.Shared.CombatMode.Pacification
_combatSystem.SetInCombatMode(uid, false, combatMode); _combatSystem.SetInCombatMode(uid, false, combatMode);
if (combatMode.CombatToggleAction != null) if (combatMode.CombatToggleAction != null)
{
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, false); _actionsSystem.SetEnabled(combatMode.CombatToggleAction, false);
}
_alertsSystem.ShowAlert(uid, AlertType.Pacified);
} }
private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args) private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args)
@@ -47,6 +51,7 @@ namespace Content.Shared.CombatMode.Pacification
if (combatMode.CombatToggleAction != null) if (combatMode.CombatToggleAction != null)
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true); _actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
}
_alertsSystem.ClearAlert(uid, AlertType.Pacified);
} }
} }

View File

@@ -1,13 +1,13 @@
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
namespace Content.Shared.CombatMode.Pacification namespace Content.Shared.CombatMode.Pacification;
{
/// <summary> /// <summary>
/// Status effect that disables combat mode. /// Status effect that disables combat mode.
/// </summary> /// </summary>
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent]
[Access(typeof(PacificationSystem))]
public sealed class PacifiedComponent : Component public sealed class PacifiedComponent : Component
{ {
} }
}

View File

@@ -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-name = [color=red]Bleed[/color]
alerts-bleed-desc = You're [color=red]bleeding[/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.

View File

@@ -1,4 +1,4 @@
- type: alertOrder - type: alertOrder
# Defines ordering in alert tab, higher up = higher in tab. # 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. # 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) # 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: Hunger
- category: Thirst - category: Thirst
- alertType: Magboots - alertType: Magboots
- alertType: Pacified
- type: alert - type: alert
id: LowOxygen id: LowOxygen
@@ -323,6 +324,14 @@
minSeverity: 0 minSeverity: 0
maxSeverity: 10 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 - type: alert
id: Debug1 id: Debug1
icons: icons:

View File

@@ -1,4 +1,4 @@
- type: trait - type: trait
id: Blindness id: Blindness
name: trait-blindness-name name: trait-blindness-name
description: trait-blindness-desc description: trait-blindness-desc
@@ -22,7 +22,7 @@
id: Pacifist id: Pacifist
name: trait-pacifist-name name: trait-pacifist-name
components: components:
- type: Pacifist - type: Pacified
- type: trait - type: trait
id: Paracusia id: Paracusia

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

View File

@@ -0,0 +1,14 @@
{
"version": 1,
"license": "CC-BY-SA-4.0",
"copyright": "@Vordenburg",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
}
]
}