Skip to content

Commit

Permalink
Fix gliding (OpenDreamProject#1575)
Browse files Browse the repository at this point in the history
Co-authored-by: ike709 <[email protected]>
  • Loading branch information
ike709 and ike709 authored Dec 30, 2023
1 parent 4434107 commit 186d10d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions OpenDreamClient/Rendering/AtomGlideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public Glide(TransformComponent transform) {
public override void Initialize() {
_spriteQuery = _entityManager.GetEntityQuery<DMISpriteComponent>();

SubscribeLocalEvent<TransformComponent, MoveEvent>(OnTransformMove);

_transformSystem.OnGlobalMoveEvent += OnTransformMove;
}

public override void Shutdown() {
Expand Down Expand Up @@ -80,18 +81,18 @@ public override void FrameUpdate(float frameTime) {
/// <summary>
/// Disables RT lerping and sets up the entity's glide
/// </summary>
private void OnTransformMove(EntityUid entity, TransformComponent transform, ref MoveEvent e) {
private void OnTransformMove(ref MoveEvent e) {
if (_ignoreMoveEvent || e.ParentChanged)
return;
if (!_spriteQuery.TryGetComponent(entity, out var sprite))
if (!_spriteQuery.TryGetComponent(e.Sender, out var sprite))
return;

_ignoreMoveEvent = true;

// Look for any in-progress glides on this transform
Glide? glide = null;
foreach (var potentiallyThisTransform in _currentGlides) {
if (potentiallyThisTransform.Transform != transform)
if (potentiallyThisTransform.Transform != e.Component)
continue;

glide = potentiallyThisTransform;
Expand All @@ -113,13 +114,13 @@ private void OnTransformMove(EntityUid entity, TransformComponent transform, ref
}

if (glide == null) {
glide = new(transform);
glide = new(e.Component);
_currentGlides.Add(glide);
}

// Move the transform to our starting point
// Also serves the function of disabling RT's lerp
_transformSystem.SetLocalPositionNoLerp(transform, startingFrom);
_transformSystem.SetLocalPositionNoLerp(e.Sender, startingFrom, e.Component);

glide.EndPos = glidingTo;
glide.MovementPerFrame = CalculateMovementPerFrame(sprite.Icon.Appearance.GlideSize);
Expand Down

0 comments on commit 186d10d

Please sign in to comment.