mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
deduplicate code + simplify getters
This commit is contained in:
58 files changed
+147
-194
No files matched your search
@@ -23,12 +23,12 @@ public class CustomColor(StringNames? nameId, string? rawId, Color32 mainColor,
|
||||
/// <summary>
|
||||
/// Gets the main color.
|
||||
/// </summary>
|
||||
public Color32 MainColor { get; } = mainColor;
|
||||
public Color32 MainColor => mainColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shadow color.
|
||||
/// </summary>
|
||||
public Color32 ShadowColor { get; } = shadowColor;
|
||||
public Color32 ShadowColor => shadowColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the color.
|
||||
|
||||
@@ -12,7 +12,7 @@ public class RegisterCustomColorsAttribute(string idPrefix) : Attribute
|
||||
/// <summary>
|
||||
/// Gets the translation ID prefix for all of the colors within the container type.
|
||||
/// </summary>
|
||||
public string IdPrefix { get; } = idPrefix;
|
||||
public string IdPrefix => idPrefix;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RegisterCustomColorsAttribute"/> class.
|
||||
|
||||
@@ -35,12 +35,12 @@ public sealed class VariableColor(
|
||||
/// <summary>
|
||||
/// Gets a delegate that takes in a time value and returns the dynamic main color.
|
||||
/// </summary>
|
||||
public Func<float, Color> MainEvaluator { get; } = mainEvaluator;
|
||||
public Func<float, Color> MainEvaluator => mainEvaluator;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a delegate that takes in a time value and returns the dynamic shadow color.
|
||||
/// </summary>
|
||||
public Func<float, Color> ShadowEvaluator { get; } = shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f));
|
||||
public Func<float, Color> ShadowEvaluator => shadowEvaluator ?? (t => mainEvaluator(t).DarkenAbsolute(0.24f));
|
||||
|
||||
/// <inheritdoc cref="VariableColor(StringNames?, string?, Func{float, Color}, Func{float, Color}?, Color32?, Color32?, float, CustomColorBrightness)"/>
|
||||
public VariableColor(
|
||||
|
||||
@@ -13,7 +13,7 @@ public sealed class MiraButtonCancelledEvent<T>(T button) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
|
||||
/// </summary>
|
||||
public T Button { get; } = button;
|
||||
public T Button => button;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,5 +25,5 @@ public sealed class MiraButtonCancelledEvent(CustomActionButton button) : MiraEv
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
|
||||
/// </summary>
|
||||
public CustomActionButton Button { get; } = button;
|
||||
public CustomActionButton Button => button;
|
||||
}
|
||||
@@ -14,12 +14,12 @@ public class MiraButtonClickEvent<T>(T button, MiraButtonClickEvent genericClick
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public T Button { get; } = button;
|
||||
public T Button => button;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the generic <see cref="MiraButtonClickEvent"/> that is invoked before this button-specific event.
|
||||
/// </summary>
|
||||
public MiraButtonClickEvent GenericClickEvent { get; } = genericClickEvent;
|
||||
public MiraButtonClickEvent GenericClickEvent => genericClickEvent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -31,5 +31,5 @@ public class MiraButtonClickEvent(CustomActionButton button) : MiraCancelableEve
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public CustomActionButton Button { get; } = button;
|
||||
public CustomActionButton Button => button;
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class UiButtonPostResetEvent(GameObject topUiRow, GameObject secondUiRow)
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GameObject"/> parent for the very top UI row.
|
||||
/// </summary>
|
||||
public GameObject MainTopUiRow { get; } = topUiRow;
|
||||
public GameObject MainTopUiRow => topUiRow;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GameObject"/> parent for the second top UI row.
|
||||
/// </summary>
|
||||
public GameObject SecondTopUiRow { get; } = secondUiRow;
|
||||
public GameObject SecondTopUiRow => secondUiRow;
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class MiraEventWrapper(Delegate eventHandler, int priority)
|
||||
/// <summary>
|
||||
/// Gets the event handler delegate.
|
||||
/// </summary>
|
||||
public Delegate EventHandler { get; } = eventHandler;
|
||||
public Delegate EventHandler => eventHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority of the handler. Lower values are called first.
|
||||
/// </summary>
|
||||
public int Priority { get; } = priority;
|
||||
public int Priority => priority;
|
||||
}
|
||||
@@ -12,5 +12,5 @@ public class RegisterEventAttribute(int priority = 0) : Attribute
|
||||
/// <summary>
|
||||
/// Gets the priority of the event. Lower values are called first.
|
||||
/// </summary>
|
||||
public int Priority { get; } = priority;
|
||||
public int Priority => priority;
|
||||
}
|
||||
@@ -14,33 +14,33 @@ public class AfterMurderEvent(PlayerControl source, PlayerControl target, Player
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that killed the <see cref="Target"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Source { get; } = source;
|
||||
public PlayerControl Source => source;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that was killed.
|
||||
/// </summary>
|
||||
public PlayerControl Target { get; } = target;
|
||||
public PlayerControl Target => target;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that was framed, if any.
|
||||
/// </summary>
|
||||
public PlayerControl? Framed { get; } = framed;
|
||||
public PlayerControl? Framed => framed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the murder was done indirectly.
|
||||
/// This is commonly used to prevent the <see cref="Source"/> <see cref="PlayerControl"/> from being killed.
|
||||
/// </summary>
|
||||
public bool IsIndirectAttack { get; } = isIndirect;
|
||||
public bool IsIndirectAttack => isIndirect;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the murder was able to bypass protective roles or general defense, such as <see cref="GuardianAngelRole"/>.
|
||||
/// </summary>
|
||||
public bool IgnoreDefense { get; } = ignoreDefense;
|
||||
public bool IgnoreDefense => ignoreDefense;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Target"/>'s <see cref="DeadBody"/>, if it exists.
|
||||
/// </summary>
|
||||
public DeadBody? DeadBody { get; } = deadBody;
|
||||
public DeadBody? DeadBody => deadBody;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AfterMurderEvent"/> class.
|
||||
|
||||
@@ -9,5 +9,5 @@ public class BeforeGameEndEvent(GameOverReason reason) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets the reason for the game end.
|
||||
/// </summary>
|
||||
public GameOverReason Reason { get; } = reason;
|
||||
public GameOverReason Reason => reason;
|
||||
}
|
||||
@@ -17,22 +17,22 @@ public sealed class BeforeMurderEvent(PlayerControl source, PlayerControl target
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is killing the <see cref="Target"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Source { get; } = source;
|
||||
public PlayerControl Source => source;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is being killed.
|
||||
/// </summary>
|
||||
public PlayerControl Target { get; } = target;
|
||||
public PlayerControl Target => target;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is being framed, if any.
|
||||
/// </summary>
|
||||
public PlayerControl? Framed { get; } = framed;
|
||||
public PlayerControl? Framed => framed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the murder was meant to be done in a meeting, via an enum.
|
||||
/// </summary>
|
||||
public MeetingCheck InMeeting { get; } = inMeeting;
|
||||
public MeetingCheck InMeeting => inMeeting;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the murder is done indirectly.
|
||||
|
||||
@@ -9,5 +9,5 @@ public class BeforeRoundStartEvent(bool triggeredByIntro) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
|
||||
/// </summary>
|
||||
public bool TriggeredByIntro { get; } = triggeredByIntro;
|
||||
public bool TriggeredByIntro => triggeredByIntro;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class GameEndEvent(EndGameManager manager) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::EndGameManager"/> instance.
|
||||
/// </summary>
|
||||
public EndGameManager EndGameManager { get; } = manager;
|
||||
public EndGameManager EndGameManager => manager;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class IntroBeginEvent(IntroCutscene introCutscene) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; } = introCutscene;
|
||||
public IntroCutscene IntroCutscene => introCutscene;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; } = introCutscene;
|
||||
public IntroCutscene IntroCutscene => introCutscene;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class IntroRoleRevealEvent(IntroCutscene introCutscene) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; } = introCutscene;
|
||||
public IntroCutscene IntroCutscene => introCutscene;
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public class RoundStartEvent(bool triggeredByIntro) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
|
||||
/// </summary>
|
||||
public bool TriggeredByIntro { get; } = triggeredByIntro;
|
||||
public bool TriggeredByIntro => triggeredByIntro;
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class SetRoleEvent(PlayerControl player, RoleTypes role) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> whose role was changed.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role that the player was set to.
|
||||
/// </summary>
|
||||
public RoleTypes Role { get; } = role;
|
||||
public RoleTypes Role => role;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public sealed class VanillaButtonCancelledEvent<T>(T button) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
|
||||
/// </summary>
|
||||
public T Button { get; } = button;
|
||||
public T Button => button;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,5 +25,5 @@ public sealed class VanillaButtonCancelledEvent(AbilityButton button) : MiraEven
|
||||
/// <summary>
|
||||
/// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
|
||||
/// </summary>
|
||||
public AbilityButton Button { get; } = button;
|
||||
public AbilityButton Button => button;
|
||||
}
|
||||
@@ -14,12 +14,12 @@ public sealed class VanillaButtonClickEvent<T>(T button, VanillaButtonClickEvent
|
||||
/// <summary>
|
||||
/// Gets the vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public T Button { get; } = button;
|
||||
public T Button => button;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the generic <see cref="VanillaButtonClickEvent"/> that is invoked before this button-specific event.
|
||||
/// </summary>
|
||||
public VanillaButtonClickEvent GenericClickEvent { get; } = genericClickEvent;
|
||||
public VanillaButtonClickEvent GenericClickEvent => genericClickEvent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -33,15 +33,15 @@ public sealed class VanillaButtonClickEvent(AbilityButton button, PlayerControl?
|
||||
/// <summary>
|
||||
/// Gets the Vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public AbilityButton Button { get; } = button;
|
||||
public AbilityButton Button => button;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target <see cref="PlayerControl"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public PlayerControl? PlayerTarget { get; } = playerTarget;
|
||||
public PlayerControl? PlayerTarget => playerTarget;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target <see cref="Vent"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public Vent? VentTarget { get; } = ventTarget;
|
||||
public Vent? VentTarget => ventTarget;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class CloseDoorsEvent(SystemTypes room) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets the room that the doors were closed in.
|
||||
/// </summary>
|
||||
public SystemTypes Room { get; } = room;
|
||||
public SystemTypes Room => room;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class PlayerOpenSabotageEvent(MapBehaviour mapBehaviour) : MiraCancelable
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MapBehaviour"/>.
|
||||
/// </summary>
|
||||
public MapBehaviour MapBehaviour { get; } = mapBehaviour;
|
||||
public MapBehaviour MapBehaviour => mapBehaviour;
|
||||
}
|
||||
@@ -11,15 +11,15 @@ public class UpdateSystemEvent(SystemTypes systemType, PlayerControl player, byt
|
||||
/// <summary>
|
||||
/// Gets the type of system that will be updated.
|
||||
/// </summary>
|
||||
public SystemTypes SystemType { get; } = systemType;
|
||||
public SystemTypes SystemType => systemType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is updating the system.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the byte amount the system is being updated by.
|
||||
/// </summary>
|
||||
public byte Amount { get; } = amount;
|
||||
public byte Amount => amount;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class EjectionEvent(ExileController controller) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::ExileController"/> instance.
|
||||
/// </summary>
|
||||
public ExileController ExileController { get; } = controller;
|
||||
public ExileController ExileController => controller;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
public MeetingHud MeetingHud => meetingHud;
|
||||
}
|
||||
@@ -12,15 +12,15 @@ public class ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target
|
||||
/// <summary>
|
||||
/// Gets the player that is reporting the body.
|
||||
/// </summary>
|
||||
public PlayerControl Reporter { get; } = reporter;
|
||||
public PlayerControl Reporter => reporter;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player that is being reported. Will be <see langword="null"/> for emergency meeting.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo? Target { get; } = target;
|
||||
public NetworkedPlayerInfo? Target => target;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DeadBody"/> that is being reported. Will be <see langword="null"/> for emergency meeting.
|
||||
/// </summary>
|
||||
public DeadBody? Body { get; } = body;
|
||||
public DeadBody? Body => body;
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public class StartMeetingEvent(MeetingHud meetingHud) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
public MeetingHud MeetingHud => meetingHud;
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class AfterVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; } = playerVoteArea;
|
||||
public PlayerVoteArea VoteArea => playerVoteArea;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player who voted.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = voter;
|
||||
public PlayerControl Player => voter;
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class BeforeVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; } = playerVoteArea;
|
||||
public PlayerVoteArea VoteArea => playerVoteArea;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player who voted.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = voter;
|
||||
public PlayerControl Player => voter;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class CheckForEndVotingEvent(bool isVotingComplete) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether default voting logic determines that voting is complete.
|
||||
/// </summary>
|
||||
public bool IsVotingComplete { get; } = isVotingComplete;
|
||||
public bool IsVotingComplete => isVotingComplete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the voting should be forced to end, regardless of the default logic.
|
||||
|
||||
@@ -13,12 +13,12 @@ public class DummyVoteEvent(DummyBehaviour dummy) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets the dummy that needs to vote.
|
||||
/// </summary>
|
||||
public DummyBehaviour Dummy { get; } = dummy;
|
||||
public DummyBehaviour Dummy => dummy;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the dummy's <see cref="PlayerVoteData"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; } = dummy.myPlayer.GetVoteData();
|
||||
public PlayerVoteData VoteData => dummy.myPlayer.GetVoteData();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the dummy can vote to skip the meeting.
|
||||
|
||||
@@ -17,18 +17,18 @@ public class HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; } = playerVoteData;
|
||||
public PlayerVoteData VoteData => playerVoteData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player id of the target.
|
||||
/// </summary>
|
||||
public byte TargetId => targetId;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player who voted.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = playerVoteData.Owner;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player id of the target.
|
||||
/// </summary>
|
||||
public byte TargetId { get; } = targetId;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
|
||||
/// </summary>
|
||||
|
||||
@@ -13,12 +13,12 @@ public class MeetingSelectEvent(PlayerVoteData playerVoteData, int targetId, boo
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; } = playerVoteData;
|
||||
public PlayerVoteData VoteData => playerVoteData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player id of the target.
|
||||
/// </summary>
|
||||
public int TargetId { get; } = targetId;
|
||||
public int TargetId => targetId;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
|
||||
|
||||
@@ -15,5 +15,5 @@ public class PopulateResultsEvent(List<CustomVote> votes) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets a list of networked <see cref="CustomVote"/>s.
|
||||
/// </summary>
|
||||
public List<CustomVote> Votes { get; } = votes;
|
||||
public List<CustomVote> Votes => votes;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exil
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="CustomVote"/>s that are being processed.
|
||||
/// </summary>
|
||||
public List<CustomVote> Votes { get; } = votes;
|
||||
public List<CustomVote> Votes => votes;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether an overruling was done. Normally set by judge but can be overwritten.
|
||||
|
||||
@@ -9,5 +9,5 @@ public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
public MeetingHud MeetingHud => meetingHud;
|
||||
}
|
||||
@@ -11,15 +11,15 @@ public class CompleteHnsTaskEvent(HideAndSeekManager hnsManager, PlayerControl p
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerControl"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerTask"/> that the player completed.
|
||||
/// </summary>
|
||||
public PlayerTask Task { get; } = task;
|
||||
public PlayerTask Task => task;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="HideAndSeekManager"/> attached to the game.
|
||||
/// </summary>
|
||||
public HideAndSeekManager HnsManager { get; } = hnsManager;
|
||||
public HideAndSeekManager HnsManager => hnsManager;
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class CompleteTaskEvent(PlayerControl player, PlayerTask task) : MiraEven
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerControl"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerTask"/> that the player completed.
|
||||
/// </summary>
|
||||
public PlayerTask Task { get; } = task;
|
||||
public PlayerTask Task => task;
|
||||
}
|
||||
@@ -11,15 +11,15 @@ public class PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody
|
||||
/// <summary>
|
||||
/// Gets the player who died.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reason the player died.
|
||||
/// </summary>
|
||||
public DeathReason DeathReason { get; } = reason;
|
||||
public DeathReason DeathReason => reason;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::DeadBody"/> associated with the player, if any.
|
||||
/// </summary>
|
||||
public DeadBody? DeadBody { get; } = deadBody;
|
||||
public DeadBody? DeadBody => deadBody;
|
||||
}
|
||||
@@ -11,5 +11,5 @@ public class PlayerJoinEvent(ClientData data) : MiraEvent
|
||||
/// <summary>
|
||||
/// Gets the player who joined.
|
||||
/// </summary>
|
||||
public ClientData ClientData { get; } = data;
|
||||
public ClientData ClientData => data;
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class PlayerLeaveEvent(ClientData data, DisconnectReasons reason) : MiraE
|
||||
/// <summary>
|
||||
/// Gets the player who left.
|
||||
/// </summary>
|
||||
public ClientData ClientData { get; } = data;
|
||||
public ClientData ClientData => data;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reason why the player left.
|
||||
/// </summary>
|
||||
public DisconnectReasons Reason { get; } = reason;
|
||||
public DisconnectReasons Reason => reason;
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class EnterVentEvent(PlayerControl player, Vent? vent) : MiraCancelableEv
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is entering the <see cref="Vent"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is entering.
|
||||
/// </summary>
|
||||
public Vent? Vent { get; } = vent;
|
||||
public Vent? Vent => vent;
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class ExitVentEvent(PlayerControl player, Vent? vent) : MiraCancelableEve
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is exiting the <see cref="Vent"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; } = player;
|
||||
public PlayerControl Player => player;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is exiting.
|
||||
/// </summary>
|
||||
public Vent? Vent { get; } = vent;
|
||||
public Vent? Vent => vent;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class PlayerUseEvent(IUsable usable) : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Gets the instance of <see cref="IUsable"/> that was used.
|
||||
/// </summary>
|
||||
public IUsable Usable { get; } = usable;
|
||||
public IUsable Usable => usable;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ public static class ModdedOptionsManager
|
||||
|
||||
while (chunks.Count > 0)
|
||||
{
|
||||
Rpc<SyncOptionsRpc>.Instance.SendTo(PlayerControl.LocalPlayer, targetId, new MiraOptionNetData(false, chunks.Dequeue()));
|
||||
Rpc<SyncGameOptionsRpc>.Instance.SendTo(PlayerControl.LocalPlayer, targetId, new MiraOptionNetData(false, chunks.Dequeue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
entry.Value = _value;
|
||||
}
|
||||
|
||||
Rpc<SyncOptionsRpc>.Instance.Send(PlayerControl.LocalPlayer, new MiraOptionNetData(true, [GetNetData()]), true);
|
||||
Rpc<SyncGameOptionsRpc>.Instance.Send(PlayerControl.LocalPlayer, new MiraOptionNetData(true, [GetNetData()]), true);
|
||||
}
|
||||
|
||||
OnValueChanged(_value);
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class MultiTargetButton<T> : CustomActionButton
|
||||
/// <summary>
|
||||
/// Gets the maximum amount of targets the button can have.
|
||||
/// </summary>
|
||||
public virtual int MaxTargets { get; } = int.MaxValue;
|
||||
public virtual int MaxTargets => int.MaxValue;
|
||||
|
||||
/// <inheritdoc cref="CustomActionButton{T}.IsTargetValid"/>
|
||||
public virtual bool IsTargetValid(T target)
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MiraKeybind(string name, KeyboardKeyCode? defaultKeycode, ModifierK
|
||||
/// <summary>
|
||||
/// Gets name of the keybind.
|
||||
/// </summary>
|
||||
public string Name { get; } = name;
|
||||
public string Name => name;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public bool Exclusive { get; } = exclusive;
|
||||
public bool Exclusive => exclusive;
|
||||
|
||||
internal string? SourcePluginName { get; set; }
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class LocalEnumSetting(
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Enum"/> type of the setting.
|
||||
/// </summary>
|
||||
public Type EnumType { get; } = enumType;
|
||||
public Type EnumType => enumType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see langword="enum"/> values.
|
||||
|
||||
@@ -41,7 +41,7 @@ public class LocalSliderSetting(
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the value should be displayed next to name.
|
||||
/// </summary>
|
||||
public bool DisplayValue { get; } = displayValue;
|
||||
public bool DisplayValue => displayValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a format for the text to use to format the number.
|
||||
@@ -51,7 +51,7 @@ public class LocalSliderSetting(
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the value should be rounded.
|
||||
/// </summary>
|
||||
public bool RoundValue { get; } = roundValue;
|
||||
public bool RoundValue => roundValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the suffix for the number value.
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class TargetedMeetingButton
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MeetingButtonUsesMode"/> for this button.
|
||||
/// </summary>
|
||||
public virtual MeetingButtonUsesMode UsesMode { get; } = MeetingButtonUsesMode.PerGame;
|
||||
public virtual MeetingButtonUsesMode UsesMode => MeetingButtonUsesMode.PerGame;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the button is enabled.
|
||||
|
||||
@@ -10,12 +10,12 @@ public readonly struct NetData(uint id, byte[] data)
|
||||
/// <summary>
|
||||
/// Gets the ID of the data.
|
||||
/// </summary>
|
||||
public uint Id { get; } = id;
|
||||
public uint Id => id;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the byte[] data.
|
||||
/// </summary>
|
||||
public byte[] Data { get; } = data;
|
||||
public byte[] Data => data;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the data in bytes.
|
||||
|
||||
@@ -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<MiraApiPlugin, MiraOptionNetData>(plugin, id)
|
||||
#pragma warning restore SA1515 // Single-line comment should be preceded by blank line
|
||||
internal abstract class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, MiraOptionNetData>(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 ?? []);
|
||||
}
|
||||
}
|
||||
@@ -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<MiraApiPlugin, MiraOptionNetData>(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 ?? []);
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -18,22 +18,22 @@ public class OptionPreset(string name, MiraPluginInfo plugin, ConfigFile presetC
|
||||
/// <summary>
|
||||
/// Gets the name of the preset.
|
||||
/// </summary>
|
||||
public string Name { get; } = name;
|
||||
public string Name => name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin associated with the preset.
|
||||
/// </summary>
|
||||
public MiraPluginInfo Plugin { get; } = plugin;
|
||||
public MiraPluginInfo Plugin => plugin;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ConfigFile"/> of the plugin associated with the preset.
|
||||
/// </summary>
|
||||
public ConfigFile PluginConfig { get; } = plugin.PluginConfig;
|
||||
public ConfigFile PluginConfig => plugin.PluginConfig;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ConfigFile"/> for the preset.
|
||||
/// </summary>
|
||||
public ConfigFile PresetConfig { get; } = presetConfig;
|
||||
public ConfigFile PresetConfig => presetConfig;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the button associated with the preset in the UI.
|
||||
|
||||
@@ -31,13 +31,13 @@ internal sealed class GuideOptionPage(
|
||||
IReadOnlyList<string> modSearchTerms,
|
||||
List<GuideOptionEntry> entries)
|
||||
{
|
||||
public AbstractOptionGroup Group { get; } = group;
|
||||
public AbstractOptionGroup Group => group;
|
||||
|
||||
public List<AbstractOptionGroup> Groups { get; } = [group];
|
||||
|
||||
public string Title { get; } = title;
|
||||
public string Title => title;
|
||||
|
||||
public LoadableAsset<Sprite> Sprite { get; } = group.Sprite;
|
||||
public LoadableAsset<Sprite> 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<string> ModSearchTerms { get; } = new(modSearchTerms, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public List<GuideOptionEntry> Entries { get; } = entries;
|
||||
public List<GuideOptionEntry> Entries => entries;
|
||||
}
|
||||
|
||||
internal static class GuideOptionPages
|
||||
|
||||
Reference in new issue
Block a user