Skip to content

Commit

Permalink
Fix 3rd person target acquisition and fix legacy peek footer text
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachHembree committed Mar 25, 2022
1 parent 2ccc84c commit 87bcb81
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void GetBlocksInsideSphere(IMyCubeGrid grid, List<IMySlimBlock> blockList
{
if (grid.PositionComp != null)
{
BoundingBoxD aabb = BoundingBoxD.CreateFromSphere(sphere);
MatrixD matrix = grid.PositionComp.WorldMatrixNormalizedInv;
Vector3D result;

Expand All @@ -115,7 +114,6 @@ public void GetBlocksInsideSphere(IMyCubeGrid grid, List<IMySlimBlock> blockList
(int)Math.Round(boundingBox.Max.Z * gridSizeR)
);

int blockCount = (grid.Max - grid.Min).Volume();
Vector3I start = Vector3I.Max(Vector3I.Min(searchMin, searchMax), grid.Min);
Vector3I end = Vector3I.Min(Vector3I.Max(searchMin, searchMax), grid.Max);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public static MyAdminSettingsEnum AdminSettings
/// <summary>
/// Returns the matrix for the player's head
/// </summary>
public static MatrixD HeadTransform { get { return PlyEnt != null ? PlyEnt.GetHeadMatrix(true) : MatrixD.Zero; } }
public static MatrixD HeadTransform { get { return PlyEnt?.GetHeadMatrix(true) ?? MatrixD.Zero; } }

/// <summary>
/// Returns players position in the world
/// </summary>
public static Vector3D Position { get { return PlyEnt != null ? PlyEnt.GetPosition() : Vector3D.Zero; } }
public static Vector3D Position { get { return PlyEnt?.GetPosition() ?? Vector3D.Zero; } }

/// <summary>
/// Returns false if the player is holding a tool or a weapon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ private bool TryGetTargetedBlockInternal(double maxDist, out IMyTerminalBlock ta
IHitInfo rayInfo;
MatrixD transform = MyAPIGateway.Session.Camera.WorldMatrix;
Vector3D headPos = transform.Translation, forward = transform.Forward;

if (!LocalPlayer.IsSpectating)
headPos += (headPos - LocalPlayer.Position).Length() * forward;

LineD line = new LineD(headPos, headPos + forward * maxDist);
target = null;

Expand Down Expand Up @@ -455,7 +459,9 @@ private bool BlockInRange()

if (Target.TBlock != null)
{
dist = (MyAPIGateway.Session.Camera.Position - Target.Position).LengthSquared();
if (LocalPlayer.IsSpectating)
dist = (MyAPIGateway.Session.Camera.Position - Target.Position).LengthSquared();

dist = Math.Min(dist, (LocalPlayer.Position - Target.Position).LengthSquared());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ private void UpdateFooterText()
$"[Copying {Target.Duplicator.GetSelectedEntryCount()} " +
$"of {Target.Duplicator.GetValidEntryCount()}]", footerFormatLeft);
}
else if ((MenuState & QuickActionMenuState.Peek) > 0)
footer.LeftTextBuilder.SetText("[Peeking]", footerFormatLeft);
else
footer.LeftTextBuilder.SetText($"[{listBody.VisStart + 1} - {listBody.VisStart + listBody.VisCount} of {listBody.EnabledCount}]", footerFormatLeft);

Expand Down

0 comments on commit 87bcb81

Please sign in to comment.