Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 2.31 KB

README.md

File metadata and controls

60 lines (46 loc) · 2.31 KB

LLM-Visitors

[UniTask] [Extension] Shortcut for 1-to-100 tickrate halls-visitors system (e.g subscriber-notifier system)

Ok but how to actually use it?

Required UniTask itself, so first-thing-first install a .unitypackage from this link. Can be used for default .NET classes if you install UniTask as NuGet package. Also feel free to change whatever you want or collab.

Simple example of our Discord Overlay Service being one of many IVisitor instances that is inside MonoHall ticking with custom tickrate:

using Cysharp.Threading.Tasks;
using LLM.Visitors.Base;
using LLM.Services.DiscordWrapper;

namespace LLM.Visitors
{
    public class DiscordVisitor : IVisitor
    {
        private DiscordService service;

        public DiscordVisitor(DiscordService service)
        {
            service.Initialize();
            service.LookupForDiscordClient();
        }

        public UniTask OnVisitorEnter() => service.EnableOverlay();
        public UniTask OnVisitorLeave() => service.DisposeOverlay();

        public void OnTick() => service.PerformOverlayTicks();
    }
}

Our Service Collection has initialized MonoHall instance:

Tip

You can create new IHall inheritance that is NOT a MonoBehaviour (like public class ClockService : IHall) and you can start it once somewhere ticking with tickrate you want, its all up to you we just showing u a simplest way

[SerializeField] private MonoHall hall;
...

private void InitializeHall(ServiceCollection services)
{
    hall.Enter(new DiscordVisitor(services.Get<DiscordService>()));
    hall.Enter(new FireabseVisitor(services.Get<Database>()));
    hall.Enter(new DevConsoleVisitor());
    hall.Enter(new LogTesterVisitor());

    DontDestroyOnLoad(hall);
}

Tip

Here is how we set it up, making ServiceCollection new additional Scene which holds our services and IHall component, so we can swap scenes and do whatever we want when those two will sit there and provide us a support when we need it. Can be done better by making it just plain C# classes ofc, yet its just an example.

MonoHall Setup Picture

MonoHall Setup Picture