Deprecate IActionBlocker in favour of cancellable events (#4193)

* Deprecate IActionBlocker in favour of cancellable events

* Bring back old speech/emoting component restrictions

* Rename action blocker listener methods

* Use Entity System public methods instead of extension methods

Co-authored-by: Vera Aguilera Puerto <gradientvera@outlook.com>
This commit is contained in:
DrSmugleaf
2021-06-19 10:03:24 +02:00
committed by GitHub
parent e1e54e9cb1
commit 9b8185db23
98 changed files with 673 additions and 365 deletions

View File

@@ -9,6 +9,8 @@ using Content.Shared.Body.Part;
using Content.Shared.Buckle.Components;
using Content.Shared.Coordinates;
using Content.Shared.EffectBlocker;
using Content.Shared.Interaction.Events;
using Content.Shared.Movement;
using NUnit.Framework;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
@@ -66,6 +68,7 @@ namespace Content.IntegrationTests.Tests.Buckle
{
var mapManager = IoCManager.Resolve<IMapManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
var gridId = new GridId(1);
var grid = mapManager.GetGrid(gridId);
@@ -79,8 +82,8 @@ namespace Content.IntegrationTests.Tests.Buckle
Assert.NotNull(buckle);
Assert.Null(buckle.BuckledTo);
Assert.False(buckle.Buckled);
Assert.True(ActionBlockerSystem.CanMove(human));
Assert.True(ActionBlockerSystem.CanChangeDirection(human));
Assert.True(actionBlocker.CanMove(human));
Assert.True(actionBlocker.CanChangeDirection(human));
Assert.True(EffectBlockerSystem.CanFall(human));
// Default state, no buckled entities, strap
@@ -96,8 +99,8 @@ namespace Content.IntegrationTests.Tests.Buckle
var player = IoCManager.Resolve<IPlayerManager>().GetAllPlayers().Single();
Assert.True(((BuckleComponentState) buckle.GetComponentState(player)).Buckled);
Assert.False(ActionBlockerSystem.CanMove(human));
Assert.False(ActionBlockerSystem.CanChangeDirection(human));
Assert.False(actionBlocker.CanMove(human));
Assert.False(actionBlocker.CanChangeDirection(human));
Assert.False(EffectBlockerSystem.CanFall(human));
Assert.That(human.Transform.WorldPosition, Is.EqualTo(chair.Transform.WorldPosition));
@@ -120,6 +123,8 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
// Still buckled
Assert.True(buckle.Buckled);
@@ -127,8 +132,8 @@ namespace Content.IntegrationTests.Tests.Buckle
Assert.True(buckle.TryUnbuckle(human));
Assert.Null(buckle.BuckledTo);
Assert.False(buckle.Buckled);
Assert.True(ActionBlockerSystem.CanMove(human));
Assert.True(ActionBlockerSystem.CanChangeDirection(human));
Assert.True(actionBlocker.CanMove(human));
Assert.True(actionBlocker.CanChangeDirection(human));
Assert.True(EffectBlockerSystem.CanFall(human));
// Unbuckle, strap
@@ -153,6 +158,8 @@ namespace Content.IntegrationTests.Tests.Buckle
await server.WaitAssertion(() =>
{
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
// Still buckled
Assert.True(buckle.Buckled);
@@ -182,8 +189,8 @@ namespace Content.IntegrationTests.Tests.Buckle
// Force unbuckle
Assert.True(buckle.TryUnbuckle(human, true));
Assert.False(buckle.Buckled);
Assert.True(ActionBlockerSystem.CanMove(human));
Assert.True(ActionBlockerSystem.CanChangeDirection(human));
Assert.True(actionBlocker.CanMove(human));
Assert.True(actionBlocker.CanChangeDirection(human));
Assert.True(EffectBlockerSystem.CanFall(human));
// Re-buckle