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

34 lines
570 B
C#

using Sandbox;
[Library( "ent_light", Title = "Light", Spawnable = true )]
public partial class LightEntity : PointLightEntity, IUse
{
public override void Spawn()
{
base.Spawn();
SetModel( "models/light/light_tubular.vmdl" );
SetupPhysicsFromModel( PhysicsMotionType.Dynamic, false );
}
public bool IsUsable( Entity user )
{
return true;
}
public bool OnUse( Entity user )
{
Enabled = !Enabled;
PlaySound( Enabled ? "flashlight-on" : "flashlight-off" );
return false;
}
public void Remove()
{
PhysicsGroup?.Wake();
Delete();
}
}