* eye on the prize * OnStackInteractUsing, TryMergeStacks, TryMergeToHands, TryMergeToContacts * namespace * Use, get count, getMaxCount * component access * add regions, mark TODO * obsolete TryAdd, public TryMergeStacks * GetMaxCount * event handlers * event handlers * SetCount * client server event handlers * move to shared * Revert "move to shared" This reverts commit 45540a2d6b8e1e6d2a8f83a584267776c7edcd73. * misc changes to shared * split * spawn and SpawnNextToOrDrop * SpawnMultipleAtPosition, SpawnMultipleNextToOrDrop, CalculateSpawns, general server cleanup * Rename Use to TryUse. * Small misc changes * Remove obsolete functions * Remove some SetCount calls * Partialize * small misc change * don't nuke the git dif with the namespace block * Comments and reordering * touchup to UpdateLingering * Summary comment for StackStatusControl * Last pass * Actual last pass (for now) * I know myself too well * fixup * goodbye lingering * fixes * review * fix test * second look * fix test * forgot * remove early comp getting --------- Co-authored-by: iaada <iaada@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
55 lines
2.2 KiB
C#
55 lines
2.2 KiB
C#
using Content.Server.Body.Systems;
|
|
using Content.Server.Stack;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Storage.Components;
|
|
using Content.Shared.Whitelist;
|
|
using Content.Shared.Xenoarchaeology.Equipment;
|
|
using Content.Shared.Xenoarchaeology.Equipment.Components;
|
|
using Robust.Shared.Collections;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Xenoarchaeology.Equipment.Systems;
|
|
|
|
/// <inheritdoc/>
|
|
public sealed class ArtifactCrusherSystem : SharedArtifactCrusherSystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly BodySystem _body = default!;
|
|
[Dependency] private readonly StackSystem _stack = default!;
|
|
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
|
|
|
// TODO: Move to shared once StackSystem spawning is in Shared and we have RandomPredicted
|
|
public override void FinishCrushing(Entity<ArtifactCrusherComponent, EntityStorageComponent> ent)
|
|
{
|
|
var (_, crusher, storage) = ent;
|
|
StopCrushing((ent, ent.Comp1), false);
|
|
AudioSystem.PlayPvs(crusher.CrushingCompleteSound, ent);
|
|
crusher.CrushingSoundEntity = null;
|
|
Dirty(ent, ent.Comp1);
|
|
|
|
var contents = new ValueList<EntityUid>(storage.Contents.ContainedEntities);
|
|
var coords = Transform(ent).Coordinates;
|
|
foreach (var contained in contents)
|
|
{
|
|
if (_whitelistSystem.IsWhitelistPass(crusher.CrushingWhitelist, contained))
|
|
{
|
|
var amount = _random.Next(crusher.MinFragments, crusher.MaxFragments);
|
|
var stacks = _stack.SpawnMultipleAtPosition(crusher.FragmentStackProtoId, amount, coords);
|
|
foreach (var stack in stacks)
|
|
{
|
|
ContainerSystem.Insert((stack, null, null, null), crusher.OutputContainer);
|
|
}
|
|
}
|
|
|
|
if (!TryComp<BodyComponent>(contained, out var body))
|
|
Del(contained);
|
|
|
|
var gibs = _body.GibBody(contained, body: body, gibOrgans: true);
|
|
foreach (var gib in gibs)
|
|
{
|
|
ContainerSystem.Insert((gib, null, null, null), crusher.OutputContainer);
|
|
}
|
|
}
|
|
}
|
|
}
|