From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Mon, 6 Mar 2023 02:37:57 +0000 (+0000)
Subject: clipping and extracting put seeds in the users hands (#14343)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=60ac402b8bb5427d17a3422f6b214f3cc8b3ebc1;p=space-station-14.git
clipping and extracting put seeds in the users hands (#14343)
---
diff --git a/Content.Server/Botany/Systems/BotanySystem.Seed.cs b/Content.Server/Botany/Systems/BotanySystem.Seed.cs
index dc3deae208..2cbe17aff1 100644
--- a/Content.Server/Botany/Systems/BotanySystem.Seed.cs
+++ b/Content.Server/Botany/Systems/BotanySystem.Seed.cs
@@ -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)
+ ///
+ /// Spawns a new seed packet on the floor at a position, then tries to put it in the user's hands if possible.
+ ///
+ public EntityUid SpawnSeedPacket(SeedData proto, EntityCoordinates coords, EntityUid user)
{
- var seed = Spawn(proto.PacketPrototype, transformCoordinates);
+ var seed = Spawn(proto.PacketPrototype, coords);
var seedComp = EnsureComp(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;
}
diff --git a/Content.Server/Botany/Systems/PlantHolderSystem.cs b/Content.Server/Botany/Systems/PlantHolderSystem.cs
index 5a5c0fbba2..da634bba8a 100644
--- a/Content.Server/Botany/Systems/PlantHolderSystem.cs
+++ b/Content.Server/Botany/Systems/PlantHolderSystem.cs
@@ -251,7 +251,7 @@ namespace Content.Server.Botany.Systems
}
component.Seed.Unique = false;
- var seed = _botanySystem.SpawnSeedPacket(component.Seed, Transform(args.User).Coordinates);
+ var seed = _botanySystem.SpawnSeedPacket(component.Seed, Transform(args.User).Coordinates, args.User);
seed.RandomOffset(0.25f);
var displayName = Loc.GetString(component.Seed.DisplayName);
_popupSystem.PopupCursor(Loc.GetString("plant-holder-component-take-sample-message",
@@ -572,7 +572,8 @@ namespace Content.Server.Botany.Systems
}
else if (component.Age < 0) // Revert back to seed packet!
{
- _botanySystem.SpawnSeedPacket(component.Seed, Transform(uid).Coordinates);
+ // will put it in the trays hands if it has any, please do not try doing this
+ _botanySystem.SpawnSeedPacket(component.Seed, Transform(uid).Coordinates, uid);
RemovePlant(uid, component);
component.ForceUpdate = true;
Update(uid, component);
diff --git a/Content.Server/Botany/Systems/SeedExtractorSystem.cs b/Content.Server/Botany/Systems/SeedExtractorSystem.cs
index d7047fdce6..4c547b96f0 100644
--- a/Content.Server/Botany/Systems/SeedExtractorSystem.cs
+++ b/Content.Server/Botany/Systems/SeedExtractorSystem.cs
@@ -50,7 +50,7 @@ public sealed class SeedExtractorSystem : EntitySystem
for (var i = 0; i < amount; i++)
{
- _botanySystem.SpawnSeedPacket(seed, coords);
+ _botanySystem.SpawnSeedPacket(seed, coords, args.User);
}
}