Better pull breakout (#3571)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2021-03-08 12:10:48 +11:00
committed by GitHub
parent 0f7da24993
commit fcb3498bba
4 changed files with 32 additions and 19 deletions

View File

@@ -2,7 +2,9 @@
using System;
using Content.Shared.Alert;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.Physics;
using Content.Shared.Physics.Pull;
using Robust.Shared.Containers;
@@ -16,7 +18,7 @@ using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Pulling
{
public abstract class SharedPullableComponent : Component, ICollideSpecial
public abstract class SharedPullableComponent : Component, ICollideSpecial, IRelayMoveInput
{
public override string Name => "Pullable";
public override uint? NetID => ContentNetIDs.PULLABLE;
@@ -331,15 +333,6 @@ namespace Content.Shared.GameObjects.Components.Pulling
}
}
private void OnClickAlert(ClickAlertEventArgs args)
{
EntitySystem
.Get<SharedPullingSystem>()
.GetPulled(args.Player)?
.GetComponentOrNull<SharedPullableComponent>()?
.TryStopPull();
}
public override void OnRemove()
{
TryStopPull();
@@ -356,6 +349,14 @@ namespace Content.Shared.GameObjects.Components.Pulling
return (_physics.CollisionLayer & collidedWith.CollisionMask) == (int) CollisionGroup.MobImpassable;
}
// TODO: Need a component bus relay so all entities can use this and not just players
void IRelayMoveInput.MoveInputPressed(ICommonSession session)
{
var entity = session.AttachedEntity;
if (entity == null || !ActionBlockerSystem.CanMove(entity)) return;
TryStopPull();
}
}
[Serializable, NetSerializable]