Skip to content

Commit

Permalink
style: fix naming violations
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Feb 5, 2024
1 parent 131e8b7 commit 25867e5
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 114 deletions.
8 changes: 4 additions & 4 deletions lc-hax/Scripts/Components/MousePan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class MousePan : MonoBehaviour {
float Pitch { get; set; } = 0.0f;

void OnEnable() {
InputListener.onLeftBracketPress += this.DecreaseMouseSensitivity;
InputListener.onRightBracketPress += this.IncreaseMouseSensitivity;
InputListener.OnLeftBracketPress += this.DecreaseMouseSensitivity;
InputListener.OnRightBracketPress += this.IncreaseMouseSensitivity;
}

void OnDisable() {
InputListener.onLeftBracketPress -= this.DecreaseMouseSensitivity;
InputListener.onRightBracketPress -= this.IncreaseMouseSensitivity;
InputListener.OnLeftBracketPress -= this.DecreaseMouseSensitivity;
InputListener.OnRightBracketPress -= this.IncreaseMouseSensitivity;
}

void IncreaseMouseSensitivity() => this.Sensitivity += 0.1f;
Expand Down
35 changes: 18 additions & 17 deletions lc-hax/Scripts/Components/RigidbodyMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
using GameNetcodeStuff;
using UnityEngine.InputSystem;

namespace Hax;
namespace Hax;

public class RigidbodyMovement : MonoBehaviour {
// Movement constants
const float baseSpeed = 5.0f;
const float sprintSpeedMultiplier = 2.8f; // Multiplier for sprinting speed
const float walkingSpeed = 0.5f; // Walking speed when left control is held
const float sprintDuration = 0.0f; // Duration sprint key must be held for sprinting (adjust as needed)
const float jumpForce = 6.5f;
const float gravity = 10.0f;
const float maxVelocityMagnitude = 12.5f; // Adjust as needed
const float BaseSpeed = 5.0f;
const float SprintSpeedMultiplier = 2.8f; // Multiplier for sprinting speed
const float WalkingSpeed = 0.5f; // Walking speed when left control is held
const float SprintDuration = 0.0f; // Duration sprint key must be held for sprinting (adjust as needed)
const float JumpForce = 6.5f;
const float Gravity = 10.0f;
const float MaxVelocityMagnitude = 12.5f; // Adjust as needed

// Components and state variables
CharacterController CharacterController { get; set; }
Expand All @@ -22,9 +23,9 @@ public class RigidbodyMovement : MonoBehaviour {
Keyboard Keyboard { get; set; } = Keyboard.current;

// Adjust collision box in Awake
const float adjustedWidth = 0.0f; // Adjust as needed
const float adjustedHeight = 0.0f; // Adjust as needed
const float adjustedDepth = -0.5f; // Adjust as needed
const float AdjustedWidth = 0.0f; // Adjust as needed
const float AdjustedHeight = 0.0f; // Adjust as needed
const float AdjustedDepth = -0.5f; // Adjust as needed

public RigidbodyMovement() => this.CharacterController = this.GetComponent<CharacterController>();

Expand All @@ -37,7 +38,7 @@ public void Init() {
void Awake() {
this.CharacterController = this.gameObject.AddComponent<CharacterController>();

this.transform.localScale = new Vector3(adjustedWidth, this.transform.localScale.y, adjustedDepth);
this.transform.localScale = new Vector3(AdjustedWidth, this.transform.localScale.y, AdjustedDepth);
this.CharacterController.height = 0.0f; // Adjust as needed
this.CharacterController.center = new Vector3(0f, 0.3f, 0.5f); // Adjust as needed

Expand All @@ -56,7 +57,7 @@ void Update() {
float speedModifier = 1.0f;

if (this.Keyboard.leftCtrlKey.isPressed) {
speedModifier = walkingSpeed;
speedModifier = WalkingSpeed;
}

// Calculate movement direction relative to character's forward direction
Expand All @@ -66,7 +67,7 @@ void Update() {
moveDirection.y = 0.0f; // Remove vertical component from the movement direction

// Apply speed and sprint modifiers
moveDirection *= (this.IsSprinting ? baseSpeed * sprintSpeedMultiplier : baseSpeed) * speedModifier;
moveDirection *= (this.IsSprinting ? BaseSpeed * SprintSpeedMultiplier : BaseSpeed) * speedModifier;

// Apply gravity
this.ApplyGravity();
Expand All @@ -86,7 +87,7 @@ void Update() {
this.IsSprintHeld = true;
}

if (!this.IsSprinting && this.SprintTimer >= sprintDuration) {
if (!this.IsSprinting && this.SprintTimer >= SprintDuration) {
this.IsSprinting = true;
}

Expand All @@ -105,11 +106,11 @@ void Update() {
// Apply gravity to the character controller
void ApplyGravity() {
Vector3 motion = Vector3.zero;
this.VelocityY -= gravity * Time.deltaTime;
this.VelocityY -= Gravity * Time.deltaTime;
motion.y = this.VelocityY;
_ = this.CharacterController.Move(motion * Time.deltaTime);
}

// Jumping action
void Jump() => this.VelocityY = jumpForce;
void Jump() => this.VelocityY = JumpForce;
}
100 changes: 50 additions & 50 deletions lc-hax/Scripts/Core/InputListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,61 @@
using UnityEngine.InputSystem;

public class InputListener : MonoBehaviour {
public static event Action<bool>? onShiftButtonHold;
public static event Action<bool>? onFButtonHold;
public static event Action<bool>? onEButtonHold;
public static event Action<bool>? onRButtonHold;
public static event Action? onMiddleButtonPress;
public static event Action? onLeftButtonPress;
public static event Action? onLeftButtonRelease;
public static event Action? onRightButtonPress;
public static event Action? onRightButtonRelease;
public static event Action? onLeftArrowKeyPress;
public static event Action? onRightArrowKeyPress;
public static event Action? onPausePress;
public static event Action? onEqualsPress;
public static event Action? onLeftBracketPress;
public static event Action? onRightBracketPress;
public static event Action? onBackslashPress;
public static event Action? onZPress;
public static event Action? onXPress;
public static event Action? onNPress;
public static event Action? onUpArrowPress;
public static event Action? onDownArrowPress;
public static event Action? onF4Press;
public static event Action? onF5Press;
public static event Action<bool>? onLeftButtonHold;
public static event Action<bool>? onRightButtonHold;
public static event Action<bool>? OnShiftButtonHold;
public static event Action<bool>? OnFButtonHold;
public static event Action<bool>? OnEButtonHold;
public static event Action<bool>? OnRButtonHold;
public static event Action? OnMiddleButtonPress;
public static event Action? OnLeftButtonPress;
public static event Action? OnLeftButtonRelease;
public static event Action? OnRightButtonPress;
public static event Action? OnRightButtonRelease;
public static event Action? OnLeftArrowKeyPress;
public static event Action? OnRightArrowKeyPress;
public static event Action? OnPausePress;
public static event Action? OnEqualsPress;
public static event Action? OnLeftBracketPress;
public static event Action? OnRightBracketPress;
public static event Action? OnBackslashPress;
public static event Action? OnZPress;
public static event Action? OnXPress;
public static event Action? OnNPress;
public static event Action? OnUpArrowPress;
public static event Action? OnDownArrowPress;
public static event Action? OnF4Press;
public static event Action? OnF5Press;
public static event Action<bool>? OnLeftButtonHold;
public static event Action<bool>? OnRightButtonHold;

(Func<bool>, Action)[] InputActions { get; } = [
(() => Mouse.current.middleButton.wasPressedThisFrame, () => InputListener.onMiddleButtonPress?.Invoke()),
(() => Mouse.current.leftButton.wasPressedThisFrame, () => InputListener.onLeftButtonPress?.Invoke()),
(() => Mouse.current.leftButton.wasReleasedThisFrame, () => InputListener.onLeftButtonRelease?.Invoke()),
(() => Mouse.current.rightButton.wasPressedThisFrame, () => InputListener.onRightButtonPress?.Invoke()),
(() => Mouse.current.rightButton.wasReleasedThisFrame, () => InputListener.onRightButtonRelease?.Invoke()),
(() => Keyboard.current[Key.Pause].wasPressedThisFrame, () => InputListener.onPausePress?.Invoke()),
(() => Keyboard.current[Key.Equals].wasPressedThisFrame, () => InputListener.onEqualsPress?.Invoke()),
(() => Keyboard.current[Key.LeftArrow].wasPressedThisFrame, () => InputListener.onLeftArrowKeyPress?.Invoke()),
(() => Keyboard.current[Key.RightArrow].wasPressedThisFrame, () => InputListener.onRightArrowKeyPress?.Invoke()),
(() => Keyboard.current[Key.LeftBracket].wasPressedThisFrame, () => InputListener.onLeftBracketPress?.Invoke()),
(() => Keyboard.current[Key.RightBracket].wasPressedThisFrame, () => InputListener.onRightBracketPress?.Invoke()),
(() => Keyboard.current[Key.Backslash].wasPressedThisFrame, () => InputListener.onBackslashPress?.Invoke()),
(() => Keyboard.current[Key.Z].wasPressedThisFrame, () => InputListener.onZPress?.Invoke()),
(() => Keyboard.current[Key.X].wasPressedThisFrame, () => InputListener.onXPress?.Invoke()),
(() => Keyboard.current[Key.N].wasPressedThisFrame, () => InputListener.onNPress?.Invoke()),
(() => Keyboard.current[Key.UpArrow].wasPressedThisFrame, () => InputListener.onUpArrowPress?.Invoke()),
(() => Keyboard.current[Key.DownArrow].wasPressedThisFrame, () => InputListener.onDownArrowPress?.Invoke()),
(() => Keyboard.current[Key.F4].wasPressedThisFrame, () => InputListener.onF4Press?.Invoke()),
(() => Keyboard.current[Key.F5].wasPressedThisFrame, () => InputListener.onF5Press?.Invoke()),
(() => Mouse.current.middleButton.wasPressedThisFrame, () => InputListener.OnMiddleButtonPress?.Invoke()),
(() => Mouse.current.leftButton.wasPressedThisFrame, () => InputListener.OnLeftButtonPress?.Invoke()),
(() => Mouse.current.leftButton.wasReleasedThisFrame, () => InputListener.OnLeftButtonRelease?.Invoke()),
(() => Mouse.current.rightButton.wasPressedThisFrame, () => InputListener.OnRightButtonPress?.Invoke()),
(() => Mouse.current.rightButton.wasReleasedThisFrame, () => InputListener.OnRightButtonRelease?.Invoke()),
(() => Keyboard.current[Key.Pause].wasPressedThisFrame, () => InputListener.OnPausePress?.Invoke()),
(() => Keyboard.current[Key.Equals].wasPressedThisFrame, () => InputListener.OnEqualsPress?.Invoke()),
(() => Keyboard.current[Key.LeftArrow].wasPressedThisFrame, () => InputListener.OnLeftArrowKeyPress?.Invoke()),
(() => Keyboard.current[Key.RightArrow].wasPressedThisFrame, () => InputListener.OnRightArrowKeyPress?.Invoke()),
(() => Keyboard.current[Key.LeftBracket].wasPressedThisFrame, () => InputListener.OnLeftBracketPress?.Invoke()),
(() => Keyboard.current[Key.RightBracket].wasPressedThisFrame, () => InputListener.OnRightBracketPress?.Invoke()),
(() => Keyboard.current[Key.Backslash].wasPressedThisFrame, () => InputListener.OnBackslashPress?.Invoke()),
(() => Keyboard.current[Key.Z].wasPressedThisFrame, () => InputListener.OnZPress?.Invoke()),
(() => Keyboard.current[Key.X].wasPressedThisFrame, () => InputListener.OnXPress?.Invoke()),
(() => Keyboard.current[Key.N].wasPressedThisFrame, () => InputListener.OnNPress?.Invoke()),
(() => Keyboard.current[Key.UpArrow].wasPressedThisFrame, () => InputListener.OnUpArrowPress?.Invoke()),
(() => Keyboard.current[Key.DownArrow].wasPressedThisFrame, () => InputListener.OnDownArrowPress?.Invoke()),
(() => Keyboard.current[Key.F4].wasPressedThisFrame, () => InputListener.OnF4Press?.Invoke()),
(() => Keyboard.current[Key.F5].wasPressedThisFrame, () => InputListener.OnF5Press?.Invoke()),
];

void Update() {
InputListener.onShiftButtonHold?.Invoke(Keyboard.current[Key.LeftShift].isPressed);
InputListener.onFButtonHold?.Invoke(Keyboard.current[Key.F].isPressed);
InputListener.onRButtonHold?.Invoke(Keyboard.current[Key.R].isPressed);
InputListener.onEButtonHold?.Invoke(Keyboard.current[Key.E].isPressed);
InputListener.onLeftButtonHold?.Invoke(Mouse.current.leftButton.isPressed);
InputListener.onRightButtonHold?.Invoke(Mouse.current.rightButton.isPressed);
InputListener.OnShiftButtonHold?.Invoke(Keyboard.current[Key.LeftShift].isPressed);
InputListener.OnFButtonHold?.Invoke(Keyboard.current[Key.F].isPressed);
InputListener.OnRButtonHold?.Invoke(Keyboard.current[Key.R].isPressed);
InputListener.OnEButtonHold?.Invoke(Keyboard.current[Key.E].isPressed);
InputListener.OnLeftButtonHold?.Invoke(Mouse.current.leftButton.isPressed);
InputListener.OnRightButtonHold?.Invoke(Mouse.current.rightButton.isPressed);

foreach ((Func<bool> keyPressed, Action eventAction) in this.InputActions) {
if (!keyPressed()) continue;
Expand Down
4 changes: 2 additions & 2 deletions lc-hax/Scripts/Modules/AntiKickMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public sealed class AntiKickMod : MonoBehaviour {
bool HasAnnouncedGameJoin { get; set; } = false;

void OnEnable() {
InputListener.onBackslashPress += this.ToggleAntiKick;
InputListener.OnBackslashPress += this.ToggleAntiKick;
GameListener.onGameEnd += this.OnGameEnd;
}

void OnDisable() {
InputListener.onBackslashPress -= this.ToggleAntiKick;
InputListener.OnBackslashPress -= this.ToggleAntiKick;
GameListener.onGameEnd -= this.OnGameEnd;
}

Expand Down
8 changes: 4 additions & 4 deletions lc-hax/Scripts/Modules/ChatMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public sealed class ChatMod : MonoBehaviour {
int HistoryIndex { get; set; } = -1;

void OnEnable() {
InputListener.onUpArrowPress += this.CycleBackInHistory;
InputListener.onDownArrowPress += this.CycleForwardInHistory;
InputListener.OnUpArrowPress += this.CycleBackInHistory;
InputListener.OnDownArrowPress += this.CycleForwardInHistory;
Chat.onExecuteCommandAttempt += this.OnHistoryAdded;
}

void OnDisable() {
InputListener.onUpArrowPress -= this.CycleBackInHistory;
InputListener.onDownArrowPress -= this.CycleForwardInHistory;
InputListener.OnUpArrowPress -= this.CycleBackInHistory;
InputListener.OnDownArrowPress -= this.CycleForwardInHistory;
Chat.onExecuteCommandAttempt -= this.OnHistoryAdded;
}

Expand Down
8 changes: 4 additions & 4 deletions lc-hax/Scripts/Modules/ClearVisionMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public sealed class ClearVisionMod : MonoBehaviour {
float LightIntensity { get; set; } = 2.0f;

void OnEnable() {
InputListener.onF4Press += this.DecreaseLightIntensity;
InputListener.onF5Press += this.IncreaseLightIntensity;
InputListener.OnF4Press += this.DecreaseLightIntensity;
InputListener.OnF5Press += this.IncreaseLightIntensity;
}

void OnDisable() {
InputListener.onF4Press -= this.DecreaseLightIntensity;
InputListener.onF5Press -= this.IncreaseLightIntensity;
InputListener.OnF4Press -= this.DecreaseLightIntensity;
InputListener.OnF5Press -= this.IncreaseLightIntensity;
}

void IncreaseLightIntensity() => this.LightIntensity = Math.Clamp(this.LightIntensity + 1.0f, 0.0f, 10.0f);
Expand Down
8 changes: 4 additions & 4 deletions lc-hax/Scripts/Modules/DisconnectMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ public sealed class DisconnectMod : MonoBehaviour {
bool IsShiftHeld { get; set; } = false;

void OnEnable() {
InputListener.onShiftButtonHold += this.HoldShift;
InputListener.onF4Press += this.TryToDisconnect;
InputListener.OnShiftButtonHold += this.HoldShift;
InputListener.OnF4Press += this.TryToDisconnect;
}

void OnDisable() {
InputListener.onShiftButtonHold -= this.HoldShift;
InputListener.onF4Press -= this.TryToDisconnect;
InputListener.OnShiftButtonHold -= this.HoldShift;
InputListener.OnF4Press -= this.TryToDisconnect;
}

void HoldShift(bool isHeld) => this.IsShiftHeld = isHeld;
Expand Down
4 changes: 2 additions & 2 deletions lc-hax/Scripts/Modules/ESPMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ void OnEnable() {
GameListener.onGameStart += this.OnGameJoin;
GameListener.onGameEnd += this.OnGameEnd;
GameListener.onShipLand += this.InitialiseRenderers;
InputListener.onPausePress += this.ToggleESP;
InputListener.OnPausePress += this.ToggleESP;
}

void OnDisable() {
GameListener.onGameStart -= this.OnGameJoin;
GameListener.onGameEnd -= this.OnGameEnd;
GameListener.onShipLand -= this.InitialiseRenderers;
InputListener.onPausePress -= this.ToggleESP;
InputListener.OnPausePress -= this.ToggleESP;
}

void OnGUI() {
Expand Down
16 changes: 8 additions & 8 deletions lc-hax/Scripts/Modules/PhantomMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ public sealed class PhantomMod : MonoBehaviour {
int CurrentSpectatorIndex { get; set; } = 0;

void OnEnable() {
InputListener.onShiftButtonHold += this.HoldShift;
InputListener.onEqualsPress += this.TogglePhantom;
InputListener.onRightArrowKeyPress += this.LookAtNextPlayer;
InputListener.onLeftArrowKeyPress += this.LookAtPreviousPlayer;
InputListener.OnShiftButtonHold += this.HoldShift;
InputListener.OnEqualsPress += this.TogglePhantom;
InputListener.OnRightArrowKeyPress += this.LookAtNextPlayer;
InputListener.OnLeftArrowKeyPress += this.LookAtPreviousPlayer;
}

void OnDisable() {
InputListener.onShiftButtonHold -= this.HoldShift;
InputListener.onEqualsPress -= this.TogglePhantom;
InputListener.onRightArrowKeyPress -= this.LookAtNextPlayer;
InputListener.onLeftArrowKeyPress -= this.LookAtPreviousPlayer;
InputListener.OnShiftButtonHold -= this.HoldShift;
InputListener.OnEqualsPress -= this.TogglePhantom;
InputListener.OnRightArrowKeyPress -= this.LookAtNextPlayer;
InputListener.OnLeftArrowKeyPress -= this.LookAtPreviousPlayer;
}

void Update() {
Expand Down
18 changes: 9 additions & 9 deletions lc-hax/Scripts/Modules/PossessionMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ void Awake() {

// Subscribes to input events and updates components based on the current state
void OnEnable() {
InputListener.onNPress += this.ToggleNoClip;
InputListener.onXPress += this.ToggleRealisticPossession;
InputListener.onZPress += this.Unpossess;
InputListener.onLeftButtonPress += this.UsePrimarySkill;
InputListener.onLeftButtonRelease += this.ReleasePrimarySkill;
InputListener.onRightButtonHold += this.OnRightMouseButtonHold;
InputListener.OnNPress += this.ToggleNoClip;
InputListener.OnXPress += this.ToggleRealisticPossession;
InputListener.OnZPress += this.Unpossess;
InputListener.OnLeftButtonPress += this.UsePrimarySkill;
InputListener.OnLeftButtonRelease += this.ReleasePrimarySkill;
InputListener.OnRightButtonHold += this.OnRightMouseButtonHold;
this.UpdateComponentsOnCurrentState(true);
}

Expand All @@ -62,9 +62,9 @@ void OnRightMouseButtonHold(bool isPressed) {

// Unsubscribes from input events
void OnDisable() {
InputListener.onNPress -= this.ToggleNoClip;
InputListener.onXPress -= this.ToggleRealisticPossession;
InputListener.onZPress -= this.Unpossess;
InputListener.OnNPress -= this.ToggleNoClip;
InputListener.OnXPress -= this.ToggleRealisticPossession;
InputListener.OnZPress -= this.Unpossess;

this.UpdateComponentsOnCurrentState(false);
}
Expand Down
4 changes: 2 additions & 2 deletions lc-hax/Scripts/Modules/StunMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ public sealed class StunMod : MonoBehaviour {
RaycastHit[] RaycastHits { get; set; } = new RaycastHit[100];

void OnEnable() => InputListener.onLeftButtonPress += this.Stun;

O
void OnDisable() => InputListener.onLeftButtonPress -= this.Stun;

bool IsHoldingADefensiveWeapon() => Helper.LocalPlayer?.currentlyHeldObjectServer.Unfake()?.itemProperties.isDefensiveWeapon is true;

O
void StunHitJam(Collider collider) {
if (collider.TryGetComponent(out EnemyAICollisionDetect enemy)) {
if (Setting.EnableStunOnLeftClick) enemy.mainScript.SetEnemyStunned(true, 5.0f);
Expand Down
Loading

0 comments on commit 25867e5

Please sign in to comment.