Skip to content

Commit

Permalink
Input implementation
Browse files Browse the repository at this point in the history
Internal keyword usage (wow!)
  • Loading branch information
SDraw committed Jan 28, 2023
1 parent 9afa795 commit 8737f61
Show file tree
Hide file tree
Showing 22 changed files with 1,045 additions and 631 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Merged set of MelonLoader mods for ChilloutVR.
| Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working |
| Extended Game Notifications | ml_egn | 1.0.0 | Yes | Working
| Four Point Tracking | ml_fpt | 1.0.9 | Retired | Deprecated | In-game feature since 2022r170 update
| Leap Motion Extension | ml_lme | 1.2.9 | Yes | Working |
| Leap Motion Extension | ml_lme | 1.3.0 | Yes, update review | Working |
| Pickup Arm Movement | ml_pam | 1.0.0 | Yes | Working |
| Server Connection Info | ml_sci | 1.0.2 | Retired | Retired | Superseded by `Extended Game Notifications`
3 changes: 2 additions & 1 deletion ml_amt/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ABI_RC.Systems.MovementSystem;
using System.Reflection;
using UnityEngine;
using System.Collections;

namespace ml_amt
{
Expand Down Expand Up @@ -71,7 +72,7 @@ public override void OnInitializeMelon()
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
}

System.Collections.IEnumerator WaitForLocalPlayer()
IEnumerator WaitForLocalPlayer()
{
while(PlayerSetup.Instance == null)
yield return null;
Expand Down
8 changes: 4 additions & 4 deletions ml_amt/MotionTweaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ enum PoseState

readonly List<AvatarParameter> m_parameters = null;

public MotionTweaker()
internal MotionTweaker()
{
m_parameters = new List<AvatarParameter>();
}
Expand Down Expand Up @@ -159,7 +159,7 @@ void Update()
}
}

public void OnAvatarClear()
internal void OnAvatarClear()
{
m_vrIk = null;
m_locomotionLayer = -1;
Expand All @@ -181,7 +181,7 @@ public void OnAvatarClear()
m_parameters.Clear();
}

public void OnSetupAvatar()
internal void OnSetupAvatar()
{
m_isInVR = Utils.IsInVR();
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>();
Expand Down Expand Up @@ -239,7 +239,7 @@ public void OnSetupAvatar()
m_avatarReady = true;
}

public void OnCalibrate()
internal void OnCalibrate()
{
if(m_avatarReady && BodySystem.isCalibratedAsFullBody && BodySystem.enableHipTracking && !BodySystem.enableRightFootTracking && !BodySystem.enableLeftFootTracking && !BodySystem.enableLeftKneeTracking && !BodySystem.enableRightKneeTracking)
{
Expand Down
30 changes: 16 additions & 14 deletions ml_amt/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,24 @@ enum ModSetting
static public event Action<bool> FollowHipsChange;
static public event Action<bool> CollisionScaleChange;

public static void Init()
internal static void Init()
{
ms_category = MelonLoader.MelonPreferences.CreateCategory("AMT");

ms_entries = new List<MelonLoader.MelonPreferences_Entry>();
ms_entries.Add(ms_category.CreateEntry(ModSetting.IKOverrideCrouch.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), 65));
ms_entries.Add(ms_category.CreateEntry(ModSetting.IKOverrideProne.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.ProneLimit.ToString(), 30));
ms_entries.Add(ms_category.CreateEntry(ModSetting.PoseTransitions.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.AdjustedMovement.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.IKOverrideFly.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.IKOverrideJump.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.FollowHips.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.CollisionScale.ToString(), true));
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
{
ms_category.CreateEntry(ModSetting.IKOverrideCrouch.ToString(), true),
ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), 65),
ms_category.CreateEntry(ModSetting.IKOverrideProne.ToString(), true),
ms_category.CreateEntry(ModSetting.ProneLimit.ToString(), 30),
ms_category.CreateEntry(ModSetting.PoseTransitions.ToString(), true),
ms_category.CreateEntry(ModSetting.AdjustedMovement.ToString(), true),
ms_category.CreateEntry(ModSetting.IKOverrideFly.ToString(), true),
ms_category.CreateEntry(ModSetting.IKOverrideJump.ToString(), true),
ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), true),
ms_category.CreateEntry(ModSetting.FollowHips.ToString(), true),
ms_category.CreateEntry(ModSetting.CollisionScale.ToString(), true)
};

