mirror of
https://github.com/celisej567/gm_construct_port.git
synced 2026-01-01 09:48:13 +03:00
36 lines
639 B
C#
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();
|
|
}
|
|
}
|