Revert "Actions Rework" (#6888)

This commit is contained in:
Leon Friedrich
2022-02-25 18:55:18 +13:00
committed by GitHub
parent 5ac5dd6a64
commit 49ae383f06
135 changed files with 5165 additions and 3119 deletions

View File

@@ -1,7 +1,9 @@
using Content.Server.Actions;
using Content.Server.DoAfter;
using Content.Server.Hands.Components;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Examine;
@@ -11,6 +13,10 @@ using Content.Shared.MobState;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Player;
using Robust.Shared.Utility;
@@ -24,7 +30,6 @@ namespace Content.Server.Guardian
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly DamageableSystem _damageSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionSystem = default!;
public override void Initialize()
{
@@ -45,22 +50,9 @@ namespace Content.Server.Guardian
SubscribeLocalEvent<GuardianHostComponent, MobStateChangedEvent>(OnHostStateChange);
SubscribeLocalEvent<GuardianHostComponent, ComponentShutdown>(OnHostShutdown);
SubscribeLocalEvent<GuardianHostComponent, GuardianToggleActionEvent>(OnPerformAction);
SubscribeLocalEvent<GuardianComponent, AttackAttemptEvent>(OnGuardianAttackAttempt);
}
private void OnPerformAction(EntityUid uid, GuardianHostComponent component, GuardianToggleActionEvent args)
{
if (args.Handled)
return;
if (component.HostedGuardian != null)
ToggleGuardian(component);
args.Handled = true;
}
private void OnGuardianUnplayer(EntityUid uid, GuardianComponent component, PlayerDetachedEvent args)
{
var host = component.Host;
@@ -82,14 +74,12 @@ namespace Content.Server.Guardian
private void OnHostInit(EntityUid uid, GuardianHostComponent component, ComponentInit args)
{
component.GuardianContainer = uid.EnsureContainer<ContainerSlot>("GuardianContainer");
_actionSystem.AddAction(uid, component.Action, null);
}
private void OnHostShutdown(EntityUid uid, GuardianHostComponent component, ComponentShutdown args)
{
if (component.HostedGuardian == null) return;
EntityManager.QueueDeleteEntity(component.HostedGuardian.Value);
_actionSystem.RemoveAction(uid, component.Action);
}
private void OnGuardianAttackAttempt(EntityUid uid, GuardianComponent component, AttackAttemptEvent args)
@@ -161,6 +151,9 @@ namespace Content.Server.Guardian
return;
}
// Can't work without actions
EntityManager.EnsureComponent<ServerActionsComponent>(target);
if (component.Injecting) return;
component.Injecting = true;
@@ -182,7 +175,8 @@ namespace Content.Server.Guardian
comp.Used ||
!TryComp<HandsComponent>(ev.User, out var hands) ||
!hands.IsHolding(comp.Owner) ||
HasComp<GuardianHostComponent>(ev.Target))
HasComp<GuardianHostComponent>(ev.Target) ||
!TryComp<SharedActionsComponent>(ev.Target, out var actions))
{
comp.Injecting = false;
return;
@@ -200,6 +194,8 @@ namespace Content.Server.Guardian
{
guardianComponent.Host = ev.Target;
// Grant the user the recall action and notify them
actions.Grant(ActionType.ManifestGuardian);
SoundSystem.Play(Filter.Entities(ev.Target), "/Audio/Effects/guardian_inject.ogg", ev.Target);
_popupSystem.PopupEntity(Loc.GetString("guardian-created"), ev.Target, Filter.Entities(ev.Target));