mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
seperate some role configs
This commit is contained in:
1 parent
3de9482233
commit
e950278bf9
9 files changed
+93
-86
No files matched your search
@@ -16,9 +16,10 @@ public class NeutralKillerRole : ImpostorRole, ICustomRole
|
||||
UseVanillaKillButton = true,
|
||||
CanGetKilled = true,
|
||||
CanUseVent = true,
|
||||
RoleGroup = new RoleGroup("Outcast", Color.gray),
|
||||
};
|
||||
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
||||
|
||||
public override void SpawnTaskHeader(PlayerControl playerControl)
|
||||
{
|
||||
// remove existing task header.
|
||||
|
||||
@@ -39,20 +39,12 @@ public static class IntroCutscenePatches
|
||||
return;
|
||||
}
|
||||
|
||||
if (customRole.Configuration.IntroTeamColor is { } color)
|
||||
if (customRole.IntroConfiguration is { } introConfig)
|
||||
{
|
||||
__instance.BackgroundBar.material.SetColor(ShaderID.Color, color);
|
||||
__instance.TeamTitle.color = color;
|
||||
}
|
||||
|
||||
if (customRole.Configuration.IntroTeamTitle is { } title)
|
||||
{
|
||||
__instance.TeamTitle.text = title;
|
||||
}
|
||||
|
||||
if (customRole.Configuration.IntroTeamDescription is { } description)
|
||||
{
|
||||
__instance.ImpostorText.text = description;
|
||||
__instance.BackgroundBar.material.SetColor(ShaderID.Color, introConfig.IntroTeamColor);
|
||||
__instance.TeamTitle.color = introConfig.IntroTeamColor;
|
||||
__instance.TeamTitle.text = introConfig.IntroTeamTitle;
|
||||
__instance.ImpostorText.text = introConfig.IntroTeamDescription;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,20 +57,12 @@ public static class IntroCutscenePatches
|
||||
return true;
|
||||
}
|
||||
|
||||
if (customRole.Configuration.IntroTeamColor is { } color)
|
||||
if (customRole.IntroConfiguration is { } introConfig)
|
||||
{
|
||||
__instance.BackgroundBar.material.SetColor(ShaderID.Color, color);
|
||||
__instance.TeamTitle.color = color;
|
||||
}
|
||||
|
||||
if (customRole.Configuration.IntroTeamTitle is { } title)
|
||||
{
|
||||
__instance.TeamTitle.text = title;
|
||||
}
|
||||
|
||||
if (customRole.Configuration.IntroTeamDescription is { } description)
|
||||
{
|
||||
__instance.ImpostorText.text = description;
|
||||
__instance.BackgroundBar.material.SetColor(ShaderID.Color, introConfig.IntroTeamColor);
|
||||
__instance.TeamTitle.color = introConfig.IntroTeamColor;
|
||||
__instance.TeamTitle.text = introConfig.IntroTeamTitle;
|
||||
__instance.ImpostorText.text = introConfig.IntroTeamDescription;
|
||||
}
|
||||
|
||||
if (customRole.Team is not ModdedRoleTeams.Custom)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace MiraAPI.Patches.Options;
|
||||
[HarmonyPatch(typeof(RolesSettingsMenu))]
|
||||
public static class RoleSettingMenuPatches
|
||||
{
|
||||
private static Dictionary<RoleGroup, bool> RoleGroupHidden { get; } = [];
|
||||
private static Dictionary<RoleOptionsGroup, bool> RoleGroupHidden { get; } = [];
|
||||
private static List<CategoryHeaderEditRole> CategoryHeaderEditRoles { get; } = [];
|
||||
private static List<RoleOptionSetting> RoleOptionSettings { get; } = [];
|
||||
|
||||
@@ -61,7 +61,7 @@ public static class RoleSettingMenuPatches
|
||||
var num3 = 0;
|
||||
|
||||
var roleGroups = GameSettingMenuPatches.SelectedMod?.CustomRoles.Values.OfType<ICustomRole>()
|
||||
.ToLookup(x => x.Configuration.RoleGroup);
|
||||
.ToLookup(x => x.RoleOptionsGroup);
|
||||
|
||||
if (roleGroups is null)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,10 @@ public static class TaskAdderPatch
|
||||
private static readonly Dictionary<string, string> ModsFolders = [];
|
||||
private static Scroller? _scroller;
|
||||
|
||||
/// <summary>
|
||||
/// Adds custom roles to the TaskAdder.
|
||||
/// </summary>
|
||||
/// <param name="__instance">TaskAdder instance.</param>
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(TaskAdderGame), nameof(TaskAdderGame.Begin))]
|
||||
public static void AddRolesFolder(TaskAdderGame __instance)
|
||||
@@ -86,13 +90,17 @@ public static class TaskAdderPatch
|
||||
__instance.GoToRoot();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the color of the role button based on the role.
|
||||
/// </summary>
|
||||
/// <param name="__instance">TaskAddButton instance.</param>
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(TaskAddButton), "Role", MethodType.Setter)]
|
||||
[HarmonyPatch(typeof(TaskAddButton), nameof(TaskAddButton.Role), MethodType.Setter)]
|
||||
public static void RoleGetterPatch(TaskAddButton __instance)
|
||||
{
|
||||
if (__instance.role is ICustomRole { Team: ModdedRoleTeams.Custom } customRole)
|
||||
{
|
||||
__instance.FileImage.color = customRole.Configuration.IntroTeamColor ?? Color.gray;
|
||||
__instance.FileImage.color = customRole.IntroConfiguration?.IntroTeamColor ?? Color.gray;
|
||||
}
|
||||
|
||||
__instance.RolloverHandler.OutColor = __instance.FileImage.color;
|
||||
|
||||
@@ -39,31 +39,8 @@ public struct CustomRoleConfiguration
|
||||
HideSettings = roleBehaviour?.IsDead == true;
|
||||
ShowInFreeplay = roleBehaviour?.IsDead == false;
|
||||
CanModifyChance = true;
|
||||
IntroTeamColor = role.Team switch
|
||||
{
|
||||
ModdedRoleTeams.Custom => Color.gray,
|
||||
_ => null,
|
||||
};
|
||||
IntroTeamTitle = role.Team switch
|
||||
{
|
||||
ModdedRoleTeams.Custom => "NEUTRAL",
|
||||
_ => null,
|
||||
};
|
||||
IntroTeamDescription = role.Team switch
|
||||
{
|
||||
ModdedRoleTeams.Custom => "You are Neutral. You do not have a team.",
|
||||
_ => null,
|
||||
};
|
||||
RoleGroup = role.Team switch
|
||||
{
|
||||
ModdedRoleTeams.Crewmate => RoleGroup.Crewmate,
|
||||
ModdedRoleTeams.Impostor => RoleGroup.Impostor,
|
||||
ModdedRoleTeams.Custom => RoleGroup.Neutral,
|
||||
};
|
||||
}
|
||||
|
||||
public RoleGroup RoleGroup;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hard limit of players that can have this role. This property is used to set a limit in the Role Options menu. If set to 0, the role will not be assigned at start.
|
||||
/// </summary>
|
||||
@@ -134,21 +111,6 @@ public struct CustomRoleConfiguration
|
||||
/// </summary>
|
||||
public bool ShowInFreeplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color to show during the "Team" part of the intro cutscene.
|
||||
/// </summary>
|
||||
public Color? IntroTeamColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title text to show during the "Team" part of the intro cutscene.
|
||||
/// </summary>
|
||||
public string? IntroTeamTitle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description text to show during the "Team" part of the intro cutscene.
|
||||
/// </summary>
|
||||
public string? IntroTeamDescription;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the outline color for the KillButton if <see cref="UseVanillaKillButton"/> is true.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BepInEx.Configuration;
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities;
|
||||
@@ -43,6 +44,26 @@ public interface ICustomRole
|
||||
/// </summary>
|
||||
CustomRoleConfiguration Configuration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role options group.
|
||||
/// </summary>
|
||||
public RoleOptionsGroup RoleOptionsGroup => Team switch
|
||||
{
|
||||
ModdedRoleTeams.Crewmate => RoleOptionsGroup.Crewmate,
|
||||
ModdedRoleTeams.Impostor => RoleOptionsGroup.Impostor,
|
||||
ModdedRoleTeams.Custom => RoleOptionsGroup.Neutral,
|
||||
_ => new RoleOptionsGroup(RoleName, RoleColor),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role's IntroCutscene configuration.
|
||||
/// </summary>
|
||||
public RoleIntroConfiguration? IntroConfiguration => Team switch
|
||||
{
|
||||
ModdedRoleTeams.Custom => RoleIntroConfiguration.Neutral,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent mod of this role.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a group of roles.
|
||||
/// </summary>
|
||||
/// <param name="Name">The group's name.</param>
|
||||
/// <param name="Color">The group's color.</param>
|
||||
/// <param name="Priority">The priority to sort by on role setting screen. Negative means first.</param>
|
||||
public record struct RoleGroup(string Name, Color Color, int Priority = 0)
|
||||
{
|
||||
public static RoleGroup Crewmate { get; } = new("Crewmate", Palette.CrewmateBlue, -2);
|
||||
public static RoleGroup Impostor { get; } = new("Impostor", Palette.ImpostorRed, -1);
|
||||
public static RoleGroup Neutral { get; } = new("Neutral Roles", Color.gray);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Used to configure the intro cutscene.
|
||||
/// </summary>
|
||||
/// <param name="IntroTeamColor">The color to show during the "Team" part of the intro cutscene.</param>
|
||||
/// <param name="IntroTeamTitle">The title text to show during the "Team" part of the intro cutscene.</param>
|
||||
/// <param name="IntroTeamDescription">The description text to show during the "Team" part of the intro cutscene.</param>
|
||||
public record struct RoleIntroConfiguration(Color IntroTeamColor, string IntroTeamTitle, string IntroTeamDescription)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default configuration for the "Neutral" team.
|
||||
/// </summary>
|
||||
public static RoleIntroConfiguration Neutral { get; } = new(
|
||||
Color.gray,
|
||||
"NEUTRAL",
|
||||
"You are Neutral. You do not have a team.");
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a group of roles.
|
||||
/// </summary>
|
||||
/// <param name="Name">The group's name.</param>
|
||||
/// <param name="Color">The group's color.</param>
|
||||
/// <param name="Priority">The priority to sort by on role setting screen. Negative means first.</param>
|
||||
public record struct RoleOptionsGroup(string Name, Color Color, int Priority = 0)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default group for crewmates.
|
||||
/// </summary>
|
||||
public static RoleOptionsGroup Crewmate { get; } = new("Crewmate", Palette.CrewmateBlue, -2);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default group for impostors.
|
||||
/// </summary>
|
||||
public static RoleOptionsGroup Impostor { get; } = new("Impostor", Palette.ImpostorRed, -1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default group for neutral roles.
|
||||
/// </summary>
|
||||
public static RoleOptionsGroup Neutral { get; } = new("Neutral Roles", Color.gray);
|
||||
}
|
||||
Reference in new issue
Block a user