private void DeleteTeleporterRoutes(int aPlayerId, int aSourceId, int aTargetId) { Request_Player_Info(aPlayerId.ToId(), (P) => { var deletedCount = TeleporterDB.Delete(aSourceId, aTargetId); SaveTeleporterDB(); AlertPlayer(P.entityId, $"Delete {deletedCount} teleporter from {aSourceId}"); }); }
private void CleanUpTeleporterRoutes(int aPlayerId) { Request_GlobalStructure_List(G => { var GlobalFlatIdList = G.globalStructures.Aggregate(new List <int>(), (L, P) => { L.AddRange(P.Value.Select(S => S.id)); return(L); }); var TeleporterFlatIdList = TeleporterDB.TeleporterRoutes.Aggregate(new List <int>(), (L, P) => { L.Add(P.A.Id); L.Add(P.B.Id); return(L); }); var DeleteList = TeleporterFlatIdList.Where(I => !GlobalFlatIdList.Contains(I)).Distinct(); var DelCount = DeleteList.Aggregate(0, (C, I) => C + TeleporterDB.Delete(I, 0)); log($"CleanUpTeleporterRoutes: {DelCount} Structures: {DeleteList.Aggregate("", (S, I) => S + "," + I)}", LogLevel.Message); InformPlayer(aPlayerId, $"CleanUp: {DelCount} TeleporterRoutes"); if (DelCount > 0) { SaveTeleporterDB(); } }); }