mirror of
https://github.com/celisej567/gm_construct_port.git
synced 2026-09-19 20:11:46 +03:00
Add files via upload
This commit is contained in:
35
code/Player.Use.cs
Normal file
35
code/Player.Use.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user