Files
sbox-public/engine/Sandbox.Engine/Scene/GameObjectSystems/VerletRopeSystem.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

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 ) );
}
}