mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
* Well lets try check this * Some changes * Change * Well * Change ControllerManager.Update * Nothing * Optimaze more? * Fix error build * Fix win check * Change * Fix * Optimaze some roles in OnCheckPlayerPosition * More optimaze * Full optimaze roles in OnGlobalFixedUpdate * Optimaze some add-ons * ProgressText * Change * Optimaze NameNotifyManager * Optimaze NotifyRoles and some roles * Move the displayed version * Some changes * Optimaze OnFixedUpdate in some roles * Fix bugs * Optimaze IsActive & V4 version * Optimaze MapRoom.DoorsUpdate * Cache TryCatch in IsActive * Change * Fix * More optimze TaskPanelBehaviour * Cache GetRoleColor & ColorString & AllStringNames & Change RemoveHtmlTags * Cache TryCast VentilationSystem & ICriticalSabotage & IUsable and more optimaze * Fix CountAlivePlayers * Fix exceptios * Replace some CachedAllPlayerControls to EnumeratePlayerControls * Replace some CachedAlivePlayerControls to EnumerateAlivePlayerControls * Fixes * Fix modded clients * Fix errors * Fix again * Optimaze & add null check * Fix crash in Starlight * Use only Main.PluginVersion in LobbySharingAPI * Optimaze code in FixedUpdate * Fix * Optimize GetProgressText for Roles * Some changes in Translations * Cache Enum.GetValues and StringBuilder * Changes * CustomRole.ColoredTextByRole() * Optimaze Lobby & Meeting * ColorStringPrefix => ColorPrefix * Add null check * Remove * Fixes & optimaze * Fixes * Changes * Fix * Fix * Fix * Remove * Fix * Change * Revert
128 lines
4.0 KiB
C#
128 lines
4.0 KiB
C#
using System.Collections.Generic;
|
|
using AmongUs.GameOptions;
|
|
using EHR.Modules;
|
|
using Hazel;
|
|
using static EHR.Options;
|
|
using static EHR.Translator;
|
|
|
|
namespace EHR.Roles;
|
|
|
|
public class Jailor : RoleBase
|
|
{
|
|
private const int Id = 63420;
|
|
public static List<byte> PlayerIdList = [];
|
|
|
|
private static OptionItem JailCooldown;
|
|
private static OptionItem NotifyJailedOnMeeting;
|
|
public static OptionItem UsePet;
|
|
|
|
private byte JailorId;
|
|
public byte JailorTarget;
|
|
|
|
public override bool IsEnable => PlayerIdList.Count > 0;
|
|
|
|
public override void SetupCustomOption()
|
|
{
|
|
SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Jailor);
|
|
|
|
JailCooldown = new FloatOptionItem(Id + 10, "JailorJailCooldown", new(0f, 60f, 1f), 15f, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.Jailor])
|
|
.SetValueFormat(OptionFormat.Seconds);
|
|
|
|
NotifyJailedOnMeeting = new BooleanOptionItem(Id + 18, "notifyJailedOnMeeting", true, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.Jailor]);
|
|
|
|
UsePet = CreatePetUseSetting(Id + 11, CustomRoles.Jailor);
|
|
}
|
|
|
|
public override void Init()
|
|
{
|
|
PlayerIdList = [];
|
|
JailorTarget = byte.MaxValue;
|
|
}
|
|
|
|
public override void Add(byte playerId)
|
|
{
|
|
PlayerIdList.Add(playerId);
|
|
JailorTarget = byte.MaxValue;
|
|
JailorId = playerId;
|
|
}
|
|
|
|
public override void Remove(byte playerId)
|
|
{
|
|
PlayerIdList.Remove(playerId);
|
|
}
|
|
|
|
public override void ApplyGameOptions(IGameOptions opt, byte playerId)
|
|
{
|
|
opt.SetVision(false);
|
|
}
|
|
|
|
public override void SetKillCooldown(byte id)
|
|
{
|
|
Main.AllPlayerKillCooldown[id] = Utils.GetPlayerById(id).IsAlive() ? JailCooldown.GetFloat() : 0f;
|
|
}
|
|
|
|
public override bool CanUseKillButton(PlayerControl pc)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
private static void SendRPC(byte jailerId, byte targetId)
|
|
{
|
|
if (!Utils.DoRPC) return;
|
|
|
|
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorTarget, SendOption.Reliable);
|
|
writer.Write(jailerId);
|
|
writer.Write(targetId);
|
|
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
|
}
|
|
|
|
public static void ReceiveRPC(MessageReader reader)
|
|
{
|
|
byte jailerId = reader.ReadByte();
|
|
if (Main.PlayerStates[jailerId].Role is not Jailor jl) return;
|
|
|
|
byte targetId = reader.ReadByte();
|
|
jl.JailorTarget = targetId;
|
|
}
|
|
|
|
public override bool OnCheckMurder(PlayerControl killer, PlayerControl target)
|
|
{
|
|
if (JailorTarget != byte.MaxValue)
|
|
{
|
|
killer.Notify(GetString("JailorTargetAlreadySelected"));
|
|
return false;
|
|
}
|
|
|
|
JailorTarget = target.PlayerId;
|
|
killer.Notify(GetString("SuccessfullyJailed"));
|
|
killer.ResetKillCooldown();
|
|
killer.SetKillCooldown();
|
|
SendRPC(killer.PlayerId, target.PlayerId);
|
|
Utils.NotifyRoles(SpecifySeer: killer, SpecifyTarget: target);
|
|
return false;
|
|
}
|
|
|
|
public override void OnReportDeadBody()
|
|
{
|
|
if (!NotifyJailedOnMeeting.GetBool()) return;
|
|
if (JailorTarget == byte.MaxValue) return;
|
|
|
|
PlayerControl tpc = Utils.GetPlayerById(JailorTarget);
|
|
if (!tpc) return;
|
|
|
|
if (tpc.IsAlive()) LateTask.New(() => Utils.SendMessage(GetString("JailedNotifyMsg"), JailorTarget, CustomRoles.Jailor.ColoredTextByRole(GetString("JailorTitle")), importance: MessageImportance.High), 0.3f, "JailorNotifyJailed");
|
|
}
|
|
|
|
public override void AfterMeetingTasks()
|
|
{
|
|
JailorTarget = byte.MaxValue;
|
|
}
|
|
|
|
public override string GetSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false)
|
|
{
|
|
if (hud || seer.PlayerId != JailorId || target.PlayerId != JailorTarget) return string.Empty;
|
|
return CustomRoles.Jailor.ColoredTextByRole(GetString("JailedSuffix"));
|
|
}
|
|
} |