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

@@ -13,19 +13,27 @@ using Content.Shared.Popups;
using Content.Shared.Pulling.Components;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Hands.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedHandsComponent))]
#pragma warning disable 618
public sealed class HandsComponent : SharedHandsComponent, IBodyPartAdded, IBodyPartRemoved
public sealed class HandsComponent : SharedHandsComponent, IBodyPartAdded, IBodyPartRemoved, IDisarmedAct
#pragma warning restore 618
{
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[DataField("disarmedSound")] SoundSpecifier _disarmedSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
int IDisarmedAct.Priority => int.MaxValue; // We want this to be the last disarm act to run.
#region Pull/Disarm
void IBodyPartAdded.BodyPartAdded(BodyPartAddedEventArgs args)
@@ -54,10 +62,33 @@ namespace Content.Server.Hands.Components
RemoveHand(args.Slot);
}
public bool BreakPulls()
bool IDisarmedAct.Disarmed(DisarmedActEvent @event)
{
if (BreakPulls())
return false;
var source = @event.Source;
var target = @event.Target;
SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f));
if (ActiveHand != null && Drop(ActiveHand, false))
{
source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", _entities.GetComponent<MetaDataComponent>(source).EntityName), ("disarmed", _entities.GetComponent<MetaDataComponent>(target).EntityName)));
source.PopupMessageCursor(Loc.GetString("hands-component-disarm-success-message", ("disarmed", _entities.GetComponent<MetaDataComponent>(target).EntityName)));
}
else
{
source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", _entities.GetComponent<MetaDataComponent>(source).EntityName), ("shoved", _entities.GetComponent<MetaDataComponent>(target).EntityName)));
source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", _entities.GetComponent<MetaDataComponent>(target).EntityName)));
}
return true;
}
private bool BreakPulls()
{
// What is this API??
// I just wanted to do actions not deal with this shit...
if (!_entities.TryGetComponent(Owner, out SharedPullerComponent? puller)
|| puller.Pulling is not {Valid: true} pulling || !_entities.TryGetComponent(puller.Pulling.Value, out SharedPullableComponent? pullable))
return false;

View File

@@ -1,12 +1,9 @@
using System.Linq;
using Content.Server.Act;
using Content.Server.Administration.Logs;
using Content.Server.Hands.Components;
using Content.Server.Popups;
using Content.Server.Stack;
using Content.Server.Storage.Components;
using Content.Server.Strip;
using Content.Server.Stunnable;
using Content.Server.Throwing;
using Content.Shared.ActionBlocker;
using Content.Shared.Database;
@@ -21,7 +18,6 @@ using Content.Shared.Popups;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Input.Binding;
@@ -42,7 +38,6 @@ namespace Content.Server.Hands.Systems
[Dependency] private readonly AdminLogSystem _logSystem = default!;
[Dependency] private readonly StrippableSystem _strippableSystem = default!;
[Dependency] private readonly SharedHandVirtualItemSystem _virtualSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
@@ -53,7 +48,6 @@ namespace Content.Server.Hands.Systems
SubscribeNetworkEvent<ClientInteractUsingInHandMsg>(HandleInteractUsingInHand);
SubscribeNetworkEvent<UseInHandMsg>(HandleUseInHand);
SubscribeNetworkEvent<MoveItemFromHandMsg>(HandleMoveItemFromHand);
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] { typeof(StunSystem) });
SubscribeLocalEvent<HandsComponent, PullAttemptMessage>(HandlePullAttempt);
SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
@@ -82,26 +76,6 @@ namespace Content.Server.Hands.Systems
args.State = new HandsComponentState(hands.Hands, hands.ActiveHand);
}
private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent args)
{
if (args.Handled || component.BreakPulls())
return;
if (component.ActiveHand == null || !component.Drop(component.ActiveHand, false))
return;
var targetName = Name(args.Target);
var msgOther = Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name(args.Source)), ("disarmed", targetName));
var msgUser = Loc.GetString("hands-component-disarm-success-message", ("disarmed", targetName));
var filter = Filter.Pvs(args.Source).RemoveWhereAttachedEntity(e => e == args.Source);
_popupSystem.PopupEntity(msgOther, args.Source, filter);
_popupSystem.PopupEntity(msgUser, args.Source, Filter.Entities(args.Source));
args.Handled = true; // no shove/stun.
}
#region EntityInsertRemove
public override void RemoveHeldEntityFromHand(EntityUid uid, Hand hand, SharedHandsComponent? hands = null)
{