mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-02 11:28:19 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
23 lines
595 B
C#
23 lines
595 B
C#
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Simulates VerletRope components in parallel during PrePhysicsStep
|
|
/// </summary>
|
|
internal sealed class VerletRopeGameSystem : GameObjectSystem
|
|
{
|
|
public VerletRopeGameSystem( Scene scene ) : base( scene )
|
|
{
|
|
// Listen to StartFixedUpdate to run before physics
|
|
Listen( Stage.StartFixedUpdate, -100, UpdateRopes, "UpdateRopes" );
|
|
}
|
|
|
|
void UpdateRopes()
|
|
{
|
|
var ropes = Scene.GetAll<VerletRope>();
|
|
if ( ropes.Count() == 0 ) return;
|
|
|
|
var timeDelta = Time.Delta;
|
|
Sandbox.Utility.Parallel.ForEach( ropes, rope => rope.Simulate( timeDelta ) );
|
|
}
|
|
}
|