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:
50
code/Inventory.cs
Normal file
50
code/Inventory.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Sandbox;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
partial class Inventory : BaseInventory
|
||||
{
|
||||
public Inventory( Player player ) : base( player )
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CanAdd( Entity entity )
|
||||
{
|
||||
if ( !entity.IsValid() )
|
||||
return false;
|
||||
|
||||
if ( !base.CanAdd( entity ) )
|
||||
return false;
|
||||
|
||||
return !IsCarryingType( entity.GetType() );
|
||||
}
|
||||
|
||||
public override bool Add( Entity entity, bool makeActive = false )
|
||||
{
|
||||
if ( !entity.IsValid() )
|
||||
return false;
|
||||
|
||||
if ( IsCarryingType( entity.GetType() ) )
|
||||
return false;
|
||||
|
||||
return base.Add( entity, makeActive );
|
||||
}
|
||||
|
||||
public bool IsCarryingType( Type t )
|
||||
{
|
||||
return List.Any( x => x?.GetType() == t );
|
||||
}
|
||||
|
||||
public override bool Drop( Entity ent )
|
||||
{
|
||||
if ( !Host.IsServer )
|
||||
return false;
|
||||
|
||||
if ( !Contains( ent ) )
|
||||
return false;
|
||||
|
||||
ent.OnCarryDrop( Owner );
|
||||
|
||||
return ent.Parent == null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user