mirror of
https://github.com/celisej567/gm_construct_port.git
synced 2026-01-01 09:48:13 +03:00
51 lines
853 B
C#
51 lines
853 B
C#
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;
|
|
}
|
|
}
|