-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
46 lines (40 loc) · 1.24 KB
/
Main.cs
File metadata and controls
46 lines (40 loc) · 1.24 KB
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
using BoneLib;
using MelonLoader;
using UnityEngine;
using static RagdollFix.Preferences;
namespace RagdollFix
{
internal partial class Main : MelonMod
{
private bool _sceneLoaded;
private bool _previousRagdollState;
private bool _currentRagdollState;
public override void OnInitializeMelon()
{
Hooking.OnLevelInitialized += _ => { OnSceneAwake(); };
MelonPreferencesCreator();
BoneMenuCreator();
}
private void OnSceneAwake()
{
_sceneLoaded = true;
_previousRagdollState = Player.physicsRig._legsKinematic;
}
public override void OnUpdate()
{
if (_sceneLoaded)
{
if (IsEnabled)
{
_currentRagdollState = Player.physicsRig._legsKinematic;
if (!_previousRagdollState && _currentRagdollState)
{
var teleport = Player.physicsRig.feet.transform.position + new Vector3(0, 0.25f, 0);
Player.rigManager.Teleport(teleport);
}
}
}
_previousRagdollState = _currentRagdollState;
}
}
}