CatStation/Content.Shared/Botany/Traits/Systems/PlantTraitLigneousSystem.cs
ahandleman c46f74c355
Various small botany bugfixes and reverts to prior behavior (#45842)
* Various small botany bugfixes and reverts to prior behavior

* oops rainbow cannabis needs it too

* oops, need to keep remove around for stuff like phal and plant-b-gone

* fix comment

* Fixed to make it selectable

* No need for plantPhalaxEntityEffect

* Ok moving removing this to its own PR because actually the guidebook stuff is weird and I wanna get this out the door.

* endless fixes to the botany

* renaming methods

* Refactored to remove PlantPhalanximineEntityEffectSystem because it's just a trait.

* removed the actual file

* renamed to noun/description for clarity

---------

Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
2026-09-06 17:46:38 +00:00

54 lines
1.9 KiB
C#

using Content.Shared.Botany.Components;
using Content.Shared.Botany.Events;
using Content.Shared.Botany.Systems;
using Content.Shared.Botany.Traits.Components;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Tools.Systems;
namespace Content.Shared.Botany.Traits.Systems;
/// <inheritdoc cref="PlantTraitLigneousComponent"/>
public sealed partial class PlantTraitLigneousSystem : EntitySystem
{
[Dependency] private PlantHarvestSystem _plantHarvest = default!;
[Dependency] private PlantHolderSystem _plantHolder = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private SharedToolSystem _tool = default!;
[Dependency] private EntityQuery<PlantHolderComponent> _holderQuery;
[SubscribeLocalEvent]
private void OnInteractUsing(Entity<PlantTraitLigneousComponent> ent, ref InteractUsingEvent args)
{
if (args.Handled)
return;
if (!_holderQuery.TryComp(ent.Owner, out var holder))
return;
if (!holder.ReadyForHarvest)
return;
if (_plantHolder.IsDead(ent.Owner))
{
_popup.PopupCursor(Loc.GetString("plant-component-dead-plant-message"), args.User);
return;
}
// Ligneous requires sharp tool.
var harvestToolQuality = ent.Comp.HarvestToolQuality;
if (harvestToolQuality.HasValue && !_tool.HasQuality(args.Used, harvestToolQuality.Value))
return;
_plantHarvest.TryHandleHarvest(ent.Owner, args.User);
args.Handled = true;
}
[SubscribeLocalEvent(before: [typeof(PlantHarvestSystem)])]
private void OnHarvestAttempt(Entity<PlantTraitLigneousComponent> ent, ref PlantHarvestAttemptEvent args)
{
_popup.PopupCursor(Loc.GetString("plant-component-ligneous-cant-harvest-message"), args.User);
args.Cancelled = true;
}
}