From 8bdcf44a32c4ff2c198988642b12ca470d96dc28 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Sat, 7 Nov 2026 02:57:36 -0500 Subject: [PATCH] deduplicate code + simplify getters --- MiraAPI/Colors/CustomColor.cs | 4 +- .../Colors/RegisterCustomColorsAttribute.cs | 2 +- MiraAPI/Colors/VariableColor.cs | 4 +- .../Events/Mira/MiraButtonCancelledEvent.cs | 4 +- MiraAPI/Events/Mira/MiraButtonClickEvent.cs | 6 +- MiraAPI/Events/Mira/UiButtonPostResetEvent.cs | 4 +- MiraAPI/Events/MiraEventWrapper.cs | 4 +- MiraAPI/Events/RegisterEventAttribute.cs | 2 +- .../Vanilla/Gameplay/AfterMurderEvent.cs | 12 ++-- .../Vanilla/Gameplay/BeforeGameEndEvent.cs | 2 +- .../Vanilla/Gameplay/BeforeMurderEvent.cs | 8 +-- .../Vanilla/Gameplay/BeforeRoundStartEvent.cs | 2 +- .../Events/Vanilla/Gameplay/GameEndEvent.cs | 2 +- .../Vanilla/Gameplay/IntroBeginEvent.cs | 2 +- .../Events/Vanilla/Gameplay/IntroEndEvent.cs | 2 +- .../Vanilla/Gameplay/IntroRoleRevealEvent.cs | 2 +- .../Vanilla/Gameplay/RoundStartEvent.cs | 2 +- .../Events/Vanilla/Gameplay/SetRoleEvent.cs | 4 +- .../Gameplay/VanillaButtonCancelledEvent.cs | 4 +- .../Gameplay/VanillaButtonClickEvent.cs | 10 +-- MiraAPI/Events/Vanilla/Map/CloseDoorsEvent.cs | 2 +- .../Vanilla/Map/PlayerOpenSabotageEvent.cs | 2 +- .../Events/Vanilla/Map/UpdateSystemEvent.cs | 6 +- .../Events/Vanilla/Meeting/EjectionEvent.cs | 2 +- .../Events/Vanilla/Meeting/EndMeetingEvent.cs | 2 +- .../Events/Vanilla/Meeting/ReportBodyEvent.cs | 6 +- .../Vanilla/Meeting/StartMeetingEvent.cs | 2 +- .../Vanilla/Meeting/Voting/AfterVoteEvent.cs | 4 +- .../Vanilla/Meeting/Voting/BeforeVoteEvent.cs | 4 +- .../Meeting/Voting/CheckForEndVotingEvent.cs | 2 +- .../Vanilla/Meeting/Voting/DummyVoteEvent.cs | 4 +- .../Vanilla/Meeting/Voting/HandleVoteEvent.cs | 12 ++-- .../Meeting/Voting/MeetingSelectEvent.cs | 4 +- .../Meeting/Voting/PopulateResultsEvent.cs | 2 +- .../Meeting/Voting/ProcessVotesEvent.cs | 2 +- .../Meeting/Voting/VotingCompleteEvent.cs | 2 +- .../Vanilla/Player/CompleteHnsTaskEvent.cs | 6 +- .../Vanilla/Player/CompleteTaskEvent.cs | 4 +- .../Events/Vanilla/Player/PlayerDeathEvent.cs | 6 +- .../Events/Vanilla/Player/PlayerJoinEvent.cs | 2 +- .../Events/Vanilla/Player/PlayerLeaveEvent.cs | 4 +- .../Events/Vanilla/Usables/EnterVentEvent.cs | 4 +- .../Events/Vanilla/Usables/ExitVentEvent.cs | 4 +- .../Events/Vanilla/Usables/PlayerUseEvent.cs | 2 +- MiraAPI/GameOptions/CollectionBuilder.cs | 4 +- MiraAPI/GameOptions/ModdedOptionsManager.cs | 2 +- .../GameOptions/OptionTypes/ModdedOption.cs | 2 +- MiraAPI/Hud/MultiTargetButton.cs | 2 +- MiraAPI/Keybinds/MiraKeybind.cs | 4 +- .../SettingTypes/LocalEnumSetting.cs | 2 +- .../SettingTypes/LocalSliderSetting.cs | 4 +- .../MeetingAbilities/TargetedMeetingButton.cs | 2 +- MiraAPI/Networking/NetData.cs | 4 +- MiraAPI/Networking/SyncOptionsRpc.cs | 47 +++++++++----- MiraAPI/Networking/SyncRoleOptionsRpc.cs | 64 ------------------- MiraAPI/Patches/RoleGuidePatches.cs | 12 ++-- MiraAPI/Presets/OptionPreset.cs | 8 +-- MiraAPI/Utilities/GuideOptionsPatches.cs | 12 ++-- 58 files changed, 147 insertions(+), 194 deletions(-) delete mode 100644 MiraAPI/Networking/SyncRoleOptionsRpc.cs diff --git a/MiraAPI/Colors/CustomColor.cs b/MiraAPI/Colors/CustomColor.cs index d9225e25..156bb3b5 100644 --- a/MiraAPI/Colors/CustomColor.cs +++ b/MiraAPI/Colors/CustomColor.cs @@ -23,12 +23,12 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor, /// /// Gets the main color. /// - public Color32 MainColor { get; } = mainColor; + public Color32 MainColor => mainColor; /// /// Gets the shadow color. /// - public Color32 ShadowColor { get; } = shadowColor; + public Color32 ShadowColor => shadowColor; /// /// Gets the name of the color. diff --git a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs index b7c96206..eecba2b5 100644 --- a/MiraAPI/Colors/RegisterCustomColorsAttribute.cs +++ b/MiraAPI/Colors/RegisterCustomColorsAttribute.cs @@ -12,7 +12,7 @@ public class RegisterCustomColorsAttribute(string idPrefix) : Attribute /// /// Gets the translation ID prefix for all of the colors within the container type. /// - public string IdPrefix { get; } = idPrefix; + public string IdPrefix => idPrefix; /// /// Initializes a new instance of the class. diff --git a/MiraAPI/Colors/VariableColor.cs b/MiraAPI/Colors/VariableColor.cs index b3ff8ad1..6a6eae1c 100644 --- a/MiraAPI/Colors/VariableColor.cs +++ b/MiraAPI/Colors/VariableColor.cs @@ -35,12 +35,12 @@ public sealed class VariableColor( /// /// Gets a delegate that takes in a time value and returns the dynamic main color. /// - public Func MainEvaluator { get; } = mainEvaluator; + public Func MainEvaluator => mainEvaluator; /// /// Gets a delegate that takes in a time value and returns the dynamic shadow color. /// - public Func ShadowEvaluator { get; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f)); + public Func ShadowEvaluator => shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f)); /// public VariableColor( diff --git a/MiraAPI/Events/Mira/MiraButtonCancelledEvent.cs b/MiraAPI/Events/Mira/MiraButtonCancelledEvent.cs index 6973c4f0..5ac4e910 100644 --- a/MiraAPI/Events/Mira/MiraButtonCancelledEvent.cs +++ b/MiraAPI/Events/Mira/MiraButtonCancelledEvent.cs @@ -13,7 +13,7 @@ public sealed class MiraButtonCancelledEvent(T button) : MiraEvent /// /// Gets the whose click was cancelled. /// - public T Button { get; } = button; + public T Button => button; } /// @@ -25,5 +25,5 @@ public sealed class MiraButtonCancelledEvent(CustomActionButton button) : MiraEv /// /// Gets the whose click was cancelled. /// - public CustomActionButton Button { get; } = button; + public CustomActionButton Button => button; } diff --git a/MiraAPI/Events/Mira/MiraButtonClickEvent.cs b/MiraAPI/Events/Mira/MiraButtonClickEvent.cs index 72237d24..9105aa0a 100644 --- a/MiraAPI/Events/Mira/MiraButtonClickEvent.cs +++ b/MiraAPI/Events/Mira/MiraButtonClickEvent.cs @@ -14,12 +14,12 @@ public class MiraButtonClickEvent(T button, MiraButtonClickEvent genericClick /// /// Gets the that was clicked. /// - public T Button { get; } = button; + public T Button => button; /// /// Gets the generic that is invoked before this button-specific event. /// - public MiraButtonClickEvent GenericClickEvent { get; } = genericClickEvent; + public MiraButtonClickEvent GenericClickEvent => genericClickEvent; } /// @@ -31,5 +31,5 @@ public class MiraButtonClickEvent(CustomActionButton button) : MiraCancelableEve /// /// Gets the that was clicked. /// - public CustomActionButton Button { get; } = button; + public CustomActionButton Button => button; } diff --git a/MiraAPI/Events/Mira/UiButtonPostResetEvent.cs b/MiraAPI/Events/Mira/UiButtonPostResetEvent.cs index 38c17555..0e5f2c0b 100644 --- a/MiraAPI/Events/Mira/UiButtonPostResetEvent.cs +++ b/MiraAPI/Events/Mira/UiButtonPostResetEvent.cs @@ -12,10 +12,10 @@ public class UiButtonPostResetEvent(GameObject topUiRow, GameObject secondUiRow) /// /// Gets the parent for the very top UI row. /// - public GameObject MainTopUiRow { get; } = topUiRow; + public GameObject MainTopUiRow => topUiRow; /// /// Gets the parent for the second top UI row. /// - public GameObject SecondTopUiRow { get; } = secondUiRow; + public GameObject SecondTopUiRow => secondUiRow; } diff --git a/MiraAPI/Events/MiraEventWrapper.cs b/MiraAPI/Events/MiraEventWrapper.cs index 2a2c410a..469a98d3 100644 --- a/MiraAPI/Events/MiraEventWrapper.cs +++ b/MiraAPI/Events/MiraEventWrapper.cs @@ -12,10 +12,10 @@ public class MiraEventWrapper(Delegate eventHandler, int priority) /// /// Gets the event handler delegate. /// - public Delegate EventHandler { get; } = eventHandler; + public Delegate EventHandler => eventHandler; /// /// Gets the priority of the handler. Lower values are called first. /// - public int Priority { get; } = priority; + public int Priority => priority; } diff --git a/MiraAPI/Events/RegisterEventAttribute.cs b/MiraAPI/Events/RegisterEventAttribute.cs index 062f30ec..494d7689 100644 --- a/MiraAPI/Events/RegisterEventAttribute.cs +++ b/MiraAPI/Events/RegisterEventAttribute.cs @@ -12,5 +12,5 @@ public class RegisterEventAttribute(int priority = 0) : Attribute /// /// Gets the priority of the event. Lower values are called first. /// - public int Priority { get; } = priority; + public int Priority => priority; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs index 1ca09d67..640f4ce3 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs @@ -14,33 +14,33 @@ public class AfterMurderEvent(PlayerControl source, PlayerControl target, Player /// /// Gets the that killed the . /// - public PlayerControl Source { get; } = source; + public PlayerControl Source => source; /// /// Gets the that was killed. /// - public PlayerControl Target { get; } = target; + public PlayerControl Target => target; /// /// Gets the that was framed, if any. /// - public PlayerControl? Framed { get; } = framed; + public PlayerControl? Framed => framed; /// /// Gets a value indicating whether the murder was done indirectly. /// This is commonly used to prevent the from being killed. /// - public bool IsIndirectAttack { get; } = isIndirect; + public bool IsIndirectAttack => isIndirect; /// /// Gets a value indicating whether the murder was able to bypass protective roles or general defense, such as . /// - public bool IgnoreDefense { get; } = ignoreDefense; + public bool IgnoreDefense => ignoreDefense; /// /// Gets the 's , if it exists. /// - public DeadBody? DeadBody { get; } = deadBody; + public DeadBody? DeadBody => deadBody; /// /// Initializes a new instance of the class. diff --git a/MiraAPI/Events/Vanilla/Gameplay/BeforeGameEndEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/BeforeGameEndEvent.cs index 0b96741f..603f35d3 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/BeforeGameEndEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/BeforeGameEndEvent.cs @@ -9,5 +9,5 @@ public class BeforeGameEndEvent(GameOverReason reason) : MiraCancelableEvent /// /// Gets the reason for the game end. /// - public GameOverReason Reason { get; } = reason; + public GameOverReason Reason => reason; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs index 61dd2648..c2bdf0dd 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs @@ -17,22 +17,22 @@ public sealed class BeforeMurderEvent(PlayerControl source, PlayerControl target /// /// Gets the that is killing the . /// - public PlayerControl Source { get; } = source; + public PlayerControl Source => source; /// /// Gets the that is being killed. /// - public PlayerControl Target { get; } = target; + public PlayerControl Target => target; /// /// Gets the that is being framed, if any. /// - public PlayerControl? Framed { get; } = framed; + public PlayerControl? Framed => framed; /// /// Gets whether the murder was meant to be done in a meeting, via an enum. /// - public MeetingCheck InMeeting { get; } = inMeeting; + public MeetingCheck InMeeting => inMeeting; /// /// Gets or sets a value indicating whether the murder is done indirectly. diff --git a/MiraAPI/Events/Vanilla/Gameplay/BeforeRoundStartEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/BeforeRoundStartEvent.cs index 841f24dc..80067b74 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/BeforeRoundStartEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/BeforeRoundStartEvent.cs @@ -9,5 +9,5 @@ public class BeforeRoundStartEvent(bool triggeredByIntro) : MiraCancelableEvent /// /// Gets a value indicating whether the event was triggered by the or . /// - public bool TriggeredByIntro { get; } = triggeredByIntro; + public bool TriggeredByIntro => triggeredByIntro; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/GameEndEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/GameEndEvent.cs index 5d94b4b0..783f7bcd 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/GameEndEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/GameEndEvent.cs @@ -9,5 +9,5 @@ public class GameEndEvent(EndGameManager manager) : MiraEvent /// /// Gets the instance. /// - public EndGameManager EndGameManager { get; } = manager; + public EndGameManager EndGameManager => manager; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/IntroBeginEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/IntroBeginEvent.cs index b381390a..72215e21 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/IntroBeginEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/IntroBeginEvent.cs @@ -9,5 +9,5 @@ public class IntroBeginEvent(IntroCutscene introCutscene) : MiraEvent /// /// Gets the instance. /// - public IntroCutscene IntroCutscene { get; } = introCutscene; + public IntroCutscene IntroCutscene => introCutscene; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/IntroEndEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/IntroEndEvent.cs index bdd64bd8..246e232c 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/IntroEndEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/IntroEndEvent.cs @@ -9,5 +9,5 @@ public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent /// /// Gets the instance. /// - public IntroCutscene IntroCutscene { get; } = introCutscene; + public IntroCutscene IntroCutscene => introCutscene; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/IntroRoleRevealEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/IntroRoleRevealEvent.cs index 417e96b2..37ec4853 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/IntroRoleRevealEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/IntroRoleRevealEvent.cs @@ -9,5 +9,5 @@ public class IntroRoleRevealEvent(IntroCutscene introCutscene) : MiraEvent /// /// Gets the instance. /// - public IntroCutscene IntroCutscene { get; } = introCutscene; + public IntroCutscene IntroCutscene => introCutscene; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs index e9356ed7..7a6db14a 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs @@ -10,5 +10,5 @@ public class RoundStartEvent(bool triggeredByIntro) : MiraEvent /// /// Gets a value indicating whether the event was triggered by the or . /// - public bool TriggeredByIntro { get; } = triggeredByIntro; + public bool TriggeredByIntro => triggeredByIntro; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/SetRoleEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/SetRoleEvent.cs index f20996ac..a1bea90d 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/SetRoleEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/SetRoleEvent.cs @@ -12,10 +12,10 @@ public class SetRoleEvent(PlayerControl player, RoleTypes role) : MiraEvent /// /// Gets the whose role was changed. /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the role that the player was set to. /// - public RoleTypes Role { get; } = role; + public RoleTypes Role => role; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs index 73200808..e4826a01 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs @@ -13,7 +13,7 @@ public sealed class VanillaButtonCancelledEvent(T button) : MiraEvent /// /// Gets the Vanilla whose click was cancelled. /// - public T Button { get; } = button; + public T Button => button; } /// @@ -25,5 +25,5 @@ public sealed class VanillaButtonCancelledEvent(AbilityButton button) : MiraEven /// /// Gets the Vanilla whose click was cancelled. /// - public AbilityButton Button { get; } = button; + public AbilityButton Button => button; } diff --git a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs index cd7028ae..4e87c87b 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs @@ -14,12 +14,12 @@ public sealed class VanillaButtonClickEvent(T button, VanillaButtonClickEvent /// /// Gets the vanilla that was clicked. /// - public T Button { get; } = button; + public T Button => button; /// /// Gets the generic that is invoked before this button-specific event. /// - public VanillaButtonClickEvent GenericClickEvent { get; } = genericClickEvent; + public VanillaButtonClickEvent GenericClickEvent => genericClickEvent; } /// @@ -33,15 +33,15 @@ public sealed class VanillaButtonClickEvent(AbilityButton button, PlayerControl? /// /// Gets the Vanilla that was clicked. /// - public AbilityButton Button { get; } = button; + public AbilityButton Button => button; /// /// Gets the target , if any, of the Vanilla that was clicked. /// - public PlayerControl? PlayerTarget { get; } = playerTarget; + public PlayerControl? PlayerTarget => playerTarget; /// /// Gets the target , if any, of the Vanilla that was clicked. /// - public Vent? VentTarget { get; } = ventTarget; + public Vent? VentTarget => ventTarget; } diff --git a/MiraAPI/Events/Vanilla/Map/CloseDoorsEvent.cs b/MiraAPI/Events/Vanilla/Map/CloseDoorsEvent.cs index d0ce1ccc..86241e97 100644 --- a/MiraAPI/Events/Vanilla/Map/CloseDoorsEvent.cs +++ b/MiraAPI/Events/Vanilla/Map/CloseDoorsEvent.cs @@ -9,5 +9,5 @@ public class CloseDoorsEvent(SystemTypes room) : MiraCancelableEvent /// /// Gets the room that the doors were closed in. /// - public SystemTypes Room { get; } = room; + public SystemTypes Room => room; } diff --git a/MiraAPI/Events/Vanilla/Map/PlayerOpenSabotageEvent.cs b/MiraAPI/Events/Vanilla/Map/PlayerOpenSabotageEvent.cs index 4e9327ff..d342b321 100644 --- a/MiraAPI/Events/Vanilla/Map/PlayerOpenSabotageEvent.cs +++ b/MiraAPI/Events/Vanilla/Map/PlayerOpenSabotageEvent.cs @@ -9,5 +9,5 @@ public class PlayerOpenSabotageEvent(MapBehaviour mapBehaviour) : MiraCancelable /// /// Gets the . /// - public MapBehaviour MapBehaviour { get; } = mapBehaviour; + public MapBehaviour MapBehaviour => mapBehaviour; } diff --git a/MiraAPI/Events/Vanilla/Map/UpdateSystemEvent.cs b/MiraAPI/Events/Vanilla/Map/UpdateSystemEvent.cs index b1382e56..e39b29d7 100644 --- a/MiraAPI/Events/Vanilla/Map/UpdateSystemEvent.cs +++ b/MiraAPI/Events/Vanilla/Map/UpdateSystemEvent.cs @@ -11,15 +11,15 @@ public class UpdateSystemEvent(SystemTypes systemType, PlayerControl player, byt /// /// Gets the type of system that will be updated. /// - public SystemTypes SystemType { get; } = systemType; + public SystemTypes SystemType => systemType; /// /// Gets the that is updating the system. /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the byte amount the system is being updated by. /// - public byte Amount { get; } = amount; + public byte Amount => amount; } diff --git a/MiraAPI/Events/Vanilla/Meeting/EjectionEvent.cs b/MiraAPI/Events/Vanilla/Meeting/EjectionEvent.cs index 5c0eaeff..e2203ca9 100644 --- a/MiraAPI/Events/Vanilla/Meeting/EjectionEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/EjectionEvent.cs @@ -9,5 +9,5 @@ public class EjectionEvent(ExileController controller) : MiraEvent /// /// Gets the instance. /// - public ExileController ExileController { get; } = controller; + public ExileController ExileController => controller; } diff --git a/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs b/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs index da6642fc..ad958ede 100644 --- a/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/EndMeetingEvent.cs @@ -9,5 +9,5 @@ public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent /// /// Gets the instance. /// - public MeetingHud MeetingHud { get; } = meetingHud; + public MeetingHud MeetingHud => meetingHud; } diff --git a/MiraAPI/Events/Vanilla/Meeting/ReportBodyEvent.cs b/MiraAPI/Events/Vanilla/Meeting/ReportBodyEvent.cs index 139aa77d..891d61b4 100644 --- a/MiraAPI/Events/Vanilla/Meeting/ReportBodyEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/ReportBodyEvent.cs @@ -12,15 +12,15 @@ public class ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target /// /// Gets the player that is reporting the body. /// - public PlayerControl Reporter { get; } = reporter; + public PlayerControl Reporter => reporter; /// /// Gets the player that is being reported. Will be for emergency meeting. /// - public NetworkedPlayerInfo? Target { get; } = target; + public NetworkedPlayerInfo? Target => target; /// /// Gets the that is being reported. Will be for emergency meeting. /// - public DeadBody? Body { get; } = body; + public DeadBody? Body => body; } diff --git a/MiraAPI/Events/Vanilla/Meeting/StartMeetingEvent.cs b/MiraAPI/Events/Vanilla/Meeting/StartMeetingEvent.cs index a38b3c6c..ce373eb7 100644 --- a/MiraAPI/Events/Vanilla/Meeting/StartMeetingEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/StartMeetingEvent.cs @@ -10,5 +10,5 @@ public class StartMeetingEvent(MeetingHud meetingHud) : MiraEvent /// /// Gets the instance. /// - public MeetingHud MeetingHud { get; } = meetingHud; + public MeetingHud MeetingHud => meetingHud; } diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/AfterVoteEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/AfterVoteEvent.cs index 34df3f9d..c6610f79 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/AfterVoteEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/AfterVoteEvent.cs @@ -10,10 +10,10 @@ public class AfterVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter) /// /// Gets the instance of the voter's . /// - public PlayerVoteArea VoteArea { get; } = playerVoteArea; + public PlayerVoteArea VoteArea => playerVoteArea; /// /// Gets the player who voted. /// - public PlayerControl Player { get; } = voter; + public PlayerControl Player => voter; } diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/BeforeVoteEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/BeforeVoteEvent.cs index 9d21b716..b666d490 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/BeforeVoteEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/BeforeVoteEvent.cs @@ -10,10 +10,10 @@ public class BeforeVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter) /// /// Gets the instance of the voter's . /// - public PlayerVoteArea VoteArea { get; } = playerVoteArea; + public PlayerVoteArea VoteArea => playerVoteArea; /// /// Gets the player who voted. /// - public PlayerControl Player { get; } = voter; + public PlayerControl Player => voter; } diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/CheckForEndVotingEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/CheckForEndVotingEvent.cs index 656ef44f..c6212dcc 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/CheckForEndVotingEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/CheckForEndVotingEvent.cs @@ -9,7 +9,7 @@ public class CheckForEndVotingEvent(bool isVotingComplete) : MiraCancelableEvent /// /// Gets a value indicating whether default voting logic determines that voting is complete. /// - public bool IsVotingComplete { get; } = isVotingComplete; + public bool IsVotingComplete => isVotingComplete; /// /// Gets or sets a value indicating whether the voting should be forced to end, regardless of the default logic. diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/DummyVoteEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/DummyVoteEvent.cs index 1bb0bc84..febf84cc 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/DummyVoteEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/DummyVoteEvent.cs @@ -13,12 +13,12 @@ public class DummyVoteEvent(DummyBehaviour dummy) : MiraCancelableEvent /// /// Gets the dummy that needs to vote. /// - public DummyBehaviour Dummy { get; } = dummy; + public DummyBehaviour Dummy => dummy; /// /// Gets the instance of the dummy's . /// - public PlayerVoteData VoteData { get; } = dummy.myPlayer.GetVoteData(); + public PlayerVoteData VoteData => dummy.myPlayer.GetVoteData(); /// /// Gets or sets a value indicating whether the dummy can vote to skip the meeting. diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/HandleVoteEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/HandleVoteEvent.cs index 5d3008d6..f9592cb5 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/HandleVoteEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/HandleVoteEvent.cs @@ -17,18 +17,18 @@ public class HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool /// /// Gets the instance of the voter's . /// - public PlayerVoteData VoteData { get; } = playerVoteData; + public PlayerVoteData VoteData => playerVoteData; + + /// + /// Gets the player id of the target. + /// + public byte TargetId => targetId; /// /// Gets the player who voted. /// public PlayerControl Player { get; } = playerVoteData.Owner; - /// - /// Gets the player id of the target. - /// - public byte TargetId { get; } = targetId; - /// /// Gets the of the target. /// diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/MeetingSelectEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/MeetingSelectEvent.cs index aff24f7f..3042a1a2 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/MeetingSelectEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/MeetingSelectEvent.cs @@ -13,12 +13,12 @@ public class MeetingSelectEvent(PlayerVoteData playerVoteData, int targetId, boo /// /// Gets the instance of the voter's . /// - public PlayerVoteData VoteData { get; } = playerVoteData; + public PlayerVoteData VoteData => playerVoteData; /// /// Gets the player id of the target. /// - public int TargetId { get; } = targetId; + public int TargetId => targetId; /// /// Gets the of the target. diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/PopulateResultsEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/PopulateResultsEvent.cs index 3914722f..bc49cb4a 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/PopulateResultsEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/PopulateResultsEvent.cs @@ -15,5 +15,5 @@ public class PopulateResultsEvent(List votes) : MiraCancelableEvent /// /// Gets a list of networked s. /// - public List Votes { get; } = votes; + public List Votes => votes; } diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/ProcessVotesEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/ProcessVotesEvent.cs index 40a7f1a5..0c0abdbf 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/ProcessVotesEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/ProcessVotesEvent.cs @@ -27,7 +27,7 @@ public class ProcessVotesEvent(List votes, NetworkedPlayerInfo? exil /// /// Gets the list of s that are being processed. /// - public List Votes { get; } = votes; + public List Votes => votes; /// /// Gets or sets a value indicating whether an overruling was done. Normally set by judge but can be overwritten. diff --git a/MiraAPI/Events/Vanilla/Meeting/Voting/VotingCompleteEvent.cs b/MiraAPI/Events/Vanilla/Meeting/Voting/VotingCompleteEvent.cs index 52d4c369..b601fbdc 100644 --- a/MiraAPI/Events/Vanilla/Meeting/Voting/VotingCompleteEvent.cs +++ b/MiraAPI/Events/Vanilla/Meeting/Voting/VotingCompleteEvent.cs @@ -9,5 +9,5 @@ public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent /// /// Gets the instance. /// - public MeetingHud MeetingHud { get; } = meetingHud; + public MeetingHud MeetingHud => meetingHud; } diff --git a/MiraAPI/Events/Vanilla/Player/CompleteHnsTaskEvent.cs b/MiraAPI/Events/Vanilla/Player/CompleteHnsTaskEvent.cs index 7528fc15..c21f6a49 100644 --- a/MiraAPI/Events/Vanilla/Player/CompleteHnsTaskEvent.cs +++ b/MiraAPI/Events/Vanilla/Player/CompleteHnsTaskEvent.cs @@ -11,15 +11,15 @@ public class CompleteHnsTaskEvent(HideAndSeekManager hnsManager, PlayerControl p /// /// Gets the instance of the . /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the instance of the that the player completed. /// - public PlayerTask Task { get; } = task; + public PlayerTask Task => task; /// /// Gets the instance of the attached to the game. /// - public HideAndSeekManager HnsManager { get; } = hnsManager; + public HideAndSeekManager HnsManager => hnsManager; } diff --git a/MiraAPI/Events/Vanilla/Player/CompleteTaskEvent.cs b/MiraAPI/Events/Vanilla/Player/CompleteTaskEvent.cs index 95b24304..642e04d2 100644 --- a/MiraAPI/Events/Vanilla/Player/CompleteTaskEvent.cs +++ b/MiraAPI/Events/Vanilla/Player/CompleteTaskEvent.cs @@ -10,10 +10,10 @@ public class CompleteTaskEvent(PlayerControl player, PlayerTask task) : MiraEven /// /// Gets the instance of the . /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the instance of the that the player completed. /// - public PlayerTask Task { get; } = task; + public PlayerTask Task => task; } diff --git a/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs b/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs index b03d2aa1..4a3e2869 100644 --- a/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs +++ b/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs @@ -11,15 +11,15 @@ public class PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody /// /// Gets the player who died. /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the reason the player died. /// - public DeathReason DeathReason { get; } = reason; + public DeathReason DeathReason => reason; /// /// Gets the associated with the player, if any. /// - public DeadBody? DeadBody { get; } = deadBody; + public DeadBody? DeadBody => deadBody; } diff --git a/MiraAPI/Events/Vanilla/Player/PlayerJoinEvent.cs b/MiraAPI/Events/Vanilla/Player/PlayerJoinEvent.cs index 5f664723..18229e9e 100644 --- a/MiraAPI/Events/Vanilla/Player/PlayerJoinEvent.cs +++ b/MiraAPI/Events/Vanilla/Player/PlayerJoinEvent.cs @@ -11,5 +11,5 @@ public class PlayerJoinEvent(ClientData data) : MiraEvent /// /// Gets the player who joined. /// - public ClientData ClientData { get; } = data; + public ClientData ClientData => data; } diff --git a/MiraAPI/Events/Vanilla/Player/PlayerLeaveEvent.cs b/MiraAPI/Events/Vanilla/Player/PlayerLeaveEvent.cs index 1af8bdea..63446cb8 100644 --- a/MiraAPI/Events/Vanilla/Player/PlayerLeaveEvent.cs +++ b/MiraAPI/Events/Vanilla/Player/PlayerLeaveEvent.cs @@ -12,10 +12,10 @@ public class PlayerLeaveEvent(ClientData data, DisconnectReasons reason) : MiraE /// /// Gets the player who left. /// - public ClientData ClientData { get; } = data; + public ClientData ClientData => data; /// /// Gets the reason why the player left. /// - public DisconnectReasons Reason { get; } = reason; + public DisconnectReasons Reason => reason; } diff --git a/MiraAPI/Events/Vanilla/Usables/EnterVentEvent.cs b/MiraAPI/Events/Vanilla/Usables/EnterVentEvent.cs index 4d6eaaa0..85af54a9 100644 --- a/MiraAPI/Events/Vanilla/Usables/EnterVentEvent.cs +++ b/MiraAPI/Events/Vanilla/Usables/EnterVentEvent.cs @@ -10,10 +10,10 @@ public class EnterVentEvent(PlayerControl player, Vent? vent) : MiraCancelableEv /// /// Gets the that is entering the . /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the that the is entering. /// - public Vent? Vent { get; } = vent; + public Vent? Vent => vent; } diff --git a/MiraAPI/Events/Vanilla/Usables/ExitVentEvent.cs b/MiraAPI/Events/Vanilla/Usables/ExitVentEvent.cs index 3c0782e0..4612bf6a 100644 --- a/MiraAPI/Events/Vanilla/Usables/ExitVentEvent.cs +++ b/MiraAPI/Events/Vanilla/Usables/ExitVentEvent.cs @@ -10,10 +10,10 @@ public class ExitVentEvent(PlayerControl player, Vent? vent) : MiraCancelableEve /// /// Gets the that is exiting the . /// - public PlayerControl Player { get; } = player; + public PlayerControl Player => player; /// /// Gets the that the is exiting. /// - public Vent? Vent { get; } = vent; + public Vent? Vent => vent; } diff --git a/MiraAPI/Events/Vanilla/Usables/PlayerUseEvent.cs b/MiraAPI/Events/Vanilla/Usables/PlayerUseEvent.cs index a23ce0e8..b2893a59 100644 --- a/MiraAPI/Events/Vanilla/Usables/PlayerUseEvent.cs +++ b/MiraAPI/Events/Vanilla/Usables/PlayerUseEvent.cs @@ -9,7 +9,7 @@ public class PlayerUseEvent(IUsable usable) : MiraCancelableEvent /// /// Gets the instance of that was used. /// - public IUsable Usable { get; } = usable; + public IUsable Usable => usable; /// /// Gets a value indicating whether the is a , , or . diff --git a/MiraAPI/GameOptions/CollectionBuilder.cs b/MiraAPI/GameOptions/CollectionBuilder.cs index 99d42d9e..103030b3 100644 --- a/MiraAPI/GameOptions/CollectionBuilder.cs +++ b/MiraAPI/GameOptions/CollectionBuilder.cs @@ -3,6 +3,6 @@ namespace System.Runtime.CompilerServices; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)] internal sealed class CollectionBuilderAttribute(Type builderType, string methodName) : Attribute { - public Type BuilderType { get; } = builderType; - public string MethodName { get; } = methodName; + public Type BuilderType => builderType; + public string MethodName => methodName; } diff --git a/MiraAPI/GameOptions/ModdedOptionsManager.cs b/MiraAPI/GameOptions/ModdedOptionsManager.cs index 0fb10bb3..677f43ee 100644 --- a/MiraAPI/GameOptions/ModdedOptionsManager.cs +++ b/MiraAPI/GameOptions/ModdedOptionsManager.cs @@ -365,7 +365,7 @@ public static class ModdedOptionsManager while (chunks.Count > 0) { - Rpc.Instance.SendTo(PlayerControl.LocalPlayer, targetId, new MiraOptionNetData(false, chunks.Dequeue())); + Rpc.Instance.SendTo(PlayerControl.LocalPlayer, targetId, new MiraOptionNetData(false, chunks.Dequeue())); } } diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs index b8959420..622006c4 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs @@ -162,7 +162,7 @@ public abstract class ModdedOption : IModdedOption entry.Value = _value; } - Rpc.Instance.Send(PlayerControl.LocalPlayer, new MiraOptionNetData(true, [GetNetData()]), true); + Rpc.Instance.Send(PlayerControl.LocalPlayer, new MiraOptionNetData(true, [GetNetData()]), true); } OnValueChanged(_value); diff --git a/MiraAPI/Hud/MultiTargetButton.cs b/MiraAPI/Hud/MultiTargetButton.cs index 6f931e7e..ec12a346 100644 --- a/MiraAPI/Hud/MultiTargetButton.cs +++ b/MiraAPI/Hud/MultiTargetButton.cs @@ -22,7 +22,7 @@ public abstract class MultiTargetButton : CustomActionButton /// /// Gets the maximum amount of targets the button can have. /// - public virtual int MaxTargets { get; } = int.MaxValue; + public virtual int MaxTargets => int.MaxValue; /// public virtual bool IsTargetValid(T target) diff --git a/MiraAPI/Keybinds/MiraKeybind.cs b/MiraAPI/Keybinds/MiraKeybind.cs index ef466b52..3153f37c 100644 --- a/MiraAPI/Keybinds/MiraKeybind.cs +++ b/MiraAPI/Keybinds/MiraKeybind.cs @@ -15,7 +15,7 @@ public class MiraKeybind(string name, KeyboardKeyCode? defaultKeycode, ModifierK /// /// Gets name of the keybind. /// - public string Name { get; } = name; + public string Name => name; /// /// Gets the default keycode of this keybind. @@ -37,7 +37,7 @@ public class MiraKeybind(string name, KeyboardKeyCode? defaultKeycode, ModifierK /// Gets a value indicating whether this keybind should be checked for conflicts with other exclusive keybinds using the same key. /// Active exclusive controller bindings take priority over vanilla actions during gameplay. /// - public bool Exclusive { get; } = exclusive; + public bool Exclusive => exclusive; internal string? SourcePluginName { get; set; } diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs index 5fcbb081..61d995cc 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs @@ -31,7 +31,7 @@ public class LocalEnumSetting( /// /// Gets the type of the setting. /// - public Type EnumType { get; } = enumType; + public Type EnumType => enumType; /// /// Gets the values. diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs index 14f1ffe9..2c813bbe 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs @@ -41,7 +41,7 @@ public class LocalSliderSetting( /// /// Gets a value indicating whether the value should be displayed next to name. /// - public bool DisplayValue { get; } = displayValue; + public bool DisplayValue => displayValue; /// /// Gets a format for the text to use to format the number. @@ -51,7 +51,7 @@ public class LocalSliderSetting( /// /// Gets a value indicating whether the value should be rounded. /// - public bool RoundValue { get; } = roundValue; + public bool RoundValue => roundValue; /// /// Gets the suffix for the number value. diff --git a/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs b/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs index aeeeedd8..0a05c5a0 100644 --- a/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs +++ b/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs @@ -64,7 +64,7 @@ public abstract class TargetedMeetingButton /// /// Gets the for this button. /// - public virtual MeetingButtonUsesMode UsesMode { get; } = MeetingButtonUsesMode.PerGame; + public virtual MeetingButtonUsesMode UsesMode => MeetingButtonUsesMode.PerGame; /// /// Determines if the button is enabled. diff --git a/MiraAPI/Networking/NetData.cs b/MiraAPI/Networking/NetData.cs index aa9a52ee..db8c91c4 100644 --- a/MiraAPI/Networking/NetData.cs +++ b/MiraAPI/Networking/NetData.cs @@ -10,12 +10,12 @@ public readonly struct NetData(uint id, byte[] data) /// /// Gets the ID of the data. /// - public uint Id { get; } = id; + public uint Id => id; /// /// Gets the byte[] data. /// - public byte[] Data { get; } = data; + public byte[] Data => data; /// /// Gets the length of the data in bytes. diff --git a/MiraAPI/Networking/SyncOptionsRpc.cs b/MiraAPI/Networking/SyncOptionsRpc.cs index 9cf83a3d..2c6ee922 100644 --- a/MiraAPI/Networking/SyncOptionsRpc.cs +++ b/MiraAPI/Networking/SyncOptionsRpc.cs @@ -1,27 +1,24 @@ using Hazel; using MiraAPI.GameOptions; +using MiraAPI.Roles; using Reactor.Networking.Attributes; using Reactor.Networking.Rpc; namespace MiraAPI.Networking; +internal readonly struct MiraOptionNetData(bool showNotif, NetData[] data) +{ + public bool ShouldShowNotifications => showNotif; + public NetData[] Data => data; +} + // METHOD RPC DOESN'T WORK WITH THE ARRAYS AND STUFF SO THIS IS HOW WE WILL DO IT FOR NOW -[RegisterCustomRpc((uint)MiraRpc.SyncGameOptions)] -#pragma warning disable SA1515 // Single-line comment should be preceded by blank line (Justification: ReSharper suppression.) -// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated by Reactor.) -internal sealed class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) -#pragma warning restore SA1515 // Single-line comment should be preceded by blank line +internal abstract class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) { public override RpcLocalHandling LocalHandling => RpcLocalHandling.None; public override void Write(MessageWriter writer, MiraOptionNetData data) { - /*if (data == null) - { - writer.WritePacked(0U); - return; - }*/ - var info = data.Data; writer.Write(data.ShouldShowNotifications); writer.WritePacked((uint)info.Length); @@ -46,14 +43,34 @@ internal sealed class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCust return new MiraOptionNetData(shouldShowNotif, data); } +} +[RegisterCustomRpc((uint)MiraRpc.SyncGameOptions)] +#pragma warning disable SA1515 // Single-line comment should be preceded by blank line (Justification: ReSharper suppression.) +// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated by Reactor.) +internal sealed class SyncGameOptionsRpc(MiraApiPlugin plugin, uint id) : SyncOptionsRpc(plugin, id) +#pragma warning restore SA1515 // Single-line comment should be preceded by blank line +{ public override void Handle(PlayerControl innerNetObject, MiraOptionNetData data) { - if (AmongUsClient.Instance.HostId != innerNetObject.OwnerId) + if (AmongUsClient.Instance.HostId == innerNetObject.OwnerId) { - return; + ModdedOptionsManager.HandleSyncOptions(data.ShouldShowNotifications, data.Data ?? []); + } + } +} + +[RegisterCustomRpc((uint)MiraRpc.SyncRoleOptions)] +#pragma warning disable SA1515 // Single-line comment should be preceded by blank line (Justification: ReSharper suppression.) +// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated by Reactor.) +internal sealed class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : SyncOptionsRpc(plugin, id) +#pragma warning restore SA1515 // Single-line comment should be preceded by blank line +{ + public override void Handle(PlayerControl innerNetObject, MiraOptionNetData data) + { + if (AmongUsClient.Instance.HostId == innerNetObject.OwnerId) + { + CustomRoleManager.HandleSyncRoleOptions(data.ShouldShowNotifications, data.Data ?? []); } - - ModdedOptionsManager.HandleSyncOptions(data.ShouldShowNotifications, data.Data ?? []); } } diff --git a/MiraAPI/Networking/SyncRoleOptionsRpc.cs b/MiraAPI/Networking/SyncRoleOptionsRpc.cs deleted file mode 100644 index eb632ed4..00000000 --- a/MiraAPI/Networking/SyncRoleOptionsRpc.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Hazel; -using MiraAPI.Roles; -using Reactor.Networking.Attributes; -using Reactor.Networking.Rpc; - -namespace MiraAPI.Networking; - -internal readonly struct MiraOptionNetData(bool showNotif, NetData[] data) -{ - public bool ShouldShowNotifications { get; } = showNotif; - public NetData[] Data { get; } = data; -} - -[RegisterCustomRpc((uint)MiraRpc.SyncRoleOptions)] -#pragma warning disable SA1515 // Single-line comment should be preceded by blank line (Justification: ReSharper suppression.) -// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated by Reactor.) -internal sealed class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) -#pragma warning restore SA1515 // Single-line comment should be preceded by blank line -{ - public override RpcLocalHandling LocalHandling => RpcLocalHandling.None; - - public override void Write(MessageWriter writer, MiraOptionNetData data) - { - /*if (data == null) - { - writer.WritePacked(0U); - return; - }*/ - - var info = data.Data; - writer.Write(data.ShouldShowNotifications); - writer.WritePacked((uint)info.Length); - foreach (var netData in info) - { - writer.WritePacked(netData.Id); - writer.WriteBytesAndSize(netData.Data); - } - } - - public override MiraOptionNetData Read(MessageReader reader) - { - var shouldShowNotif = reader.ReadBoolean(); - var length = reader.ReadPackedUInt32(); - var data = new NetData[length]; - for (var i = 0; i < length; i++) - { - var dataId = reader.ReadPackedUInt32(); - var bytes = reader.ReadBytesAndSize(); - data[i] = new NetData(dataId, bytes); - } - - return new MiraOptionNetData(shouldShowNotif, data); - } - - public override void Handle(PlayerControl innerNetObject, MiraOptionNetData data) - { - if (AmongUsClient.Instance.HostId != innerNetObject.OwnerId) - { - return; - } - - CustomRoleManager.HandleSyncRoleOptions(data.ShouldShowNotifications, data.Data ?? []); - } -} diff --git a/MiraAPI/Patches/RoleGuidePatches.cs b/MiraAPI/Patches/RoleGuidePatches.cs index edaf0910..45254c81 100644 --- a/MiraAPI/Patches/RoleGuidePatches.cs +++ b/MiraAPI/Patches/RoleGuidePatches.cs @@ -962,13 +962,13 @@ public static class RoleGuidePatches private sealed class DetailedPanel(string title, string category, string modId, RoleBehaviour? role, GameModifier? modifier, uint typeId) { + public string Title => title; + public string Category => category; + public string ModId => modId; + public RoleBehaviour? Role => role; + public GameModifier? Modifier => modifier; + public uint TypeId => typeId; public MatchInfoRolePanel? Panel { get; set; } - public string Title { get; } = title; - public string Category { get; } = category; - public string ModId { get; } = modId; - public RoleBehaviour? Role { get; } = role; - public GameModifier? Modifier { get; } = modifier; - public uint TypeId { get; } = typeId; public int Amount { get; set; } public int Chance { get; set; } public float Likelihood { get; set; } diff --git a/MiraAPI/Presets/OptionPreset.cs b/MiraAPI/Presets/OptionPreset.cs index 6ecab1fd..90eb3894 100644 --- a/MiraAPI/Presets/OptionPreset.cs +++ b/MiraAPI/Presets/OptionPreset.cs @@ -18,22 +18,22 @@ public class OptionPreset(string name, MiraPluginInfo plugin, ConfigFile presetC /// /// Gets the name of the preset. /// - public string Name { get; } = name; + public string Name => name; /// /// Gets the plugin associated with the preset. /// - public MiraPluginInfo Plugin { get; } = plugin; + public MiraPluginInfo Plugin => plugin; /// /// Gets the of the plugin associated with the preset. /// - public ConfigFile PluginConfig { get; } = plugin.PluginConfig; + public ConfigFile PluginConfig => plugin.PluginConfig; /// /// Gets the for the preset. /// - public ConfigFile PresetConfig { get; } = presetConfig; + public ConfigFile PresetConfig => presetConfig; /// /// Gets or sets the button associated with the preset in the UI. diff --git a/MiraAPI/Utilities/GuideOptionsPatches.cs b/MiraAPI/Utilities/GuideOptionsPatches.cs index f44626a4..50fd9510 100644 --- a/MiraAPI/Utilities/GuideOptionsPatches.cs +++ b/MiraAPI/Utilities/GuideOptionsPatches.cs @@ -31,13 +31,13 @@ internal sealed class GuideOptionPage( IReadOnlyList modSearchTerms, List entries) { - public AbstractOptionGroup Group { get; } = group; + public AbstractOptionGroup Group => group; public List Groups { get; } = [group]; - public string Title { get; } = title; + public string Title => title; - public LoadableAsset Sprite { get; } = group.Sprite; + public LoadableAsset Sprite => group.Sprite; public int Order { get; set; } = order; @@ -45,13 +45,13 @@ internal sealed class GuideOptionPage( public uint GroupPriority { get; set; } = groupPriority; - public int Columns { get; } = columns; + public int Columns => columns; - public string ModAbbreviation { get; } = modAbbreviation; + public string ModAbbreviation => modAbbreviation; public HashSet ModSearchTerms { get; } = new(modSearchTerms, StringComparer.OrdinalIgnoreCase); - public List Entries { get; } = entries; + public List Entries => entries; } internal static class GuideOptionPages