ModernUO/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Objectives.cs
Kamron Batman b90ac0d481
perf: Migrate Quest gumps to DynamicGump (#2416)
## Summary

Migrates the Quest system gumps from legacy `Gump` to `DynamicGump` / `StaticGump<T>`.

**Renames** `Engines/ML Quests/Gumps/BaseQuestGump` to **`BaseMLQuestGump`** to
disambiguate from the Core quest abstract (`Engines/Quests/Core/QuestSystem.cs`).
Both abstracts now extend `DynamicGump`.

**Abstract bases**:
- `Server.Engines.Quests.BaseQuestGump` (Core) - now `abstract DynamicGump`. Holds constants and a static `AddHtmlObject(ref DynamicGumpBuilder, ...)` helper. Concrete subclasses each provide their own `BuildLayout`.
- `Server.Engines.MLQuests.Gumps.BaseMLQuestGump` (ML, renamed) - now `abstract DynamicGump` with a `protected abstract BuildContent(ref DynamicGumpBuilder)` hook. The base's `BuildLayout` draws shared chrome (background art, frame, label header) and then invokes `BuildContent`; subclasses use `BuildPage`, `SetTitle`, `RegisterButton`, `SetPageCount`, and content helpers (`AddDescription`, `AddObjectives`, `AddObjectivesProgress`, `AddRewardsPage`, `AddRewards`, `AddConversation`).

**Concrete Core gumps** migrated to `DynamicGump`:
- `QuestCancelGump`, `QuestOfferGump` (Core), `QuestObjectivesGump`, `QuestConversationsGump`, `QuestLogUpdatedGump`, `QuestItemInfoGump`, `SheetMusicOfferGump` (Impresario), `PaintedImageGump` (renamed from `PaintedImage.InternalGump`).

**Concrete ML gumps** migrated to `DynamicGump` (extending `BaseMLQuestGump` or directly):
- `InfoNPCGump`, `QuestConversationGump`, `QuestLogDetailedGump`, `QuestLogGump`, `QuestOfferGump` (ML), `QuestReportBackGump`, `QuestRewardGump`, `QuestCancelConfirmGump`, `RaceChangeConfirmGump`.

**`StaticGump<T>` migrations**:
- `ScrollOfAbraxusGump` (Dark Tides). Its layout is a single hard-coded cliloc (1060116) with no per-instance dynamic content - safe to cache.

**Cliloc rule**: Every other quest dialog bakes per-instance cliloc IDs into its layout (quest titles, NPC names, race-specific prompts, era-conditional progress messages, escort destinations). Per the cliloc rule, baking different cliloc numbers into a cached layout would defeat `StaticGump<T>` caching - so all of these are `DynamicGump`.

**Signature changes** to support the migration:
- `QuestObjective.RenderMessage`/`RenderProgress` now take `ref DynamicGumpBuilder builder` (15 overrides updated across Collector, Solen Matriarch, Ambitious Solen Queen, Study of the Solen Hive, Terrible Hatchlings, The Summoning, Uzeraan Turmoil, Witch Apprentice, Emino's Undertaking).
- ML `BaseObjective.WriteToGump` / `BaseObjectiveInstance.WriteToGump` / `BaseReward.WriteToGump` now take `ref DynamicGumpBuilder` (KillObjective, GainSkillObjective, EscortObjective, CollectObjective, DeliverObjective, BaseReward).

**Empty-gump and `Singleton` rules**: All concrete gumps now have private constructors with static `DisplayTo` entry points that null-check the player NetState before allocation. All gumps that shouldn't stack are `Singleton => true`.

**External callers updated**: `MLQuest.SendOffer`/`OnRefuse`, `MLQuestEntry.SendProgressGump`/`SendRewardGump`/`SendReportBackGump`, `MLQuestSystem.QuestGumpRequest` and `ViewQuestsCommand`, `BoonCollector` (Darius/Nedrick), `SirHelper.OnDoubleClick` (no longer caches a single shared `InfoNPCGump` instance - `DisplayTo` constructs one per click and the gump's `Singleton => true` handles deduplication), `RaceChangeDeed.OnDoubleClick`, `PaintedImage.OnDoubleClick`, `ScrollOfAbraxus.OnDoubleClick`, `Impresario.OnTalk`, and `PlayerMobile`'s `BaseQuestGump` alias is now `BaseMLQuestGump`.

**Concrete subclasses found beyond the listed entry points**: `SheetMusicOfferGump` (in Impresario.cs), `PaintedImageGump` (was `PaintedImage.InternalGump`), `QuestObjectivesGump`, `QuestConversationsGump`, `QuestLogUpdatedGump`, `QuestItemInfoGump` (the Core base has these embedded across `QuestSystem.cs`/`QuestObjective.cs`/`QuestConversation.cs`/`QuestItemInfo.cs`).

**Code-standards cleanup**: Renamed legacy `m_X` private fields to `_x` in rewritten files; braces on all control flow.
2026-04-25 20:23:13 -07:00

134 lines
3.6 KiB
C#

using Server.Gumps;
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.Quests.Zento
{
public class FirstKillObjective : QuestObjective
{
public override int Message => 1063316;
public override void RenderProgress(ref DynamicGumpBuilder builder)
{
if (!Completed)
{
// Deathwatch Beetle Hatchlings killed:
builder.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0xC6BF);
builder.AddLabel(70, 280, 0x64, "0");
builder.AddLabel(100, 280, 0x64, "/");
builder.AddLabel(130, 280, 0x64, "10");
}
else
{
base.RenderProgress(ref builder);
}
}
public override void OnKill(BaseCreature creature, Container corpse)
{
if (creature is DeathwatchBeetleHatchling)
{
Complete();
}
}
public override void OnComplete()
{
System.AddObjective(new SecondKillObjective());
}
}
public class SecondKillObjective : QuestObjective
{
public override int Message => 1063320;
public override void RenderProgress(ref DynamicGumpBuilder builder)
{
if (!Completed)
{
// Deathwatch Beetle Hatchlings killed:
builder.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0xC6BF);
builder.AddLabel(70, 280, 0x64, "1");
builder.AddLabel(100, 280, 0x64, "/");
builder.AddLabel(130, 280, 0x64, "10");
}
else
{
base.RenderProgress(ref builder);
}
}
public override void OnKill(BaseCreature creature, Container corpse)
{
if (creature is DeathwatchBeetleHatchling)
{
Complete();
System.AddObjective(new ThirdKillObjective(2));
}
}
public override void OnRead()
{
if (!Completed)
{
Complete();
System.AddObjective(new ThirdKillObjective(1));
}
}
}
public class ThirdKillObjective : QuestObjective
{
public ThirdKillObjective(int startingProgress) => CurProgress = startingProgress;
public ThirdKillObjective()
{
}
public override int Message => 1063319;
public override int MaxProgress => 10;
public override void RenderProgress(ref DynamicGumpBuilder builder)
{
if (!Completed)
{
// Deathwatch Beetle Hatchlings killed:
builder.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0xC6BF);
builder.AddLabel(70, 280, 0x64, $"{CurProgress}");
builder.AddLabel(100, 280, 0x64, "/");
builder.AddLabel(130, 280, 0x64, "10");
}
else
{
base.RenderProgress(ref builder);
}
}
public override void OnKill(BaseCreature creature, Container corpse)
{
if (creature is DeathwatchBeetleHatchling)
{
CurProgress++;
}
}
public override void OnComplete()
{
System.AddObjective(new ReturnObjective());
}
}
public class ReturnObjective : QuestObjective
{
public override int Message => 1063313;
public override void OnComplete()
{
System.AddConversation(new EndConversation());
}
}
}