ActionBlocker CanChangeDirection uses EntityUid exclusively

This commit is contained in:
Vera Aguilera Puerto
2021-11-09 13:48:59 +01:00
parent cba96ad830
commit a2a8a6303f
4 changed files with 12 additions and 18 deletions

View File

@@ -83,7 +83,7 @@ namespace Content.IntegrationTests.Tests.Buckle
Assert.Null(buckle.BuckledTo);
Assert.False(buckle.Buckled);
Assert.True(actionBlocker.CanMove(human.Uid));
Assert.True(actionBlocker.CanChangeDirection(human));
Assert.True(actionBlocker.CanChangeDirection(human.Uid));
Assert.True(standingState.Down(human.Uid));
Assert.True(standingState.Stand(human.Uid));
@@ -101,7 +101,7 @@ namespace Content.IntegrationTests.Tests.Buckle
var player = IoCManager.Resolve<IPlayerManager>().GetAllPlayers().Single();
Assert.True(((BuckleComponentState) buckle.GetComponentState(player)).Buckled);
Assert.False(actionBlocker.CanMove(human.Uid));
Assert.False(actionBlocker.CanChangeDirection(human));
Assert.False(actionBlocker.CanChangeDirection(human.Uid));
Assert.False(standingState.Down(human.Uid));
Assert.That((human.Transform.WorldPosition - chair.Transform.WorldPosition).Length, Is.LessThanOrEqualTo(buckle.BuckleOffset.Length));
@@ -135,7 +135,7 @@ namespace Content.IntegrationTests.Tests.Buckle
Assert.Null(buckle.BuckledTo);
Assert.False(buckle.Buckled);
Assert.True(actionBlocker.CanMove(human.Uid));
Assert.True(actionBlocker.CanChangeDirection(human));
Assert.True(actionBlocker.CanChangeDirection(human.Uid));
Assert.True(standingState.Down(human.Uid));
// Unbuckle, strap
@@ -193,7 +193,7 @@ namespace Content.IntegrationTests.Tests.Buckle
Assert.True(buckle.TryUnbuckle(human, true));
Assert.False(buckle.Buckled);
Assert.True(actionBlocker.CanMove(human.Uid));
Assert.True(actionBlocker.CanChangeDirection(human));
Assert.True(actionBlocker.CanChangeDirection(human.Uid));
Assert.True(standingState.Down(human.Uid));
// Re-buckle

View File

@@ -115,18 +115,12 @@ namespace Content.Shared.ActionBlocker
return !ev.Cancelled;
}
public bool CanChangeDirection(IEntity entity)
{
var ev = new ChangeDirectionAttemptEvent(entity);
RaiseLocalEvent(entity.Uid, ev);
return !ev.Cancelled;
}
public bool CanChangeDirection(EntityUid uid)
{
return CanChangeDirection(EntityManager.GetEntity(uid));
var ev = new ChangeDirectionAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
public bool CanShiver(IEntity entity)

View File

@@ -4,11 +4,11 @@ namespace Content.Shared.Interaction.Events
{
public class ChangeDirectionAttemptEvent : CancellableEntityEventArgs
{
public ChangeDirectionAttemptEvent(IEntity entity)
public ChangeDirectionAttemptEvent(EntityUid uid)
{
Entity = entity;
Uid = uid;
}
public IEntity Entity { get; }
public EntityUid Uid { get; }
}
}

View File

@@ -45,7 +45,7 @@ namespace Content.Shared.Interaction
public bool TryFaceAngle(IEntity user, Angle diffAngle)
{
if (_actionBlockerSystem.CanChangeDirection(user))
if (_actionBlockerSystem.CanChangeDirection(user.Uid))
{
user.Transform.WorldRotation = diffAngle;
return true;