Files
tbd-station-14/Content.Server/Botany/Systems/LogSystem.cs
Winkarst-cpu 021adbe1e1 New Feature: Kitchen spike rework (#38723)
* Start

* Wow, text

* Ultra raw

* More stuff

* Wow, DOT and gibbing!!!

* More stuff

* More

* Update

* Yes

* Almost there

* Done?

* I forgot

* Update

* Update

* Update

* Update

* Update

* Update

* Update

* Update

* Update

* Beck

* Unhardcode
2025-08-19 10:56:36 -07:00

51 lines
1.6 KiB
C#

using Content.Server.Botany.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Kitchen.Components;
using Content.Shared.Random;
using Robust.Shared.Containers;
namespace Content.Server.Botany.Systems;
public sealed class LogSystem : EntitySystem
{
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LogComponent, InteractUsingEvent>(OnInteractUsing);
}
private void OnInteractUsing(EntityUid uid, LogComponent component, InteractUsingEvent args)
{
if (!HasComp<SharpComponent>(args.Used))
return;
// if in some container, try pick up, else just drop to world
var inContainer = _containerSystem.IsEntityInContainer(uid);
var pos = Transform(uid).Coordinates;
for (var i = 0; i < component.SpawnCount; i++)
{
var plank = Spawn(component.SpawnedPrototype, pos);
if (inContainer)
_handsSystem.PickupOrDrop(args.User, plank);
else
{
var xform = Transform(plank);
_containerSystem.AttachParentToContainerOrGrid((plank, xform));
xform.LocalRotation = 0;
_randomHelper.RandomOffset(plank, 0.25f);
}
}
QueueDel(uid);
args.Handled = true;
}
}