CatStation/Content.Shared/Botany/Systems/SeedExtractorSystem.cs
SlothBasket b1323acc43
Botany Refactor Bugfixes and Value adjustments (#45752)
* Fixes Cryoxadone De-Age, properly adjusts lastHarvest. If age would be reduced below 0 reverts plant to seed with current genetics.

* Botany Bugfixes. Cryoxadone De-Age fix. Cryox Regression to seed re-added. Seedless Produce no longer have seeds. Proper Temp tollerance ranges restored. Production no longer clamped to maturation.

* Restore Content Server+Client run configuration

* Fix formatting in Content Server+Client run configuration

* Address botany review feedback

* review

* fix weed

* fix

* fix 2

* Update PlantSystem.cs

* refactor: revert to EntityTerminatingEvent and leave warning for next generations

---------

Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
Co-authored-by: Fildrance <fildrance@gmail.com>
2026-09-03 14:57:34 +00:00

61 lines
2.2 KiB
C#

using Content.Shared.Botany.Components;
using Content.Shared.Botany.Items.Components;
using Content.Shared.Botany.Traits.Components;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Power.EntitySystems;
using Content.Shared.Random.Helpers;
using Robust.Shared.Timing;
namespace Content.Shared.Botany.Systems;
public sealed partial class SeedExtractorSystem : EntitySystem
{
[Dependency] private BotanySystem _botany = default!;
[Dependency] private IGameTiming _timing = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private SharedPowerReceiverSystem _powerReceiver = default!;
[Dependency] private EntityQuery<ProduceComponent> _produceQuery;
[SubscribeLocalEvent]
private void OnInteractUsing(Entity<SeedExtractorComponent> ent, ref InteractUsingEvent args)
{
if (!_powerReceiver.IsPowered(ent.Owner))
return;
if (!_produceQuery.TryComp(args.Used, out var produce))
return;
if (produce.PlantProtoId == null)
return;
EntityUid? snapshot = null;
if (produce.PlantData != null)
snapshot = produce.PlantData;
if (_botany.TryGetPlantComponent<PlantTraitSeedlessComponent>(snapshot, produce.PlantProtoId, out _))
{
_popup.PopupCursor(Loc.GetString("seed-extractor-component-no-seeds", ("name", args.Used)),
args.User,
PopupType.SmallCaution);
return;
}
_popup.PopupCursor(Loc.GetString("seed-extractor-component-interact-message", ("name", args.Used)),
args.User);
PredictedQueueDel(args.Used);
args.Handled = true;
var random = SharedRandomExtensions.PredictedRandom(_timing, GetNetEntity(ent));
var amount = ent.Comp.BaseSeeds.NextFloat(random);
var coords = Transform(ent).Coordinates;
for (var i = 0; i < amount; i++)
{
if (_botany.TryGetPlantComponent<PlantDataComponent>(snapshot, produce.PlantProtoId, out var plantData))
_botany.SpawnSeedPacket(plantData, produce.PlantProtoId.Value, snapshot, coords, args.User);
}
}
}