2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Buckle.Components;
|
2021-10-13 13:14:30 +11:00
|
|
|
using Content.Shared.Interaction.Events;
|
2021-08-10 10:34:01 +10:00
|
|
|
using Content.Shared.Movement;
|
2021-06-27 19:02:46 +10:00
|
|
|
using Content.Shared.Standing;
|
2021-06-28 14:17:08 +10:00
|
|
|
using Content.Shared.Throwing;
|
2021-05-30 23:30:44 +10:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.Physics.Dynamics;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Buckle
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
|
|
|
|
public abstract class SharedBuckleSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
SubscribeLocalEvent<SharedBuckleComponent, PreventCollideEvent>(PreventCollision);
|
2021-06-27 19:02:46 +10:00
|
|
|
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
|
|
|
|
|
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
|
2021-06-28 14:17:08 +10:00
|
|
|
SubscribeLocalEvent<SharedBuckleComponent, ThrowPushbackAttemptEvent>(HandleThrowPushback);
|
2021-08-10 10:34:01 +10:00
|
|
|
SubscribeLocalEvent<SharedBuckleComponent, MovementAttemptEvent>(HandleMove);
|
2021-10-13 13:14:30 +11:00
|
|
|
SubscribeLocalEvent<SharedBuckleComponent, ChangeDirectionAttemptEvent>(OnBuckleChangeDirectionAttempt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBuckleChangeDirectionAttempt(EntityUid uid, SharedBuckleComponent component, ChangeDirectionAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.Buckled)
|
|
|
|
|
args.Cancel();
|
2021-08-10 10:34:01 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleMove(EntityUid uid, SharedBuckleComponent component, MovementAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.Buckled)
|
|
|
|
|
args.Cancel();
|
2021-06-27 19:02:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleStand(EntityUid uid, SharedBuckleComponent component, StandAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.Buckled)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleDown(EntityUid uid, SharedBuckleComponent component, DownAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.Buckled)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|
|
|
|
|
|
2021-06-28 14:17:08 +10:00
|
|
|
private void HandleThrowPushback(EntityUid uid, SharedBuckleComponent component, ThrowPushbackAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!component.Buckled) return;
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-30 23:30:44 +10:00
|
|
|
private void PreventCollision(EntityUid uid, SharedBuckleComponent component, PreventCollideEvent args)
|
|
|
|
|
{
|
2021-12-03 16:30:34 +01:00
|
|
|
if (args.BodyB.Owner != component.LastEntityBuckledTo) return;
|
2021-05-30 23:30:44 +10:00
|
|
|
|
|
|
|
|
if (component.Buckled || component.DontCollide)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|