mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Start making the settings actually work
This commit is contained in:
1 parent
f2ee653560
commit
f6f659b95a
8 files changed
+39
-11
No files matched your search
@@ -760,7 +760,7 @@ internal static class CustomRolesHelper
|
||||
CustomRoles.Hangman or
|
||||
CustomRoles.Generator;
|
||||
|
||||
public static bool CheckAddonConflict(CustomRoles role, PlayerControl pc) => role.IsAdditionRole() && pc.GetCustomRole() is not CustomRoles.GuardianAngelEHR and not CustomRoles.God && !pc.Is(CustomRoles.Madmate) && !pc.Is(CustomRoles.Egoist) && !pc.Is(CustomRoles.GM) && role is not CustomRoles.Lovers && !pc.Is(CustomRoles.Needy) && (!pc.HasSubRole() || pc.GetCustomSubRoles().Count < Options.NoLimitAddonsNumMax.GetInt()) && (!Options.AddonCanBeSettings.TryGetValue(role, out var o) || ((o.Imp.GetBool() || !pc.GetCustomRole().IsImpostor()) && (o.Neutral.GetBool() || !pc.GetCustomRole().IsNeutral()) && (o.Crew.GetBool() || !pc.IsCrewmate()))) && role switch
|
||||
public static bool CheckAddonConflict(CustomRoles role, PlayerControl pc) => role.IsAdditionRole() && (!Main.NeverSpawnTogetherCombos.TryGetValue(pc.GetCustomRole(), out var bannedAddon) || role != bannedAddon) && pc.GetCustomRole() is not CustomRoles.GuardianAngelEHR and not CustomRoles.God && !pc.Is(CustomRoles.Madmate) && !pc.Is(CustomRoles.Egoist) && !pc.Is(CustomRoles.GM) && role is not CustomRoles.Lovers && !pc.Is(CustomRoles.Needy) && (!pc.HasSubRole() || pc.GetCustomSubRoles().Count < Options.NoLimitAddonsNumMax.GetInt()) && (!Options.AddonCanBeSettings.TryGetValue(role, out var o) || ((o.Imp.GetBool() || !pc.GetCustomRole().IsImpostor()) && (o.Neutral.GetBool() || !pc.GetCustomRole().IsNeutral()) && (o.Crew.GetBool() || !pc.IsCrewmate()))) && role switch
|
||||
{
|
||||
CustomRoles.Sidekick when pc.Is(CustomRoles.Madmate) => false,
|
||||
CustomRoles.Madmate when pc.Is(CustomRoles.Sidekick) => false,
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EHR.Modules
|
||||
{
|
||||
@@ -50,6 +51,7 @@ namespace EHR.Modules
|
||||
}
|
||||
|
||||
public static HashSet<CustomTeam> CustomTeams = [];
|
||||
public static HashSet<CustomTeam> EnabledCustomTeams = [];
|
||||
public static CustomTeam WinnerTeam;
|
||||
public static Dictionary<CustomTeam, HashSet<byte>> CustomTeamPlayerIds = [];
|
||||
public static List<CustomTeamOptionGroup> CustomTeamOptions = [];
|
||||
@@ -79,6 +81,8 @@ namespace EHR.Modules
|
||||
#pragma warning disable CA1806
|
||||
File.ReadAllLines("./EHR_DATA/CTA_Data.txt").Do(x => new CustomTeam(x));
|
||||
#pragma warning restore CA1806
|
||||
|
||||
RefreshCustomOptions();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -90,10 +94,14 @@ namespace EHR.Modules
|
||||
{
|
||||
CustomTeamOptions.ForEach(x => x.AllOptions.ForEach(o => OptionItem.Remove(o.Id)));
|
||||
CustomTeamOptions.Clear();
|
||||
EnabledCustomTeams.Clear();
|
||||
|
||||
const int startId = 649000;
|
||||
const TabGroup tab = TabGroup.GameSettings;
|
||||
CustomTeamOptions = CustomTeams.Select((x, i) => CreateSetting(x, startId + (6 * i))).ToList();
|
||||
OptionSaver.Load();
|
||||
EnabledCustomTeams = CustomTeamOptions.Where(x => x.Enabled.GetBool()).Select(x => x.Team).ToHashSet();
|
||||
|
||||
return;
|
||||
|
||||
static CustomTeamOptionGroup CreateSetting(CustomTeam team, int id)
|
||||
@@ -107,24 +115,25 @@ namespace EHR.Modules
|
||||
|
||||
CustomTeamOptionGroup group = new(team, enabled, knowRoles, winWithOriginalTeam, killEachOther, guessEachOther, arrows);
|
||||
group.AllOptions.Skip(1).Do(x => x.SetParent(group.Enabled));
|
||||
group.AllOptions.ForEach(x => x.SetColor(new Color32(215, 227, 84, byte.MaxValue)));
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitializeCustomTeamPlayers()
|
||||
{
|
||||
if (CustomTeams.Count == 0) return;
|
||||
if (EnabledCustomTeams.Count == 0) return;
|
||||
|
||||
CustomTeamPlayerIds = Main.PlayerStates
|
||||
.IntersectBy(Main.AllAlivePlayerControls.Select(x => x.PlayerId), x => x.Key)
|
||||
.GroupBy(x => CustomTeams.FirstOrDefault(t => t.TeamMembers.Contains(x.Value.MainRole)), x => x.Key)
|
||||
.GroupBy(x => EnabledCustomTeams.FirstOrDefault(t => t.TeamMembers.Contains(x.Value.MainRole)), x => x.Key)
|
||||
.Where(x => x.Key != null)
|
||||
.ToDictionary(x => x.Key, x => x.ToHashSet());
|
||||
}
|
||||
|
||||
public static bool CheckCustomTeamGameEnd()
|
||||
{
|
||||
if (CustomTeams.Count == 0 || CustomTeamPlayerIds.Count == 0) return false;
|
||||
if (EnabledCustomTeams.Count == 0 || CustomTeamPlayerIds.Count == 0) return false;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -158,16 +167,25 @@ namespace EHR.Modules
|
||||
return false;
|
||||
}
|
||||
|
||||
public static CustomTeam GetCustomTeam(byte id) => CustomTeams.FirstOrDefault(x => x.TeamMembers.Contains(Main.PlayerStates[id].MainRole));
|
||||
public static CustomTeam GetCustomTeam(byte id) => EnabledCustomTeams.FirstOrDefault(x => x.TeamMembers.Contains(Main.PlayerStates[id].MainRole));
|
||||
|
||||
public static bool AreInSameCustomTeam(byte id1, byte id2)
|
||||
{
|
||||
if (CustomTeams.Count == 0) return false;
|
||||
if (EnabledCustomTeams.Count == 0) return false;
|
||||
|
||||
var team1 = GetCustomTeam(id1);
|
||||
var team2 = GetCustomTeam(id2);
|
||||
|
||||
return team1 != null && team2 != null && team1.Equals(team2);
|
||||
}
|
||||
|
||||
public static bool GetSettingForPlayerTeam(byte id, string settingName)
|
||||
{
|
||||
var team = GetCustomTeam(id);
|
||||
var optionsGroup = CustomTeamOptionGroup.First(x => x.Team.Equals(team));
|
||||
var setting = optionsGroup.GetType().GetFields().FirstOrDefault(x => x.Name == settingName);
|
||||
if (setting == null) return false;
|
||||
return setting.GetValue(optionsGroup) as bool ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ public static class DevManager
|
||||
DevUserList.Add(new(code: "tinedpun#6584", color: "#0000ff", tag: "Translator PT-BR", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "Dechis"));
|
||||
DevUserList.Add(new(code: "swiftlord#8072", color: "null", tag: "null", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "But What About"));
|
||||
DevUserList.Add(new(code: "ovalinstep#2984", color: "null", tag: "null", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "Seleneous"));
|
||||
DevUserList.Add(new(code: "seleneous#6930", color: "null", tag: "null", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "Seleneous"));
|
||||
DevUserList.Add(new(code: "innerruler#4140", color: "null", tag: "null", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "thewhiskas27"));
|
||||
DevUserList.Add(new(code: "urbanecalf#4975", color: "#420773", tag: "Streamer", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "Gugutsik"));
|
||||
DevUserList.Add(new(code: "crustzonal#9589", color: "null", tag: "null", isUp: true, isDev: false, deBug: false, colorCmd: false, upName: "aviiiv0102"));
|
||||
|
||||
@@ -2152,8 +2152,8 @@ public static class Options
|
||||
CTAPlayersCanSeeEachOthersRoles = BooleanOptionItem.Create(23551, "CTA.PlayersCanSeeEachOthersRoles", true, TabGroup.GameSettings)
|
||||
.SetGameMode(CustomGameMode.Standard)
|
||||
.SetColor(new Color32(215, 227, 84, byte.MaxValue));
|
||||
|
||||
CustomTeamManager.RefreshCustomOptions();
|
||||
|
||||
CustomTeamManager.LoadCustomTeams();
|
||||
|
||||
LoadingPercentage = 100;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public static class OptionSaver
|
||||
if (DefaultPresetFileInfo.Exists)
|
||||
{
|
||||
string presetNmber = File.ReadAllText(DefaultPresetFileInfo.FullName);
|
||||
if (int.TryParse(presetNmber, out int number) && number >= 0 && number <= 4) return number;
|
||||
if (int.TryParse(presetNmber, out int number) && number is >= 0 and <= 4) return number;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -773,7 +773,7 @@ public static class Utils
|
||||
__instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Crewpostor) && Options.AlliesKnowCrewpostor.GetBool() ||
|
||||
__instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool() ||
|
||||
__instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosImp.GetBool() ||
|
||||
CustomTeamManager.AreInSameCustomTeam(__instance.PlayerId, PlayerControl.LocalPlayer.PlayerId) && Options.CTAPlayersCanSeeEachOthersRoles.GetBool() ||
|
||||
CustomTeamManager.AreInSameCustomTeam(__instance.PlayerId, PlayerControl.LocalPlayer.PlayerId) && CustomTeamManager.GetSettingForPlayerTeam(__instance.PlayerId, "KnowRoles") ||
|
||||
Main.PlayerStates.Values.Any(x => x.Role.KnowRole(PlayerControl.LocalPlayer, __instance)) ||
|
||||
PlayerControl.LocalPlayer.IsRevealedPlayer(__instance) ||
|
||||
PlayerControl.LocalPlayer.Is(CustomRoles.God) ||
|
||||
|
||||
@@ -78,6 +78,12 @@
|
||||
"ROT.AddonType.Helpful": "★ Helpful Add-ons",
|
||||
"ROT.AddonType.Harmful": "★ Harmful Add-ons",
|
||||
"ROT.AddonType.Mixed": "★ Mixed Add-ons",
|
||||
"CTA.TeamEnabled": "Enable {0} Team",
|
||||
"CTA.KnowRoles": "Players Know Each Others' Roles",
|
||||
"CTA.WinWithOriginalTeam": "Players Can Win With Their Original Team",
|
||||
"CTA.KillEachOther": "Players Can Kill Each Other",
|
||||
"CTA.GuessEachOther": "Players Can Guess Each Other",
|
||||
"CTA.Arrows": "Players Have Arrow Pointing Towards Each Other",
|
||||
"GM": "Game Master",
|
||||
"Sunnyboy": "Sunnyboy",
|
||||
"Bard": "Bard",
|
||||
|
||||
@@ -288,8 +288,11 @@ namespace EHR.Neutral
|
||||
if (AllTasksCompleted) return Translator.GetString("Rogue.AllTasksCompleted");
|
||||
if (CurrentTask.IsCompleted) return Translator.GetString("Rogue.TaskCompleted");
|
||||
|
||||
float d = Main.RealOptionsData.GetFloat(FloatOptionNames.KillCooldown);
|
||||
string c = GotRewards.Contains(Reward.Morph) && MorphCooldown > 0
|
||||
? string.Format(Translator.GetString("CDPT"), MorphCooldown) + "\n"
|
||||
? MorphCooldown <= d
|
||||
? string.Format(Translator.GetString("CDPT"), MorphCooldown) + "\n"
|
||||
: $"\u21b9 ({MorphCooldown - d}s)"
|
||||
: string.Empty;
|
||||
|
||||
string o = Translator.GetString("Rogue.Objective." + CurrentTask.Objective);
|
||||
|
||||
Reference in new issue
Block a user