Esempio n. 1
0
        /// <summary>
        ///   Whether a <c>Transform</c> is already aligned.
        /// </summary>
        private bool AlreadyAligned(Transform t)
        {
            var     p = t.position;
            Vector3 aligned;

            if (_rectGrid)
            {
                var s = t.lossyScale;
                aligned = _rectGrid.AlignVector3(p, s);
            }
            else if (_hexGrid)
            {
                aligned = _hexGrid.AlignVector3(p);
            }
            else
            {
                const string message = "Only rectangular or hexagonal grids supported.";
                throw new System.NotSupportedException(message);
            }
            var inPlace    = (p - aligned).sqrMagnitude <= Mathf.Epsilon;
            var deltaAngle = Quaternion.Angle(GridTransfrom.rotation, t.rotation);
            var rotated    = !_rotateTransform || deltaAngle <= Mathf.Epsilon;

            return(inPlace && rotated);
        }