feat: Adds SerializableFieldChanged option (#2324)
This commit is contained in:
parent
06bb2f552e
commit
fd2f90cba9
6 changed files with 62 additions and 122 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"isRoot": true,
|
"isRoot": true,
|
||||||
"tools": {
|
"tools": {
|
||||||
"modernuoschemagenerator": {
|
"modernuoschemagenerator": {
|
||||||
"version": "2.14.1",
|
"version": "2.14.2",
|
||||||
"commands": [
|
"commands": [
|
||||||
"ModernUOSchemaGenerator"
|
"ModernUOSchemaGenerator"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* ModernUO *
|
* ModernUO *
|
||||||
* Copyright 2019-2023 - ModernUO Development Team *
|
* Copyright 2019-2026 - ModernUO Development Team *
|
||||||
* Email: hi@modernuo.com *
|
* Email: hi@modernuo.com *
|
||||||
* File: ResistanceMod.cs *
|
* File: ResistanceMod.cs *
|
||||||
* *
|
* *
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using ModernUO.Serialization;
|
using ModernUO.Serialization;
|
||||||
|
|
||||||
namespace Server;
|
namespace Server;
|
||||||
|
|
@ -20,6 +21,20 @@ namespace Server;
|
||||||
[SerializationGenerator(0)]
|
[SerializationGenerator(0)]
|
||||||
public partial class ResistanceMod : MobileMod
|
public partial class ResistanceMod : MobileMod
|
||||||
{
|
{
|
||||||
|
[SerializableField(0)]
|
||||||
|
private ResistanceType _type;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(0)]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void OnTypeChanged(ResistanceType oldValue, ResistanceType newValue) => Owner?.UpdateResistances();
|
||||||
|
|
||||||
|
[SerializableField(1)]
|
||||||
|
private int _offset;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(1)]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void OnOffsetChanged(int oldValue, int newValue) => Owner?.UpdateResistances();
|
||||||
|
|
||||||
public ResistanceMod(Mobile owner) : base(owner)
|
public ResistanceMod(Mobile owner) : base(owner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -29,36 +44,4 @@ public partial class ResistanceMod : MobileMod
|
||||||
_type = type;
|
_type = type;
|
||||||
_offset = offset;
|
_offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializableProperty(0)]
|
|
||||||
public ResistanceType Type
|
|
||||||
{
|
|
||||||
get => _type;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_type != value)
|
|
||||||
{
|
|
||||||
_type = value;
|
|
||||||
|
|
||||||
Owner?.UpdateResistances();
|
|
||||||
MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializableProperty(1)]
|
|
||||||
public int Offset
|
|
||||||
{
|
|
||||||
get => _offset;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_offset != value)
|
|
||||||
{
|
|
||||||
_offset = value;
|
|
||||||
|
|
||||||
Owner?.UpdateResistances();
|
|
||||||
MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* ModernUO *
|
* ModernUO *
|
||||||
* Copyright 2019-2023 - ModernUO Development Team *
|
* Copyright 2019-2026 - ModernUO Development Team *
|
||||||
* Email: hi@modernuo.com *
|
* Email: hi@modernuo.com *
|
||||||
* File: SkillMod.cs *
|
* File: SkillMod.cs *
|
||||||
* *
|
* *
|
||||||
|
|
@ -21,6 +21,35 @@ namespace Server;
|
||||||
[SerializationGenerator(0)]
|
[SerializationGenerator(0)]
|
||||||
public abstract partial class SkillMod : MobileMod
|
public abstract partial class SkillMod : MobileMod
|
||||||
{
|
{
|
||||||
|
[SerializableField(0)]
|
||||||
|
private bool _obeyCap;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(0)]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void OnObeCapChanged(bool oldValue, bool newValue) => Owner?.Skills[_skill]?.Update();
|
||||||
|
|
||||||
|
[SerializableField(1)]
|
||||||
|
private SkillName _skill;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(1)]
|
||||||
|
private void OnSkillChanged(SkillName oldValue, SkillName newValue)
|
||||||
|
{
|
||||||
|
Owner?.Skills[newValue]?.Update();
|
||||||
|
Owner?.Skills[oldValue]?.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializableField(2)]
|
||||||
|
private bool _relative;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(2)]
|
||||||
|
private void OnRelativeChanged(bool oldValue, bool newValue) => Owner?.Skills[_skill]?.Update();
|
||||||
|
|
||||||
|
[SerializableField(3)]
|
||||||
|
private double _value;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(3)]
|
||||||
|
private void OnValueChanged(double oldValue, double newValue) => Owner?.Skills[_skill]?.Update();
|
||||||
|
|
||||||
public SkillMod(Mobile owner) : base(owner)
|
public SkillMod(Mobile owner) : base(owner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -32,80 +61,12 @@ public abstract partial class SkillMod : MobileMod
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializableProperty(0)]
|
|
||||||
public bool ObeyCap
|
|
||||||
{
|
|
||||||
get => _obeyCap;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_obeyCap = value;
|
|
||||||
|
|
||||||
var sk = Owner?.Skills[_skill];
|
|
||||||
sk?.Update();
|
|
||||||
MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializableProperty(1)]
|
|
||||||
public SkillName Skill
|
|
||||||
{
|
|
||||||
get => _skill;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_skill != value)
|
|
||||||
{
|
|
||||||
var oldUpdate = Owner?.Skills[_skill];
|
|
||||||
|
|
||||||
_skill = value;
|
|
||||||
|
|
||||||
var sk = Owner?.Skills[_skill];
|
|
||||||
sk?.Update();
|
|
||||||
oldUpdate?.Update();
|
|
||||||
MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializableProperty(2)]
|
|
||||||
public bool Relative
|
|
||||||
{
|
|
||||||
get => _relative;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_relative != value)
|
|
||||||
{
|
|
||||||
_relative = value;
|
|
||||||
|
|
||||||
var sk = Owner?.Skills[_skill];
|
|
||||||
sk?.Update();
|
|
||||||
MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Absolute
|
public bool Absolute
|
||||||
{
|
{
|
||||||
get => !Relative;
|
get => !Relative;
|
||||||
set => Relative = !value;
|
set => Relative = !value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializableProperty(3)]
|
|
||||||
public double Value
|
|
||||||
{
|
|
||||||
get => _value;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_value != value)
|
|
||||||
{
|
|
||||||
_value = value;
|
|
||||||
|
|
||||||
var sk = Owner?.Skills[_skill];
|
|
||||||
sk?.Update();
|
|
||||||
MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Remove() => Owner?.RemoveSkillMod(this);
|
public void Remove() => Owner?.RemoveSkillMod(this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@
|
||||||
<PackageReference Include="LibDeflate.Bindings" Version="1.0.2.120" />
|
<PackageReference Include="LibDeflate.Bindings" Version="1.0.2.120" />
|
||||||
<PackageReference Include="System.IO.Hashing" Version="10.0.2" />
|
<PackageReference Include="System.IO.Hashing" Version="10.0.2" />
|
||||||
|
|
||||||
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.14.0" />
|
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.14.2" />
|
||||||
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.14.1" />
|
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.14.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="Migrations/*.v*.json" />
|
<AdditionalFiles Include="Migrations/*.v*.json" />
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using ModernUO.Serialization;
|
using ModernUO.Serialization;
|
||||||
|
|
||||||
namespace Server.Items
|
namespace Server.Items
|
||||||
|
|
@ -51,6 +52,16 @@ namespace Server.Items
|
||||||
[SerializationGenerator(2, false)]
|
[SerializationGenerator(2, false)]
|
||||||
public partial class ThighBoots : BaseShoes, IArcaneEquip
|
public partial class ThighBoots : BaseShoes, IArcaneEquip
|
||||||
{
|
{
|
||||||
|
[EncodedInt]
|
||||||
|
[InvalidateProperties]
|
||||||
|
[SerializableField(0)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private int _curArcaneCharges;
|
||||||
|
|
||||||
|
[SerializableFieldChanged(0)]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void OnCurArcaneChargesChanged(int oldValue, int newValue) => Update();
|
||||||
|
|
||||||
[Constructible]
|
[Constructible]
|
||||||
public ThighBoots(int hue = 0) : base(0x1711, hue)
|
public ThighBoots(int hue = 0) : base(0x1711, hue)
|
||||||
{
|
{
|
||||||
|
|
@ -60,21 +71,6 @@ namespace Server.Items
|
||||||
|
|
||||||
public override CraftResource DefaultResource => CraftResource.RegularLeather;
|
public override CraftResource DefaultResource => CraftResource.RegularLeather;
|
||||||
|
|
||||||
[EncodedInt]
|
|
||||||
[SerializableProperty(0)]
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public int CurArcaneCharges
|
|
||||||
{
|
|
||||||
get => _curArcaneCharges;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_curArcaneCharges = value;
|
|
||||||
InvalidateProperties();
|
|
||||||
Update();
|
|
||||||
this.MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[EncodedInt]
|
[EncodedInt]
|
||||||
[SerializableProperty(1)]
|
[SerializableProperty(1)]
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@
|
||||||
<PackageReference Include="ModernUO.CodeGeneratedEvents.Generator" Version="1.0.3.2" PrivateAssets="all" />
|
<PackageReference Include="ModernUO.CodeGeneratedEvents.Generator" Version="1.0.3.2" PrivateAssets="all" />
|
||||||
<PackageReference Include="Zstd.Binaries" Version="1.6.0" />
|
<PackageReference Include="Zstd.Binaries" Version="1.6.0" />
|
||||||
|
|
||||||
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.14.0" />
|
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.14.2" />
|
||||||
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.14.1" />
|
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.14.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="Migrations/*.v*.json" />
|
<AdditionalFiles Include="Migrations/*.v*.json" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue