From: miniduikboot Date: Sun, 21 Jul 2024 20:31:41 +0000 (+0200) Subject: Add dirty tracking to PlayerOutfit X-Git-Tag: v1.10.0~7^2~14 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=615469c6c89bbf45baa0f9d1772acb70dea19067;p=rhonda%2Fimpostor.git Add dirty tracking to PlayerOutfit To prevent excessive modifications in the codebase, which is prone to issues if a callsite is missed, automatically do this using properties. Keep the access modifiers intact for now. --- diff --git a/src/Impostor.Api/Innersloth/Customization/PlayerOutfit.cs b/src/Impostor.Api/Innersloth/Customization/PlayerOutfit.cs index c6abce0..a93fc5e 100644 --- a/src/Impostor.Api/Innersloth/Customization/PlayerOutfit.cs +++ b/src/Impostor.Api/Innersloth/Customization/PlayerOutfit.cs @@ -2,19 +2,57 @@ namespace Impostor.Api.Innersloth.Customization { public class PlayerOutfit { - public string PlayerName { get; internal set; } = string.Empty; + private string _playerName = string.Empty; + private ColorType _color = (ColorType)(-1); + private string _hatId = "missing"; + private string _petId = "missing"; + private string _skinId = "missing"; + private string _visorId = "missing"; + private string _namePlateId = "missing"; - public ColorType Color { get; internal set; } = (ColorType)(-1); + public bool IsDirty { get; internal set; } - public string HatId { get; internal set; } = "missing"; + public string PlayerName + { + get => _playerName; + internal set => SetField(ref _playerName, value); + } - public string PetId { get; internal set; } = "missing"; + public ColorType Color + { + get => _color; + internal set => SetField(ref _color, value); + } - public string SkinId { get; internal set; } = "missing"; + public string HatId + { + get => _hatId; + internal set => SetField(ref _hatId, value); + } - public string VisorId { get; internal set; } = "missing"; + public string PetId + { + get => _petId; + internal set => SetField(ref _petId, value); + } - public string NamePlateId { get; internal set; } = "missing"; + public string SkinId + { + get => _skinId; + internal set => SetField(ref _skinId, value); + } + + public string VisorId + { + get => _visorId; + internal set => SetField(ref _visorId, value); + } + + public string NamePlateId + { + get => _namePlateId; + internal set => SetField(ref _namePlateId, value); + } private byte HatSequenceId { get; set; } = 0; @@ -70,5 +108,11 @@ namespace Impostor.Api.Innersloth.Customization VisorSequenceId = reader.ReadByte(); NamePlateSequenceId = reader.ReadByte(); } + + private void SetField(ref T field, T value) + { + field = value; + IsDirty = true; + } } }