Snap to nearest cardinal on traversal (#10869)

This commit is contained in:
metalgearsloth
2022-08-29 15:59:19 +10:00
committed by GitHub
parent fe177f4a3e
commit 3fa666bd06
54 changed files with 222 additions and 49 deletions

View File

@@ -916,7 +916,7 @@ namespace Content.Shared.CCVar
/// - When traversing grids it will snap to the nearest cardinal which will generally be imperceptible.
/// </summary>
public static readonly CVarDef<bool> CameraRotationLocked =
CVarDef.Create("shuttle.camera_rotation_locked", true, CVar.REPLICATED);
CVarDef.Create("shuttle.camera_rotation_locked", false, CVar.REPLICATED);
/// <summary>
/// Whether cargo shuttles are enabled.

View File

@@ -10,5 +10,10 @@ namespace Content.Shared.Decals
[DataField("sprite")] public SpriteSpecifier Sprite { get; } = SpriteSpecifier.Invalid;
[DataField("tags")] public List<string> Tags = new();
[DataField("showMenu")] public bool ShowMenu = true;
/// <summary>
/// If the decal is rotated compared to our eye should we snap it to south.
/// </summary>
[DataField("snapCardinals")] public bool SnapCardinals = false;
}
}

View File

@@ -10,6 +10,7 @@ using Content.Shared.Input;
using Content.Shared.Interaction.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Movement.Components;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Throwing;
@@ -797,7 +798,16 @@ namespace Content.Shared.Interaction
RaiseLocalEvent(item, dropMsg, true);
if (dropMsg.Handled)
_adminLogger.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(user):user} dropped {ToPrettyString(item):entity}");
Transform(item).LocalRotation = Angle.Zero;
// If the dropper is rotated then use their targetrelativerotation as the drop rotation
var rotation = Angle.Zero;
if (TryComp<InputMoverComponent>(user, out var mover))
{
rotation = mover.TargetRelativeRotation;
}
Transform(item).LocalRotation = rotation;
}
#endregion

View File

@@ -17,7 +17,7 @@ namespace Content.Shared.Movement.Systems
/// </summary>
public abstract partial class SharedMoverController
{
public bool CameraRotationLocked { get; private set; }
public bool CameraRotationLocked { get; set; }
private void InitializeInput()
{

View File

@@ -202,7 +202,7 @@ namespace Content.Shared.Movement.Systems
var angleDiff = Angle.ShortestDistance(mover.RelativeRotation, mover.TargetRelativeRotation);
// if we've just traversed then lerp to our target rotation.
if (!angleDiff.EqualsApprox(Angle.Zero, 0.005))
if (!angleDiff.EqualsApprox(Angle.Zero, 0.001))
{
var adjustment = angleDiff * 5f * frameTime;
var minAdjustment = 0.005 * frameTime;