Add files via upload

This commit is contained in:
celisej567
2021-08-05 17:54:51 +03:00
committed by GitHub
parent d58ad89d11
commit 76b55e2a87
57 changed files with 5632 additions and 0 deletions

50
code/Inventory.cs Normal file
View 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;
}
}