* Gateway generation * Gateway stuff * gatewehs * mercenaries * play area * Range fixes and tweaks * weh * Gateway UI polish * Lots of fixes * Knock some items off * Fix dungeon spawning Realistically we should probably be using a salvage job. * wahwah * wehvs * expression * weh * eee * a * a * WEH * frfr * Gatwey * Fix gateway windows * Fix gateway windows * a * a * Better layer masking * a * a * Noise fixes * a * Fix fractal calculations * a * More fixes * Fixes * Add layers back in * Fixes * namespaces and ftl * Other TODO * Fix distance * Cleanup * Fix test
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Content.Shared.Movement.Components;
|
|
using Robust.Shared.Physics.Events;
|
|
|
|
namespace Content.Server.Movement.Systems;
|
|
|
|
public sealed class BoundarySystem : EntitySystem
|
|
{
|
|
/*
|
|
* The real reason this even exists is because with out mover controller it's really easy to clip out of bounds on chain shapes.
|
|
*/
|
|
|
|
[Dependency] private readonly SharedTransformSystem _xform = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<BoundaryComponent, StartCollideEvent>(OnBoundaryCollide);
|
|
}
|
|
|
|
private void OnBoundaryCollide(Entity<BoundaryComponent> ent, ref StartCollideEvent args)
|
|
{
|
|
var center = _xform.GetWorldPosition(ent.Owner);
|
|
var otherXform = Transform(args.OtherEntity);
|
|
var collisionPoint = _xform.GetWorldPosition(otherXform);
|
|
var offset = collisionPoint - center;
|
|
offset = offset.Normalized() * (offset.Length() - ent.Comp.Offset);
|
|
// If for whatever reason you want to yeet them to the other side.
|
|
// offset = new Angle(MathF.PI).RotateVec(offset);
|
|
|
|
_xform.SetWorldPosition(otherXform, center + offset);
|
|
}
|
|
}
|