mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-15 01:39:39 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
26 lines
436 B
C#
26 lines
436 B
C#
using Sandbox.Movement;
|
|
namespace Sandbox;
|
|
|
|
|
|
public sealed partial class PlayerController : Component
|
|
{
|
|
public MoveMode Mode { get; private set; }
|
|
|
|
void ChooseBestMoveMode()
|
|
{
|
|
var best = GetComponents<MoveMode>( false ).MaxBy( x => x.Score( this ) );
|
|
if ( Mode == best ) return;
|
|
|
|
Mode?.OnModeEnd( best );
|
|
|
|
Mode = best;
|
|
|
|
if ( Body?.PhysicsBody is { } body )
|
|
{
|
|
body.Sleeping = false;
|
|
}
|
|
|
|
Mode?.OnModeBegin();
|
|
}
|
|
}
|