## Summary Second PR in the player-facing legacy gump migration. Converts the four Plants system gumps: - `MainPlantGump`, `ReproductionGump`, `EmptyTheBowlGump` → `DynamicGump`. Layout varies by plant status, growth stage, health, and pollination/resource availability — cannot use cached `StaticGump<T>`. - `SetToDecorativeGump` → `StaticGump<SetToDecorativeGump>`. Pure confirmation dialog with no per-instance variation. All four: - `Singleton => true` (auto-replace previous plant gump on re-open instead of stacking) - Constructor `private`; entry is static `DisplayTo(Mobile, PlantItem)` per the empty-gump rule (CLAUDE.md §13) - `OnResponse` self-refresh paths converted from `from.SendGump(new XGump(_plant))` to `from.SendGump(this)` — saves an allocation on every help/info button click and on every "gather resources/seeds/pollen" action - Helper draw methods take `ref DynamicGumpBuilder builder` instead of mutating instance state - Renamed legacy `m_Plant` to `_plant` per CLAUDE.md §12 Updated external callers to use the new entry points: - `PlantItem.OnDoubleClick` → `MainPlantGump.DisplayTo(from, this)` - `PlantPourTarget.OnTargetFinish` → `MainPlantGump.DisplayTo(from, m_Plant)` (also drops the now-redundant legacy `singleton: true` flag — `Singleton` property handles it) - `PollinateTarget.OnTargetFinish` → `ReproductionGump.DisplayTo(from, m_Plant)`
29 lines
893 B
C#
29 lines
893 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))
|
|
{
|
|
MainPlantGump.DisplayTo(from, m_Plant);
|
|
}
|
|
}
|
|
}
|
|
}
|