## 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.*
62 lines
1.3 KiB
C#
62 lines
1.3 KiB
C#
using System;
|
|
using ModernUO.Serialization;
|
|
|
|
namespace Server.Items
|
|
{
|
|
public enum WaterState
|
|
{
|
|
Dead,
|
|
Dying,
|
|
Unhealthy,
|
|
Healthy,
|
|
Strong
|
|
}
|
|
|
|
public enum FoodState
|
|
{
|
|
Dead,
|
|
Starving,
|
|
Hungry,
|
|
Full,
|
|
Overfed
|
|
}
|
|
|
|
[PropertyObject]
|
|
[SerializationGenerator(0, false)]
|
|
public partial class AquariumState
|
|
{
|
|
[DirtyTrackingEntity]
|
|
private Aquarium _aquarium;
|
|
|
|
public AquariumState(Aquarium parent) => _aquarium = parent;
|
|
|
|
[SerializableProperty(0)]
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int State
|
|
{
|
|
get => _state;
|
|
set
|
|
{
|
|
if (_state != value)
|
|
{
|
|
_state = Math.Clamp(value, 0, 4);
|
|
MarkDirty();
|
|
}
|
|
}
|
|
}
|
|
|
|
[SerializableField(1)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private int _maintain;
|
|
|
|
[SerializableField(2)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private int _improve;
|
|
|
|
[SerializableField(3)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private int _added;
|
|
|
|
public override string ToString() => "...";
|
|
}
|
|
}
|