CatStation/Content.Shared/Botany/Items/Systems/BotanyHoeSystem.cs
Jessica M 355dda8f9d
You can now water plants directly (#45931)
* plant holder relay

* did i fuck up merge conflicts? lets find out

* relay also handle
2026-09-19 02:44:07 +00:00

63 lines
1.9 KiB
C#

using Content.Shared.Botany.Components;
using Content.Shared.Botany.Events;
using Content.Shared.Botany.Items.Components;
using Content.Shared.Botany.Systems;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Robust.Shared.Player;
namespace Content.Shared.Botany.Items.Systems;
/// <summary>
/// System for taking a sample of a plant.
/// </summary>
public sealed partial class BotanyHoeSystem : EntitySystem
{
[Dependency] private PlantTraySystem _plantTray = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private EntityQuery<PlantTrayComponent> _trayQuery;
[SubscribeLocalEvent]
private void OnAfterInteract(Entity<BotanyHoeComponent> ent, ref AfterInteractEvent args)
{
if (args.Target == null || args.Handled || !args.CanReach)
return;
if (!_trayQuery.HasComp(args.Target.Value))
return;
var ev = new TrayHoeAttemptEvent(ent, args.User);
RaiseLocalEvent(args.Target.Value, ref ev);
args.Handled = true;
}
[SubscribeLocalEvent]
private void OnTrayHoeAttempt(Entity<PlantTrayComponent> ent, ref TrayHoeAttemptEvent args)
{
if (args.Cancelled)
return;
if (ent.Comp.WeedLevel <= 0)
{
_popup.PopupCursor(Loc.GetString("plant-hoe-component-no-weeds-popup"), args.User);
return;
}
_popup.PopupCursor(
Loc.GetString("plant-hoe-component-already-seeded-popup",
("name", ent.Owner)),
args.User,
PopupType.Medium);
_popup.PopupEntity(
Loc.GetString("plant-hoe-component-remove-weeds-others-popup",
("otherName", Identity.Entity(args.User, EntityManager))),
ent.Owner,
Filter.PvsExcept(args.User),
true);
_plantTray.AdjustWeed(ent.AsNullable(), -args.Hoe.Comp.WeedAmount);
}
}