ModernUO/Projects/UOContent/Engines/Plants/PlantPourTarget.cs
Kamron Batman 8282b00ca2
feat: Moves gumps out of the core (#1916)
> [!Important]
> **Developer Note**
> This code change will **completely move gumps out of the core**


### Summary

- Adds `GetGumps()` convenience which exposes methods to Find/Close/Send multiple gumps. This helper is a performance improvement by eliminating the Dictionary<Player, List> lookup for gumps.
2024-08-09 19:07:32 -07:00

29 lines
902 B
C#

using Server.Gumps;
using Server.Targeting;
namespace Server.Engines.Plants
{
public class PlantPourTarget : Target
{
private readonly PlantItem m_Plant;
public PlantPourTarget(PlantItem plant) : base(3, true, TargetFlags.None) => m_Plant = plant;
protected override void OnTarget(Mobile from, object targeted)
{
if (!m_Plant.Deleted && from.InRange(m_Plant.GetWorldLocation(), 3) && targeted is Item item)
{
m_Plant.Pour(from, item);
}
}
protected override void OnTargetFinish(Mobile from)
{
if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant &&
from.InRange(m_Plant.GetWorldLocation(), 3) && m_Plant.IsUsableBy(from))
{
from.SendGump(new MainPlantGump(m_Plant), true);
}
}
}
}