private void Application_OnPlayfieldLoaded(IPlayfield playfield) { PlayfieldScriptData data = null; InitGameDependedData(ModApi.Application.Mode == ApplicationMode.SinglePlayer); PlayfieldData.TryAdd(playfield.Name, data = new PlayfieldScriptData(this) { PlayfieldName = playfield.Name, Playfield = playfield, }); UpdateScriptingModInfoData(); ModApi.Log($"StartScripts for {playfield.Name} pending"); TaskTools.Delay(Configuration.Current.DelayStartForNSecondsOnPlayfieldLoad, () => { ModApi.Log($"StartScripts for {playfield.Name}"); data.PauseScripts = false; if (ModApi.Application.Mode == ApplicationMode.SinglePlayer) { ModApi.Log(playfield.Entities?.Aggregate($"Player:{playfield.Players.FirstOrDefault().Value?.Name} PlayerDriving:{playfield.Players.FirstOrDefault().Value?.DrivingEntity?.Name}", (L, E) => L + $" {E.Key}:{E.Value.Name}")); data.AddEntity(playfield.Players.FirstOrDefault().Value?.DrivingEntity); playfield.Entities?.ForEach(E => data.AddEntity(E.Value)); } }); data.Playfield.OnEntityLoaded += data.Playfield_OnEntityLoaded; data.Playfield.OnEntityUnloaded += data.Playfield_OnEntityUnloaded; }
private void Application_OnPlayfieldLoaded(string playfieldName) { ModApi.Log($"StartScripts for {playfieldName} pending"); TaskTools.Delay(Configuration.Current.DelayStartForNSecondsOnPlayfieldLoad, () => { ModApi.Log($"StartScripts for {playfieldName}"); PauseScripts = false; }); }
private void GameplayManager_Event_Player_Connected(Id player) { if (OfflineWarpPlayer.Current.TryRemove(player.id, out var warpData)) { OfflineWarpPlayer.Save(); TaskTools.Delay(Program.AppSettings.PlayerOfflineWarpDelay, () => WarpTo(player.id, warpData.WarpToData)); } }
private void SendWelcomeMessage(Player aPlayer) { if (string.IsNullOrEmpty(SysteminfoManager.Value.SystemConfig.Current.WelcomeMessage)) { return; } TaskTools.Delay(60, () => ChatManager.Value.ChatMessageADM(string.Format(SysteminfoManager.Value.SystemConfig.Current.WelcomeMessage, aPlayer.PlayerName))); }
public SectorsManager() { PlayfieldsWatcher = new FileSystemWatcher(Path.Combine(EmpyrionConfiguration.SaveGamePath, "Sectors"), "Sectors.yaml"); PlayfieldsWatcher.Created += (S, A) => TaskTools.Delay(10, ReadSectors); PlayfieldsWatcher.Deleted += (S, A) => TaskTools.Delay(10, ReadSectors); PlayfieldsWatcher.Changed += (S, A) => TaskTools.Delay(10, ReadSectors); PlayfieldsWatcher.EnableRaisingEvents = true; TaskTools.Delay(1, ReadSectors); }
public GlobalStructureList GlobalStructureList() { try { LastGlobalStructureList.Current = Request_GlobalStructure_List().Result; TaskTools.Delay(0, () => LastGlobalStructureList.Save()); } catch { } return(LastGlobalStructureList.Current); }
public AdminconfigYamlStruct(string aFilename) { if (!File.Exists(aFilename)) { return; } Load(aFilename); mAdminconfigYamlFileWatcher = new FileSystemWatcher { Path = Path.GetDirectoryName(aFilename), NotifyFilter = NotifyFilters.LastWrite, Filter = Path.GetFileName(aFilename) }; mAdminconfigYamlFileWatcher.Changed += (s, e) => TaskTools.Delay(10, () => Load(aFilename)); mAdminconfigYamlFileWatcher.EnableRaisingEvents = true; }
private void SyncronizePlayersWithSaveGameDirectory() { TaskTools.Delay(1, () => { var KnownPlayers = Directory .GetFiles(PlayersDirectory) .Select(F => Path.GetFileNameWithoutExtension(F)); using (var DB = new PlayerContext()) { DB.Players .Where(P => !KnownPlayers.Contains(P.SteamId)) .ForEach(P => DB.Players.Remove(P)); DB.SaveChangesAsync(); } }); }
public override void Initialize(ModGameAPI dediAPI) { DediAPI = dediAPI; try { Log($"**EmpyrionPoiRestore loaded: {string.Join(" ", Environment.GetCommandLineArgs())}", LogLevel.Message); LoadConfiguration(); LogLevel = Configuration.Current.LogLevel; ChatCommandManager.CommandPrefix = Configuration.Current.ChatCommandPrefix; ChatCommands.Add(new ChatCommand(@"poipos help", (I, A) => DisplayHelp(I.playerId, null), "display help")); ChatCommands.Add(new ChatCommand(@"poipos add (?<Name>.+)", (I, A) => StorePoiPosAndRot(I.playerId, A), "store POI pos and rot", PermissionType.Admin)); TaskTools.Intervall(Configuration.Current.CheckPoiPositionsEveryNSeconds * 1000, async() => await CheckPlayfields()); Event_Playfield_Loaded += P => TaskTools.Delay(Configuration.Current.CheckPoiPositionsNSecondsAfterPlayfieldLoaded, async() => await CheckPlayfields()); } catch (Exception Error) { Log($"**EmpyrionPoiRestore Error: {Error} {string.Join(" ", Environment.GetCommandLineArgs())}", LogLevel.Error); } }