ModernUO/Projects/UOContent/Items/Special/Veteran Rewards/FlamingHead.cs
Kamron Batman ab5f615840
perf: Migrate Veteran Reward gumps to DynamicGump/StaticGump (#2415)
## Summary

Migrates 16 player-facing legacy `Gump` subclasses in the Veteran Rewards system to `DynamicGump` or `StaticGump<T>`, renames every nested `InternalGump`/`ConfirmGump` to system-prefixed names, and updates external callers to use new static `DisplayTo` entry points.

### Reward chain (Engines/Veteran Rewards)

| Gump | Base type | Reasoning |
|---|---|---|
| `RewardNoticeGump` | `StaticGump<T>` | Fixed layout |
| `RewardChoiceGump` | `DynamicGump` | Layout shape varies (per-player categories, entries, pages) |
| `RewardConfirmGump` | `DynamicGump` | `entry.Name` is a dynamic cliloc per reward (cliloc rule) |
| `RewardOptionGump` | `DynamicGump` | Title cliloc and per-option clilocs are dynamic (cliloc rule) |
| `RewardDemolitionGump` | `DynamicGump` | `question` cliloc is dynamic per caller (cliloc rule) |

### Statue (Engines/Veteran Rewards/Character Statue Maker)

| Gump | Base type | Reasoning |
|---|---|---|
| `CharacterStatueGump` | `DynamicGump` | Pose/Direction/Material labels are dynamic clilocs (cliloc rule) |
| `CharacterPlinthGump` | `DynamicGump` | `statue.Name`, sculpted-on date, and statue-type cliloc are dynamic (cliloc rule) |

### Decorations (Items/Special/Veteran Rewards) — every `InternalGump` renamed

| Original | New name | Base type | Reasoning |
|---|---|---|---|
| `Banner.InternalGump` | `BannerGump` | `StaticGump<T>` | Fully fixed item-id picker over `Start..End` range |
| `Brazier.InternalGump` | `BrazierGump` | `StaticGump<T>` | Fixed two-item picker |
| `Cannon.InternalGump` | `CannonGump` | `DynamicGump` | `keg.Validate()` value passed as `~1_CHARGES~` arg (cliloc-arg rule) |
| `DecorativeShield.InternalGump` | `DecorativeShieldGump` | `StaticGump<T>` | Fixed item picker over a constant range |
| `DecorativeShield.FacingGump` | `DecorativeShieldFacingGump` | `DynamicGump` | Item ids depend on instance state |
| `HangingSkeleton.InternalGump` | `HangingSkeletonGump` | `StaticGump<T>` | Fixed item picker (5 hard-coded ids) |
| `PottedCactus.InternalGump` | `PottedCactusGump` | `StaticGump<T>` | Fixed 6-item picker |
| `StoneAnkh.InternalGump` | `StoneAnkhGump` | `StaticGump<T>` | Fixed two-direction picker |
| `WallBanner.InternalGump` | `WallBannerGump` | `StaticGump<T>` | Fixed 30-banner picker across 5 pages |
| `WeaponEngravingTool.InternalGump` | `WeaponEngravingToolGump` | `StaticGump<T>` | Fixed text-entry dialog |
| `WeaponEngravingTool.ConfirmGump` | `WeaponEngravingToolConfirmGump` | `DynamicGump` | Layout branches on `guildmaster != null` |

### External callers updated

`RewardSystem`, `CharacterStatue`, `FireFliesDeed`, `FlamingHead`, `Banner`, `DecorativeShield`, `HangingSkeleton`, `StoneAnkh` (RewardDemolitionGump callers); `AnkhOfSacrifice`, `Cannon`, `MiningCart`, `MinotaurStatue`, `TreeStump` (RewardOptionGump callers); `TinkerGuildmaster` (engraver confirm gump).

The pre-existing `FacingGump` inside `Banner.cs` (already `DynamicGump`) was left as-is — it is private, nested inside `InternalTarget`, and never referenced outside.
2026-04-25 20:09:27 -07:00

222 lines
6.1 KiB
C#

using ModernUO.Serialization;
using Server.Engines.VeteranRewards;
using Server.Gumps;
using Server.Multis;
using Server.Targeting;
namespace Server.Items;
[SerializationGenerator(0)]
public partial class FlamingHead : StoneFaceTrapNoDamage, IAddon, IRewardItem
{
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _isRewardItem;
[Constructible]
public FlamingHead(StoneFaceTrapType type = StoneFaceTrapType.NorthWall)
{
LootType = LootType.Blessed;
Movable = false;
Type = type;
}
public override int LabelNumber => 1041266; // Flaming Head
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
public Item Deed =>
new FlamingHeadDeed
{
IsRewardItem = _isRewardItem
};
public bool CouldFit(IPoint3D p, Map map)
{
if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true)
{
return false;
}
if (Type == StoneFaceTrapType.NorthWestWall)
{
return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map) &&
BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // north and west wall
}
if (Type == StoneFaceTrapType.NorthWall)
{
return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // north wall
}
if (Type == StoneFaceTrapType.WestWall)
{
return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // west wall
}
return false;
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
if (Core.ML && _isRewardItem)
{
list.Add(1076218); // 2nd Year Veteran Reward
}
}
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(Location, 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
return;
}
var house = BaseHouse.FindHouseAt(this);
if (house?.IsOwner(from) == true)
{
RewardDemolitionGump.DisplayTo(from, this, 1018329); // Do you wish to re-deed this skull?
}
else
{
// You can only re-deed a skull if you placed it or you are the owner of the house.
from.SendLocalizedMessage(1018328);
}
}
}
[SerializationGenerator(0)]
public partial class FlamingHeadDeed : Item, IRewardItem
{
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _isRewardItem;
[Constructible]
public FlamingHeadDeed() : base(0x14F0) => LootType = LootType.Blessed;
public override double DefaultWeight => 1.0;
public override int LabelNumber => 1041050; // a flaming head deed
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
if (_isRewardItem)
{
list.Add(1076218); // 2nd Year Veteran Reward
}
}
public override void OnDoubleClick(Mobile from)
{
if (_isRewardItem && !RewardSystem.CheckIsUsableBy(from, this))
{
return;
}
if (IsChildOf(from.Backpack))
{
var house = BaseHouse.FindHouseAt(from);
if (house?.IsOwner(from) == true)
{
from.SendLocalizedMessage(1042264); // Where would you like to place this head?
from.Target = new InternalTarget(this);
}
else
{
from.SendLocalizedMessage(502115); // You must be in your house to do this.
}
}
else
{
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
}
}
private class InternalTarget : Target
{
private readonly FlamingHeadDeed _deed;
public InternalTarget(FlamingHeadDeed deed) : base(-1, true, TargetFlags.None) => _deed = deed;
protected override void OnTarget(Mobile from, object targeted)
{
if (_deed?.Deleted != false)
{
return;
}
if (!_deed.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
return;
}
var house = BaseHouse.FindHouseAt(from);
if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(502115); // You must be in your house to do this.
return;
}
var p = targeted as IPoint3D;
var map = from.Map;
if (p == null || map == null)
{
return;
}
var p3d = new Point3D(p);
var id = TileData.ItemTable[0x10F5];
house = BaseHouse.FindHouseAt(p3d, map, id.Height);
if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
return;
}
if (!map.CanFit(p3d, id.Height))
{
from.SendLocalizedMessage(1042266); // The head must be placed next to a wall.
return;
}
var north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map);
var west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map);
if (!(north || west))
{
from.SendLocalizedMessage(1042266); // The head must be placed next to a wall.
return;
}
var facing = north switch
{
true when west => StoneFaceTrapType.NorthWestWall,
true => StoneFaceTrapType.NorthWall,
_ => StoneFaceTrapType.WestWall
};
var head = new FlamingHead(facing)
{
IsRewardItem = _deed.IsRewardItem
};
_deed.Delete();
house.Addons.Add(head);
head.MoveToWorld(p3d, map);
}
}
}