From af604835dd9b213a612f973e3577f35074642161 Mon Sep 17 00:00:00 2001 From: notzerotwo_ <63092138+NotZer0Two@users.noreply.github.com> Date: Mon, 29 Dec 2025 19:33:30 +0100 Subject: [PATCH 1/2] Player Wrapper --- .idea/.idea.MegaAPI/.idea/encodings.xml | 4 + .idea/.idea.MegaAPI/.idea/indexLayout.xml | 8 ++ .idea/.idea.MegaAPI/.idea/vcs.xml | 6 ++ MegaAPI.sln.DotSettings.user | 5 ++ MegaAPI/API/Player.cs | 93 +++++++++++++++++++++++ MegaAPI/Patches/PlayerInitializer.cs | 23 ++++++ 6 files changed, 139 insertions(+) create mode 100644 .idea/.idea.MegaAPI/.idea/encodings.xml create mode 100644 .idea/.idea.MegaAPI/.idea/indexLayout.xml create mode 100644 .idea/.idea.MegaAPI/.idea/vcs.xml create mode 100644 MegaAPI.sln.DotSettings.user create mode 100644 MegaAPI/API/Player.cs create mode 100644 MegaAPI/Patches/PlayerInitializer.cs diff --git a/.idea/.idea.MegaAPI/.idea/encodings.xml b/.idea/.idea.MegaAPI/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.MegaAPI/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.MegaAPI/.idea/indexLayout.xml b/.idea/.idea.MegaAPI/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.MegaAPI/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.MegaAPI/.idea/vcs.xml b/.idea/.idea.MegaAPI/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.MegaAPI/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MegaAPI.sln.DotSettings.user b/MegaAPI.sln.DotSettings.user new file mode 100644 index 0000000..3286347 --- /dev/null +++ b/MegaAPI.sln.DotSettings.user @@ -0,0 +1,5 @@ + + ForceIncluded + ForceIncluded + ForceIncluded + \ No newline at end of file diff --git a/MegaAPI/API/Player.cs b/MegaAPI/API/Player.cs new file mode 100644 index 0000000..c74d592 --- /dev/null +++ b/MegaAPI/API/Player.cs @@ -0,0 +1,93 @@ +namespace MegaAPI.API; + +using Il2Cpp; +using Il2CppPlayer.SoundManager; +using UnityEngine; + +/// +/// The wrapper representing the in-game players. +/// +public static class Player +{ + /// + /// Gets the of the player. + /// + public static PlayerExtraMovement PlayerExtraMovement { get; internal set; } + + /// + /// Gets the of the player. + /// + public static PlayerMovement PlayerMovement { get; internal set; } + + /// + /// Gets the of the player. + /// + public static PlayerMenu PlayerMenu { get; internal set; } + + /// + /// Gets the of the player. + /// + public static getPlayerName GetPlayerName { get; internal set; } + + /// + /// Gets the of the player. + /// + public static SoundManager SoundManager { get; internal set; } + + /// + /// Gets the encapsulated . + /// + public static GameObject GameObject { get; internal set; } + + /// + /// Gets the 's . + /// + public static Transform Transform => PlayerMovement.transform; + + /// + /// Gets or sets the player's FOV. + /// + public static float FOV + { + get => PlayerMovement.FOV; + set => PlayerMovement.FOV = value; + } + + /// + /// Gets or sets the player's Sensitivity. + /// + public static float Sensitivity + { + get => PlayerMovement.Sensitivity; + set => PlayerMovement.SetSensitivity(value); + } + + /// + /// Gets or sets a value indicating whether the player has noclip. + /// + public static bool Noclip + { + get => PlayerMovement.noClip; + set => PlayerMovement.SetNoClip(value); + } + + /// + /// Gets a value indicating whether the player is crouching. + /// + public static bool IsCrouching => PlayerMovement.crouching; + + /// + /// Sets the player gravity. + /// + /// the gravity the player can get added. + public static void SetGravity(float gravity) + { + if (gravity == 1.0) + { + PlayerMovement.extraGravity = false; + } + + PlayerMovement.extraGravity = true; + PlayerMovement.extraGravityStrength = gravity; + } +} diff --git a/MegaAPI/Patches/PlayerInitializer.cs b/MegaAPI/Patches/PlayerInitializer.cs new file mode 100644 index 0000000..3f3147b --- /dev/null +++ b/MegaAPI/Patches/PlayerInitializer.cs @@ -0,0 +1,23 @@ +namespace MegaAPI.Patches; + +using HarmonyLib; +using Il2Cpp; +using MegaAPI.API; + +/// +/// Loads the custom commands. +/// +[HarmonyPatch(typeof(PlayerMovement), nameof(PlayerMovement.Init))] +public class PlayerInitializer +{ + [HarmonyPostfix] + private static void Postfix(PlayerMovement __instance) + { + Player.PlayerMovement = __instance; + Player.PlayerExtraMovement = __instance.extraMovement; + Player.PlayerMenu = __instance.playerMenu.GetComponent(); + Player.GameObject = __instance.gameObject; + + Player.SetGravity(-50); + } +} From 89a9eff52b2322838e4f0114c793013ebd2a521b Mon Sep 17 00:00:00 2001 From: notzerotwo_ <63092138+NotZer0Two@users.noreply.github.com> Date: Tue, 30 Dec 2025 09:13:49 +0100 Subject: [PATCH 2/2] Player Wrapper Completed --- MegaAPI.sln.DotSettings.user | 2 + MegaAPI/API/Player.cs | 265 ++++++++++++++++++++++++++- MegaAPI/Patches/PlayerInitializer.cs | 2 - 3 files changed, 261 insertions(+), 8 deletions(-) diff --git a/MegaAPI.sln.DotSettings.user b/MegaAPI.sln.DotSettings.user index 3286347..1386bfa 100644 --- a/MegaAPI.sln.DotSettings.user +++ b/MegaAPI.sln.DotSettings.user @@ -2,4 +2,6 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded + ForceIncluded \ No newline at end of file diff --git a/MegaAPI/API/Player.cs b/MegaAPI/API/Player.cs index c74d592..df05e26 100644 --- a/MegaAPI/API/Player.cs +++ b/MegaAPI/API/Player.cs @@ -24,11 +24,6 @@ public static class Player /// public static PlayerMenu PlayerMenu { get; internal set; } - /// - /// Gets the of the player. - /// - public static getPlayerName GetPlayerName { get; internal set; } - /// /// Gets the of the player. /// @@ -71,18 +66,149 @@ public static bool Noclip set => PlayerMovement.SetNoClip(value); } + /// + /// Gets or sets a value indicating whether the player has cinematic camera. + /// + public static bool CinematicCamera + { + get => PlayerMovement.cinematicCamera; + set => PlayerMovement.SetCinematicCamera(value); + } + + /// + /// Gets or sets the max speed possible to reach before it gets countered. + /// + // TODO: This makes the game in cheating mode + public static float MaxSpeedGround + { + get => PlayerMovement.maxSpeedNormal; + set => PlayerMovement.maxSpeedNormal = value; + } + + /// + /// Gets or sets the max speed possible to reach before it gets countered. + /// + // TODO: This makes the game in cheating mode + public static float MaxSpeedAir + { + get => PlayerMovement.maxSpeedAir; + set => PlayerMovement.maxSpeedAir = value; + } + + /// + /// Gets or sets the current speed. + /// + /// Try to not set the speed because you could encounter problems with the . + // TODO: This makes the game in cheating mode + public static float Speed + { + get => PlayerMovement.speed; + set => PlayerMovement.speed = value; + } + + /// + /// Gets or sets the current jump force. + /// + /// Try to not set the speed because you could encounter problems with the . + // TODO: This makes the game in cheating mode + public static float JumpForce + { + get => PlayerMovement.jumpForce; + set => PlayerMovement.jumpForce = value; + } + + /// + /// Gets or sets the current wall run tilt. + /// + /// a value less or equal to 0 will make the tilt disable. + public static float Tilt + { + get => PlayerExtraMovement.Tilt; + set + { + if (value <= 0) + { + PlayerExtraMovement.SetWallRunTiltEnabled(false); + return; + } + + PlayerExtraMovement.SetWallRunTiltEnabled(true); + PlayerExtraMovement.Tilt = value; + } + } + + /// + /// Gets a value indicating whether the player is dead. + /// + public static float CurrentCheckpoint => PlayerMovement.checkpoint; + + /// + /// Gets a value indicating whether the player is dead. + /// + public static float CurrentLevel => PlayerMovement.level; + /// /// Gets a value indicating whether the player is crouching. /// public static bool IsCrouching => PlayerMovement.crouching; + /// + /// Gets a value indicating whether the player is grounded. + /// + public static bool IsGrounded => PlayerMovement.grounded; + + /// + /// Gets a value indicating whether the player is grounded. + /// + public static bool IsJumping => !PlayerMovement.grounded; + + /// + /// Gets a value indicating whether the player is on a slope. + /// + public static bool IsOnSlope => PlayerMovement.onSlope; + + /// + /// Gets a value indicating whether the player is wall running. + /// + public static bool IsWallRunning => PlayerExtraMovement.isWallRunning; + + /// + /// Gets a value indicating whether the player is wall jumping. + /// + public static bool IsWallJumping => PlayerExtraMovement.isWallJumping; + + /// + /// Gets a value indicating whether the player is wall running tilt enabled. + /// + public static bool IsTiltEnabled => PlayerExtraMovement.IsWallRunTiltEnabled; + + /// + /// Gets a value indicating whether the player is dead. + /// + public static bool IsDead => PlayerMovement.dead; + + /// + /// Gets a value indicating whether the game is paused. + /// + public static bool IsPaused => PlayerMenu.GameIsPaused; + + /// + /// Gets a value indicating whether the game is restarting. + /// + public static bool IsRestarting => PlayerMenu.isRestarting; + + /// + /// Gets a value indicating whether the player has open settings menu. + /// + public static bool IsSettingOpen => PlayerMenu.settingsMenuOn; + /// /// Sets the player gravity. /// /// the gravity the player can get added. public static void SetGravity(float gravity) { - if (gravity == 1.0) + if (gravity <= 1) { PlayerMovement.extraGravity = false; } @@ -90,4 +216,131 @@ public static void SetGravity(float gravity) PlayerMovement.extraGravity = true; PlayerMovement.extraGravityStrength = gravity; } + + /// + /// Trigger a Fade In animation for the player. + /// + /// the duration of the fade in animation. + public static void FadeIn(float duration) => PlayerMovement.FadeIn(duration); + + /// + /// Forces the player to crouch. + /// + /// Keeps the movement of the player. + public static void ForceCrouch(bool KeepMovement = true) => PlayerMovement.StartCrouch(KeepMovement); + + /// + /// Forces the player to Jump. + /// + public static void ForceJump() => PlayerMovement.Jump(); + + /// + /// Forces the player to die. + /// + /// if the player should die with the message or not. + public static void Kill(bool withMessage = true) => PlayerMenu.Die(withMessage); + + /// + /// Opens the setting menu for the player. + /// + /// if the menu should be open or closed. + public static void OpenSettings(bool mode) + { + if (mode) + PlayerMenu.SetSettingsMenu(true); + else + PlayerMenu.ToggleSettingsMenu(); + } + + /// + /// Pauses the player. + /// + public static void Pause() => PlayerMenu.Pause(); + + /// + /// Resume the player. + /// + public static void Resume() => PlayerMenu.Resume(); + + /// + /// makes the player go to the menu. + /// + public static void BackToMenu() => PlayerMenu.backToMenu(); + + /// + /// Makes the player retry the current level and checkpoint. + /// + public static void Retry() => PlayerMenu.retry(); + + /// + /// Makes the player restart the level. + /// + public static void RestartLevel() => PlayerMenu.restartLevel(); + + /// + /// Makes the player stop all audio sources. + /// + public static void StopAllAudio() => PlayerMenu.StopAllAudio(); + + /// + /// Makes the player able to hear all audio sources. + /// + public static void ResumeAllAudio() => PlayerMenu.ResumeAllAudio(); + + /// + /// Disables the crosshair. + /// + public static void DisableCrosshair() => PlayerMenu.ForceDisableCrosshair(); + + /// + /// Enables the crosshair. + /// + public static void EnableCrosshair() => PlayerMenu.ForceEnableCrosshair(); + + /// + /// Shake the player's camera. + /// + /// the velocity the camera should shake for. + public static void ShakeCamera(float velocity) => SoundManager.HandleCameraShake(velocity); + + /// + /// Plays the death sound for the player. + /// + /// if the sound played should be the one for water. + public static void DeathSound(bool water = false) => SoundManager.DeathSound(water); + + /// + /// Plays the jump sound for the player. + /// + public static void PlayJumpSound() => SoundManager.PlayJumpSound(); + + /// + /// Plays the jump sound for the player. + /// + public static void PlayVaultSound() => SoundManager.PlayVaultSound(); + + /// + /// Plays the sneak sound for the player. + /// + public static void PlaySneakSound() => SoundManager.PlaySneakSound(); + + /// + /// Plays the dash sound for the player. + /// + public static void PlayDashSound() => SoundManager.PlayDashSound(); + + /// + /// Plays the double jump sound for the player. + /// + public static void PlayDoubleJumpSound() => SoundManager.PlayDoubleJumpSound(); + + /// + /// Plays the zoom in sound for the player. + /// + public static void PlayZoomInSound() => SoundManager.PlayZoomInSound(); + + /// + /// Plays the zoom out sound for the player. + /// + public static void PlayZoomOutSound() => SoundManager.PlayZoomOutSound(); } diff --git a/MegaAPI/Patches/PlayerInitializer.cs b/MegaAPI/Patches/PlayerInitializer.cs index 3f3147b..f07529f 100644 --- a/MegaAPI/Patches/PlayerInitializer.cs +++ b/MegaAPI/Patches/PlayerInitializer.cs @@ -17,7 +17,5 @@ private static void Postfix(PlayerMovement __instance) Player.PlayerExtraMovement = __instance.extraMovement; Player.PlayerMenu = __instance.playerMenu.GetComponent(); Player.GameObject = __instance.gameObject; - - Player.SetGravity(-50); } }