prerelease
This commit is contained in:
@@ -4,7 +4,8 @@ using VeloX.Audio;
|
||||
|
||||
namespace VeloX;
|
||||
|
||||
[GameResource( "Engine Stream", "engstr", "Engine Sound", Category = "VeloX", Icon = "time_to_leave" )]
|
||||
[AssetType( Name = "Engine Stream", Extension = "engstr", Category = "VeloX" )]
|
||||
[Icon( "time_to_leave" )]
|
||||
public sealed class EngineStream : GameResource
|
||||
{
|
||||
public sealed class Layer
|
||||
|
||||
@@ -26,6 +26,7 @@ public class EngineStreamPlayer( EngineStream stream ) : IDisposable
|
||||
|
||||
public void Update( float deltaTime, Vector3 position, bool isLocal = false )
|
||||
{
|
||||
|
||||
var globalPitch = 1.0f;
|
||||
|
||||
// Gear wobble effect
|
||||
@@ -50,14 +51,14 @@ public class EngineStreamPlayer( EngineStream stream ) : IDisposable
|
||||
foreach ( var (id, layer) in Stream.Layers )
|
||||
{
|
||||
EngineSounds.TryGetValue( layer, out var channel );
|
||||
|
||||
if ( !channel.IsValid() )
|
||||
|
||||
if ( !channel.IsValid() && layer.AudioPath.IsValid() )
|
||||
{
|
||||
channel = Sound.PlayFile( layer.AudioPath );
|
||||
EngineSounds[layer] = channel;
|
||||
}
|
||||
|
||||
if ( channel.Paused && (EngineSoundPaused || layer.IsMuted) )
|
||||
if ( !channel.IsValid() || channel.Paused && (EngineSoundPaused || layer.IsMuted) )
|
||||
continue;
|
||||
|
||||
// Reset controller outputs
|
||||
|
||||
29
Code/Utils/MathM.cs
Normal file
29
Code/Utils/MathM.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace VeloX.Utils;
|
||||
|
||||
public static class MathM
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Converts angular velocity (rad/s) to rotations per minute.
|
||||
/// </summary>
|
||||
public static float AngularVelocityToRPM( this float angularVelocity ) => angularVelocity * 9.5492965855137f;
|
||||
|
||||
/// <summary>
|
||||
/// Converts rotations per minute to angular velocity (rad/s).
|
||||
/// </summary>
|
||||
public static float RPMToAngularVelocity( this float RPM ) => RPM * 0.10471975511966f;
|
||||
|
||||
public static float SignedAngle( this Vector3 from, Vector3 to, Vector3 axis )
|
||||
{
|
||||
float unsignedAngle = Vector3.GetAngle( from, to );
|
||||
|
||||
float cross_x = from.y * to.z - from.z * to.y;
|
||||
float cross_y = from.z * to.x - from.x * to.z;
|
||||
float cross_z = from.x * to.y - from.y * to.x;
|
||||
float sign = MathF.Sign( axis.x * cross_x + axis.y * cross_y + axis.z * cross_z );
|
||||
return unsignedAngle * sign;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user