using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GridLock.Core")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6379a3b43be4ae7432101963c1d23ba7fe81d4b2")] [assembly: AssemblyProduct("GridLock.Core")] [assembly: AssemblyTitle("GridLock.Core")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AskaGridLock.Core { public sealed class FreeModeState { private GridPose _offset; public bool IsFree { get; private set; } public void EnterFree(GridPose shownPose, GridPose rawPose) { _offset = shownPose - rawPose; IsFree = true; } public GridPose PoseWhileFree(GridPose rawPose) { return rawPose + _offset; } public void ExitFree() { _offset = default(GridPose); IsFree = false; } public void Reset() { _offset = default(GridPose); IsFree = false; } } public readonly struct GridConfig { public const double MinSpacing = 0.01; public const double MaxSpacing = 100.0; public const double MinRotationStep = 1.0; public const double MaxRotationStep = 180.0; public const double MinSquareSize = 0.01; public const double MaxSquareSize = 1000.0; public double Spacing { get; } public double RotationStep { get; } public double SquareSize { get; } public double Cell { get; } public bool IsUsable { get { if (IsFinite(Spacing) && Spacing > 0.0 && IsFinite(RotationStep) && RotationStep > 0.0 && IsFinite(SquareSize) && SquareSize > 0.0 && IsFinite(Cell)) { return Cell > 0.0; } return false; } } public GridConfig(double spacing, double rotationStep, double squareSize) { Spacing = Clamp(spacing, 0.01, 100.0); RotationStep = Clamp(rotationStep, 1.0, 180.0); SquareSize = Clamp(squareSize, 0.01, 1000.0); Cell = Spacing * SquareSize; } public static bool IsFinite(double value) { if (!double.IsNaN(value)) { return !double.IsInfinity(value); } return false; } private static double Clamp(double value, double min, double max) { if (double.IsNaN(value)) { return min; } if (double.IsPositiveInfinity(value)) { return max; } if (double.IsNegativeInfinity(value)) { return min; } if (value < min) { return min; } if (value > max) { return max; } return value; } } public readonly struct GridPose { public double X { get; } public double Z { get; } public double Yaw { get; } public GridPose(double x, double z, double yaw) { X = x; Z = z; Yaw = yaw; } public static GridPose operator +(GridPose a, GridPose b) { return new GridPose(a.X + b.X, a.Z + b.Z, a.Yaw + b.Yaw); } public static GridPose operator -(GridPose a, GridPose b) { return new GridPose(a.X - b.X, a.Z - b.Z, a.Yaw - b.Yaw); } } public static class SnapMath { public static double SnapAxis(double world, double cell) { if (!GridConfig.IsFinite(cell) || cell <= 0.0) { return world; } double num = Math.Round(world / cell, MidpointRounding.AwayFromZero) * cell; if (!GridConfig.IsFinite(num)) { return world; } return num; } public static GridPose SnapPosition(GridPose pose, double cell) { return new GridPose(SnapAxis(pose.X, cell), SnapAxis(pose.Z, cell), pose.Yaw); } public static double SnapYaw(double yaw, double step) { if (!GridConfig.IsFinite(step) || step <= 0.0) { return yaw; } double num = Math.Round(yaw / step, MidpointRounding.AwayFromZero) * step; if (!GridConfig.IsFinite(num)) { return yaw; } return NormalizeDegrees(num); } private static double NormalizeDegrees(double degrees) { double num = degrees % 360.0; if (num < 0.0) { num += 360.0; } if (num >= 360.0) { num -= 360.0; } return num; } } }