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; /// 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 _holderQuery; [SubscribeLocalEvent] private void OnInteractUsing(Entity ent, ref InteractUsingEvent args) { if (args.Handled) return; if (!_holderQuery.TryComp(ent.Owner, out var holder)) return; if (!holder.ReadyForHarvest || _plantHolder.IsDead(ent.Owner)) return; // Ligneous requires sharp tool. if (!_tool.HasQuality(args.Used, ent.Comp.HarvestToolQuality)) return; _plantHarvest.TryHandleHarvest(ent.Owner, args.User, args.Used); args.Handled = true; } [SubscribeLocalEvent(before: [typeof(PlantHarvestSystem)])] private void OnHarvestAttempt(Entity ent, ref PlantHarvestAttemptEvent args) { if (args.Used is { } used && _tool.HasQuality(used, ent.Comp.HarvestToolQuality)) return; _popup.PopupCursor(Loc.GetString("plant-component-ligneous-cant-harvest-message"), args.User); args.Cancelled = true; } }