Better pull breakout (#3571)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
20
Content.Server/Alert/Click/StopBeingPulled.cs
Normal file
20
Content.Server/Alert/Click/StopBeingPulled.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.GameObjects.Components.Pulling;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
{
|
||||
/// <summary>
|
||||
/// Stop pulling something
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class StopBeingPulled : IAlertClick
|
||||
{
|
||||
public void AlertClicked(ClickAlertEventArgs args)
|
||||
{
|
||||
args.Player.GetComponentOrNull<SharedPullableComponent>()?.TryStopPull();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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]
|
||||
|
||||
@@ -74,14 +74,5 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickAlert(ClickAlertEventArgs args)
|
||||
{
|
||||
EntitySystem
|
||||
.Get<SharedPullingSystem>()
|
||||
.GetPulled(args.Player)?
|
||||
.GetComponentOrNull<SharedPullableComponent>()?
|
||||
.TryStopPull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@
|
||||
- type: alert
|
||||
alertType: Pulled
|
||||
icon: /Textures/Interface/Alerts/Pull/pulled.png
|
||||
onClick: !type:StopBeingPulled { }
|
||||
name: Pulled
|
||||
description: You're being pulled. Move to break free.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user