-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathTools.cs
67 lines (58 loc) · 1.69 KB
/
Tools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Manager;
using UnityEngine;
namespace KK_PovX
{
public static class Tools
{
/// <summary>
/// If the user is in free-roam camera and moving.
/// </summary>
/// <returns></returns>
public static bool InCameraFreeRoamMovement()
{
return
Controller.FreeRoamToggled &&
(
Input.GetKey(KK_PovX.FreeRoamAscendKey.Value.MainKey) ||
Input.GetKey(KK_PovX.FreeRoamDescendKey.Value.MainKey) ||
Input.GetKey(KK_PovX.FreeRoamUpKey.Value.MainKey) ||
Input.GetKey(KK_PovX.FreeRoamDownKey.Value.MainKey) ||
Input.GetKey(KK_PovX.FreeRoamLeftKey.Value.MainKey) ||
Input.GetKey(KK_PovX.FreeRoamRightKey.Value.MainKey)
);
}
public static bool HasPlayerMovement()
{
return
Game.IsInstance() &&
Game.Instance.actScene != null &&
Game.Instance.actScene.Player != null &&
!Game.Instance.actScene.Player.isActionNow;
}
// Find smallest degrees to rotate in order to get to the next angle.
public static float GetClosestAngle(float from, float to, out bool clockwise)
{
float angle = to - from;
clockwise = (angle >= 0f && angle <= 180f) || angle <= -180f;
if (angle < 0)
angle += 360f;
return clockwise ? angle : 360f - angle;
}
// Modulo without negative.
public static float Mod2(float value, float mod)
{
if (value < 0)
value = mod + (value % mod);
return value % mod;
}
// Restrict angle where origin is at angle 0.
public static float AngleClamp(float value, float min, float max)
{
if (value > min && value < 360f - max)
return min;
else if (value < 360f - max && value > min)
return 360f - max;
return value;
}
}
}