From 84651b90ea028e09b94b21f2696f89155d7003a8 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:36:14 -0400 Subject: [PATCH] precautions for role configs --- MiraAPI.Example/Roles/FreezerRole.cs | 4 ++-- MiraAPI/Roles/ICustomRole.cs | 32 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/MiraAPI.Example/Roles/FreezerRole.cs b/MiraAPI.Example/Roles/FreezerRole.cs index e649b1a..05b950f 100644 --- a/MiraAPI.Example/Roles/FreezerRole.cs +++ b/MiraAPI.Example/Roles/FreezerRole.cs @@ -9,9 +9,9 @@ public class FreezerRole : ImpostorRole, ICustomRole { public string RoleName => "Freezer"; public string RoleLongDescription => "Freeze another player for a duration of time."; - public string RoleDescription => RoleLongDescription; + public string RoleDescription => this.RoleLongDescription; public Color RoleColor => Palette.Blue; public ModdedRoleTeams Team => ModdedRoleTeams.Impostor; public LoadableAsset OptionsScreenshot => ExampleAssets.Banner; public int MaxPlayers => 2; -} \ No newline at end of file +} diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index f8c3e8d..c538e99 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -30,29 +30,29 @@ public interface ICustomRole LoadableAsset Icon => MiraAssets.Empty; - ConfigDefinition NumConfigDefinition => new("Roles", $"Num{RoleName}"); + ConfigDefinition NumConfigDefinition => new("Roles", $"Num {this.GetType().FullName}"); - ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance{RoleName}"); + ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance {this.GetType().FullName}"); - bool AffectedByLight => Team == ModdedRoleTeams.Crewmate; + bool AffectedByLight => this.Team == ModdedRoleTeams.Crewmate; - bool CanGetKilled => Team == ModdedRoleTeams.Crewmate; + bool CanGetKilled => this.Team == ModdedRoleTeams.Crewmate; - bool IsNeutral => Team == ModdedRoleTeams.Neutral; + bool IsNeutral => this.Team == ModdedRoleTeams.Neutral; - bool CanKill => Team == ModdedRoleTeams.Impostor; + bool CanKill => this.Team == ModdedRoleTeams.Impostor; - bool CanUseVent => Team == ModdedRoleTeams.Impostor; + bool CanUseVent => this.Team == ModdedRoleTeams.Impostor; - bool TasksCount => Team == ModdedRoleTeams.Crewmate; + bool TasksCount => this.Team == ModdedRoleTeams.Crewmate; bool IsGhostRole => false; bool CreateCustomTab => true; - bool HideSettings => IsGhostRole; + bool HideSettings => this.IsGhostRole; - RoleTypes GhostRole => Team == ModdedRoleTeams.Crewmate ? RoleTypes.CrewmateGhost : RoleTypes.ImpostorGhost; + RoleTypes GhostRole => this.Team == ModdedRoleTeams.Crewmate ? RoleTypes.CrewmateGhost : RoleTypes.ImpostorGhost; MiraPluginInfo ParentMod => CustomRoleManager.FindParentMod(this); @@ -68,9 +68,9 @@ public interface ICustomRole /// Reference to HudManager instance void HudUpdate(HudManager hudManager) { } - string GetCustomEjectionMessage(NetworkedPlayerInfo player) + string? GetCustomEjectionMessage(NetworkedPlayerInfo player) { - return Team == ModdedRoleTeams.Impostor ? $"{player.PlayerName} was The {RoleName}" : null; + return this.Team == ModdedRoleTeams.Impostor ? $"{player.PlayerName} was The {this.RoleName}" : null; } StringBuilder SetTabText() @@ -86,9 +86,9 @@ public interface ICustomRole NetData GetNetData() { - ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out var numEntry); - ParentMod.PluginConfig.TryGetEntry(ChanceConfigDefinition, out var chanceEntry); + this.ParentMod.PluginConfig.TryGetEntry(this.NumConfigDefinition, out var numEntry); + this.ParentMod.PluginConfig.TryGetEntry(this.ChanceConfigDefinition, out var chanceEntry); - return new NetData(RoleId.Get(GetType()), BitConverter.GetBytes(numEntry.Value).AddRangeToArray(BitConverter.GetBytes(chanceEntry.Value))); + return new NetData(RoleId.Get(this.GetType()), BitConverter.GetBytes(numEntry.Value).AddRangeToArray(BitConverter.GetBytes(chanceEntry.Value))); } -} \ No newline at end of file +}