using System; using System.Collections.Generic; using PhoenixLib.Events; using WingsAPI.Scripting.Converter; using WingsAPI.Scripting.Event; using WingsAPI.Scripting.Event.TimeSpace; using WingsEmu.Game.TimeSpaces; using WingsEmu.Game.TimeSpaces.Events; namespace Plugin.TimeSpaces.Scripting; public class SCheckForTasksCompletedEventConverter : ScriptedEventConverter { private readonly Dictionary _events; private readonly Dictionary _maps; public SCheckForTasksCompletedEventConverter(Dictionary maps, Dictionary events) { _maps = maps; _events = events; } protected override IAsyncEvent Convert(SCheckForTasksCompletedEvent e) { List list = new(); List timeSpaceSubInstances = new(); IEnumerable maps = e.Maps; foreach (SEvent scriptedEvent in e.Events) { IAsyncEvent asyncEvent = _events.GetValueOrDefault(scriptedEvent.GetType())?.Convert(scriptedEvent); if (asyncEvent == null) { continue; } list.Add(asyncEvent); } foreach (Guid map in maps) { timeSpaceSubInstances.Add(_maps[map]); } return new TimeSpaceCheckForTasksCompletedEvent { Events = list, TimeSpaceSubInstances = timeSpaceSubInstances }; } }