Files
gm_construct_port/code/Player.Use.cs
2021-08-05 17:54:51 +03:00

36 lines
639 B
C#

using Sandbox;
partial class SandboxPlayer
{
public bool IsUseDisabled()
{
return ActiveChild is IUse use && use.IsUsable( this );
}
protected override Entity FindUsable()
{
if ( IsUseDisabled() )
return null;
var tr = Trace.Ray( EyePos, EyePos + EyeRot.Forward * (85 * Scale) )
.Radius( 2 )
.HitLayer( CollisionLayer.Debris )
.Ignore( this )
.Run();
if ( tr.Entity == null ) return null;
if ( tr.Entity is not IUse use ) return null;
if ( !use.IsUsable( this ) ) return null;
return tr.Entity;
}
protected override void UseFail()
{
if ( IsUseDisabled() )
return;
base.UseFail();
}
}