using System.Collections; using System.Collections.Generic; using UnityEngine; using KairoEngine.Core; namespace KairoEngine.CharacterSystem { public static class RequestEventExtensions { public static Dictionary> list = new Dictionary>(); public static void Bind(this RequestEvents e, string title, System.Func listener) { System.Func action = null; if (list.TryGetValue(title, out action) == false) { action += listener; list.Add(title, action); } } public static void Unbind(this RequestEvents e, string title, System.Func listener) { System.Func action = null; if (list.TryGetValue(title, out action)) { action -= listener; list.Remove(title); } } public static EventResponse GetCharacterController(this RequestEvents e, string title) { System.Func action = null; EventResponse response = new EventResponse(); if (list.TryGetValue(title, out action)) { if(action != null) { CharacterController result = action(); response.value = result; if(response.value == null) response.status = EventResponseStatus.EmptyResponse; else response.status = EventResponseStatus.OK; } } else response.status = EventResponseStatus.NotFound; return response; } } }