ModernUO/Projects/UOContent/Items/Body Parts/Head.cs
Kamron Batman 936000ecf7
feat: Adds SerializedCommandProperty (#1249)
## Breaking Change
* Removes `SerializableFieldAttrAttribute` in favor of `SerializedPropertyAttr`.

## Important Change
* Adds `SerializedCommandProperty`

Example:
```cs
    [InvalidateProperties]
    [SerializableField(0)]
    [SerializedCommandProperty(AccessLevel.GameMaster)]
    private Mobile _completedBy;
```
2022-11-14 18:24:33 -08:00

61 lines
1.6 KiB
C#

using ModernUO.Serialization;
namespace Server.Items
{
public enum HeadType
{
Regular,
Duel,
Tournament
}
[SerializationGenerator(1, false)]
public partial class Head : Item
{
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private string _playerName;
[InvalidateProperties]
[SerializableField(1)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private HeadType _headType;
[Constructible]
public Head(string playerName) : this(HeadType.Regular, playerName)
{
}
[Constructible]
public Head(HeadType headType = HeadType.Regular, string playerName = null) : base(0x1DA0)
{
_headType = headType;
_playerName = playerName;
}
public override string DefaultName
{
get
{
if (_playerName == null)
{
return base.DefaultName;
}
return _headType switch
{
HeadType.Duel => $"the head of {_playerName}, taken in a duel",
HeadType.Tournament => $"the head of {_playerName}, taken in a tournament",
_ => $"the head of {_playerName}"
};
}
}
private void Deserialize(IGenericReader reader, int version)
{
_playerName = reader.ReadString();
_headType = (HeadType)reader.ReadEncodedInt();
}
}
}