mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Linq;
|
|
using EHR.Modules;
|
|
|
|
namespace EHR.Roles;
|
|
|
|
public class Helper : RoleBase
|
|
{
|
|
public static bool On;
|
|
|
|
public override bool IsEnable => On;
|
|
|
|
public override void SetupCustomOption()
|
|
{
|
|
StartSetup(651300)
|
|
.CreateOverrideTasksData();
|
|
}
|
|
|
|
public override void Init()
|
|
{
|
|
On = false;
|
|
}
|
|
|
|
public override void Add(byte playerId)
|
|
{
|
|
On = true;
|
|
}
|
|
|
|
public override void OnTaskComplete(PlayerControl pc, int completedTaskCount, int totalTaskCount)
|
|
{
|
|
var randomPlayer = Main.EnumeratePlayerControls().Without(pc).Where(x => x.Is(Team.Crewmate)).Select(x => (pc: x, ts: x.GetTaskState())).Where(x => !x.ts.IsTaskFinished && x.ts.HasTasks).Select(x => x.pc).RandomElement();
|
|
#if IL2CPP
|
|
var incompleteTasks = randomPlayer.myTasks.FindAll((Il2CppSystem.Predicate<PlayerTask>)(x => !x.IsComplete));
|
|
#else
|
|
var incompleteTasks = randomPlayer.myTasks.FindAll(x => !x.IsComplete);
|
|
#endif
|
|
RPC.PlaySoundRPC(randomPlayer.PlayerId, Sounds.TaskUpdateSound);
|
|
randomPlayer.RpcCompleteTask(incompleteTasks[IRandom.Instance.Next(0, incompleteTasks.Count)].Id);
|
|
randomPlayer.Notify(string.Format(Translator.GetString("HelperCompletedTaskForYou"), CustomRoles.Helper.ToColoredString()));
|
|
}
|
|
}
|