From 8c352bd59b1f58a1c08d9292144898a4156bdc83 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Wed, 7 Sep 2022 21:47:30 +1200 Subject: [PATCH] Clickmap changes for engine PR (#11066) --- Content.Client/Clickable/ClickableComponent.cs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Content.Client/Clickable/ClickableComponent.cs b/Content.Client/Clickable/ClickableComponent.cs index 3f4f7b511b..017fef9ca2 100644 --- a/Content.Client/Clickable/ClickableComponent.cs +++ b/Content.Client/Clickable/ClickableComponent.cs @@ -39,20 +39,10 @@ namespace Content.Client.Clickable var transform = _entMan.GetComponent(Owner); var worldRot = transform.WorldRotation; - // We need to convert world angle to a positive value. between 0 and 2pi. This is important for - // CalcRectWorldAngle to get the right angle. Otherwise can get incorrect results for sprites at angles like - // -135 degrees (seems highly specific, but AI actors & other entities can snap to those angles while - // moving). As to why we treat world-angle like this, but not eye angle or world+eye, it is just because - // thats what sprite-rendering does. - worldRot = worldRot.Reduced(); - - if (worldRot.Theta < 0) - worldRot = new Angle(worldRot.Theta + Math.Tau); - var invSpriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix()); // This should have been the rotation of the sprite relative to the screen, but this is not the case with no-rot or directional sprites. - var relativeRotation = worldRot + _eyeManager.CurrentEye.Rotation; + var relativeRotation = (worldRot + _eyeManager.CurrentEye.Rotation).Reduced().FlipPositive(); Angle cardinalSnapping = sprite.SnapCardinals ? relativeRotation.GetCardinalDir().ToAngle() : Angle.Zero; @@ -84,9 +74,7 @@ namespace Content.Client.Clickable if (layer.State == null || layer.ActualRsi is not RSI rsi || !rsi.TryGetState(layer.State, out var rsiState)) continue; - var dir = (rsiState.Directions == RSI.State.DirectionType.Dir1) - ? RSI.State.Direction.South - : relativeRotation.ToRsiDirection(rsiState.Directions); + var dir = SpriteComponent.Layer.GetDirection(rsiState.Directions, relativeRotation); // convert to layer-local coordinates layer.GetLayerDrawMatrix(dir, out var matrix);