From 0b6d6209b00f3644bee1a4884d23b343f3a52842 Mon Sep 17 00:00:00 2001 From: ang-xd Date: Sat, 24 Aug 2024 12:15:41 -0400 Subject: [PATCH] Begin teams ig --- MiraAPI/Roles/ICustomRole.cs | 35 ++++++++++++++--------------- MiraAPI/Teams/BaseTeam.cs | 12 ++++++++++ MiraAPI/Teams/Teams/CrewmateTeam.cs | 18 +++++++++++++++ MiraAPI/Teams/Teams/ImpostorTeam.cs | 13 +++++++++++ MiraAPI/Teams/Teams/NeutralTeam.cs | 13 +++++++++++ 5 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 MiraAPI/Teams/BaseTeam.cs create mode 100644 MiraAPI/Teams/Teams/CrewmateTeam.cs create mode 100644 MiraAPI/Teams/Teams/ImpostorTeam.cs create mode 100644 MiraAPI/Teams/Teams/NeutralTeam.cs diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index fcb7cca..4501fa3 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -1,12 +1,13 @@ -using System; -using AmongUs.GameOptions; +using AmongUs.GameOptions; using BepInEx.Configuration; -using MiraAPI.Utilities; -using MiraAPI.Utilities.Assets; -using System.Text; using HarmonyLib; using MiraAPI.Networking; using MiraAPI.PluginLoading; +using MiraAPI.Teams.Teams; +using MiraAPI.Utilities; +using MiraAPI.Utilities.Assets; +using System; +using System.Text; using UnityEngine; namespace MiraAPI.Roles; @@ -21,7 +22,7 @@ public interface ICustomRole Color RoleColor { get; } - ModdedRoleTeams Team { get; } + Type Team { get; } LoadableAsset OptionsScreenshot => MiraAssets.Empty; @@ -31,17 +32,15 @@ public interface ICustomRole ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance{RoleName}"); - bool AffectedByLight => Team == ModdedRoleTeams.Crewmate; + bool AffectedByLight => Team == typeof(CrewmateTeam); - bool CanGetKilled => Team == ModdedRoleTeams.Crewmate; + bool CanGetKilled => Team == typeof(CrewmateTeam); - bool IsNeutral => Team == ModdedRoleTeams.Neutral; + bool CanKill => Team == typeof(ImpostorTeam); - bool CanKill => Team == ModdedRoleTeams.Impostor; + bool CanUseVent => Team == typeof(ImpostorTeam); - bool CanUseVent => Team == ModdedRoleTeams.Impostor; - - bool TasksCount => Team == ModdedRoleTeams.Crewmate; + bool TasksCount => Team == typeof(CrewmateTeam); bool IsGhostRole => false; @@ -51,17 +50,17 @@ public interface ICustomRole bool HideSettings => IsGhostRole; - RoleTypes GhostRole => Team == ModdedRoleTeams.Crewmate ? RoleTypes.CrewmateGhost : RoleTypes.ImpostorGhost; + RoleTypes GhostRole => Team == typeof(CrewmateRole) ? RoleTypes.CrewmateGhost : RoleTypes.ImpostorGhost; MiraPluginInfo ParentMod => CustomRoleManager.FindParentMod(this); - + void PlayerControlFixedUpdate(PlayerControl playerControl) { } void HudUpdate(HudManager hudManager) { } string GetCustomEjectionMessage(NetworkedPlayerInfo player) { - return Team == ModdedRoleTeams.Impostor ? $"{player.PlayerName} was The {RoleName}" : null; + return Team == typeof(ImpostorTeam) ? $"{player.PlayerName} was The {RoleName}" : null; } StringBuilder SetTabText() @@ -69,12 +68,12 @@ public interface ICustomRole var taskStringBuilder = Helpers.CreateForRole(this); return taskStringBuilder; } - + NetData GetNetData(RoleBehaviour roleBehaviour) { ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out var numEntry); ParentMod.PluginConfig.TryGetEntry(ChanceConfigDefinition, out var chanceEntry); - + return new NetData((uint)roleBehaviour.Role, BitConverter.GetBytes(numEntry.Value).AddRangeToArray(BitConverter.GetBytes(chanceEntry.Value))); } } \ No newline at end of file diff --git a/MiraAPI/Teams/BaseTeam.cs b/MiraAPI/Teams/BaseTeam.cs new file mode 100644 index 0000000..cc6cc77 --- /dev/null +++ b/MiraAPI/Teams/BaseTeam.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace MiraAPI.Teams; +public abstract class BaseTeam +{ + public abstract string TeamName { get; } + public abstract string TeamDescription { get; } + public abstract Color TeamColor { get; } + public abstract RoleTeamTypes BaseRole { get; } + + public abstract bool DidWin(GameOverReason reason); +} \ No newline at end of file diff --git a/MiraAPI/Teams/Teams/CrewmateTeam.cs b/MiraAPI/Teams/Teams/CrewmateTeam.cs new file mode 100644 index 0000000..1623724 --- /dev/null +++ b/MiraAPI/Teams/Teams/CrewmateTeam.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +namespace MiraAPI.Teams.Teams; +public class CrewmateTeam : BaseTeam +{ + public override string TeamName => "Crewmate"; + + public override string TeamDescription => "Do your tasks"; + + public override Color TeamColor => Palette.CrewmateBlue; + + public override RoleTeamTypes BaseRole => RoleTeamTypes.Crewmate; + + public override bool DidWin(GameOverReason reason) + { + return GameManager.Instance.DidHumansWin(reason); + } +} \ No newline at end of file diff --git a/MiraAPI/Teams/Teams/ImpostorTeam.cs b/MiraAPI/Teams/Teams/ImpostorTeam.cs new file mode 100644 index 0000000..0c49011 --- /dev/null +++ b/MiraAPI/Teams/Teams/ImpostorTeam.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace MiraAPI.Teams.Teams; +public class ImpostorTeam : BaseTeam +{ + public override string TeamName => "Impostor"; + + public override string TeamDescription => "Kill and sabotage"; + + public override Color TeamColor => Palette.ImpostorRed; + + public override RoleTeamTypes BaseRole => RoleTeamTypes.Impostor; +} \ No newline at end of file diff --git a/MiraAPI/Teams/Teams/NeutralTeam.cs b/MiraAPI/Teams/Teams/NeutralTeam.cs new file mode 100644 index 0000000..52ab541 --- /dev/null +++ b/MiraAPI/Teams/Teams/NeutralTeam.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace MiraAPI.Teams.Teams; +public class NeutralTeam : BaseTeam +{ + public override string TeamName => "Neutral"; + + public override string TeamDescription => "You're on your own"; + + public override Color TeamColor => Palette.DisabledGrey; + + public override RoleTeamTypes BaseRole => RoleTeamTypes.Crewmate; +} \ No newline at end of file