Files

218 lines
7.8 KiB
C#
Raw Permalink Normal View History

using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
2021-06-09 22:19:39 +02:00
namespace Content.Server.Stack
{
/// <summary>
/// Entity system that handles everything relating to stacks.
/// This is a good example for learning how to code in an ECS manner.
/// </summary>
[UsedImplicitly]
public sealed class StackSystem : SharedStackSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public static readonly int[] DefaultSplitAmounts = { 1, 5, 10, 20, 30, 50 };
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StackComponent, GetVerbsEvent<AlternativeVerb>>(OnStackAlternativeInteract);
}
public override void SetCount(EntityUid uid, int amount, StackComponent? component = null)
{
if (!Resolve(uid, ref component, false))
return;
base.SetCount(uid, amount, component);
// Queue delete stack if count reaches zero.
if (component.Count <= 0 && !component.Lingering)
QueueDel(uid);
}
/// <summary>
2021-12-03 16:08:30 +01:00
/// Try to split this stack into two. Returns a non-null <see cref="Robust.Shared.GameObjects.EntityUid"/> if successful.
/// </summary>
public EntityUid? Split(EntityUid uid, int amount, EntityCoordinates spawnPosition, StackComponent? stack = null)
{
if (!Resolve(uid, ref stack))
2021-12-26 15:32:45 +13:00
return null;
// Try to remove the amount of things we want to split from the original stack...
if (!Use(uid, amount, stack))
return null;
// Get a prototype ID to spawn the new entity. Null is also valid, although it should rarely be picked...
var prototype = _prototypeManager.TryIndex<StackPrototype>(stack.StackTypeId, out var stackType)
Cherrypicks 5 (#399) * Give moldy food the "Trash" tag (#29380) Make moldy food items have the "Trash" tag, so they can be collected. * Add "Structure" tag to switches, buttons, and levers (#29378) shit Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es> * Revamped Meteor Swarm (#28974) * meteor code and balanced values * Meteor Swarms * Update meteors.yml * Update meteors.yml * HOO! (fix overkill bug and buff space dust) * undo BloodstreamComponent.cs changes * DamageDistribution -> DamageTypes * part 2. * meteor fixes * improve meteor spawning (#29057) * Decrease meteor frequency (#29194) * Make Projectiles Only Hit a Variety of Station Objects Unless Clicked on (#28571) * Revert "Make Projectiles Only Hit a Variety of Station Objects Unless Clicked on (#28571)" This reverts commit 4f934f02f17ce55cabc03b965eb1df7738d63148. * Makes machine parts stackable, removes unused field in stack prototypes (#28434) * Makes machine parts stacks, removes unused field in stack prototypes * forgor * Fix tests * Fixes lathe construction. Yes. This sucks but there's no better way that doesnt involve refactoring machine parts completely * detail * a * Add pressure and temperature warning text to firelocks (#28341) * fix firelocks * missing nukies can be filled in by ghost roles (#28316) * Revert "missing nukies can be filled in by ghost roles (#28316)" This reverts commit 99f13e1e45bc778a4941316fde5d89d7b91337ce. * welding gas mask (#27108) * welding gas mask * eek * Canes + Cane Blade for Syndicate Librarians (#25873) * Cane + Cane Blade * Add - type: ContainerContainer * Add another - type: ContainerContainer * Fix and add proper ContainerContainer component * Add UserInterface component * Remove Space * Stat Changes * review --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> * Fix stupid NPC. (#26868) * init commit * Review --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> * fixes --------- Co-authored-by: VeritableCalamity <34698192+Veritable-Calamity@users.noreply.github.com> Co-authored-by: eoineoineoin <github@eoinrul.es> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Ps3Moira <113228053+ps3moira@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: Vigers Ray <60344369+VigersRay@users.noreply.github.com>
2024-06-30 10:04:27 +03:00
? stackType.Spawn.ToString()
: Prototype(uid)?.ID;
2021-11-10 18:23:12 +01:00
// Set the output parameter in the event instance to the newly split stack.
var entity = Spawn(prototype, spawnPosition);
if (TryComp(entity, out StackComponent? stackComp))
{
// Set the split stack's count.
SetCount(entity, amount, stackComp);
// Don't let people dupe unlimited stacks
stackComp.Unlimited = false;
}
var ev = new StackSplitEvent(entity);
RaiseLocalEvent(uid, ref ev);
return entity;
}
/// <summary>
/// Spawns a stack of a certain stack type. See <see cref="StackPrototype"/>.
/// </summary>
public EntityUid Spawn(int amount, StackPrototype prototype, EntityCoordinates spawnPosition)
{
// Set the output result parameter to the new stack entity...
var entity = Spawn(prototype.Spawn, spawnPosition);
var stack = Comp<StackComponent>(entity);
// And finally, set the correct amount!
SetCount(entity, amount, stack);
return entity;
}
/// <summary>
2023-01-07 13:09:05 -05:00
/// Say you want to spawn 97 units of something that has a max stack count of 30.
/// This would spawn 3 stacks of 30 and 1 stack of 7.
/// </summary>
public List<EntityUid> SpawnMultiple(string entityPrototype, int amount, EntityCoordinates spawnPosition)
Upstream gp (#149) * fix borg (#719) * Automatic changelog update * Переводы снаряжения и прочей мелочи в стартовом меню (#720) * Сумки, мешки и прочее * Перевод снаряжения * перевод черт персонажа * Добавлено ничего * Automatic changelog update * Фикс отображения потери мастера для импланта подчинения (#721) * фикс отображения * brain damage is real * я блять запустил райдер ради рефактора одного ифа * а лучше даже так * Automatic changelog update * add coderabbitai config (#722) * fix (#723) * Шприц теперь является оружием массового поражения (#724) * Automatic changelog update * Пиздец (#725) Я на это потратил 2 недели * Automatic changelog update * Honk FM (#136) (#726) * Fix Cosmic Temperance и новые песенки в jukebox * Новая музыка в jucebox x2 Co-authored-by: Vorge7 <vorge228@gmail.com> * Automatic changelog update * Флаф (fluff) мне (big_zi_348) (#727) * Заработал * brain damage * fuck (#729) * Automatic changelog update * FUCKERS (#732) * Удаление ненужных суффиксов (#731) * Перевод захардкукоженной строки (#728) * Пластырь поможет * очапятка * Перевод ревенанта * Карповый перекат * Create shakeable-component.ftl * Криогеника * Хранилища скафандров * Update autotranslate-14.ftl * Update Cyborgs.xml * Комоды * Кредиты * Удалил дубликат * Информация * Пластырь миму и клоуну * Переводы всего * Перевод аплинка * Удалил ненужные суффиксы * Revert "Удалил ненужные суффиксы" This reverts commit d82f05f30c37ec2c11e5736b91239fe9dd1a4d17. * Удаление ненужных суффиксов * Перевод реагентовых слизней * Перевод аномалий * Перевод маяков * Перевод различной мелочи * Automatic changelog update * Переводы и правки Гайдов (#730) * Automatic changelog update * aaaaa (#733) * Правка локализации (#737) * Update ThirstSystem.cs (#736) * AccessConfiguratorForBorgs (#735) * Automatic changelog update * Починил бесконечную сварку (#734) * Automatic changelog update * ShowManifestFeature (#738) * Automatic changelog update * I LOVE OPENSOURCE * Изменение размеров милишек (#739) * Фикс размеров * Заготовку биты тоже * Правка * Automatic changelog update * Время после взрыва нюки (#740) * More Fun * Автоформатирование * Подкрутка * Automatic changelog update * Скальпель в армейские ботинки (#741) * Automatic changelog update * DoHeavyAttack stamina check (#742) * Automatic changelog update * aaaaaaaaaaaaaaaaaaaaaaaaaaaaa (#743) * fix retarded code (#744) * Automatic changelog update --------- Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru> Co-authored-by: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Co-authored-by: Vorge7 <vorge228@gmail.com> Co-authored-by: Valtos <valtos@spaces.ru> Co-authored-by: haiwwkes <49613070+rhailrake@users.noreply.github.com>
2024-10-24 21:36:52 +03:00
{
if (amount <= 0)
{
Log.Error(
$"Attempted to spawn an invalid stack: {entityPrototype}, {amount}. Trace: {Environment.StackTrace}");
return new();
}
var spawns = CalculateSpawns(entityPrototype, amount);
var spawnedEnts = new List<EntityUid>();
foreach (var count in spawns)
{
var entity = SpawnAtPosition(entityPrototype, spawnPosition);
spawnedEnts.Add(entity);
SetCount(entity, count);
}
return spawnedEnts;
}
/// <inheritdoc cref="SpawnMultiple(string,int,EntityCoordinates)"/>
public List<EntityUid> SpawnMultiple(string entityPrototype, int amount, EntityUid target)
{
if (amount <= 0)
{
Log.Error(
$"Attempted to spawn an invalid stack: {entityPrototype}, {amount}. Trace: {Environment.StackTrace}");
return new();
}
var spawns = CalculateSpawns(entityPrototype, amount);
var spawnedEnts = new List<EntityUid>();
foreach (var count in spawns)
{
var entity = SpawnNextToOrDrop(entityPrototype, target);
spawnedEnts.Add(entity);
SetCount(entity, count);
}
return spawnedEnts;
}
/// <summary>
/// Calculates how many stacks to spawn that total up to <paramref name="amount"/>.
/// </summary>
/// <param name="entityPrototype">The stack to spawn.</param>
/// <param name="amount">The amount of pieces across all stacks.</param>
/// <returns>The list of stack counts per entity.</returns>
private List<int> CalculateSpawns(string entityPrototype, int amount)
{
var proto = _prototypeManager.Index<EntityPrototype>(entityPrototype);
Upstream gp (#149) * fix borg (#719) * Automatic changelog update * Переводы снаряжения и прочей мелочи в стартовом меню (#720) * Сумки, мешки и прочее * Перевод снаряжения * перевод черт персонажа * Добавлено ничего * Automatic changelog update * Фикс отображения потери мастера для импланта подчинения (#721) * фикс отображения * brain damage is real * я блять запустил райдер ради рефактора одного ифа * а лучше даже так * Automatic changelog update * add coderabbitai config (#722) * fix (#723) * Шприц теперь является оружием массового поражения (#724) * Automatic changelog update * Пиздец (#725) Я на это потратил 2 недели * Automatic changelog update * Honk FM (#136) (#726) * Fix Cosmic Temperance и новые песенки в jukebox * Новая музыка в jucebox x2 Co-authored-by: Vorge7 <vorge228@gmail.com> * Automatic changelog update * Флаф (fluff) мне (big_zi_348) (#727) * Заработал * brain damage * fuck (#729) * Automatic changelog update * FUCKERS (#732) * Удаление ненужных суффиксов (#731) * Перевод захардкукоженной строки (#728) * Пластырь поможет * очапятка * Перевод ревенанта * Карповый перекат * Create shakeable-component.ftl * Криогеника * Хранилища скафандров * Update autotranslate-14.ftl * Update Cyborgs.xml * Комоды * Кредиты * Удалил дубликат * Информация * Пластырь миму и клоуну * Переводы всего * Перевод аплинка * Удалил ненужные суффиксы * Revert "Удалил ненужные суффиксы" This reverts commit d82f05f30c37ec2c11e5736b91239fe9dd1a4d17. * Удаление ненужных суффиксов * Перевод реагентовых слизней * Перевод аномалий * Перевод маяков * Перевод различной мелочи * Automatic changelog update * Переводы и правки Гайдов (#730) * Automatic changelog update * aaaaa (#733) * Правка локализации (#737) * Update ThirstSystem.cs (#736) * AccessConfiguratorForBorgs (#735) * Automatic changelog update * Починил бесконечную сварку (#734) * Automatic changelog update * ShowManifestFeature (#738) * Automatic changelog update * I LOVE OPENSOURCE * Изменение размеров милишек (#739) * Фикс размеров * Заготовку биты тоже * Правка * Automatic changelog update * Время после взрыва нюки (#740) * More Fun * Автоформатирование * Подкрутка * Automatic changelog update * Скальпель в армейские ботинки (#741) * Automatic changelog update * DoHeavyAttack stamina check (#742) * Automatic changelog update * aaaaaaaaaaaaaaaaaaaaaaaaaaaaa (#743) * fix retarded code (#744) * Automatic changelog update --------- Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru> Co-authored-by: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Co-authored-by: Vorge7 <vorge228@gmail.com> Co-authored-by: Valtos <valtos@spaces.ru> Co-authored-by: haiwwkes <49613070+rhailrake@users.noreply.github.com>
2024-10-24 21:36:52 +03:00
proto.TryGetComponent<StackComponent>(out var stack, EntityManager.ComponentFactory);
var maxCountPerStack = GetMaxCount(stack);
Upstream gp (#149) * fix borg (#719) * Automatic changelog update * Переводы снаряжения и прочей мелочи в стартовом меню (#720) * Сумки, мешки и прочее * Перевод снаряжения * перевод черт персонажа * Добавлено ничего * Automatic changelog update * Фикс отображения потери мастера для импланта подчинения (#721) * фикс отображения * brain damage is real * я блять запустил райдер ради рефактора одного ифа * а лучше даже так * Automatic changelog update * add coderabbitai config (#722) * fix (#723) * Шприц теперь является оружием массового поражения (#724) * Automatic changelog update * Пиздец (#725) Я на это потратил 2 недели * Automatic changelog update * Honk FM (#136) (#726) * Fix Cosmic Temperance и новые песенки в jukebox * Новая музыка в jucebox x2 Co-authored-by: Vorge7 <vorge228@gmail.com> * Automatic changelog update * Флаф (fluff) мне (big_zi_348) (#727) * Заработал * brain damage * fuck (#729) * Automatic changelog update * FUCKERS (#732) * Удаление ненужных суффиксов (#731) * Перевод захардкукоженной строки (#728) * Пластырь поможет * очапятка * Перевод ревенанта * Карповый перекат * Create shakeable-component.ftl * Криогеника * Хранилища скафандров * Update autotranslate-14.ftl * Update Cyborgs.xml * Комоды * Кредиты * Удалил дубликат * Информация * Пластырь миму и клоуну * Переводы всего * Перевод аплинка * Удалил ненужные суффиксы * Revert "Удалил ненужные суффиксы" This reverts commit d82f05f30c37ec2c11e5736b91239fe9dd1a4d17. * Удаление ненужных суффиксов * Перевод реагентовых слизней * Перевод аномалий * Перевод маяков * Перевод различной мелочи * Automatic changelog update * Переводы и правки Гайдов (#730) * Automatic changelog update * aaaaa (#733) * Правка локализации (#737) * Update ThirstSystem.cs (#736) * AccessConfiguratorForBorgs (#735) * Automatic changelog update * Починил бесконечную сварку (#734) * Automatic changelog update * ShowManifestFeature (#738) * Automatic changelog update * I LOVE OPENSOURCE * Изменение размеров милишек (#739) * Фикс размеров * Заготовку биты тоже * Правка * Automatic changelog update * Время после взрыва нюки (#740) * More Fun * Автоформатирование * Подкрутка * Automatic changelog update * Скальпель в армейские ботинки (#741) * Automatic changelog update * DoHeavyAttack stamina check (#742) * Automatic changelog update * aaaaaaaaaaaaaaaaaaaaaaaaaaaaa (#743) * fix retarded code (#744) * Automatic changelog update --------- Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru> Co-authored-by: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Co-authored-by: Vorge7 <vorge228@gmail.com> Co-authored-by: Valtos <valtos@spaces.ru> Co-authored-by: haiwwkes <49613070+rhailrake@users.noreply.github.com>
2024-10-24 21:36:52 +03:00
var amounts = new List<int>();
while (amount > 0)
{
var countAmount = Math.Min(maxCountPerStack, amount);
amount -= countAmount;
Upstream gp (#149) * fix borg (#719) * Automatic changelog update * Переводы снаряжения и прочей мелочи в стартовом меню (#720) * Сумки, мешки и прочее * Перевод снаряжения * перевод черт персонажа * Добавлено ничего * Automatic changelog update * Фикс отображения потери мастера для импланта подчинения (#721) * фикс отображения * brain damage is real * я блять запустил райдер ради рефактора одного ифа * а лучше даже так * Automatic changelog update * add coderabbitai config (#722) * fix (#723) * Шприц теперь является оружием массового поражения (#724) * Automatic changelog update * Пиздец (#725) Я на это потратил 2 недели * Automatic changelog update * Honk FM (#136) (#726) * Fix Cosmic Temperance и новые песенки в jukebox * Новая музыка в jucebox x2 Co-authored-by: Vorge7 <vorge228@gmail.com> * Automatic changelog update * Флаф (fluff) мне (big_zi_348) (#727) * Заработал * brain damage * fuck (#729) * Automatic changelog update * FUCKERS (#732) * Удаление ненужных суффиксов (#731) * Перевод захардкукоженной строки (#728) * Пластырь поможет * очапятка * Перевод ревенанта * Карповый перекат * Create shakeable-component.ftl * Криогеника * Хранилища скафандров * Update autotranslate-14.ftl * Update Cyborgs.xml * Комоды * Кредиты * Удалил дубликат * Информация * Пластырь миму и клоуну * Переводы всего * Перевод аплинка * Удалил ненужные суффиксы * Revert "Удалил ненужные суффиксы" This reverts commit d82f05f30c37ec2c11e5736b91239fe9dd1a4d17. * Удаление ненужных суффиксов * Перевод реагентовых слизней * Перевод аномалий * Перевод маяков * Перевод различной мелочи * Automatic changelog update * Переводы и правки Гайдов (#730) * Automatic changelog update * aaaaa (#733) * Правка локализации (#737) * Update ThirstSystem.cs (#736) * AccessConfiguratorForBorgs (#735) * Automatic changelog update * Починил бесконечную сварку (#734) * Automatic changelog update * ShowManifestFeature (#738) * Automatic changelog update * I LOVE OPENSOURCE * Изменение размеров милишек (#739) * Фикс размеров * Заготовку биты тоже * Правка * Automatic changelog update * Время после взрыва нюки (#740) * More Fun * Автоформатирование * Подкрутка * Automatic changelog update * Скальпель в армейские ботинки (#741) * Automatic changelog update * DoHeavyAttack stamina check (#742) * Automatic changelog update * aaaaaaaaaaaaaaaaaaaaaaaaaaaaa (#743) * fix retarded code (#744) * Automatic changelog update --------- Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru> Co-authored-by: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Co-authored-by: Vorge7 <vorge228@gmail.com> Co-authored-by: Valtos <valtos@spaces.ru> Co-authored-by: haiwwkes <49613070+rhailrake@users.noreply.github.com>
2024-10-24 21:36:52 +03:00
amounts.Add(countAmount);
}
Upstream gp (#149) * fix borg (#719) * Automatic changelog update * Переводы снаряжения и прочей мелочи в стартовом меню (#720) * Сумки, мешки и прочее * Перевод снаряжения * перевод черт персонажа * Добавлено ничего * Automatic changelog update * Фикс отображения потери мастера для импланта подчинения (#721) * фикс отображения * brain damage is real * я блять запустил райдер ради рефактора одного ифа * а лучше даже так * Automatic changelog update * add coderabbitai config (#722) * fix (#723) * Шприц теперь является оружием массового поражения (#724) * Automatic changelog update * Пиздец (#725) Я на это потратил 2 недели * Automatic changelog update * Honk FM (#136) (#726) * Fix Cosmic Temperance и новые песенки в jukebox * Новая музыка в jucebox x2 Co-authored-by: Vorge7 <vorge228@gmail.com> * Automatic changelog update * Флаф (fluff) мне (big_zi_348) (#727) * Заработал * brain damage * fuck (#729) * Automatic changelog update * FUCKERS (#732) * Удаление ненужных суффиксов (#731) * Перевод захардкукоженной строки (#728) * Пластырь поможет * очапятка * Перевод ревенанта * Карповый перекат * Create shakeable-component.ftl * Криогеника * Хранилища скафандров * Update autotranslate-14.ftl * Update Cyborgs.xml * Комоды * Кредиты * Удалил дубликат * Информация * Пластырь миму и клоуну * Переводы всего * Перевод аплинка * Удалил ненужные суффиксы * Revert "Удалил ненужные суффиксы" This reverts commit d82f05f30c37ec2c11e5736b91239fe9dd1a4d17. * Удаление ненужных суффиксов * Перевод реагентовых слизней * Перевод аномалий * Перевод маяков * Перевод различной мелочи * Automatic changelog update * Переводы и правки Гайдов (#730) * Automatic changelog update * aaaaa (#733) * Правка локализации (#737) * Update ThirstSystem.cs (#736) * AccessConfiguratorForBorgs (#735) * Automatic changelog update * Починил бесконечную сварку (#734) * Automatic changelog update * ShowManifestFeature (#738) * Automatic changelog update * I LOVE OPENSOURCE * Изменение размеров милишек (#739) * Фикс размеров * Заготовку биты тоже * Правка * Automatic changelog update * Время после взрыва нюки (#740) * More Fun * Автоформатирование * Подкрутка * Automatic changelog update * Скальпель в армейские ботинки (#741) * Automatic changelog update * DoHeavyAttack stamina check (#742) * Automatic changelog update * aaaaaaaaaaaaaaaaaaaaaaaaaaaaa (#743) * fix retarded code (#744) * Automatic changelog update --------- Co-authored-by: RavmorganButOnCocaine <valtos@nextmail.ru> Co-authored-by: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Co-authored-by: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Co-authored-by: Vorge7 <vorge228@gmail.com> Co-authored-by: Valtos <valtos@spaces.ru> Co-authored-by: haiwwkes <49613070+rhailrake@users.noreply.github.com>
2024-10-24 21:36:52 +03:00
return amounts;
}
private void OnStackAlternativeInteract(EntityUid uid, StackComponent stack, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract || args.Hands == null || stack.Count == 1)
return;
AlternativeVerb halve = new()
{
Text = Loc.GetString("comp-stack-split-halve"),
Category = VerbCategory.Split,
Act = () => UserSplit(uid, args.User, stack.Count / 2, stack),
Priority = 1
};
args.Verbs.Add(halve);
var priority = 0;
foreach (var amount in DefaultSplitAmounts)
{
if (amount >= stack.Count)
continue;
AlternativeVerb verb = new()
{
Text = amount.ToString(),
Category = VerbCategory.Split,
Act = () => UserSplit(uid, args.User, amount, stack),
// we want to sort by size, not alphabetically by the verb text.
Priority = priority
};
priority--;
args.Verbs.Add(verb);
}
}
private void UserSplit(EntityUid uid, EntityUid userUid, int amount,
StackComponent? stack = null,
TransformComponent? userTransform = null)
{
if (!Resolve(uid, ref stack))
return;
if (!Resolve(userUid, ref userTransform))
return;
if (amount <= 0)
{
Popup.PopupCursor(Loc.GetString("comp-stack-split-too-small"), userUid, PopupType.Medium);
return;
}
if (Split(uid, amount, userTransform.Coordinates, stack) is not {} split)
return;
Hands.PickupOrDrop(userUid, split);
Popup.PopupCursor(Loc.GetString("comp-stack-split"), userUid);
}
}
}