mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
110 lines
4.1 KiB
C#
110 lines
4.1 KiB
C#
using System.Collections.Generic;
|
|
using AmongUs.GameOptions;
|
|
using EHR.Modules.Extensions;
|
|
using static EHR.Options;
|
|
|
|
namespace EHR.Roles;
|
|
|
|
internal class SecurityGuard : RoleBase
|
|
{
|
|
public static HashSet<byte> BlockSabo = [];
|
|
|
|
public static bool On;
|
|
public override bool IsEnable => On;
|
|
|
|
public override void SetupCustomOption()
|
|
{
|
|
SetupRoleOptions(6860, TabGroup.CrewmateRoles, CustomRoles.SecurityGuard);
|
|
|
|
SecurityGuardSkillCooldown = new FloatOptionItem(6862, "SecurityGuardSkillCooldown", new(0f, 180f, 1f), 15f, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard])
|
|
.SetValueFormat(OptionFormat.Seconds);
|
|
|
|
SecurityGuardSkillDuration = new FloatOptionItem(6863, "SecurityGuardSkillDuration", new(0f, 180f, 1f), 10f, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard])
|
|
.SetValueFormat(OptionFormat.Seconds);
|
|
|
|
SecurityGuardSkillMaxOfUsage = new IntegerOptionItem(6866, "AbilityUseLimit", new(0, 30, 1), 1, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard])
|
|
.SetValueFormat(OptionFormat.Times);
|
|
|
|
SecurityGuardAbilityUseGainWithEachTaskCompleted = new FloatOptionItem(6867, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.05f), 0.4f, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard])
|
|
.SetValueFormat(OptionFormat.Times);
|
|
|
|
SecurityGuardAbilityChargesWhenFinishedTasks = new FloatOptionItem(6868, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.05f), 0.2f, TabGroup.CrewmateRoles)
|
|
.SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard])
|
|
.SetValueFormat(OptionFormat.Times);
|
|
}
|
|
|
|
public override void Add(byte playerId)
|
|
{
|
|
On = true;
|
|
playerId.SetAbilityUseLimit(SecurityGuardSkillMaxOfUsage.GetFloat());
|
|
}
|
|
|
|
public override void Init()
|
|
{
|
|
On = false;
|
|
}
|
|
|
|
public override void ApplyGameOptions(IGameOptions opt, byte playerId)
|
|
{
|
|
if (UsePets.GetBool()) return;
|
|
|
|
AURoleOptions.EngineerInVentMaxTime = 1f;
|
|
AURoleOptions.EngineerCooldown = SecurityGuardSkillCooldown.GetFloat();
|
|
}
|
|
|
|
public override void GetProgressText(byte playerId, bool comms, StringBuilder resultText)
|
|
{
|
|
resultText.Append(Utils.GetAbilityUseLimitDisplay(playerId, BlockSabo.Contains(playerId)))
|
|
.Append(Utils.GetTaskCount(playerId, comms));
|
|
}
|
|
|
|
// Revert this if needed, recommended to actually add a text called "SaboBlock" or something
|
|
//public override void SetButtonTexts(HudManager hud, byte id)
|
|
//{
|
|
// if (UsePets.GetBool())
|
|
// hud.PetButton.buttonLabelText.text = Translator.GetString("SecurityGuardVentButtonText");
|
|
// else
|
|
// hud.AbilityButton.buttonLabelText.text = Translator.GetString("SecurityGuardVentButtonText");
|
|
//}
|
|
|
|
public override void OnPet(PlayerControl pc)
|
|
{
|
|
Guard(pc);
|
|
}
|
|
|
|
public override void OnEnterVent(PlayerControl pc, Vent vent)
|
|
{
|
|
if (UsePets.GetBool()) return;
|
|
Guard(pc);
|
|
}
|
|
|
|
private static void Guard(PlayerControl pc)
|
|
{
|
|
if (BlockSabo.Contains(pc.PlayerId)) return;
|
|
|
|
if (pc.GetAbilityUseLimit() >= 1)
|
|
{
|
|
BlockSabo.Add(pc.PlayerId);
|
|
_ = new CountdownTimer(SecurityGuardSkillDuration.GetInt(), () =>
|
|
{
|
|
BlockSabo.Remove(pc.PlayerId);
|
|
pc.RpcResetAbilityCooldown();
|
|
pc.Notify(Translator.GetString("SecurityGuardSkillStop"));
|
|
}, onCanceled: () => BlockSabo.Remove(pc.PlayerId));
|
|
pc.RpcRemoveAbilityUse(notify: false);
|
|
pc.Notify(Translator.GetString("SecurityGuardSkillInUse"), SecurityGuardSkillDuration.GetFloat());
|
|
}
|
|
else
|
|
pc.Notify(Translator.GetString("OutOfAbilityUsesDoMoreTasks"));
|
|
}
|
|
|
|
public override bool CanUseVent(PlayerControl pc, int ventId)
|
|
{
|
|
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
|
|
}
|
|
}
|