This repository was archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHighStep.cs
71 lines (63 loc) · 2.36 KB
/
HighStep.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
68
69
70
71
using MelonLoader;
using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using VRC.SDKBase;
namespace Astrum
{
partial class AstralMovement
{
public static class HighStep
{
public static PropertyInfo m_maxStepHeight;
public static MethodInfo m_GetComponent;
private static bool enabled = false;
[UIProperty<bool>("Movement", "HighStep")]
public static bool Enabled
{
get => enabled;
set {
enabled = value;
if (value)
Set(height);
else Set(0.5f);
}
}
private static float height = 0;
[UIProperty<float>("Movement", "HighStep.Height")]
public static float Height
{
get => height;
set {
height = value;
if (enabled)
Set(value);
}
}
public static void Initialize()
{
m_maxStepHeight = AppDomain.CurrentDomain.GetAssemblies()
.First(x => x.GetName().Name == "Assembly-CSharp")
.GetExportedTypes()
.Where(x => x.BaseType == typeof(MonoBehaviour))
.SelectMany(x => x.GetProperties())
.Where(x => x.PropertyType == typeof(float))
.FirstOrDefault(x => x.Name == "maxStepHeight");
if (m_maxStepHeight is null)
AstralCore.Logger.Warn("Failed to find LocomotionInputController");
else
{
AstralCore.Logger.Info("LocomotionInputController is " + m_maxStepHeight.DeclaringType.Name);
m_GetComponent = typeof(GameObject).GetMethod(nameof(GameObject.GetComponent), new Type[0] { }).MakeGenericMethod(m_maxStepHeight.DeclaringType);
}
}
public static void Set(float height)
{
if (Networking.LocalPlayer?.gameObject is null) return;
object inputController = m_GetComponent.Invoke(Networking.LocalPlayer.gameObject, new object[0] { });
m_maxStepHeight.SetValue(inputController, height);
}
}
}
}