Load();

Expand Down Expand Up @@ -194,7 +196,7 @@ static void OnToggleUpdate(string p_name, string p_value)
FollowHipsChange?.Invoke(ms_followHips);
}
break;

case ModSetting.CollisionScale:
{
ms_collisionScale = bool.Parse(p_value);
Expand Down
8 changes: 4 additions & 4 deletions ml_dht/HeadTracked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void OnLookIKPostUpdate()
}
}

public void OnEyeControllerUpdate(CVREyeController p_component)
internal void OnEyeControllerUpdate(CVREyeController p_component)
{
if(m_enabled)
{
Expand All @@ -99,7 +99,7 @@ public void OnEyeControllerUpdate(CVREyeController p_component)
}
}

public void OnFaceTrackingUpdate(CVRFaceTracking p_component)
internal void OnFaceTrackingUpdate(CVRFaceTracking p_component)
{
if(m_enabled && m_faceOverride)
{
Expand All @@ -117,7 +117,7 @@ public void OnFaceTrackingUpdate(CVRFaceTracking p_component)
}
}

public void OnSetupAvatar()
internal void OnSetupAvatar()
{
m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent<CVRAvatar>();
m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head);
Expand All @@ -130,7 +130,7 @@ public void OnSetupAvatar()
m_lookIK.solver.OnPostUpdate += this.OnLookIKPostUpdate;

}
public void OnAvatarClear()
internal void OnAvatarClear()
{
m_avatarDescriptor = null;
m_lookIK = null;
Expand Down
57 changes: 31 additions & 26 deletions ml_dht/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,46 @@ enum ModSetting
Smoothing,
FaceOverride
}

static bool ms_enabled = false;
static bool ms_headTracking = true;
static bool ms_eyeTracking = true;
static bool ms_blinking = true;
static bool ms_mirrored = false;
static float ms_smoothing = 0.5f;
static bool ms_faceOverride = true;

static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;

static public event Action<bool> EnabledChange;
static public event Action<bool> HeadTrackingChange;
static public event Action<bool> EyeTrackingChange;
static public event Action<bool> BlinkingChange;
static public event Action<bool> MirroredChange;
static public event Action<float> SmoothingChange;
static public event Action<bool> FaceOverrideChange;
public static void Init()

internal static void Init()
{
ms_category = MelonLoader.MelonPreferences.CreateCategory("DHT");

ms_entries = new List<MelonLoader.MelonPreferences_Entry>();
ms_entries.Add(ms_category.CreateEntry(ModSetting.Enabled.ToString(), false));
ms_entries.Add(ms_category.CreateEntry(ModSetting.HeadTracking.ToString(), false));
ms_entries.Add(ms_category.CreateEntry(ModSetting.EyeTracking.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.Blinking.ToString(), true));
ms_entries.Add(ms_category.CreateEntry(ModSetting.Mirrored.ToString(), false));
ms_entries.Add(ms_category.CreateEntry(ModSetting.Smoothing.ToString(), 50));
ms_entries.Add(ms_category.CreateEntry(ModSetting.FaceOverride.ToString(), true));


ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
{
ms_category.CreateEntry(ModSetting.Enabled.ToString(), false),
ms_category.CreateEntry(ModSetting.HeadTracking.ToString(), false),
ms_category.CreateEntry(ModSetting.EyeTracking.ToString(), true),
ms_category.CreateEntry(ModSetting.Blinking.ToString(), true),
ms_category.CreateEntry(ModSetting.Mirrored.ToString(), false),
ms_category.CreateEntry(ModSetting.Smoothing.ToString(), 50),
ms_category.CreateEntry(ModSetting.FaceOverride.ToString(), true)
};

Load();

MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
}

