🔍 s&box Package Code Search
Search C# source code, UI razor templates, shaders, and configs across s&box packages.
🔗 Raw Facepunch API Link: https://public.facepunch.com/sbox/code/search/1/?ident=notpointless.chomnr_head_bobbing_effect&take=20
Showing code results for query:
*
(3 total matches found)
Game
library
using System;
namespace Sandbox;
[Title( "Head Bobbing Effect" )]
[Category( "Camera" )]
[Description( "Polished first-person camera motion driven by player velocity." )]
[Icon( "visibility" )]
public sealed class FirstPersonHeadBob : Component
{
const float MeanAbsoluteCosine = 0.6366198f;
[Property, Group( "Motion" ), Range( 0f, 2f )]
public float Amount { get; set; } = 1f;
[Property, Group( "Motion" ), Range( 0f, 3f )]
public float HorizontalAmount { get; set; } = 0.85f;
[Property, Group( "Motion" ), Range( 0f, 3f )]
public float VerticalAmount { get; set; } = 1.2f;
[Property, Group( "Motion" ), Range( 0.5f, 4f )]
public float StepFrequency { get; set; } = 1.9f;
[Property, Group( "Motion" ), Range( 0f, 0.5f )]
public float GaitDetail { get; set; } = 0.12f;
[Property, Group( "Motion" ), Range( 0.25f, 1f )]
public float CrouchMultiplier { get; set; } = 0.72f;
[Property, Group( "Idle" ), Range( 0f, 1f )]
public float IdleAmount { get; set; } = 0.5f;
[Property, Group( "Idle" ), Range( 0.05f, 1f )]
public float BreathingFrequency { get; set; } = 0.23f;
[Property, Group( "Idle" ), Range( 0f, 1f )]
public float IdlePitchAmount { get; set; } = 0.32f;
[Property, Group( "Rotation" ), Range( 0f, 2f )]
public float PitchAmount { get; set; } = 0.38f;
[Property, Group( "Rotation" ), Range( 0f, 2f )]
public float RollAmount { get; set; } = 0.62f;
[Property, Group( "Velocity" ), Range( 0f, 2f )]
public float VelocityPitchAmount { get; set; } = 0.32f;
[Property, Group( "Velocity" ), Range( 0f, 3f )]
public float VelocityRollAmount { get; set; } = 0.75f;
[Property, Group( "Velocity" ), Range( 0f, 3f )]
public float InertiaAmount { get; set; } = 0.85f;
[Property, Group( "Velocity" ), Range( 1f, 30f )]
public float VelocitySmoothing { get; set; } = 6.5f;
[Property, Group( "Velocity" ), Range( 1f, 30f )]
public float InertiaSmoothing { get; set; } = 3.5f;
[Property, Group( "Response" ), Range( 1f, 30f )]
public float BlendSpeed { get; set; } = 6.5f;
[Property, Group( "Response" ), Range( 1f, 30f )]
public float CadenceSmoothing { get; set; } = 5.5f;
[Property, Group( "Response" ), Range( 1f, 30f )]
public float AirborneBlendSpeed { get; set; } = 5f;
[Property, Group( "Landing" ), Range( 0f, 4f )]
public float LandingDip { get; set; } = 1.6f;
[Property, Group( "Landing" ), Range( 1f, 30f )]
public float LandingSpring { get; set; } = 15f;
[Property, Group( "Landing" ), Range( 0.1f, 2f )]
public float LandingDamping { get; set; } = 0.82f;
[Property, Group( "Speed" ), Range( 0f, 100f )]
public float MinimumSpeed { get; set; } = 1.5f;
[Property, Group( "Speed" ), Range( 1f, 500f )]
public float ReferenceSpeed { get; set; } = 110f;
[Property, Group( "Speed" ), Range( 1f, 3f )]
public float MaximumSpeedScale { get; set; } = 1.65f;
[Property, Group( "Safety" ), Range( 0.5f, 8f )]
public float MaximumPositionOffset { get; set; } = 3.5f;
[Property, Group( "Safety" ), Range( 0.5f, 5f )]
public float MaximumRotationOffset { get; set; } = 2.5f;
PlayerController Controller { get; set; }
float _gaitPhase;
float _idlePhase;
float _movementStrength;
float _cadence;
float _landingOffset;
float _landingVelocity;
float _lastVerticalVelocity;
Vector3 _velocity;
Vector3 _smoothedVelocity;
Vector3 _inertiaVelocity;
bool _wasGrounded;
bool _isGrounded;
bool _initialized;
protected override void OnStart()
{
Controller = Components.Get<PlayerController>();
InitializeState();
}
protected override void OnDisabled()
{
_initialized = false;
_movementStrength = 0f;
_cadence = 0f;
_landingOffset = 0f;
_landingVelocity = 0f;
}
protected override void OnUpdate()
{
Controller ??= Components.Get<PlayerController>();
if ( !Controller.IsValid() || IsProxy || Controller.ThirdPerson )
{
_initialized = false;
return;
}
if ( !_initialized )
InitializeState();
var delta = MathF.Min( Time.Delta, 0.05f );
if ( delta <= 0f )
return;
_velocity = Controller.Velocity;
var planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );
var planarSpeed = planarVelocity.Length;
var grounded = Controller.IsOnGround;
var moving = grounded && planarSpeed >= MinimumSpeed;
var referenceSpeed = MathF.Max( ReferenceSpeed, 1f );
var speedScale = (planarSpeed / referenceSpeed).Clamp( 0f, MaximumSpeedScale );
var crouchScale = Controller.IsDucking ? CrouchMultiplier : 1f;
var targetStrength = moving ? speedScale * crouchScale : 0f;
var targetCadence = moving ? speedScale * MathF.Sqrt( crouchScale ) : 0f;
var movementBlendSpeed = grounded ? BlendSpeed : AirborneBlendSpeed;
_movementStrength = MathX.LerpTo(
_movementStrength,
targetStrength,
ExponentialBlend( movementBlendSpeed, delta )
);
_cadence = MathX.LerpTo(
_cadence,
targetCadence,
ExponentialBlend( CadenceSmoothing, delta )
);
_smoothedVelocity = Vector3.Lerp(
_smoothedVelocity,
planarVelocity,
ExponentialBlend( VelocitySmoothing, delta )
);
_inertiaVelocity = Vector3.Lerp(
_inertiaVelocity,
_smoothedVelocity,
ExponentialBlend( InertiaSmoothing, delta )
);
_idlePhase = (_idlePhase + MathF.Tau * BreathingFrequency * delta) % (MathF.Tau * 2f);
if ( grounded && _cadence > 0.001f )
{
_gaitPhase += MathF.PI * StepFrequency * _cadence * delta;
_gaitPhase %= MathF.Tau * 2f;
}
if ( grounded && !_wasGrounded )
{
var impact = (-_lastVerticalVelocity / 600f).Clamp( 0f, 1f );
_landingVelocity -= impact * LandingDip * LandingSpring;
}
UpdateLandingSpring( delta );
if ( !grounded )
_lastVerticalVelocity = _velocity.z;
_wasGrounded = grounded;
_isGrounded = grounded;
}
protected override void OnPreRender()
{
if ( !_initialized || !Controller.IsValid() || IsProxy || Controller.ThirdPerson )
return;
var camera = Scene.Camera;
if ( !camera.IsValid() )
return;
var rotation = camera.WorldRotation;
var flatForward = new Vector3( rotation.Forward.x, rotation.Forward.y, 0f );
var flatLength = flatForward.Length;
flatForward = flatLength > 0.001f ? flatForward / flatLength : Vector3.Forward;
var flatRight = new Vector3( -flatForward.y, flatForward.x, 0f );
var referenceSpeed = MathF.Max( ReferenceSpeed, 1f );
var forwardSpeed = (_smoothedVelocity.Dot( flatForward ) / referenceSpeed)
.Clamp( -MaximumSpeedScale, MaximumSpeedScale );
var sideSpeed = (_smoothedVelocity.Dot( flatRight ) / referenceSpeed)
.Clamp( -MaximumSpeedScale, MaximumSpeedScale );
var velocityLag = (_smoothedVelocity - _inertiaVelocity) / referenceSpeed;
var lagForward = velocityLag.Dot( flatForward ).Clamp( -1f, 1f );
var lagSide = velocityLag.Dot( flatRight ).Clamp( -1f, 1f );
var sideWave = MathF.Sin( _gaitPhase * 0.5f );
var sideDetail = MathF.Sin( _gaitPhase * 1.5f + 0.35f ) * GaitDetail;
var footPlant = MathF.Abs( MathF.Cos( _gaitPhase ) ) - MeanAbsoluteCosine;
var stepDetail = MathF.Sin( _gaitPhase * 2f + 0.7f ) * GaitDetail;
var movementAmount = Amount * _movementStrength;
var idleBlend = _isGrounded
? 1f - (_movementStrength / 0.45f).Clamp( 0f, 1f )
: 0f;
var breathWave = MathF.Sin( _idlePhase );
var weightShift = MathF.Sin( _idlePhase * 0.5f );
var sideOffset = (sideWave + sideDetail) * HorizontalAmount * movementAmount;
sideOffset += weightShift * IdleAmount * 0.22f * idleBlend * Amount;
sideOffset -= lagSide * InertiaAmount * Amount;
var verticalOffset = -(footPlant + stepDetail) * VerticalAmount * movementAmount;
verticalOffset += breathWave * IdleAmount * idleBlend * Amount;
verticalOffset += _landingOffset * Amount;
var forwardOffset = -lagForward * InertiaAmount * Amount;
var pitch = (footPlant + stepDetail * 0.5f) * PitchAmount * movementAmount;
pitch -= breathWave * IdlePitchAmount * idleBlend * Amount;
pitch -= forwardSpeed * VelocityPitchAmount * Amount;
pitch -= lagForward * VelocityPitchAmount * Amount;
var roll = -(sideWave + sideDetail * 0.5f) * RollAmount * movementAmount;
roll += weightShift * IdlePitchAmount * 0.22f * idleBlend * Amount;
roll += sideSpeed * VelocityRollAmount * Amount;
roll += lagSide * VelocityRollAmount * Amount;
var localOffset = new Vector3( forwardOffset, sideOffset, verticalOffset );
var offsetLength = localOffset.Length;
if ( offsetLength > MaximumPositionOffset )
localOffset *= MaximumPositionOffset / offsetLength;
pitch = pitch.Clamp( -MaximumRotationOffset, MaximumRotationOffset );
roll = roll.Clamp( -MaximumRotationOffset, MaximumRotationOffset );
camera.WorldPosition += rotation.Forward * localOffset.x;
camera.WorldPosition += rotation.Right * localOffset.y;
camera.WorldPosition += rotation.Up * localOffset.z;
camera.WorldRotation *= Rotation.From( pitch, 0f, roll );
}
void InitializeState()
{
if ( !Controller.IsValid() )
return;
_gaitPhase = 0f;
_movementStrength = 0f;
_cadence = 0f;
_velocity = Controller.Velocity;
var planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );
_smoothedVelocity = planarVelocity;
_inertiaVelocity = planarVelocity;
_wasGrounded = Controller.IsOnGround;
_isGrounded = _wasGrounded;
_lastVerticalVelocity = _velocity.z;
_landingOffset = 0f;
_landingVelocity = 0f;
_initialized = true;
}
void UpdateLandingSpring( float delta )
{
var remaining = delta;
var spring = MathF.Max( LandingSpring, 1f );
var damping = MathF.Max( LandingDamping, 0.1f );
while ( remaining > 0f )
{
var step = MathF.Min( remaining, 1f / 120f );
var acceleration = -spring * spring * _landingOffset
- 2f * damping * spring * _landingVelocity;
_landingVelocity += acceleration * step;
_landingOffset += _landingVelocity * step;
remaining -= step;
}
_landingOffset = _landingOffset.Clamp( -LandingDip * 1.25f, LandingDip * 0.35f );
}
static float ExponentialBlend( float speed, float delta )
{
return 1f - MathF.Exp( -MathF.Max( speed, 0.01f ) * delta );
}
}
Game
library
using System;
namespace Sandbox;
[Title( "Head Bobbing Effect" )]
[Category( "Camera" )]
[Description( "Polished first-person camera motion driven by player velocity." )]
[Icon( "visibility" )]
public sealed class FirstPersonHeadBob : Component
{
const float MeanAbsoluteCosine = 0.6366198f;
[Property, Group( "Motion" ), Range( 0f, 2f )]
public float Amount { get; set; } = 1f;
[Property, Group( "Motion" ), Range( 0f, 3f )]
public float HorizontalAmount { get; set; } = 0.85f;
[Property, Group( "Motion" ), Range( 0f, 3f )]
public float VerticalAmount { get; set; } = 1.2f;
[Property, Group( "Motion" ), Range( 0.5f, 4f )]
public float StepFrequency { get; set; } = 1.9f;
[Property, Group( "Motion" ), Range( 0f, 0.5f )]
public float GaitDetail { get; set; } = 0.12f;
[Property, Group( "Motion" ), Range( 0.25f, 1f )]
public float CrouchMultiplier { get; set; } = 0.72f;
[Property, Group( "Idle" ), Range( 0f, 1f )]
public float IdleAmount { get; set; } = 0.5f;
[Property, Group( "Idle" ), Range( 0.05f, 1f )]
public float BreathingFrequency { get; set; } = 0.23f;
[Property, Group( "Idle" ), Range( 0f, 1f )]
public float IdlePitchAmount { get; set; } = 0.32f;
[Property, Group( "Rotation" ), Range( 0f, 2f )]
public float PitchAmount { get; set; } = 0.38f;
[Property, Group( "Rotation" ), Range( 0f, 2f )]
public float RollAmount { get; set; } = 0.62f;
[Property, Group( "Velocity" ), Range( 0f, 2f )]
public float VelocityPitchAmount { get; set; } = 0.32f;
[Property, Group( "Velocity" ), Range( 0f, 3f )]
public float VelocityRollAmount { get; set; } = 0.75f;
[Property, Group( "Velocity" ), Range( 0f, 3f )]
public float InertiaAmount { get; set; } = 0.85f;
[Property, Group( "Velocity" ), Range( 1f, 30f )]
public float VelocitySmoothing { get; set; } = 6.5f;
[Property, Group( "Velocity" ), Range( 1f, 30f )]
public float InertiaSmoothing { get; set; } = 3.5f;
[Property, Group( "Response" ), Range( 1f, 30f )]
public float BlendSpeed { get; set; } = 6.5f;
[Property, Group( "Response" ), Range( 1f, 30f )]
public float CadenceSmoothing { get; set; } = 5.5f;
[Property, Group( "Response" ), Range( 1f, 30f )]
public float AirborneBlendSpeed { get; set; } = 5f;
[Property, Group( "Landing" ), Range( 0f, 4f )]
public float LandingDip { get; set; } = 1.6f;
[Property, Group( "Landing" ), Range( 1f, 30f )]
public float LandingSpring { get; set; } = 15f;
[Property, Group( "Landing" ), Range( 0.1f, 2f )]
public float LandingDamping { get; set; } = 0.82f;
[Property, Group( "Speed" ), Range( 0f, 100f )]
public float MinimumSpeed { get; set; } = 1.5f;
[Property, Group( "Speed" ), Range( 1f, 500f )]
public float ReferenceSpeed { get; set; } = 110f;
[Property, Group( "Speed" ), Range( 1f, 3f )]
public float MaximumSpeedScale { get; set; } = 1.65f;
[Property, Group( "Safety" ), Range( 0.5f, 8f )]
public float MaximumPositionOffset { get; set; } = 3.5f;
[Property, Group( "Safety" ), Range( 0.5f, 5f )]
public float MaximumRotationOffset { get; set; } = 2.5f;
PlayerController Controller { get; set; }
float _gaitPhase;
float _idlePhase;
float _movementStrength;
float _cadence;
float _landingOffset;
float _landingVelocity;
float _lastVerticalVelocity;
Vector3 _velocity;
Vector3 _smoothedVelocity;
Vector3 _inertiaVelocity;
bool _wasGrounded;
bool _isGrounded;
bool _initialized;
protected override void OnStart()
{
Controller = Components.Get<PlayerController>();
InitializeState();
}
protected override void OnDisabled()
{
_initialized = false;
_movementStrength = 0f;
_cadence = 0f;
_landingOffset = 0f;
_landingVelocity = 0f;
}
protected override void OnUpdate()
{
Controller ??= Components.Get<PlayerController>();
if ( !Controller.IsValid() || IsProxy || Controller.ThirdPerson )
{
_initialized = false;
return;
}
if ( !_initialized )
InitializeState();
var delta = MathF.Min( Time.Delta, 0.05f );
if ( delta <= 0f )
return;
_velocity = Controller.Velocity;
var planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );
var planarSpeed = planarVelocity.Length;
var grounded = Controller.IsOnGround;
var moving = grounded && planarSpeed >= MinimumSpeed;
var referenceSpeed = MathF.Max( ReferenceSpeed, 1f );
var speedScale = (planarSpeed / referenceSpeed).Clamp( 0f, MaximumSpeedScale );
var crouchScale = Controller.IsDucking ? CrouchMultiplier : 1f;
var targetStrength = moving ? speedScale * crouchScale : 0f;
var targetCadence = moving ? speedScale * MathF.Sqrt( crouchScale ) : 0f;
var movementBlendSpeed = grounded ? BlendSpeed : AirborneBlendSpeed;
_movementStrength = MathX.LerpTo(
_movementStrength,
targetStrength,
ExponentialBlend( movementBlendSpeed, delta )
);
_cadence = MathX.LerpTo(
_cadence,
targetCadence,
ExponentialBlend( CadenceSmoothing, delta )
);
_smoothedVelocity = Vector3.Lerp(
_smoothedVelocity,
planarVelocity,
ExponentialBlend( VelocitySmoothing, delta )
);
_inertiaVelocity = Vector3.Lerp(
_inertiaVelocity,
_smoothedVelocity,
ExponentialBlend( InertiaSmoothing, delta )
);
_idlePhase = (_idlePhase + MathF.Tau * BreathingFrequency * delta) % (MathF.Tau * 2f);
if ( grounded && _cadence > 0.001f )
{
_gaitPhase += MathF.PI * StepFrequency * _cadence * delta;
_gaitPhase %= MathF.Tau * 2f;
}
if ( grounded && !_wasGrounded )
{
var impact = (-_lastVerticalVelocity / 600f).Clamp( 0f, 1f );
_landingVelocity -= impact * LandingDip * LandingSpring;
}
UpdateLandingSpring( delta );
if ( !grounded )
_lastVerticalVelocity = _velocity.z;
_wasGrounded = grounded;
_isGrounded = grounded;
}
protected override void OnPreRender()
{
if ( !_initialized || !Controller.IsValid() || IsProxy || Controller.ThirdPerson )
return;
var camera = Scene.Camera;
if ( !camera.IsValid() )
return;
var rotation = camera.WorldRotation;
var flatForward = new Vector3( rotation.Forward.x, rotation.Forward.y, 0f );
var flatLength = flatForward.Length;
flatForward = flatLength > 0.001f ? flatForward / flatLength : Vector3.Forward;
var flatRight = new Vector3( -flatForward.y, flatForward.x, 0f );
var referenceSpeed = MathF.Max( ReferenceSpeed, 1f );
var forwardSpeed = (_smoothedVelocity.Dot( flatForward ) / referenceSpeed)
.Clamp( -MaximumSpeedScale, MaximumSpeedScale );
var sideSpeed = (_smoothedVelocity.Dot( flatRight ) / referenceSpeed)
.Clamp( -MaximumSpeedScale, MaximumSpeedScale );
var velocityLag = (_smoothedVelocity - _inertiaVelocity) / referenceSpeed;
var lagForward = velocityLag.Dot( flatForward ).Clamp( -1f, 1f );
var lagSide = velocityLag.Dot( flatRight ).Clamp( -1f, 1f );
var sideWave = MathF.Sin( _gaitPhase * 0.5f );
var sideDetail = MathF.Sin( _gaitPhase * 1.5f + 0.35f ) * GaitDetail;
var footPlant = MathF.Abs( MathF.Cos( _gaitPhase ) ) - MeanAbsoluteCosine;
var stepDetail = MathF.Sin( _gaitPhase * 2f + 0.7f ) * GaitDetail;
var movementAmount = Amount * _movementStrength;
var idleBlend = _isGrounded
? 1f - (_movementStrength / 0.45f).Clamp( 0f, 1f )
: 0f;
var breathWave = MathF.Sin( _idlePhase );
var weightShift = MathF.Sin( _idlePhase * 0.5f );
var sideOffset = (sideWave + sideDetail) * HorizontalAmount * movementAmount;
sideOffset += weightShift * IdleAmount * 0.22f * idleBlend * Amount;
sideOffset -= lagSide * InertiaAmount * Amount;
var verticalOffset = -(footPlant + stepDetail) * VerticalAmount * movementAmount;
verticalOffset += breathWave * IdleAmount * idleBlend * Amount;
verticalOffset += _landingOffset * Amount;
var forwardOffset = -lagForward * InertiaAmount * Amount;
var pitch = (footPlant + stepDetail * 0.5f) * PitchAmount * movementAmount;
pitch -= breathWave * IdlePitchAmount * idleBlend * Amount;
pitch -= forwardSpeed * VelocityPitchAmount * Amount;
pitch -= lagForward * VelocityPitchAmount * Amount;
var roll = -(sideWave + sideDetail * 0.5f) * RollAmount * movementAmount;
roll += weightShift * IdlePitchAmount * 0.22f * idleBlend * Amount;
roll += sideSpeed * VelocityRollAmount * Amount;
roll += lagSide * VelocityRollAmount * Amount;
var localOffset = new Vector3( forwardOffset, sideOffset, verticalOffset );
var offsetLength = localOffset.Length;
if ( offsetLength > MaximumPositionOffset )
localOffset *= MaximumPositionOffset / offsetLength;
pitch = pitch.Clamp( -MaximumRotationOffset, MaximumRotationOffset );
roll = roll.Clamp( -MaximumRotationOffset, MaximumRotationOffset );
camera.WorldPosition += rotation.Forward * localOffset.x;
camera.WorldPosition += rotation.Right * localOffset.y;
camera.WorldPosition += rotation.Up * localOffset.z;
camera.WorldRotation *= Rotation.From( pitch, 0f, roll );
}
void InitializeState()
{
if ( !Controller.IsValid() )
return;
_gaitPhase = 0f;
_movementStrength = 0f;
_cadence = 0f;
_velocity = Controller.Velocity;
var planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );
_smoothedVelocity = planarVelocity;
_inertiaVelocity = planarVelocity;
_wasGrounded = Controller.IsOnGround;
_isGrounded = _wasGrounded;
_lastVerticalVelocity = _velocity.z;
_landingOffset = 0f;
_landingVelocity = 0f;
_initialized = true;
}
void UpdateLandingSpring( float delta )
{
var remaining = delta;
var spring = MathF.Max( LandingSpring, 1f );
var damping = MathF.Max( LandingDamping, 0.1f );
while ( remaining > 0f )
{
var step = MathF.Min( remaining, 1f / 120f );
var acceleration = -spring * spring * _landingOffset
- 2f * damping * spring * _landingVelocity;
_landingVelocity += acceleration * step;
_landingOffset += _landingVelocity * step;
remaining -= step;
}
_landingOffset = _landingOffset.Clamp( -LandingDip * 1.25f, LandingDip * 0.35f );
}
static float ExponentialBlend( float speed, float delta )
{
return 1f - MathF.Exp( -MathF.Max( speed, 0.01f ) * delta );
}
}
Game
library
global using static Sandbox.Internal.GlobalGameNamespace;
global using Microsoft.AspNetCore.Components;
global using Microsoft.AspNetCore.Components.Rendering;
[assembly: global::System.Reflection.AssemblyMetadata( "AddonTitle", "Head Bobbing Effect" )]
[assembly: global::System.Reflection.AssemblyMetadata( "AddonIdent", "chomnr_head_bobbing_effect" )]
[assembly: global::System.Reflection.AssemblyMetadata( "OrgIdent", "notpointless" )]
[assembly: global::System.Reflection.AssemblyMetadata( "Ident", "notpointless.chomnr_head_bobbing_effect" )]
[assembly: global::System.Reflection.AssemblyMetadata( "EngineVersion", "28" )]
[assembly: global::System.Reflection.AssemblyMetadata( "EngineMinorVersion", "1" )]
[assembly: System.Runtime.Versioning.TargetFramework( ".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0" )]
[assembly: global::System.Reflection.AssemblyMetadata( "CompileTime", "2026-08-05T20:29:59.4807449Z" )]
[assembly: global::System.Reflection.AssemblyVersion("0.0.129.0")]
[assembly: global::System.Reflection.AssemblyFileVersion("0.0.129.0")]
Debug: View Raw JSON Response
{
"TotalCount": 3,
"Files": [
{
"Ident": "notpointless.chomnr_head_bobbing_effect",
"Path": "Code/FirstPersonHeadBob.cs",
"FileName": "FirstPersonHeadBob.cs",
"PackageType": "library",
"CodeKind": "Game",
"AssetVersionId": 339025,
"Code": "using System;\n\nnamespace Sandbox;\n\n[Title( \"Head Bobbing Effect\" )]\n[Category( \"Camera\" )]\n[Description( \"Polished first-person camera motion driven by player velocity.\" )]\n[Icon( \"visibility\" )]\npublic sealed class FirstPersonHeadBob : Component\n{\n\tconst float MeanAbsoluteCosine = 0.6366198f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 2f )]\n\tpublic float Amount { get; set; } = 1f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 3f )]\n\tpublic float HorizontalAmount { get; set; } = 0.85f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 3f )]\n\tpublic float VerticalAmount { get; set; } = 1.2f;\n\n\t[Property, Group( \"Motion\" ), Range( 0.5f, 4f )]\n\tpublic float StepFrequency { get; set; } = 1.9f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 0.5f )]\n\tpublic float GaitDetail { get; set; } = 0.12f;\n\n\t[Property, Group( \"Motion\" ), Range( 0.25f, 1f )]\n\tpublic float CrouchMultiplier { get; set; } = 0.72f;\n\n\t[Property, Group( \"Idle\" ), Range( 0f, 1f )]\n\tpublic float IdleAmount { get; set; } = 0.5f;\n\n\t[Property, Group( \"Idle\" ), Range( 0.05f, 1f )]\n\tpublic float BreathingFrequency { get; set; } = 0.23f;\n\n\t[Property, Group( \"Idle\" ), Range( 0f, 1f )]\n\tpublic float IdlePitchAmount { get; set; } = 0.32f;\n\n\t[Property, Group( \"Rotation\" ), Range( 0f, 2f )]\n\tpublic float PitchAmount { get; set; } = 0.38f;\n\n\t[Property, Group( \"Rotation\" ), Range( 0f, 2f )]\n\tpublic float RollAmount { get; set; } = 0.62f;\n\n\t[Property, Group( \"Velocity\" ), Range( 0f, 2f )]\n\tpublic float VelocityPitchAmount { get; set; } = 0.32f;\n\n\t[Property, Group( \"Velocity\" ), Range( 0f, 3f )]\n\tpublic float VelocityRollAmount { get; set; } = 0.75f;\n\n\t[Property, Group( \"Velocity\" ), Range( 0f, 3f )]\n\tpublic float InertiaAmount { get; set; } = 0.85f;\n\n\t[Property, Group( \"Velocity\" ), Range( 1f, 30f )]\n\tpublic float VelocitySmoothing { get; set; } = 6.5f;\n\n\t[Property, Group( \"Velocity\" ), Range( 1f, 30f )]\n\tpublic float InertiaSmoothing { get; set; } = 3.5f;\n\n\t[Property, Group( \"Response\" ), Range( 1f, 30f )]\n\tpublic float BlendSpeed { get; set; } = 6.5f;\n\n\t[Property, Group( \"Response\" ), Range( 1f, 30f )]\n\tpublic float CadenceSmoothing { get; set; } = 5.5f;\n\n\t[Property, Group( \"Response\" ), Range( 1f, 30f )]\n\tpublic float AirborneBlendSpeed { get; set; } = 5f;\n\n\t[Property, Group( \"Landing\" ), Range( 0f, 4f )]\n\tpublic float LandingDip { get; set; } = 1.6f;\n\n\t[Property, Group( \"Landing\" ), Range( 1f, 30f )]\n\tpublic float LandingSpring { get; set; } = 15f;\n\n\t[Property, Group( \"Landing\" ), Range( 0.1f, 2f )]\n\tpublic float LandingDamping { get; set; } = 0.82f;\n\n\t[Property, Group( \"Speed\" ), Range( 0f, 100f )]\n\tpublic float MinimumSpeed { get; set; } = 1.5f;\n\n\t[Property, Group( \"Speed\" ), Range( 1f, 500f )]\n\tpublic float ReferenceSpeed { get; set; } = 110f;\n\n\t[Property, Group( \"Speed\" ), Range( 1f, 3f )]\n\tpublic float MaximumSpeedScale { get; set; } = 1.65f;\n\n\t[Property, Group( \"Safety\" ), Range( 0.5f, 8f )]\n\tpublic float MaximumPositionOffset { get; set; } = 3.5f;\n\n\t[Property, Group( \"Safety\" ), Range( 0.5f, 5f )]\n\tpublic float MaximumRotationOffset { get; set; } = 2.5f;\n\n\tPlayerController Controller { get; set; }\n\n\tfloat _gaitPhase;\n\tfloat _idlePhase;\n\tfloat _movementStrength;\n\tfloat _cadence;\n\tfloat _landingOffset;\n\tfloat _landingVelocity;\n\tfloat _lastVerticalVelocity;\n\tVector3 _velocity;\n\tVector3 _smoothedVelocity;\n\tVector3 _inertiaVelocity;\n\tbool _wasGrounded;\n\tbool _isGrounded;\n\tbool _initialized;\n\n\tprotected override void OnStart()\n\t{\n\t\tController = Components.Get<PlayerController>();\n\t\tInitializeState();\n\t}\n\n\tprotected override void OnDisabled()\n\t{\n\t\t_initialized = false;\n\t\t_movementStrength = 0f;\n\t\t_cadence = 0f;\n\t\t_landingOffset = 0f;\n\t\t_landingVelocity = 0f;\n\t}\n\n\tprotected override void OnUpdate()\n\t{\n\t\tController ??= Components.Get<PlayerController>();\n\n\t\tif ( !Controller.IsValid() || IsProxy || Controller.ThirdPerson )\n\t\t{\n\t\t\t_initialized = false;\n\t\t\treturn;\n\t\t}\n\n\t\tif ( !_initialized )\n\t\t\tInitializeState();\n\n\t\tvar delta = MathF.Min( Time.Delta, 0.05f );\n\t\tif ( delta <= 0f )\n\t\t\treturn;\n\n\t\t_velocity = Controller.Velocity;\n\t\tvar planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );\n\t\tvar planarSpeed = planarVelocity.Length;\n\t\tvar grounded = Controller.IsOnGround;\n\t\tvar moving = grounded && planarSpeed >= MinimumSpeed;\n\t\tvar referenceSpeed = MathF.Max( ReferenceSpeed, 1f );\n\t\tvar speedScale = (planarSpeed / referenceSpeed).Clamp( 0f, MaximumSpeedScale );\n\t\tvar crouchScale = Controller.IsDucking ? CrouchMultiplier : 1f;\n\t\tvar targetStrength = moving ? speedScale * crouchScale : 0f;\n\t\tvar targetCadence = moving ? speedScale * MathF.Sqrt( crouchScale ) : 0f;\n\t\tvar movementBlendSpeed = grounded ? BlendSpeed : AirborneBlendSpeed;\n\n\t\t_movementStrength = MathX.LerpTo(\n\t\t\t_movementStrength,\n\t\t\ttargetStrength,\n\t\t\tExponentialBlend( movementBlendSpeed, delta )\n\t\t);\n\t\t_cadence = MathX.LerpTo(\n\t\t\t_cadence,\n\t\t\ttargetCadence,\n\t\t\tExponentialBlend( CadenceSmoothing, delta )\n\t\t);\n\t\t_smoothedVelocity = Vector3.Lerp(\n\t\t\t_smoothedVelocity,\n\t\t\tplanarVelocity,\n\t\t\tExponentialBlend( VelocitySmoothing, delta )\n\t\t);\n\t\t_inertiaVelocity = Vector3.Lerp(\n\t\t\t_inertiaVelocity,\n\t\t\t_smoothedVelocity,\n\t\t\tExponentialBlend( InertiaSmoothing, delta )\n\t\t);\n\n\t\t_idlePhase = (_idlePhase + MathF.Tau * BreathingFrequency * delta) % (MathF.Tau * 2f);\n\n\t\tif ( grounded && _cadence > 0.001f )\n\t\t{\n\t\t\t_gaitPhase += MathF.PI * StepFrequency * _cadence * delta;\n\t\t\t_gaitPhase %= MathF.Tau * 2f;\n\t\t}\n\n\t\tif ( grounded && !_wasGrounded )\n\t\t{\n\t\t\tvar impact = (-_lastVerticalVelocity / 600f).Clamp( 0f, 1f );\n\t\t\t_landingVelocity -= impact * LandingDip * LandingSpring;\n\t\t}\n\n\t\tUpdateLandingSpring( delta );\n\n\t\tif ( !grounded )\n\t\t\t_lastVerticalVelocity = _velocity.z;\n\n\t\t_wasGrounded = grounded;\n\t\t_isGrounded = grounded;\n\t}\n\n\tprotected override void OnPreRender()\n\t{\n\t\tif ( !_initialized || !Controller.IsValid() || IsProxy || Controller.ThirdPerson )\n\t\t\treturn;\n\n\t\tvar camera = Scene.Camera;\n\t\tif ( !camera.IsValid() )\n\t\t\treturn;\n\n\t\tvar rotation = camera.WorldRotation;\n\t\tvar flatForward = new Vector3( rotation.Forward.x, rotation.Forward.y, 0f );\n\t\tvar flatLength = flatForward.Length;\n\t\tflatForward = flatLength > 0.001f ? flatForward / flatLength : Vector3.Forward;\n\t\tvar flatRight = new Vector3( -flatForward.y, flatForward.x, 0f );\n\t\tvar referenceSpeed = MathF.Max( ReferenceSpeed, 1f );\n\t\tvar forwardSpeed = (_smoothedVelocity.Dot( flatForward ) / referenceSpeed)\n\t\t\t.Clamp( -MaximumSpeedScale, MaximumSpeedScale );\n\t\tvar sideSpeed = (_smoothedVelocity.Dot( flatRight ) / referenceSpeed)\n\t\t\t.Clamp( -MaximumSpeedScale, MaximumSpeedScale );\n\t\tvar velocityLag = (_smoothedVelocity - _inertiaVelocity) / referenceSpeed;\n\t\tvar lagForward = velocityLag.Dot( flatForward ).Clamp( -1f, 1f );\n\t\tvar lagSide = velocityLag.Dot( flatRight ).Clamp( -1f, 1f );\n\n\t\tvar sideWave = MathF.Sin( _gaitPhase * 0.5f );\n\t\tvar sideDetail = MathF.Sin( _gaitPhase * 1.5f + 0.35f ) * GaitDetail;\n\t\tvar footPlant = MathF.Abs( MathF.Cos( _gaitPhase ) ) - MeanAbsoluteCosine;\n\t\tvar stepDetail = MathF.Sin( _gaitPhase * 2f + 0.7f ) * GaitDetail;\n\t\tvar movementAmount = Amount * _movementStrength;\n\t\tvar idleBlend = _isGrounded\n\t\t\t? 1f - (_movementStrength / 0.45f).Clamp( 0f, 1f )\n\t\t\t: 0f;\n\t\tvar breathWave = MathF.Sin( _idlePhase );\n\t\tvar weightShift = MathF.Sin( _idlePhase * 0.5f );\n\n\t\tvar sideOffset = (sideWave + sideDetail) * HorizontalAmount * movementAmount;\n\t\tsideOffset += weightShift * IdleAmount * 0.22f * idleBlend * Amount;\n\t\tsideOffset -= lagSide * InertiaAmount * Amount;\n\n\t\tvar verticalOffset = -(footPlant + stepDetail) * VerticalAmount * movementAmount;\n\t\tverticalOffset += breathWave * IdleAmount * idleBlend * Amount;\n\t\tverticalOffset += _landingOffset * Amount;\n\n\t\tvar forwardOffset = -lagForward * InertiaAmount * Amount;\n\t\tvar pitch = (footPlant + stepDetail * 0.5f) * PitchAmount * movementAmount;\n\t\tpitch -= breathWave * IdlePitchAmount * idleBlend * Amount;\n\t\tpitch -= forwardSpeed * VelocityPitchAmount * Amount;\n\t\tpitch -= lagForward * VelocityPitchAmount * Amount;\n\n\t\tvar roll = -(sideWave + sideDetail * 0.5f) * RollAmount * movementAmount;\n\t\troll += weightShift * IdlePitchAmount * 0.22f * idleBlend * Amount;\n\t\troll += sideSpeed * VelocityRollAmount * Amount;\n\t\troll += lagSide * VelocityRollAmount * Amount;\n\n\t\tvar localOffset = new Vector3( forwardOffset, sideOffset, verticalOffset );\n\t\tvar offsetLength = localOffset.Length;\n\t\tif ( offsetLength > MaximumPositionOffset )\n\t\t\tlocalOffset *= MaximumPositionOffset / offsetLength;\n\n\t\tpitch = pitch.Clamp( -MaximumRotationOffset, MaximumRotationOffset );\n\t\troll = roll.Clamp( -MaximumRotationOffset, MaximumRotationOffset );\n\n\t\tcamera.WorldPosition += rotation.Forward * localOffset.x;\n\t\tcamera.WorldPosition += rotation.Right * localOffset.y;\n\t\tcamera.WorldPosition += rotation.Up * localOffset.z;\n\t\tcamera.WorldRotation *= Rotation.From( pitch, 0f, roll );\n\t}\n\n\tvoid InitializeState()\n\t{\n\t\tif ( !Controller.IsValid() )\n\t\t\treturn;\n\n\t\t_gaitPhase = 0f;\n\t\t_movementStrength = 0f;\n\t\t_cadence = 0f;\n\t\t_velocity = Controller.Velocity;\n\t\tvar planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );\n\t\t_smoothedVelocity = planarVelocity;\n\t\t_inertiaVelocity = planarVelocity;\n\t\t_wasGrounded = Controller.IsOnGround;\n\t\t_isGrounded = _wasGrounded;\n\t\t_lastVerticalVelocity = _velocity.z;\n\t\t_landingOffset = 0f;\n\t\t_landingVelocity = 0f;\n\t\t_initialized = true;\n\t}\n\n\tvoid UpdateLandingSpring( float delta )\n\t{\n\t\tvar remaining = delta;\n\t\tvar spring = MathF.Max( LandingSpring, 1f );\n\t\tvar damping = MathF.Max( LandingDamping, 0.1f );\n\n\t\twhile ( remaining > 0f )\n\t\t{\n\t\t\tvar step = MathF.Min( remaining, 1f / 120f );\n\t\t\tvar acceleration = -spring * spring * _landingOffset\n\t\t\t\t- 2f * damping * spring * _landingVelocity;\n\t\t\t_landingVelocity += acceleration * step;\n\t\t\t_landingOffset += _landingVelocity * step;\n\t\t\tremaining -= step;\n\t\t}\n\n\t\t_landingOffset = _landingOffset.Clamp( -LandingDip * 1.25f, LandingDip * 0.35f );\n\t}\n\n\tstatic float ExponentialBlend( float speed, float delta )\n\t{\n\t\treturn 1f - MathF.Exp( -MathF.Max( speed, 0.01f ) * delta );\n\t}\n}\n"
},
{
"Ident": "notpointless.chomnr_head_bobbing_effect",
"Path": "FirstPersonHeadBob.cs",
"FileName": "FirstPersonHeadBob.cs",
"PackageType": "library",
"CodeKind": "Game",
"AssetVersionId": 339025,
"Code": "using System;\n\nnamespace Sandbox;\n\n[Title( \"Head Bobbing Effect\" )]\n[Category( \"Camera\" )]\n[Description( \"Polished first-person camera motion driven by player velocity.\" )]\n[Icon( \"visibility\" )]\npublic sealed class FirstPersonHeadBob : Component\n{\n\tconst float MeanAbsoluteCosine = 0.6366198f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 2f )]\n\tpublic float Amount { get; set; } = 1f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 3f )]\n\tpublic float HorizontalAmount { get; set; } = 0.85f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 3f )]\n\tpublic float VerticalAmount { get; set; } = 1.2f;\n\n\t[Property, Group( \"Motion\" ), Range( 0.5f, 4f )]\n\tpublic float StepFrequency { get; set; } = 1.9f;\n\n\t[Property, Group( \"Motion\" ), Range( 0f, 0.5f )]\n\tpublic float GaitDetail { get; set; } = 0.12f;\n\n\t[Property, Group( \"Motion\" ), Range( 0.25f, 1f )]\n\tpublic float CrouchMultiplier { get; set; } = 0.72f;\n\n\t[Property, Group( \"Idle\" ), Range( 0f, 1f )]\n\tpublic float IdleAmount { get; set; } = 0.5f;\n\n\t[Property, Group( \"Idle\" ), Range( 0.05f, 1f )]\n\tpublic float BreathingFrequency { get; set; } = 0.23f;\n\n\t[Property, Group( \"Idle\" ), Range( 0f, 1f )]\n\tpublic float IdlePitchAmount { get; set; } = 0.32f;\n\n\t[Property, Group( \"Rotation\" ), Range( 0f, 2f )]\n\tpublic float PitchAmount { get; set; } = 0.38f;\n\n\t[Property, Group( \"Rotation\" ), Range( 0f, 2f )]\n\tpublic float RollAmount { get; set; } = 0.62f;\n\n\t[Property, Group( \"Velocity\" ), Range( 0f, 2f )]\n\tpublic float VelocityPitchAmount { get; set; } = 0.32f;\n\n\t[Property, Group( \"Velocity\" ), Range( 0f, 3f )]\n\tpublic float VelocityRollAmount { get; set; } = 0.75f;\n\n\t[Property, Group( \"Velocity\" ), Range( 0f, 3f )]\n\tpublic float InertiaAmount { get; set; } = 0.85f;\n\n\t[Property, Group( \"Velocity\" ), Range( 1f, 30f )]\n\tpublic float VelocitySmoothing { get; set; } = 6.5f;\n\n\t[Property, Group( \"Velocity\" ), Range( 1f, 30f )]\n\tpublic float InertiaSmoothing { get; set; } = 3.5f;\n\n\t[Property, Group( \"Response\" ), Range( 1f, 30f )]\n\tpublic float BlendSpeed { get; set; } = 6.5f;\n\n\t[Property, Group( \"Response\" ), Range( 1f, 30f )]\n\tpublic float CadenceSmoothing { get; set; } = 5.5f;\n\n\t[Property, Group( \"Response\" ), Range( 1f, 30f )]\n\tpublic float AirborneBlendSpeed { get; set; } = 5f;\n\n\t[Property, Group( \"Landing\" ), Range( 0f, 4f )]\n\tpublic float LandingDip { get; set; } = 1.6f;\n\n\t[Property, Group( \"Landing\" ), Range( 1f, 30f )]\n\tpublic float LandingSpring { get; set; } = 15f;\n\n\t[Property, Group( \"Landing\" ), Range( 0.1f, 2f )]\n\tpublic float LandingDamping { get; set; } = 0.82f;\n\n\t[Property, Group( \"Speed\" ), Range( 0f, 100f )]\n\tpublic float MinimumSpeed { get; set; } = 1.5f;\n\n\t[Property, Group( \"Speed\" ), Range( 1f, 500f )]\n\tpublic float ReferenceSpeed { get; set; } = 110f;\n\n\t[Property, Group( \"Speed\" ), Range( 1f, 3f )]\n\tpublic float MaximumSpeedScale { get; set; } = 1.65f;\n\n\t[Property, Group( \"Safety\" ), Range( 0.5f, 8f )]\n\tpublic float MaximumPositionOffset { get; set; } = 3.5f;\n\n\t[Property, Group( \"Safety\" ), Range( 0.5f, 5f )]\n\tpublic float MaximumRotationOffset { get; set; } = 2.5f;\n\n\tPlayerController Controller { get; set; }\n\n\tfloat _gaitPhase;\n\tfloat _idlePhase;\n\tfloat _movementStrength;\n\tfloat _cadence;\n\tfloat _landingOffset;\n\tfloat _landingVelocity;\n\tfloat _lastVerticalVelocity;\n\tVector3 _velocity;\n\tVector3 _smoothedVelocity;\n\tVector3 _inertiaVelocity;\n\tbool _wasGrounded;\n\tbool _isGrounded;\n\tbool _initialized;\n\n\tprotected override void OnStart()\n\t{\n\t\tController = Components.Get<PlayerController>();\n\t\tInitializeState();\n\t}\n\n\tprotected override void OnDisabled()\n\t{\n\t\t_initialized = false;\n\t\t_movementStrength = 0f;\n\t\t_cadence = 0f;\n\t\t_landingOffset = 0f;\n\t\t_landingVelocity = 0f;\n\t}\n\n\tprotected override void OnUpdate()\n\t{\n\t\tController ??= Components.Get<PlayerController>();\n\n\t\tif ( !Controller.IsValid() || IsProxy || Controller.ThirdPerson )\n\t\t{\n\t\t\t_initialized = false;\n\t\t\treturn;\n\t\t}\n\n\t\tif ( !_initialized )\n\t\t\tInitializeState();\n\n\t\tvar delta = MathF.Min( Time.Delta, 0.05f );\n\t\tif ( delta <= 0f )\n\t\t\treturn;\n\n\t\t_velocity = Controller.Velocity;\n\t\tvar planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );\n\t\tvar planarSpeed = planarVelocity.Length;\n\t\tvar grounded = Controller.IsOnGround;\n\t\tvar moving = grounded && planarSpeed >= MinimumSpeed;\n\t\tvar referenceSpeed = MathF.Max( ReferenceSpeed, 1f );\n\t\tvar speedScale = (planarSpeed / referenceSpeed).Clamp( 0f, MaximumSpeedScale );\n\t\tvar crouchScale = Controller.IsDucking ? CrouchMultiplier : 1f;\n\t\tvar targetStrength = moving ? speedScale * crouchScale : 0f;\n\t\tvar targetCadence = moving ? speedScale * MathF.Sqrt( crouchScale ) : 0f;\n\t\tvar movementBlendSpeed = grounded ? BlendSpeed : AirborneBlendSpeed;\n\n\t\t_movementStrength = MathX.LerpTo(\n\t\t\t_movementStrength,\n\t\t\ttargetStrength,\n\t\t\tExponentialBlend( movementBlendSpeed, delta )\n\t\t);\n\t\t_cadence = MathX.LerpTo(\n\t\t\t_cadence,\n\t\t\ttargetCadence,\n\t\t\tExponentialBlend( CadenceSmoothing, delta )\n\t\t);\n\t\t_smoothedVelocity = Vector3.Lerp(\n\t\t\t_smoothedVelocity,\n\t\t\tplanarVelocity,\n\t\t\tExponentialBlend( VelocitySmoothing, delta )\n\t\t);\n\t\t_inertiaVelocity = Vector3.Lerp(\n\t\t\t_inertiaVelocity,\n\t\t\t_smoothedVelocity,\n\t\t\tExponentialBlend( InertiaSmoothing, delta )\n\t\t);\n\n\t\t_idlePhase = (_idlePhase + MathF.Tau * BreathingFrequency * delta) % (MathF.Tau * 2f);\n\n\t\tif ( grounded && _cadence > 0.001f )\n\t\t{\n\t\t\t_gaitPhase += MathF.PI * StepFrequency * _cadence * delta;\n\t\t\t_gaitPhase %= MathF.Tau * 2f;\n\t\t}\n\n\t\tif ( grounded && !_wasGrounded )\n\t\t{\n\t\t\tvar impact = (-_lastVerticalVelocity / 600f).Clamp( 0f, 1f );\n\t\t\t_landingVelocity -= impact * LandingDip * LandingSpring;\n\t\t}\n\n\t\tUpdateLandingSpring( delta );\n\n\t\tif ( !grounded )\n\t\t\t_lastVerticalVelocity = _velocity.z;\n\n\t\t_wasGrounded = grounded;\n\t\t_isGrounded = grounded;\n\t}\n\n\tprotected override void OnPreRender()\n\t{\n\t\tif ( !_initialized || !Controller.IsValid() || IsProxy || Controller.ThirdPerson )\n\t\t\treturn;\n\n\t\tvar camera = Scene.Camera;\n\t\tif ( !camera.IsValid() )\n\t\t\treturn;\n\n\t\tvar rotation = camera.WorldRotation;\n\t\tvar flatForward = new Vector3( rotation.Forward.x, rotation.Forward.y, 0f );\n\t\tvar flatLength = flatForward.Length;\n\t\tflatForward = flatLength > 0.001f ? flatForward / flatLength : Vector3.Forward;\n\t\tvar flatRight = new Vector3( -flatForward.y, flatForward.x, 0f );\n\t\tvar referenceSpeed = MathF.Max( ReferenceSpeed, 1f );\n\t\tvar forwardSpeed = (_smoothedVelocity.Dot( flatForward ) / referenceSpeed)\n\t\t\t.Clamp( -MaximumSpeedScale, MaximumSpeedScale );\n\t\tvar sideSpeed = (_smoothedVelocity.Dot( flatRight ) / referenceSpeed)\n\t\t\t.Clamp( -MaximumSpeedScale, MaximumSpeedScale );\n\t\tvar velocityLag = (_smoothedVelocity - _inertiaVelocity) / referenceSpeed;\n\t\tvar lagForward = velocityLag.Dot( flatForward ).Clamp( -1f, 1f );\n\t\tvar lagSide = velocityLag.Dot( flatRight ).Clamp( -1f, 1f );\n\n\t\tvar sideWave = MathF.Sin( _gaitPhase * 0.5f );\n\t\tvar sideDetail = MathF.Sin( _gaitPhase * 1.5f + 0.35f ) * GaitDetail;\n\t\tvar footPlant = MathF.Abs( MathF.Cos( _gaitPhase ) ) - MeanAbsoluteCosine;\n\t\tvar stepDetail = MathF.Sin( _gaitPhase * 2f + 0.7f ) * GaitDetail;\n\t\tvar movementAmount = Amount * _movementStrength;\n\t\tvar idleBlend = _isGrounded\n\t\t\t? 1f - (_movementStrength / 0.45f).Clamp( 0f, 1f )\n\t\t\t: 0f;\n\t\tvar breathWave = MathF.Sin( _idlePhase );\n\t\tvar weightShift = MathF.Sin( _idlePhase * 0.5f );\n\n\t\tvar sideOffset = (sideWave + sideDetail) * HorizontalAmount * movementAmount;\n\t\tsideOffset += weightShift * IdleAmount * 0.22f * idleBlend * Amount;\n\t\tsideOffset -= lagSide * InertiaAmount * Amount;\n\n\t\tvar verticalOffset = -(footPlant + stepDetail) * VerticalAmount * movementAmount;\n\t\tverticalOffset += breathWave * IdleAmount * idleBlend * Amount;\n\t\tverticalOffset += _landingOffset * Amount;\n\n\t\tvar forwardOffset = -lagForward * InertiaAmount * Amount;\n\t\tvar pitch = (footPlant + stepDetail * 0.5f) * PitchAmount * movementAmount;\n\t\tpitch -= breathWave * IdlePitchAmount * idleBlend * Amount;\n\t\tpitch -= forwardSpeed * VelocityPitchAmount * Amount;\n\t\tpitch -= lagForward * VelocityPitchAmount * Amount;\n\n\t\tvar roll = -(sideWave + sideDetail * 0.5f) * RollAmount * movementAmount;\n\t\troll += weightShift * IdlePitchAmount * 0.22f * idleBlend * Amount;\n\t\troll += sideSpeed * VelocityRollAmount * Amount;\n\t\troll += lagSide * VelocityRollAmount * Amount;\n\n\t\tvar localOffset = new Vector3( forwardOffset, sideOffset, verticalOffset );\n\t\tvar offsetLength = localOffset.Length;\n\t\tif ( offsetLength > MaximumPositionOffset )\n\t\t\tlocalOffset *= MaximumPositionOffset / offsetLength;\n\n\t\tpitch = pitch.Clamp( -MaximumRotationOffset, MaximumRotationOffset );\n\t\troll = roll.Clamp( -MaximumRotationOffset, MaximumRotationOffset );\n\n\t\tcamera.WorldPosition += rotation.Forward * localOffset.x;\n\t\tcamera.WorldPosition += rotation.Right * localOffset.y;\n\t\tcamera.WorldPosition += rotation.Up * localOffset.z;\n\t\tcamera.WorldRotation *= Rotation.From( pitch, 0f, roll );\n\t}\n\n\tvoid InitializeState()\n\t{\n\t\tif ( !Controller.IsValid() )\n\t\t\treturn;\n\n\t\t_gaitPhase = 0f;\n\t\t_movementStrength = 0f;\n\t\t_cadence = 0f;\n\t\t_velocity = Controller.Velocity;\n\t\tvar planarVelocity = new Vector3( _velocity.x, _velocity.y, 0f );\n\t\t_smoothedVelocity = planarVelocity;\n\t\t_inertiaVelocity = planarVelocity;\n\t\t_wasGrounded = Controller.IsOnGround;\n\t\t_isGrounded = _wasGrounded;\n\t\t_lastVerticalVelocity = _velocity.z;\n\t\t_landingOffset = 0f;\n\t\t_landingVelocity = 0f;\n\t\t_initialized = true;\n\t}\n\n\tvoid UpdateLandingSpring( float delta )\n\t{\n\t\tvar remaining = delta;\n\t\tvar spring = MathF.Max( LandingSpring, 1f );\n\t\tvar damping = MathF.Max( LandingDamping, 0.1f );\n\n\t\twhile ( remaining > 0f )\n\t\t{\n\t\t\tvar step = MathF.Min( remaining, 1f / 120f );\n\t\t\tvar acceleration = -spring * spring * _landingOffset\n\t\t\t\t- 2f * damping * spring * _landingVelocity;\n\t\t\t_landingVelocity += acceleration * step;\n\t\t\t_landingOffset += _landingVelocity * step;\n\t\t\tremaining -= step;\n\t\t}\n\n\t\t_landingOffset = _landingOffset.Clamp( -LandingDip * 1.25f, LandingDip * 0.35f );\n\t}\n\n\tstatic float ExponentialBlend( float speed, float delta )\n\t{\n\t\treturn 1f - MathF.Exp( -MathF.Max( speed, 0.01f ) * delta );\n\t}\n}\n"
},
{
"Ident": "notpointless.chomnr_head_bobbing_effect",
"Path": ".obj/__compiler_extra.cs",
"FileName": "__compiler_extra.cs",
"PackageType": "library",
"CodeKind": "Game",
"AssetVersionId": 339025,
"Code": "global using static Sandbox.Internal.GlobalGameNamespace;\r\nglobal using Microsoft.AspNetCore.Components;\r\nglobal using Microsoft.AspNetCore.Components.Rendering;\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"AddonTitle\", \"Head Bobbing Effect\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"AddonIdent\", \"chomnr_head_bobbing_effect\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"OrgIdent\", \"notpointless\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"Ident\", \"notpointless.chomnr_head_bobbing_effect\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"EngineVersion\", \"28\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"EngineMinorVersion\", \"1\" )]\r\n\r\n[assembly: System.Runtime.Versioning.TargetFramework( \".NETCoreApp,Version=v9.0\", FrameworkDisplayName = \".NET 9.0\" )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \"CompileTime\", \"2026-08-05T20:29:59.4807449Z\" )]\r\n[assembly: global::System.Reflection.AssemblyVersion(\"0.0.129.0\")]\r\n[assembly: global::System.Reflection.AssemblyFileVersion(\"0.0.129.0\")]"
}
]
}