Delete unused role files

This commit is contained in:
Gurge44 committed 2023-09-27 19:16:33 +02:00
1 parent c019bd9242
commit 43388d654e
3 files changed
-225

No files matched your search

-127
View File
@@ -1,127 +0,0 @@
using Hazel;
using System.Collections.Generic;
using System.Linq;
using TOHE.Modules;
using UnityEngine;
namespace TOHE.Roles.Crewmate;
public static class Counterfeiter
{
private static readonly int Id = 8500;
private static List<byte> playerIdList = new();
private static Dictionary<byte, List<byte>> clientList = new();
private static List<byte> notActiveList = new();
public static Dictionary<byte, int> SeelLimit = new();
public static OptionItem CounterfeiterSkillCooldown;
public static OptionItem CounterfeiterSkillLimitTimes;
public static void SetupCustomOption()
{
Options.SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Counterfeiter);
CounterfeiterSkillCooldown = FloatOptionItem.Create(Id + 10, "CounterfeiterSkillCooldown", new(2.5f, 60f, 2.5f), 20f, TabGroup.CrewmateRoles, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Counterfeiter])
.SetValueFormat(OptionFormat.Seconds);
CounterfeiterSkillLimitTimes = IntegerOptionItem.Create(Id + 11, "CounterfeiterSkillLimitTimes", new(1, 10, 1), 2, TabGroup.CrewmateRoles, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Counterfeiter])
.SetValueFormat(OptionFormat.Times);
}
public static void Init()
{
playerIdList = new();
clientList = new();
notActiveList = new();
SeelLimit = new();
}
public static void Add(byte playerId)
{
playerIdList.Add(playerId);
SeelLimit.Add(playerId, CounterfeiterSkillLimitTimes.GetInt());
if (!AmongUsClient.Instance.AmHost) return;
if (!Main.ResetCamPlayerList.Contains(playerId))
Main.ResetCamPlayerList.Add(playerId);
}
public static bool IsEnable => playerIdList.Any();
private static void SendRPC(byte playerId)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCounterfeiterSellLimit, SendOption.Reliable, -1);
writer.Write(playerId);
writer.Write(SeelLimit[playerId]);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
public static void ReceiveRPC(MessageReader reader)
{
byte PlayerId = reader.ReadByte();
int Limit = reader.ReadInt32();
if (SeelLimit.ContainsKey(PlayerId))
SeelLimit[PlayerId] = Limit;
else
SeelLimit.Add(PlayerId, CounterfeiterSkillLimitTimes.GetInt());
}
public static bool CanUseKillButton(byte playerId)
=> !Main.PlayerStates[playerId].IsDead
&& SeelLimit.TryGetValue(playerId, out var x) && x >= 1;
public static string GetSeelLimit(byte playerId) => Utils.ColorString(CanUseKillButton(playerId) ? Utils.GetRoleColor(CustomRoles.Counterfeiter).ShadeColor(0.25f) : Color.gray, SeelLimit.TryGetValue(playerId, out var x) ? $"({x})" : "Invalid");
public static void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = CanUseKillButton(id) ? CounterfeiterSkillCooldown.GetFloat() : 0f;
public static bool IsClient(byte playerId)
{
foreach (var pc in clientList)
if (pc.Value.Contains(playerId)) return true;
return false;
}
public static bool IsClient(byte pc, byte tar) => clientList.TryGetValue(pc, out var x) && x.Contains(tar);
public static bool CanBeClient(PlayerControl pc) => pc != null && pc.IsAlive() && !GameStates.IsMeeting && !IsClient(pc.PlayerId);
public static bool CanSeel(byte playerId) => playerIdList.Contains(playerId) && SeelLimit.TryGetValue(playerId, out int x) && x > 0;
public static void SeelToClient(PlayerControl pc, PlayerControl target)
{
if (pc == null || target == null || !pc.Is(CustomRoles.Counterfeiter)) return;
SeelLimit[pc.PlayerId]--;
SendRPC(pc.PlayerId);
if (!clientList.ContainsKey(pc.PlayerId)) clientList.Add(pc.PlayerId, new());
clientList[pc.PlayerId].Add(target.PlayerId);
//pc.RpcGuardAndKill(pc);
notActiveList.Add(pc.PlayerId);
pc.SetKillCooldown();
pc.RPCPlayCustomSound("Bet");
Utils.NotifyRoles(SpecifySeer: pc);
Logger.Info($"赝品商 {pc.GetRealName()} 将赝品卖给了 {target.GetRealName()}", "Counterfeiter");
}
public static bool OnClientMurder(PlayerControl pc)
{
if (!IsClient(pc.PlayerId) || notActiveList.Contains(pc.PlayerId)) return false;
byte cfId = byte.MaxValue;
foreach (var cf in clientList)
if (cf.Value.Contains(pc.PlayerId)) cfId = cf.Key;
if (cfId == byte.MaxValue) return false;
var killer = Utils.GetPlayerById(cfId);
var target = pc;
if (killer == null) return false;
target.SetRealKiller(killer);
target.Data.IsDead = true;
Main.PlayerStates[target.PlayerId].deathReason = PlayerState.DeathReason.Misfire;
target.RpcMurderPlayerV3(target);
Main.PlayerStates[target.PlayerId].SetDead();
Logger.Info($"赝品商 {pc.GetRealName()} 的客户 {target.GetRealName()} 因使用赝品走火自杀", "Counterfeiter");
return true;
}
public static void OnReportDeadBody()
{
notActiveList.Clear();
foreach (var cl in clientList)
foreach (var pc in cl.Value)
{
var target = Utils.GetPlayerById(pc);
if (target == null || !target.IsAlive()) continue;
var role = target.GetCustomRole();
if (
(role.IsCrewmate() && !role.IsCK()) ||
(role.IsNeutral() && !role.IsNK())
)
{
var killer = Utils.GetPlayerById(cl.Key);
if (killer == null) continue;
CheckForEndVotingPatch.TryAddAfterMeetingDeathPlayers(PlayerState.DeathReason.Misfire, target.PlayerId);
target.SetRealKiller(Utils.GetPlayerById(pc));
Logger.Info($"赝品商 {killer.GetRealName()} 的客户 {target.GetRealName()} 因不带刀自杀", "Counterfeiter");
}
}
}
}
-51
View File
@@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static TOHE.Options;
namespace TOHE;
public static class Reverie
{
private static readonly int Id = 1153;
public static List<byte> playerIdList = new();
private static OptionItem DefaultKillCooldown;
private static OptionItem ReduceKillCooldown;
private static OptionItem MinKillCooldown;
private static Dictionary<byte, float> NowCooldown;
public static void SetupCustomOption()
{
SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Reverie);
DefaultKillCooldown = FloatOptionItem.Create(Id + 10, "SansDefaultKillCooldown", new(0f, 180f, 2.5f), 30f, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Reverie])
.SetValueFormat(OptionFormat.Seconds);
ReduceKillCooldown = FloatOptionItem.Create(Id + 11, "SansReduceKillCooldown", new(0f, 30f, 0.5f), 2f, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Reverie])
.SetValueFormat(OptionFormat.Seconds);
MinKillCooldown = FloatOptionItem.Create(Id + 12, "SansMinKillCooldown", new(0f, 30f, 2.5f), 10f, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Reverie])
.SetValueFormat(OptionFormat.Seconds);
}
public static void Init()
{
playerIdList = new();
NowCooldown = new();
}
public static void Add(byte playerId)
{
playerIdList.Add(playerId);
NowCooldown.TryAdd(playerId, DefaultKillCooldown.GetFloat());
if (!AmongUsClient.Instance.AmHost) return;
if (!Main.ResetCamPlayerList.Contains(playerId))
Main.ResetCamPlayerList.Add(playerId);
}
public static bool IsEnable => playerIdList.Any();
public static void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = NowCooldown[id];
public static void OnCheckMurder(PlayerControl killer)
{
NowCooldown[killer.PlayerId] = Math.Clamp(NowCooldown[killer.PlayerId] - ReduceKillCooldown.GetFloat(), MinKillCooldown.GetFloat(), DefaultKillCooldown.GetFloat());
killer.ResetKillCooldown();
killer.SyncSettings();
}
}
-47
View File
@@ -1,47 +0,0 @@
using AmongUs.GameOptions;
using System.Collections.Generic;
using System.Linq;
using static TOHE.Options;
namespace TOHE.Roles.Neutral;
public static class NWitch
{
private static readonly int Id = 10300;
public static List<byte> playerIdList = new();
private static OptionItem ControlCooldown;
public static OptionItem CanVent;
private static OptionItem HasImpostorVision;
public static void SetupCustomOption()
{
//NWitchは1人固定
SetupSingleRoleOptions(Id, TabGroup.NeutralRoles, CustomRoles.NWitch, 1, zeroOne: false);
ControlCooldown = FloatOptionItem.Create(Id + 10, "ControlCooldown", new(0f, 180f, 1f), 30f, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.NWitch])
.SetValueFormat(OptionFormat.Seconds);
CanVent = BooleanOptionItem.Create(Id + 11, "CanVent", false, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.NWitch]);
HasImpostorVision = BooleanOptionItem.Create(Id + 13, "ImpostorVision", true, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.NWitch]);
}
public static void Init()
{
playerIdList = new();
}
public static void Add(byte playerId)
{
playerIdList.Add(playerId);
if (!AmongUsClient.Instance.AmHost) return;
if (!Main.ResetCamPlayerList.Contains(playerId))
Main.ResetCamPlayerList.Add(playerId);
}
public static bool IsEnable => playerIdList.Any();
public static void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = ControlCooldown.GetFloat();
public static void ApplyGameOptions(IGameOptions opt) => opt.SetVision(HasImpostorVision.GetBool());
public static void CanUseVent(PlayerControl player)
{
bool NWitch_canUse = CanVent.GetBool();
DestroyableSingleton<HudManager>.Instance.ImpostorVentButton.ToggleVisible(NWitch_canUse && !player.Data.IsDead);
player.Data.Role.CanVent = NWitch_canUse;
}
}