static System.Collections.IEnumerator WaitMainMenuUi()
{
while(ViewManager.Instance == null)
Expand All @@ -76,18 +78,18 @@ static System.Collections.IEnumerator WaitMainMenuUi()
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSettingDHT", l_entry.DisplayName, l_entry.GetValueAsString());
};
}

static void Load()
{
ms_enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
ms_headTracking = (bool)ms_entries[(int)ModSetting.HeadTracking].BoxedValue;
ms_eyeTracking = (bool)ms_entries[(int)ModSetting.EyeTracking].BoxedValue;
ms_blinking = (bool)ms_entries[(int)ModSetting.Blinking].BoxedValue;
ms_headTracking = (bool)ms_entries[(int)ModSetting.HeadTracking].BoxedValue;
ms_eyeTracking = (bool)ms_entries[(int)ModSetting.EyeTracking].BoxedValue;
ms_blinking = (bool)ms_entries[(int)ModSetting.Blinking].BoxedValue;
ms_mirrored = (bool)ms_entries[(int)ModSetting.Mirrored].BoxedValue;
ms_smoothing = ((int)ms_entries[(int)ModSetting.Smoothing].BoxedValue) * 0.01f;
ms_faceOverride = (bool)ms_entries[(int)ModSetting.FaceOverride].BoxedValue;
}

static void OnSliderUpdate(string p_name, string p_value)
{
if(Enum.TryParse(p_name, out ModSetting l_setting))
Expand All @@ -105,7 +107,7 @@ static void OnSliderUpdate(string p_name, string p_value)
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
}
}

static void OnToggleUpdate(string p_name, string p_value)
{
if(Enum.TryParse(p_name, out ModSetting l_setting))
Expand All @@ -130,13 +132,15 @@ static void OnToggleUpdate(string p_name, string p_value)
{
ms_eyeTracking = bool.Parse(p_value);
EyeTrackingChange?.Invoke(ms_eyeTracking);
} break;
}
break;

case ModSetting.Blinking:
{
ms_blinking = bool.Parse(p_value);
BlinkingChange?.Invoke(ms_blinking);
} break;
}
break;

case ModSetting.Mirrored:
{
Expand All @@ -149,13 +153,14 @@ static void OnToggleUpdate(string p_name, string p_value)
{
ms_faceOverride = bool.Parse(p_value);
FaceOverrideChange?.Invoke(ms_faceOverride);
} break;
}
break;
}

ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
}
}

public static bool Enabled
{
get => ms_enabled;
Expand Down
2 changes: 1 addition & 1 deletion ml_dht/ml_dht.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\"</PostBuildEvent>
<PostBuildEvent>copy /y "$(TargetPath)" "D:\Games\Steam\steamapps\common\ChilloutVR\Mods\"</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion ml_dht/ml_dht.csproj.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferencePath>C:\Games\Steam\common\ChilloutVR\MelonLoader\;C:\Games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath>
<ReferencePath>D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\;D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions ml_egn/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void OnPropSpawned()
else
{
if(Utils.IsMenuOpened())
ViewManager.Instance.TriggerAlert("Prop Error", "Not connected to live instance", -1, true);
Utils.ShowMenuAlert("Prop Error", "Not connected to live instance");
else
Utils.ShowHUDNotification("(Local) Client", "Unable to spawn prop", "Not connected to live instance");
}
Expand All @@ -70,7 +70,7 @@ static void OnPropSpawned()
}
}

static void OnGameNetworkConnectionClosed(object __0, DisconnectedEventArgs __1)
static void OnGameNetworkConnectionClosed(DisconnectedEventArgs __1)
{
try
{
Expand Down
Loading

0 comments on commit 8737f61

Please sign in to comment.