Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Readiciona CanCombineStacks
Browse files Browse the repository at this point in the history
  • Loading branch information
rbertoche committed Jul 23, 2023
1 parent 9852032 commit 33ade11
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Content.Server/Storage/EntitySystems/StorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,29 @@ public bool Insert(EntityUid uid, EntityUid insertEnt, ServerStorageComponent? s
return true;
}

private bool CanCombineStacks(
ServerStorageComponent storageComp,
StackComponent stack)
{
if (storageComp.Storage == null)
return false;

var stackQuery = GetEntityQuery<StackComponent>();
var countLeft = stack.Count;
foreach (var ent in storageComp.Storage.ContainedEntities)
{
if (!stackQuery.TryGetComponent(ent, out var destStack))
continue;

if (destStack.StackTypeId != stack.StackTypeId)
continue;

countLeft -= _stack.GetAvailableSpace(stack);
}

return countLeft <= 0;
}

// REMOVE: remove and drop on the ground
public bool RemoveAndDrop(EntityUid uid, EntityUid removeEnt, ServerStorageComponent? storageComp = null)
{
Expand Down

0 comments on commit 33ade11

Please sign in to comment.