feat: Updates to Serialization Generator v2.2 (#1157)

* Adds `SerializationProperty` - This will generate the private variable for serialization. Also provides an option `useField` to specify your own. Example:
  ```cs
  [SerializationProperty(0, useField: nameof(_resource)]
  ```
This commit is contained in:
Kamron Batman 2022-09-04 08:45:27 -07:00 committed by GitHub
parent d82028a071
commit 89815ad4d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 242 additions and 361 deletions

View file

@ -24,9 +24,6 @@ namespace Server.Items
[SerializationGenerator(3, false)]
public abstract partial class BaseAddon : Item, IChoppable, IAddon
{
[SerializableField(1, "private", "private")]
private CraftResource _rawResource;
public BaseAddon() : base(1)
{
Movable = false;
@ -66,16 +63,17 @@ namespace Server.Items
}
}
[SerializableProperty(1)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _rawResource;
get => _resource;
set
{
if (_rawResource != value)
if (_resource != value)
{
RawResource = value;
Hue = CraftResources.GetHue(_rawResource);
_resource = value;
Hue = CraftResources.GetHue(_resource);
InvalidateProperties();
this.MarkDirty();
@ -285,7 +283,7 @@ namespace Server.Items
if (version == 2)
{
_rawResource = (CraftResource)reader.ReadEncodedInt();
_resource = (CraftResource)reader.ReadEncodedInt();
}
}
}