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,
|
Essence,
|
||||||
Corporeal,
|
Corporeal,
|
||||||
Bleed,
|
Bleed,
|
||||||
|
Pacified,
|
||||||
Debug1,
|
Debug1,
|
||||||
Debug2,
|
Debug2,
|
||||||
Debug3,
|
Debug3,
|
||||||
|
|||||||
@@ -1,52 +1,57 @@
|
|||||||
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 SharedCombatModeSystem _combatSystem = default!;
|
||||||
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
base.Initialize();
|
||||||
[Dependency] private readonly SharedCombatModeSystem _combatSystem = default!;
|
SubscribeLocalEvent<PacifiedComponent, ComponentStartup>(OnStartup);
|
||||||
|
SubscribeLocalEvent<PacifiedComponent, ComponentShutdown>(OnShutdown);
|
||||||
|
SubscribeLocalEvent<PacifiedComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
private void OnAttackAttempt(EntityUid uid, PacifiedComponent component, AttackAttemptEvent args)
|
||||||
{
|
{
|
||||||
base.Initialize();
|
args.Cancel();
|
||||||
SubscribeLocalEvent<PacifiedComponent, ComponentStartup>(OnStartup);
|
}
|
||||||
SubscribeLocalEvent<PacifiedComponent, ComponentShutdown>(OnShutdown);
|
|
||||||
SubscribeLocalEvent<PacifiedComponent, AttackAttemptEvent>(OnAttackAttempt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAttackAttempt(EntityUid uid, PacifiedComponent component, AttackAttemptEvent args)
|
private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args)
|
||||||
{
|
{
|
||||||
args.Cancel();
|
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
||||||
}
|
return;
|
||||||
|
|
||||||
private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args)
|
if (combatMode.CanDisarm != null)
|
||||||
{
|
_combatSystem.SetCanDisarm(uid, false, combatMode);
|
||||||
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (combatMode.CanDisarm != null)
|
_combatSystem.SetInCombatMode(uid, false, combatMode);
|
||||||
_combatSystem.SetCanDisarm(uid, false, combatMode);
|
|
||||||
|
|
||||||
_combatSystem.SetInCombatMode(uid, false, combatMode);
|
if (combatMode.CombatToggleAction != null)
|
||||||
|
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, false);
|
||||||
|
|
||||||
if (combatMode.CombatToggleAction != null)
|
_alertsSystem.ShowAlert(uid, AlertType.Pacified);
|
||||||
{
|
}
|
||||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args)
|
private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args)
|
||||||
{
|
{
|
||||||
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
if (!TryComp<CombatModeComponent>(uid, out var combatMode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (combatMode.CanDisarm != null)
|
if (combatMode.CanDisarm != null)
|
||||||
_combatSystem.SetCanDisarm(uid, true, combatMode);
|
_combatSystem.SetCanDisarm(uid, true, combatMode);
|
||||||
|
|
||||||
if (combatMode.CombatToggleAction != null)
|
if (combatMode.CombatToggleAction != null)
|
||||||
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
|
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);
|
||||||
}
|
|
||||||
|
_alertsSystem.ClearAlert(uid, AlertType.Pacified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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]
|
||||||
public sealed class PacifiedComponent : Component
|
[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-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.
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
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