Skip to content

Commit

Permalink
actually fix player collision this time, hide status ui, maybe fix be…
Browse files Browse the repository at this point in the history
…pinex patch
  • Loading branch information
o7Moon committed Nov 5, 2023
1 parent 051a04a commit 186778f
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Plugin : BasePlugin
public static ConfigEntry<KeyCode> save_bind;
public static ConfigEntry<KeyCode> load_bind;
public static ConfigEntry<bool> disable_player_collision;
public static ConfigEntry<bool> hide_status;

public static ConfigEntry<bool> shift_on_load;
public override void Load()
Expand All @@ -30,6 +31,7 @@ public override void Load()
load_bind = Config.Bind<KeyCode>("Keys","Load Position",KeyCode.Mouse0,"the key used for teleporting to the current savestate");
shift_on_load = Config.Bind<bool>("Keys","Shift Load Modifier", true, "if true, must also hold shift to load position");
disable_player_collision = Config.Bind<bool>("Settings","Disable Player Collision",true,"if true, disables collision with other players in practice.");
hide_status = Config.Bind<bool>("Settings","Disable status UI", false, "if true, the status ui (player count, health) is hidden in practice.");

SceneManager.sceneLoaded += (UnityAction<Scene,LoadSceneMode>) onSceneLoad;

Expand Down Expand Up @@ -63,7 +65,6 @@ public static void playerUpdatePost(PlayerMovement __instance){
Rigidbody rb = __instance.GetComponent<Rigidbody>();

PlayerInput input = __instance.GetComponent<PlayerInput>();
//Debug.Log(saved_rot.ToString());
input.desiredX = saved_rot.x;
input.SetMouseOffset(saved_rot.y);
input.cameraRot = new Vector3(saved_rot.y,saved_rot.x,input.actualWallRotation);
Expand All @@ -76,6 +77,16 @@ public static void playerUpdatePost(PlayerMovement __instance){
}
}

[HarmonyPatch(typeof(GameUI), nameof(GameUI.Start))]
[HarmonyPostfix]
public static void onUiStart(GameUI __instance) {
if (!isPractice()) return;
if (!hide_status.Value) return;

Transform s = __instance.transform.FindChild("Status");
if (s != null) s.gameObject.SetActive(false);
}

[HarmonyPatch(typeof(PlayerManager),nameof(PlayerManager.Awake))]
[HarmonyPrefix]
public static void onPlayerAwake(PlayerManager __instance){
Expand All @@ -85,9 +96,12 @@ public static void onPlayerAwake(PlayerManager __instance){
if (!disable_player_collision.Value) return;
if (!isPractice()) return;

// exclude all of this player's colliders from interacting with all of the client player's colliders.
// this is a very questionable way of doing this but its the only way that doesnt break nametags.
foreach (Collider c in __instance.gameObject.GetComponentsInChildren<Collider>()){
if (c.gameObject.layer == 6)// if this collider is ground layer
c.gameObject.layer = 4; // HACK (set collision layer to water)
foreach (Collider l in PlayerInput.Instance.gameObject.GetComponentsInChildren<Collider>()) {
Physics.IgnoreCollision(c, l, true);
}
}
}

Expand All @@ -99,6 +113,11 @@ public static void onPlayerAwake(PlayerManager __instance){
[HarmonyPatch(typeof(MonoBehaviourPublicObjomaOblogaTMObseprUnique), "Method_Public_Void_PDM_2")]
[HarmonyPatch(typeof(MonoBehaviourPublicTeplUnique), "Method_Private_Void_PDM_32")]
static class patch2{
[HarmonyPatch(typeof(MonoBehaviourPublicGataInefObInUnique), "Method_Private_Void_GameObject_Boolean_Vector3_Quaternion_0")]
[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "Method_Private_Void_0")]
[HarmonyPatch(typeof(MonoBehaviourPublicVesnUnique), "Method_Private_Void_0")]
[HarmonyPatch(typeof(MonoBehaviourPublicObjomaOblogaTMObseprUnique), "Method_Public_Void_PDM_2")]
[HarmonyPatch(typeof(MonoBehaviourPublicTeplUnique), "Method_Private_Void_PDM_32")]
[HarmonyPrefix]
public static bool Detect(System.Reflection.MethodBase __originalMethod)
{
Expand Down

0 comments on commit 186778f

Please sign in to comment.