clipping and extracting put seeds in the users hands (#14343)

This commit is contained in:
deltanedas
2023-03-06 02:37:57 +00:00
committed by GitHub
parent 5947fbc042
commit 60ac402b8b
3 changed files with 13 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ using Content.Server.Kitchen.Components;
using Content.Server.Popups;
using Content.Shared.Botany;
using Content.Shared.Examine;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Random.Helpers;
using Content.Shared.Slippery;
@@ -22,6 +23,7 @@ namespace Content.Server.Botany.Systems;
public sealed partial class BotanySystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
@@ -88,9 +90,12 @@ public sealed partial class BotanySystem : EntitySystem
#region SeedPrototype prototype stuff
public EntityUid SpawnSeedPacket(SeedData proto, EntityCoordinates transformCoordinates)
/// <summary>
/// Spawns a new seed packet on the floor at a position, then tries to put it in the user's hands if possible.
/// </summary>
public EntityUid SpawnSeedPacket(SeedData proto, EntityCoordinates coords, EntityUid user)
{
var seed = Spawn(proto.PacketPrototype, transformCoordinates);
var seed = Spawn(proto.PacketPrototype, coords);
var seedComp = EnsureComp<SeedComponent>(seed);
seedComp.Seed = proto;
@@ -106,6 +111,8 @@ public sealed partial class BotanySystem : EntitySystem
var val = Loc.GetString("botany-seed-packet-name", ("seedName", name), ("seedNoun", noun));
MetaData(seed).EntityName = val;
// try to automatically place in user's other hand
_hands.TryPickupAnyHand(user, seed);
return seed;
}