mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using EHR.Modules;
|
|
using Exception = System.Exception;
|
|
|
|
namespace EHR.Roles;
|
|
|
|
public class TaskMaster : IAddon
|
|
{
|
|
public AddonTypes Type => AddonTypes.Helpful;
|
|
|
|
public void SetupCustomOption()
|
|
{
|
|
Options.SetupAdtRoleOptions(655500, CustomRoles.TaskMaster, canSetNum: true);
|
|
}
|
|
|
|
public static void AfterMeetingTasks(PlayerControl pc)
|
|
{
|
|
try
|
|
{
|
|
TaskState ts = pc.GetTaskState();
|
|
if (!ts.HasTasks || ts.IsTaskFinished || !Utils.HasTasks(pc.Data, forRecompute: false)) return;
|
|
#if IL2CPP
|
|
var incompleteTasks = pc.myTasks.FindAll((Il2CppSystem.Predicate<PlayerTask>)(x => !x.IsComplete));
|
|
#else
|
|
var incompleteTasks = pc.myTasks.FindAll(x => !x.IsComplete);
|
|
#endif
|
|
LateTask.New(() =>
|
|
{
|
|
if (GameStates.IsEnded) return;
|
|
RPC.PlaySoundRPC(pc.PlayerId, Sounds.TaskUpdateSound);
|
|
pc.RpcCompleteTask(incompleteTasks[IRandom.Instance.Next(0, incompleteTasks.Count)].Id);
|
|
}, 0.3f, log: false);
|
|
}
|
|
catch (Exception e) { Utils.ThrowException(e); }
|
|
}
|
|
} |