コード例 #1
0
        /// <summary>
        /// Calculate VehicleTurret draw offset given <paramref name="rot"/>
        /// </summary>
        /// <param name="rot"></param>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        /// <param name="rotationOffset"></param>
        /// <param name="turretRotation"></param>
        /// <param name="attachedTo"></param>
        /// <returns></returns>
        public static Pair <float, float> ShipDrawOffset(Rot8 rot, float xOffset, float yOffset, out Pair <float, float> rotationOffset, float turretRotation = 0, VehicleTurret attachedTo = null)
        {
            rotationOffset = new Pair <float, float>(0, 0);
            if (attachedTo != null)
            {
                return(Ext_Math.RotatePointClockwise(attachedTo.turretRenderLocation.x + xOffset, attachedTo.turretRenderLocation.y + yOffset, turretRotation));
            }

            return(rot.AsInt switch
            {
                //North
                0 => new Pair <float, float>(xOffset, yOffset),
                //East
                1 => new Pair <float, float>(yOffset, -xOffset),
                //South
                2 => new Pair <float, float>(-xOffset, -yOffset),
                //West
                3 => new Pair <float, float>(-yOffset, xOffset),
                //NorthEast
                4 => Ext_Math.RotatePointClockwise(yOffset, -xOffset, 45f),
                //SouthEast
                5 => Ext_Math.RotatePointCounterClockwise(yOffset, -xOffset, 45f),
                //SouthWest
                6 => Ext_Math.RotatePointClockwise(-yOffset, xOffset, 45f),
                //NorthWest
                7 => Ext_Math.RotatePointCounterClockwise(-yOffset, xOffset, 45f),
                //Default
                _ => throw new ArgumentOutOfRangeException("VehicleRotation is not within bounds. RotationInt must be between 0 and 7 for each lateral, longitudinal, and diagonal direction.")
            });
コード例 #2
0
 /// <summary>
 /// Calculate VehicleTurret draw offset
 /// </summary>
 /// <param name="vehicle"></param>
 /// <param name="xOffset"></param>
 /// <param name="yOffset"></param>
 /// <param name="rotationOffset"></param>
 /// <param name="turretRotation"></param>
 /// <param name="attachedTo"></param>
 public static Pair <float, float> TurretDrawOffset(float angle, float xOffset, float yOffset, out Pair <float, float> rotationOffset, float turretRotation = 0, VehicleTurret attachedTo = null)
 {
     rotationOffset = new Pair <float, float>(0, 0);
     if (attachedTo != null)
     {
         return(Ext_Math.RotatePointClockwise(attachedTo.turretRenderLocation.x + xOffset, attachedTo.turretRenderLocation.y + yOffset, turretRotation));
     }
     return(Ext_Math.RotatePointClockwise(xOffset, yOffset, angle));
 }