mirror of
https://github.com/creazy231/cs2-css-flashlight.git
synced 2026-09-27 20:17:04 +02:00
🔦 Modernize flashlight for CSS/.NET 10
Bump to CounterStrikeSharp 1.0.371 and .NET 10, replace per-tick light spawns with a parented light_barn, add plugin config, real unit tests, and refresh CI plus docs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
081278a8ae
commit
a0ef6311ee
13 changed files with 847 additions and 434 deletions
62
Flashlight/FlashlightLogic.cs
Normal file
62
Flashlight/FlashlightLogic.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Flashlight;
|
||||
|
||||
public static class FlashlightLogic
|
||||
{
|
||||
public static bool TryToggle(ref bool isOn, ref bool canToggle)
|
||||
{
|
||||
if (!canToggle)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
isOn = !isOn;
|
||||
canToggle = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsUsePressedEdge(bool usePressed, bool wasUsePressed)
|
||||
{
|
||||
return usePressed && !wasUsePressed;
|
||||
}
|
||||
|
||||
public static float GetEyeOffsetZ(bool isCrouching, float standOffset, float crouchOffset)
|
||||
{
|
||||
return isCrouching ? crouchOffset : standOffset;
|
||||
}
|
||||
|
||||
public static Vector3 CalculateLightOrigin(
|
||||
Vector3 pawnOrigin,
|
||||
Vector3 forward,
|
||||
float eyeOffsetZ,
|
||||
float forwardDistance)
|
||||
{
|
||||
return new Vector3(
|
||||
pawnOrigin.X + forward.X * forwardDistance,
|
||||
pawnOrigin.Y + forward.Y * forwardDistance,
|
||||
pawnOrigin.Z + eyeOffsetZ + forward.Z * forwardDistance);
|
||||
}
|
||||
|
||||
public static Vector3 ForwardFromAnglesDegrees(float pitch, float yaw)
|
||||
{
|
||||
var pitchRad = pitch * (MathF.PI / 180f);
|
||||
var yawRad = yaw * (MathF.PI / 180f);
|
||||
var cosPitch = MathF.Cos(pitchRad);
|
||||
|
||||
return new Vector3(
|
||||
cosPitch * MathF.Cos(yawRad),
|
||||
cosPitch * MathF.Sin(yawRad),
|
||||
-MathF.Sin(pitchRad));
|
||||
}
|
||||
|
||||
public static bool ShouldCreateLight(bool isOn, bool hasValidLight)
|
||||
{
|
||||
return isOn && !hasValidLight;
|
||||
}
|
||||
|
||||
public static bool ShouldDestroyLight(bool isOn, bool hasValidLight)
|
||||
{
|
||||
return !isOn && hasValidLight;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue