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 System;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Physics.Pull;
|
using Content.Shared.Physics.Pull;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -16,7 +18,7 @@ using Robust.Shared.Serialization;
|
|||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Pulling
|
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 string Name => "Pullable";
|
||||||
public override uint? NetID => ContentNetIDs.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()
|
public override void OnRemove()
|
||||||
{
|
{
|
||||||
TryStopPull();
|
TryStopPull();
|
||||||
@@ -356,6 +349,14 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
|
|
||||||
return (_physics.CollisionLayer & collidedWith.CollisionMask) == (int) CollisionGroup.MobImpassable;
|
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]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -74,14 +74,5 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClickAlert(ClickAlertEventArgs args)
|
|
||||||
{
|
|
||||||
EntitySystem
|
|
||||||
.Get<SharedPullingSystem>()
|
|
||||||
.GetPulled(args.Player)?
|
|
||||||
.GetComponentOrNull<SharedPullableComponent>()?
|
|
||||||
.TryStopPull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,7 @@
|
|||||||
- type: alert
|
- type: alert
|
||||||
alertType: Pulled
|
alertType: Pulled
|
||||||
icon: /Textures/Interface/Alerts/Pull/pulled.png
|
icon: /Textures/Interface/Alerts/Pull/pulled.png
|
||||||
|
onClick: !type:StopBeingPulled { }
|
||||||
name: Pulled
|
name: Pulled
|
||||||
description: You're being pulled. Move to break free.
|
description: You're being pulled. Move to break free.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user