## Summary ### Changes - Adds `[IgnoreDupe]` and `[SerializedIgnoreDupe]` - Updates all _known_ classes that need the attribute. Some might be missing, please helps us find them! - Adds `Item.Dupe()` command and encapsulates `CopyProperties` and `OnAfterDuped`. This is also overridable. - Updates Dupe command to use the new logic. - Fixes duping multiple kinds of objects that used to be outright broken. ### Bug Fixes - Fixes issue with durability after duping - Fixes issue with hue after duping > [!Note] > **Developer Note** > Customizing how duping an item works now requires two steps: > 1. Add `[IgnoreDupe]` or `[SerializedIgnoreDupe]` to the property/field > 2. Add custom logic in an `OnAfterDuped` override > > When do you need to do this? > *When the property being copied is not a primitive, and you need to manually deep-clone the contents of the property such as with Lists, Dictionaries, or sub classes.*
59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using ModernUO.Serialization;
|
|
using Server.ContextMenus;
|
|
using Server.Gumps;
|
|
using Server.Multis;
|
|
|
|
namespace Server.Items;
|
|
|
|
[Flippable(0x234E, 0x234F)]
|
|
[SerializationGenerator(1)]
|
|
public partial class TapestryOfSosaria : Item, ISecurable
|
|
{
|
|
[SerializedIgnoreDupe]
|
|
[SerializableField(0)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private SecureLevel _level;
|
|
|
|
[Constructible]
|
|
public TapestryOfSosaria() : base(0x234E)
|
|
{
|
|
Weight = 1.0;
|
|
LootType = LootType.Blessed;
|
|
}
|
|
|
|
public override int LabelNumber => 1062917; // The Tapestry of Sosaria
|
|
|
|
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
|
{
|
|
base.GetContextMenuEntries(from, list);
|
|
|
|
SetSecureLevelEntry.AddTo(from, this, list);
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (from.InRange(GetWorldLocation(), 2))
|
|
{
|
|
from.CloseGump<InternalGump>();
|
|
from.SendGump(new InternalGump());
|
|
}
|
|
else
|
|
{
|
|
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
|
}
|
|
}
|
|
|
|
private void Deserialize(IGenericReader reader, int version)
|
|
{
|
|
Level = (SecureLevel)reader.ReadEncodedInt();
|
|
}
|
|
|
|
private class InternalGump : Gump
|
|
{
|
|
public InternalGump() : base(50, 50)
|
|
{
|
|
AddImage(0, 0, 0x2C95);
|
|
}
|
|
}
|
|
}
|