sasalka/Code/Inventory/Usable/PickupItem.cs
2025-06-10 23:24:50 +03:00

30 lines
518 B
C#

using Sandbox.Gravity;
using Sasalka;
namespace Sandbox.UI;
[Icon( "skip_next" )]
public sealed class PickupItem : InteractionButton
{
[Property] public override string Label { get; set; } = "E";
public override bool Press( IPressable.Event e )
{
base.Press( e );
if ( e.Source.Components.TryGet<Dedugan>( out var dedugan ) )
{
dedugan.Inventory.AddItem( Components.Get<InventoryItem>() );
RpcDestroy();
}
return true;
}
[Rpc.Broadcast]
void RpcDestroy()
{
GameObject.Destroy();
}
}