Gateway destinations (#21040)
* 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
This commit is contained in:
32
Content.Server/Movement/Systems/BoundarySystem.cs
Normal file
32
Content.Server/Movement/Systems/BoundarySystem.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user