Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .idea/.idea.MegaAPI/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.MegaAPI/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.MegaAPI/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions MegaAPI.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AgameDebug_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F28fd596fa01147c5ac2fa6b92cff5209352a00_003Fc6_003Fa7afb9b6_003FgameDebug_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIConsoleCommand_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F28fd596fa01147c5ac2fa6b92cff5209352a00_003F6d_003Fefadd0cc_003FIConsoleCommand_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMelonMod_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F6111a3fd3a7766d590da5a83875564ed5292844da3cfc646e9b30c879e853f8_003FMelonMod_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APlayerMenu_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F28fd596fa01147c5ac2fa6b92cff5209352a00_003Fd7_003F06597227_003FPlayerMenu_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASoundManager_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F28fd596fa01147c5ac2fa6b92cff5209352a00_003F1f_003Fd37b7dec_003FSoundManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
</wpf:ResourceDictionary>
346 changes: 346 additions & 0 deletions MegaAPI/API/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
namespace MegaAPI.API;

using Il2Cpp;
using Il2CppPlayer.SoundManager;
using UnityEngine;

/// <summary>
/// The wrapper representing the in-game players.
/// </summary>
public static class Player
{
/// <summary>
/// Gets the <see cref="PlayerExtraMovement"/> of the player.
/// </summary>
public static PlayerExtraMovement PlayerExtraMovement { get; internal set; }

/// <summary>
/// Gets the <see cref="PlayerMovement"/> of the player.
/// </summary>
public static PlayerMovement PlayerMovement { get; internal set; }

/// <summary>
/// Gets the <see cref="PlayerMenu"/> of the player.
/// </summary>
public static PlayerMenu PlayerMenu { get; internal set; }

/// <summary>
/// Gets the <see cref="SoundManager"/> of the player.
/// </summary>
public static SoundManager SoundManager { get; internal set; }

/// <summary>
/// Gets the encapsulated <see cref="UnityEngine.GameObject"/>.
/// </summary>
public static GameObject GameObject { get; internal set; }

/// <summary>
/// Gets the <see cref="PlayerMovement"/>'s <see cref="UnityEngine.Transform"/>.
/// </summary>
public static Transform Transform => PlayerMovement.transform;

/// <summary>
/// Gets or sets the player's FOV.
/// </summary>
public static float FOV
{
get => PlayerMovement.FOV;
set => PlayerMovement.FOV = value;
}

/// <summary>
/// Gets or sets the player's Sensitivity.
/// </summary>
public static float Sensitivity
{
get => PlayerMovement.Sensitivity;
set => PlayerMovement.SetSensitivity(value);
}

/// <summary>
/// Gets or sets a value indicating whether the player has noclip.
/// </summary>
public static bool Noclip
{
get => PlayerMovement.noClip;
set => PlayerMovement.SetNoClip(value);
}

/// <summary>
/// Gets or sets a value indicating whether the player has cinematic camera.
/// </summary>
public static bool CinematicCamera
{
get => PlayerMovement.cinematicCamera;
set => PlayerMovement.SetCinematicCamera(value);
}

/// <summary>
/// Gets or sets the max speed possible to reach before it gets countered. <seealso cref="PlayerMovement.CounterMovement"/>
/// </summary>
// TODO: This makes the game in cheating mode
public static float MaxSpeedGround
{
get => PlayerMovement.maxSpeedNormal;
set => PlayerMovement.maxSpeedNormal = value;
}

/// <summary>
/// Gets or sets the max speed possible to reach before it gets countered. <seealso cref="PlayerMovement.CounterMovement"/>
/// </summary>
// TODO: This makes the game in cheating mode
public static float MaxSpeedAir
{
get => PlayerMovement.maxSpeedAir;
set => PlayerMovement.maxSpeedAir = value;
}

/// <summary>
/// Gets or sets the current speed.
/// </summary>
/// <remarks>Try to not set the speed because you could encounter problems with the <see cref="PlayerMovement.CounterMovement"/>.</remarks>
// TODO: This makes the game in cheating mode
public static float Speed
{
get => PlayerMovement.speed;
set => PlayerMovement.speed = value;
}

/// <summary>
/// Gets or sets the current jump force.
/// </summary>
/// <remarks>Try to not set the speed because you could encounter problems with the <see cref="PlayerMovement.CounterMovement"/>.</remarks>
// TODO: This makes the game in cheating mode
public static float JumpForce
{
get => PlayerMovement.jumpForce;
set => PlayerMovement.jumpForce = value;
}

/// <summary>
/// Gets or sets the current wall run tilt.
/// </summary>
/// <remarks>a value less or equal to 0 will make the tilt disable.</remarks>
public static float Tilt
{
get => PlayerExtraMovement.Tilt;
set
{
if (value <= 0)
{
PlayerExtraMovement.SetWallRunTiltEnabled(false);
return;
}

PlayerExtraMovement.SetWallRunTiltEnabled(true);
PlayerExtraMovement.Tilt = value;
}
}

/// <summary>
/// Gets a value indicating whether the player is dead.
/// </summary>
public static float CurrentCheckpoint => PlayerMovement.checkpoint;

/// <summary>
/// Gets a value indicating whether the player is dead.
/// </summary>
public static float CurrentLevel => PlayerMovement.level;

/// <summary>
/// Gets a value indicating whether the player is crouching.
/// </summary>
public static bool IsCrouching => PlayerMovement.crouching;

/// <summary>
/// Gets a value indicating whether the player is grounded.
/// </summary>
public static bool IsGrounded => PlayerMovement.grounded;

/// <summary>
/// Gets a value indicating whether the player is grounded.
/// </summary>
public static bool IsJumping => !PlayerMovement.grounded;

/// <summary>
/// Gets a value indicating whether the player is on a slope.
/// </summary>
public static bool IsOnSlope => PlayerMovement.onSlope;

/// <summary>
/// Gets a value indicating whether the player is wall running.
/// </summary>
public static bool IsWallRunning => PlayerExtraMovement.isWallRunning;

/// <summary>
/// Gets a value indicating whether the player is wall jumping.
/// </summary>
public static bool IsWallJumping => PlayerExtraMovement.isWallJumping;

/// <summary>
/// Gets a value indicating whether the player is wall running tilt enabled.
/// </summary>
public static bool IsTiltEnabled => PlayerExtraMovement.IsWallRunTiltEnabled;

/// <summary>
/// Gets a value indicating whether the player is dead.
/// </summary>
public static bool IsDead => PlayerMovement.dead;

/// <summary>
/// Gets a value indicating whether the game is paused.
/// </summary>
public static bool IsPaused => PlayerMenu.GameIsPaused;

/// <summary>
/// Gets a value indicating whether the game is restarting.
/// </summary>
public static bool IsRestarting => PlayerMenu.isRestarting;

/// <summary>
/// Gets a value indicating whether the player has open settings menu.
/// </summary>
public static bool IsSettingOpen => PlayerMenu.settingsMenuOn;

/// <summary>
/// Sets the player gravity.
/// </summary>
/// <param name="gravity">the gravity the player can get added.</param>
public static void SetGravity(float gravity)
{
if (gravity <= 1)
{
PlayerMovement.extraGravity = false;
}

PlayerMovement.extraGravity = true;
PlayerMovement.extraGravityStrength = gravity;
}

/// <summary>
/// Trigger a Fade In animation for the player.
/// </summary>
/// <param name="duration">the duration of the fade in animation.</param>
public static void FadeIn(float duration) => PlayerMovement.FadeIn(duration);

/// <summary>
/// Forces the player to crouch.
/// </summary>
/// <param name="KeepMovement">Keeps the movement of the player.</param>
public static void ForceCrouch(bool KeepMovement = true) => PlayerMovement.StartCrouch(KeepMovement);

/// <summary>
/// Forces the player to Jump.
/// </summary>
public static void ForceJump() => PlayerMovement.Jump();

/// <summary>
/// Forces the player to die.
/// </summary>
/// <param name="withMessage">if the player should die with the message or not.</param>
public static void Kill(bool withMessage = true) => PlayerMenu.Die(withMessage);

/// <summary>
/// Opens the setting menu for the player.
/// </summary>
/// <param name="mode">if the menu should be open or closed.</param>
public static void OpenSettings(bool mode)
{
if (mode)
PlayerMenu.SetSettingsMenu(true);
else
PlayerMenu.ToggleSettingsMenu();
}

/// <summary>
/// Pauses the player.
/// </summary>
public static void Pause() => PlayerMenu.Pause();

/// <summary>
/// Resume the player.
/// </summary>
public static void Resume() => PlayerMenu.Resume();

/// <summary>
/// makes the player go to the menu.
/// </summary>
public static void BackToMenu() => PlayerMenu.backToMenu();

/// <summary>
/// Makes the player retry the current level and checkpoint.
/// </summary>
public static void Retry() => PlayerMenu.retry();

/// <summary>
/// Makes the player restart the level.
/// </summary>
public static void RestartLevel() => PlayerMenu.restartLevel();

/// <summary>
/// Makes the player stop all audio sources.
/// </summary>
public static void StopAllAudio() => PlayerMenu.StopAllAudio();

/// <summary>
/// Makes the player able to hear all audio sources.
/// </summary>
public static void ResumeAllAudio() => PlayerMenu.ResumeAllAudio();

/// <summary>
/// Disables the crosshair.
/// </summary>
public static void DisableCrosshair() => PlayerMenu.ForceDisableCrosshair();

/// <summary>
/// Enables the crosshair.
/// </summary>
public static void EnableCrosshair() => PlayerMenu.ForceEnableCrosshair();

/// <summary>
/// Shake the player's camera.
/// </summary>
/// <param name="velocity">the velocity the camera should shake for.</param>
public static void ShakeCamera(float velocity) => SoundManager.HandleCameraShake(velocity);

/// <summary>
/// Plays the death sound for the player.
/// </summary>
/// <param name="water">if the sound played should be the one for water.</param>
public static void DeathSound(bool water = false) => SoundManager.DeathSound(water);

/// <summary>
/// Plays the jump sound for the player.
/// </summary>
public static void PlayJumpSound() => SoundManager.PlayJumpSound();

/// <summary>
/// Plays the jump sound for the player.
/// </summary>
public static void PlayVaultSound() => SoundManager.PlayVaultSound();

/// <summary>
/// Plays the sneak sound for the player.
/// </summary>
public static void PlaySneakSound() => SoundManager.PlaySneakSound();

/// <summary>
/// Plays the dash sound for the player.
/// </summary>
public static void PlayDashSound() => SoundManager.PlayDashSound();

/// <summary>
/// Plays the double jump sound for the player.
/// </summary>
public static void PlayDoubleJumpSound() => SoundManager.PlayDoubleJumpSound();

/// <summary>
/// Plays the zoom in sound for the player.
/// </summary>
public static void PlayZoomInSound() => SoundManager.PlayZoomInSound();

/// <summary>
/// Plays the zoom out sound for the player.
/// </summary>
public static void PlayZoomOutSound() => SoundManager.PlayZoomOutSound();
}
Loading