public int ServerCombine(Stackable toAdd) { if (!StacksWith(toAdd)) { Logger.LogErrorFormat($"{toAdd} doesn't stack with {this}, cannot combine. Consider adding" + " this prefab to stacksWith if these really should be stackable.", Category.Objects); return(0); } var amountToConsume = Math.Min(toAdd.amount, SpareCapacity); if (amountToConsume <= 0) { return(0); } Logger.LogTraceFormat("Combining {0} <- {1}", Category.Objects, GetInstanceID(), toAdd.GetInstanceID()); toAdd.ServerConsume(amountToConsume); SyncAmount(amount, amount + amountToConsume); return(amountToConsume); }
public void ServerCombine(Stackable toAdd) { if (!StacksWith(toAdd)) { Logger.LogErrorFormat("toAdd {0} doesn't stack with this {2}, cannot combine. Consider adding" + " this prefab to stacksWith if these really should be stackable.", Category.Inventory, toAdd, this); return; } var amountToConsume = Math.Min(toAdd.amount, maxAmount - amount); if (amountToConsume <= 0) { return; } Logger.LogTraceFormat("Combining {0} <- {1}", Category.Inventory, GetInstanceID(), toAdd.GetInstanceID()); toAdd.ServerConsume(amountToConsume); SyncAmount(amount + amountToConsume); }