upd
This commit is contained in:
29
Code/Inventory/Usable/PickupItem.cs
Normal file
29
Code/Inventory/Usable/PickupItem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user