mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
51 lines
1.8 KiB
C#
51 lines
1.8 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 || _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<PlantTraitLigneousComponent> 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;
|
|
}
|
|
}
|