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:
42
code/tools/Remover.cs
Normal file
42
code/tools/Remover.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace Sandbox.Tools
|
||||
{
|
||||
[Library( "tool_remover", Title = "Remover", Description = "Remove entities", Group = "construction" )]
|
||||
public partial class RemoverTool : BaseTool
|
||||
{
|
||||
public override void Simulate()
|
||||
{
|
||||
if ( !Host.IsServer )
|
||||
return;
|
||||
|
||||
using ( Prediction.Off() )
|
||||
{
|
||||
if ( !Input.Pressed( InputButton.Attack1 ) )
|
||||
return;
|
||||
|
||||
var startPos = Owner.EyePos;
|
||||
var dir = Owner.EyeRot.Forward;
|
||||
|
||||
var tr = Trace.Ray( startPos, startPos + dir * MaxTraceDistance )
|
||||
.Ignore( Owner )
|
||||
.HitLayer( CollisionLayer.Debris )
|
||||
.Run();
|
||||
|
||||
if ( !tr.Hit || !tr.Entity.IsValid() )
|
||||
return;
|
||||
|
||||
if ( tr.Entity is Player )
|
||||
return;
|
||||
|
||||
CreateHitEffects( tr.EndPos );
|
||||
|
||||
if ( tr.Entity.IsWorld )
|
||||
return;
|
||||
|
||||
tr.Entity.Delete();
|
||||
|
||||
var particle = Particles.Create( "particles/physgun_freeze.vpcf" );
|
||||
particle.SetPosition( 0, tr.Entity.Position );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user