Finish everything & fix stuff with Rogue

This commit is contained in:
Gurge44 committed 2024-05-16 19:49:35 +02:00
1 parent 8002786ca3
commit f1b05d35b0
11 files changed
+91 -88

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
<Description>EHR</Description>
<Authors>Gurge44</Authors>
<langVersion>preview</langVersion>
<AmongUs>E:\Program Files\AmongUs</AmongUs>
<AmongUs>D:\Epic Games\AmongUs</AmongUs>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>True</Optimize>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
+1 -1
View File
@@ -1,7 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">VISIBLE_FILES</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AU/@EntryIndexedValue">AU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CD/@EntryIndexedValue">CD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CK/@EntryIndexedValue">CK</s:String>
+14 -20
View File
@@ -20,13 +20,7 @@ namespace EHR.Modules
try
{
if (!File.Exists("./EHR_DATA/CTA_Data.txt")) return;
CustomTeams.Clear();
// ReSharper disable once ObjectCreationAsStatement
#pragma warning disable CA1806
File.ReadAllLines("./EHR_DATA/CTA_Data.txt").Do(x => new CustomTeam(x));
#pragma warning restore CA1806
CustomTeams = File.ReadAllLines("./EHR_DATA/CTA_Data.txt").Select(x => new CustomTeam(x)).ToHashSet();
RefreshCustomOptions();
}
catch (Exception e)
@@ -35,23 +29,21 @@ namespace EHR.Modules
}
}
public static void RefreshCustomOptions()
private static void RefreshCustomOptions()
{
CustomTeamOptions.ForEach(x => x.AllOptions.ForEach(o => OptionItem.Remove(o.Id)));
CustomTeamOptions.Clear();
EnabledCustomTeams.Clear();
const int startId = 649000;
const int startId = 647000;
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();
UpdateEnabledTeams();
return;
static CustomTeamOptionGroup CreateSetting(CustomTeam team, int id)
{
var enabled = BooleanOptionItem.Create(id++, "CTA.TeamEnabled", true, tab);
var enabled = BooleanOptionItem.Create(id++, "CTA.FLAG" + team.TeamName, true, tab);
var knowRoles = BooleanOptionItem.Create(id++, "CTA.KnowRoles", true, tab);
var winWithOriginalTeam = BooleanOptionItem.Create(id++, "CTA.WinWithOriginalTeam", false, tab);
var killEachOther = BooleanOptionItem.Create(id++, "CTA.KillEachOther", false, tab);
@@ -59,12 +51,19 @@ namespace EHR.Modules
var arrows = BooleanOptionItem.Create(id, "CTA.Arrows", true, tab);
CustomTeamOptionGroup group = new(team, enabled, knowRoles, winWithOriginalTeam, killEachOther, guessEachOther, arrows);
group.AllOptions.Skip(1).Do(x => x.SetParent(group.Enabled));
group.AllOptions.Skip(1).Do(x => x.SetParent(enabled));
group.AllOptions.ForEach(x => x.SetColor(new Color32(215, 227, 84, byte.MaxValue)));
if (ColorUtility.TryParseHtmlString(team.RoleRevealScreenBackgroundColor, out var color)) enabled.SetColor(color);
enabled.RegisterUpdateValueEvent((_, _) => UpdateEnabledTeams());
return group;
}
}
private static void UpdateEnabledTeams()
{
EnabledCustomTeams = CustomTeamOptions.Where(x => x.Enabled.GetBool()).Select(x => x.Team).ToHashSet();
}
public static void InitializeCustomTeamPlayers()
{
if (EnabledCustomTeams.Count == 0) return;
@@ -158,11 +157,6 @@ namespace EHR.Modules
return setting.GetValue(optionsGroup) as bool? ?? false;
}
public static string GetTeamEnabledSettingDisplay(int id)
{
// INCOMPLETE - DO NOT FREAK OUT MR PHGAMING
}
internal class CustomTeam
{
public readonly string RoleRevealScreenBackgroundColor;
@@ -193,7 +187,7 @@ namespace EHR.Modules
}
}
public List<CustomRoles> TeamMembers { get; set; } = [];
public List<CustomRoles> TeamMembers { get; } = [];
public override bool Equals(object obj)
{
+28 -25
View File
@@ -155,19 +155,22 @@ public class RemoveDisableDevicesPatch
{
public static void Postfix()
{
if (!Options.DisableDevices.GetBool()) return;
var rogueForce = Rogue.On && Main.PlayerStates.Values.Any(x => x.Role is Rogue { DisableDevices: true });
if (!Options.DisableDevices.GetBool() && !rogueForce) return;
UpdateDisableDevices();
}
public static void UpdateDisableDevices()
{
var player = PlayerControl.LocalPlayer;
var rogueForce = Rogue.On && Main.PlayerStates.Values.Any(x => x.Role is Rogue { DisableDevices: true });
bool ignore = player.Is(CustomRoles.GM) ||
!player.IsAlive() ||
(Options.DisableDevicesIgnoreImpostors.GetBool() && player.Is(CustomRoleTypes.Impostor)) ||
(Options.DisableDevicesIgnoreNeutrals.GetBool() && player.Is(CustomRoleTypes.Neutral)) ||
(Options.DisableDevicesIgnoreCrewmates.GetBool() && player.Is(CustomRoleTypes.Crewmate)) ||
(Options.DisableDevicesIgnoreAfterAnyoneDied.GetBool() && GameStates.AlreadyDied);
ignore &= !rogueForce;
var admins = Object.FindObjectsOfType<MapConsole>(true);
var consoles = Object.FindObjectsOfType<SystemConsole>(true);
if (admins == null || consoles == null) return;
@@ -175,42 +178,42 @@ public class RemoveDisableDevicesPatch
{
case 3:
case 0:
if (Options.DisableSkeldAdmin.GetBool())
admins[0].gameObject.GetComponent<CircleCollider2D>().enabled = false || ignore;
if (Options.DisableSkeldCamera.GetBool())
consoles.DoIf(x => x.name == "SurvConsole", x => x.gameObject.GetComponent<PolygonCollider2D>().enabled = false || ignore);
if (Options.DisableSkeldAdmin.GetBool() || rogueForce)
admins[0].gameObject.GetComponent<CircleCollider2D>().enabled = ignore;
if (Options.DisableSkeldCamera.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "SurvConsole", x => x.gameObject.GetComponent<PolygonCollider2D>().enabled = ignore);
break;
case 1:
if (Options.DisableMiraHQAdmin.GetBool())
admins[0].gameObject.GetComponent<CircleCollider2D>().enabled = false || ignore;
if (Options.DisableMiraHQDoorLog.GetBool())
consoles.DoIf(x => x.name == "SurvLogConsole", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore);
if (Options.DisableMiraHQAdmin.GetBool() || rogueForce)
admins[0].gameObject.GetComponent<CircleCollider2D>().enabled = ignore;
if (Options.DisableMiraHQDoorLog.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "SurvLogConsole", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore);
break;
case 2:
if (Options.DisablePolusAdmin.GetBool())
admins.Do(x => x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore);
if (Options.DisablePolusCamera.GetBool())
consoles.DoIf(x => x.name == "Surv_Panel", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore);
if (Options.DisablePolusVital.GetBool())
consoles.DoIf(x => x.name == "panel_vitals", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore);
if (Options.DisablePolusAdmin.GetBool() || rogueForce)
admins.Do(x => x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore);
if (Options.DisablePolusCamera.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "Surv_Panel", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore);
if (Options.DisablePolusVital.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "panel_vitals", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore);
break;
case 4:
admins.Do(x =>
{
if ((Options.DisableAirshipCockpitAdmin.GetBool() && x.name == "panel_cockpit_map") ||
(Options.DisableAirshipRecordsAdmin.GetBool() && x.name == "records_admin_map"))
x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore;
(Options.DisableAirshipRecordsAdmin.GetBool() && x.name == "records_admin_map") || rogueForce)
x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore;
});
if (Options.DisableAirshipCamera.GetBool())
consoles.DoIf(x => x.name == "task_cams", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore);
if (Options.DisableAirshipVital.GetBool())
consoles.DoIf(x => x.name == "panel_vitals", x => x.gameObject.GetComponent<CircleCollider2D>().enabled = false || ignore);
if (Options.DisableAirshipCamera.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "task_cams", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore);
if (Options.DisableAirshipVital.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "panel_vitals", x => x.gameObject.GetComponent<CircleCollider2D>().enabled = ignore);
break;
case 5:
if (Options.DisableFungleCamera.GetBool())
consoles.DoIf(x => x.name == "BinocularsSecurityConsole", x => x.gameObject.GetComponent<PolygonCollider2D>().enabled = false || ignore);
if (Options.DisableFungleCamera.GetBool())
consoles.DoIf(x => x.name == "VitalsConsole", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = false || ignore);
if (Options.DisableFungleCamera.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "BinocularsSecurityConsole", x => x.gameObject.GetComponent<PolygonCollider2D>().enabled = ignore);
if (Options.DisableFungleCamera.GetBool() || rogueForce)
consoles.DoIf(x => x.name == "VitalsConsole", x => x.gameObject.GetComponent<BoxCollider2D>().enabled = ignore);
break;
}
}
+3 -9
View File
@@ -143,9 +143,9 @@ public abstract class OptionItem
// Getter
public virtual string GetName(bool disableColor = false, bool console = false)
{
if (Name.Contains("CTA.TeamEnabled"))
if (Name.Contains("CTA.FLAG"))
{
return Utils.ColorString(NameColor, Translator.GetString(Name, ReplacementDictionary));
return Utils.ColorString(NameColor, Translator.GetString("CTA.TeamEnabled.Prefix") + Name[8..] + Translator.GetString("CTA.TeamEnabled.Suffix"));
}
return disableColor ? Translator.GetString(Name, ReplacementDictionary, console) : Utils.ColorString(NameColor, Translator.GetString(Name, ReplacementDictionary));
@@ -275,13 +275,7 @@ public abstract class OptionItem
private static readonly List<OptionItem> Options = new(1024);
public static IReadOnlyDictionary<int, OptionItem> FastOptions => FastOpts;
private static readonly Dictionary<int, OptionItem> FastOpts = new(1024);
public static int CurrentPreset { get; set; }
public static void Remove(int id)
{
Options.RemoveAll(x => x.Id == id);
FastOpts.Remove(id);
}
private static int CurrentPreset { get; set; }
#endregion
}
+3 -3
View File
@@ -1835,15 +1835,15 @@ public static class Utils
Logger.Info($" Seers: {string.Join(", ", seerList.Select(x => x.GetRealName()))} ---- Targets: {string.Join(", ", targetList.Select(x => x.GetRealName()))}", "NR");
//seer: Players who can see changes made here
//target: Players subject to changes that seer can see
// seer: Players who can see changes made here
// target: Players subject to changes that seer can see
foreach (PlayerControl seer in seerList)
{
try
{
if (seer == null || seer.Data.Disconnected || seer.IsModClient()) continue;
string fontSize = "1.6";
string fontSize = "1.7";
if (isForMeeting && (seer.GetClient().PlatformData.Platform == Platforms.Playstation || seer.GetClient().PlatformData.Platform == Platforms.Switch)) fontSize = "70%";
//Logger.Info("NotifyRoles-Loop1-" + seer.GetNameWithRole().RemoveHtmlTags() + ":START", "NotifyRoles");
-5
View File
@@ -33,11 +33,6 @@ internal class ControllerManagerUpdatePatch
if (OrGetKeysDown(KeyCode.Alpha1 + i, KeyCode.Keypad1 + i) && OptionShower.Pages.Count >= i + 1)
OptionShower.CurrentPage = i;
}
if (GetKeysDown(KeyCode.LeftShift, KeyCode.LeftControl, KeyCode.T))
{
CustomTeamManager.RefreshCustomOptions();
}
}
if (GetKeysDown(KeyCode.LeftShift, KeyCode.LeftControl, KeyCode.X) && Main.CurrentMap == MapNames.Airship)
+2 -2
View File
@@ -178,7 +178,7 @@ class BeginCrewmatePatch
return false;
}
if (CustomTeamManager.CustomTeams.Count > 0)
if (CustomTeamManager.EnabledCustomTeams.Count > 0)
{
var team = CustomTeamManager.GetCustomTeam(PlayerControl.LocalPlayer.PlayerId);
if (team != null)
@@ -420,7 +420,7 @@ class BeginCrewmatePatch
__instance.ImpostorText.text = GetString("SubText.Madmate");
}
if (CustomTeamManager.CustomTeams.Count > 0)
if (CustomTeamManager.EnabledCustomTeams.Count > 0)
{
var team = CustomTeamManager.GetCustomTeam(PlayerControl.LocalPlayer.PlayerId);
if (team != null)
-1
View File
@@ -214,7 +214,6 @@ internal class ChangeRoleSettings
SabotageSystemTypeRepairDamagePatch.Initialize();
DoorsReset.Initialize();
GhostRolesManager.Initialize();
CustomTeamManager.LoadCustomTeams();
RoleBlockManager.Reset();
IRandom.SetInstanceById(Options.RoleAssigningAlgorithm.GetValue());
+3 -2
View File
@@ -78,7 +78,8 @@
"ROT.AddonType.Helpful": "★ Helpful Add-ons",
"ROT.AddonType.Harmful": "★ Harmful Add-ons",
"ROT.AddonType.Mixed": "★ Mixed Add-ons",
"CTA.TeamEnabled": "Enable {0} Team",
"CTA.TeamEnabled.Prefix": "Enable ",
"CTA.TeamEnabled.Suffix": " ",
"CTA.KnowRoles": "Players Know Each Others' Roles",
"CTA.WinWithOriginalTeam": "Players Can Win With Their Original Team",
"CTA.KillEachOther": "Players Can Kill Each Other",
@@ -3415,7 +3416,7 @@
"Rogue.Objective.KillInSpecificRoom": "Kill someone in {0}",
"Rogue.Objective.VentXTimes": "Vent {0} times",
"Rogue.Objective.CallEmergencyMeeting": "Call an emergency meeting",
"Rogue.Objective.KillSpecificPlayer": " Kill {0}",
"Rogue.Objective.KillSpecificPlayer": "Kill {0}",
"Rogue.Objective.KillXTimes": "Kill {0} times",
"Rogue.Objective.DontStopWalking": "Don't stop walking",
"Rogue.Objective.FixSabotage": "Fix a sabotage",
+36 -19
View File
@@ -66,7 +66,7 @@ namespace EHR.Neutral
}
public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = GotRewards.Contains(Reward.DecreasedKillCooldown) ? KillCooldown.GetFloat() / 2f : KillCooldown.GetFloat();
public override bool CanUseImpostorVentButton(PlayerControl pc) => CanVent.GetBool();
public override bool CanUseImpostorVentButton(PlayerControl pc) => CurrentTask.Objective == Objective.VentXTimes || CanVent.GetBool();
public override bool CanUseSabotage(PlayerControl pc) => GotRewards.Contains(Reward.Sabotage) || GotRewards.Contains(Reward.Morph);
public override void ApplyGameOptions(IGameOptions opt, byte id)
@@ -131,20 +131,24 @@ namespace EHR.Neutral
public override void OnFixedUpdate(PlayerControl pc)
{
if (!DoCheck || !pc.IsAlive() || !GameStates.IsInTask) return;
if (!pc.IsAlive() || !GameStates.IsInTask) return;
Count++;
if (Count < 30) return;
Count = 0;
if (LastPos is null)
if (DoCheck && Moving)
{
LastPos = pc.Pos();
return;
}
if (LastPos is null)
{
LastPos = pc.Pos();
return;
}
Moving = Vector2.Distance(pc.Pos(), LastPos.Value) >= 0.1f;
LastPos = pc.Pos();
Moving = Vector2.Distance(pc.Pos(), LastPos.Value) >= 0.1f;
LastPos = pc.Pos();
if (!Moving) pc.Notify(Utils.ColorString(Color.red, "<size=4>x</size>"));
}
if (MorphCooldown > 0)
{
@@ -163,8 +167,7 @@ namespace EHR.Neutral
{
if (CurrentTask.Objective == Objective.CallEmergencyMeeting)
{
SetTaskCompleted();
_ = new LateTask(() => { Utils.SendMessage("\n", RoguePC.PlayerId, Translator.GetString("Rogue.TaskCompleted")); }, 8f, log: false);
SetTaskCompleted(chatMessage: true);
}
}
@@ -176,11 +179,13 @@ namespace EHR.Neutral
}
}
void SetTaskCompleted()
void SetTaskCompleted(bool chatMessage = false)
{
CurrentTask.IsCompleted = true;
SendRPC();
Utils.NotifyRoles(SpecifySeer: RoguePC, SpecifyTarget: RoguePC);
if (chatMessage) _ = new LateTask(() => { Utils.SendMessage("\n", RoguePC.PlayerId, Translator.GetString("Rogue.TaskCompleted")); }, 8f, log: false);
else Utils.NotifyRoles(SpecifySeer: RoguePC, SpecifyTarget: RoguePC);
}
public override void OnReportDeadBody()
@@ -189,7 +194,7 @@ namespace EHR.Neutral
if (CurrentTask.Objective == Objective.DontStopWalking && Moving)
{
SetTaskCompleted();
SetTaskCompleted(chatMessage: true);
}
}
@@ -205,10 +210,20 @@ namespace EHR.Neutral
GotRewards.Add(CurrentTask.Reward);
}
if (CurrentTask.Reward == Reward.HelpfulAddon)
switch (CurrentTask.Reward)
{
var addon = Options.GroupedAddons[AddonTypes.Helpful].RandomElement();
RoguePC.RpcSetCustomRole(addon);
case Reward.HelpfulAddon:
var addon = Options.GroupedAddons[AddonTypes.Helpful].RandomElement();
RoguePC.RpcSetCustomRole(addon);
break;
case Reward.DecreasedKillCooldown:
RoguePC.ResetKillCooldown();
RoguePC.SyncSettings();
RoguePC.SetKillCooldown();
break;
case Reward.Sabotage when RoguePC.IsHost():
HudManager.Instance.SetHudActive(RoguePC, RoguePC.Data.Role, true);
break;
}
var objective = Enum.GetValues<Objective>().Except(GotObjectives).Shuffle()[0];
@@ -221,7 +236,6 @@ namespace EHR.Neutral
Objective.KillXTimes => IRandom.Instance.Next(2, 5),
_ => null
};
if (data is int n) RoguePC.SetAbilityUseLimit(n);
CurrentTask = (objective, reward, data, false);
SendRPC();
@@ -234,6 +248,9 @@ namespace EHR.Neutral
DoCheck = true;
}, 5f, log: false);
}
Utils.NotifyRoles(SpecifySeer: RoguePC, SpecifyTarget: RoguePC);
Logger.Info($" Objective: {Translator.GetString("Rogue.Objective." + objective)} - Reward: {Translator.GetString("Rogue.Reward." + reward)} - Data: {data}", "Rogue");
}
catch (Exception e)
{
@@ -284,7 +301,7 @@ namespace EHR.Neutral
public override string GetSuffix(PlayerControl seer, PlayerControl target, bool isHUD = false, bool isMeeting = false)
{
if (seer.PlayerId != RoguePC.PlayerId || seer.PlayerId != target.PlayerId || (target.IsModClient() && !isHUD)) return string.Empty;
if (seer.PlayerId != RoguePC.PlayerId || seer.PlayerId != target.PlayerId || (seer.IsModClient() && !isHUD) || MeetingStates.FirstMeeting) return string.Empty;
if (AllTasksCompleted) return Translator.GetString("Rogue.AllTasksCompleted");
if (CurrentTask.IsCompleted) return Translator.GetString("Rogue.TaskCompleted");
@@ -327,4 +344,4 @@ namespace EHR.Neutral
ImpostorVision
}
}
}
}