private SubspaceDisplayEntry[] GetSubspaceDisplayEntriesMCWNone() { int currentSubspace = timeSyncer.currentSubspace; List <string> allPlayers = new List <string>(); allPlayers.Add(dmpSettings.playerName); allPlayers.AddRange(clientSubspaceList.Keys); allPlayers.Sort(PlayerSorter); SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.players = allPlayers.ToArray(); sde.isUs = true; if (currentSubspace != -1) { sde.subspaceID = timeSyncer.currentSubspace; sde.subspaceEntry = timeSyncer.GetSubspace(currentSubspace); } else { sde.isWarping = true; if (clientWarpList.ContainsKey(dmpSettings.playerName)) { sde.warpingEntry = clientWarpList[dmpSettings.playerName]; } } return(new SubspaceDisplayEntry[] { sde }); }
private Tuple <SubspaceDisplayEntry[], int> GetSubspaceDisplayEntriesMCWNone() { if (cacheGetSubspaceDisplayEntriesMCWNone == null) { cacheGetSubspaceDisplayEntriesMCWNone = new Tuple <SubspaceDisplayEntry[], int>(new SubspaceDisplayEntry[] { new SubspaceDisplayEntry() }, 1); } int currentSubspace = timeSyncer.currentSubspace; List <string> allPlayers = new List <string>(); allPlayers.Add(dmpSettings.playerName); allPlayers.AddRange(clientSubspaceList.Keys); allPlayers.Sort(PlayerSorter); SubspaceDisplayEntry sde = cacheGetSubspaceDisplayEntriesMCWNone.Item1[0]; sde.players = allPlayers.ToArray(); sde.isUs = true; if (currentSubspace != -1) { sde.subspaceID = timeSyncer.currentSubspace; sde.subspaceEntry = timeSyncer.GetSubspace(currentSubspace); } else { sde.isWarping = true; if (clientWarpList.ContainsKey(dmpSettings.playerName)) { sde.warpingEntry = clientWarpList[dmpSettings.playerName]; } } return(cacheGetSubspaceDisplayEntriesMCWNone); }
private int SubpaceDisplayEntrySorter(SubspaceDisplayEntry lhs, SubspaceDisplayEntry rhs) { if (lhs == null && rhs != null) { return(1); } if (lhs != null && rhs == null) { return(-1); } if (lhs == null && rhs == null) { return(0); } long serverClock = timeSyncer.GetServerClock(); double subspace1Time = double.MinValue; double subspace2Time = double.MinValue; //LHS time if (lhs.isWarping) { if (lhs.warpingEntry != null) { float[] warpRates = TimeWarp.fetch.warpRates; if (lhs.warpingEntry.isPhysWarp) { warpRates = TimeWarp.fetch.physicsWarpRates; } long serverClockDiff = serverClock - lhs.warpingEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace1Time = lhs.warpingEntry.planetTime + (warpRates[lhs.warpingEntry.rateIndex] * secondsDiff); } } else { if (lhs.subspaceEntry != null) { long serverClockDiff = serverClock - lhs.subspaceEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace1Time = lhs.subspaceEntry.planetTime + (lhs.subspaceEntry.subspaceSpeed * secondsDiff); } } //RHS time if (rhs.isWarping) { if (rhs.warpingEntry != null) { float[] warpRates = TimeWarp.fetch.warpRates; if (rhs.warpingEntry.isPhysWarp) { warpRates = TimeWarp.fetch.physicsWarpRates; } long serverClockDiff = serverClock - rhs.warpingEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace2Time = rhs.warpingEntry.planetTime + (warpRates[rhs.warpingEntry.rateIndex] * secondsDiff); } } else { if (rhs.subspaceEntry != null) { long serverClockDiff = serverClock - rhs.subspaceEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace2Time = rhs.subspaceEntry.planetTime + (rhs.subspaceEntry.subspaceSpeed * secondsDiff); } } if (subspace1Time > subspace2Time) { return(-1); } if (subspace1Time == subspace2Time) { return(0); } return(1); }
private Tuple <SubspaceDisplayEntry[], int> GetSubspaceDisplayEntriesSubspace() { int usedCacheEntries = 0; if (cacheGetSubspaceDisplayEntriesSubspace == null) { cacheGetSubspaceDisplayEntriesSubspace = new SubspaceDisplayEntry[20]; } if (cacheGetSubspaceDisplayEntriesSubspaceDict == null) { cacheGetSubspaceDisplayEntriesSubspaceDict = new Dictionary <int, SubspaceDisplayEntry>(); } if (cacheUnknownGetSubspaceDisplayEntriesSubspaceDict == null) { cacheUnknownGetSubspaceDisplayEntriesSubspaceDict = new Dictionary <string, SubspaceDisplayEntry>(); } //Subspace/subspace simple mode Dictionary <int, List <string> > nonWarpCache = new Dictionary <int, List <string> >(); List <string> warpCache = new List <string>(); //Add us if (timeSyncer.currentSubspace != -1) { List <string> newList = new List <string>(); newList.Add(dmpSettings.playerName); nonWarpCache.Add(timeSyncer.currentSubspace, newList); } else { warpCache.Add(dmpSettings.playerName); } //Add other players foreach (KeyValuePair <string, int> clientEntry in clientSubspaceList) { if (clientEntry.Value != -1) { if (!nonWarpCache.ContainsKey(clientEntry.Value)) { nonWarpCache.Add(clientEntry.Value, new List <string>()); } if (!nonWarpCache[clientEntry.Value].Contains(clientEntry.Key)) { nonWarpCache[clientEntry.Value].Add(clientEntry.Key); } } else { if (!warpCache.Contains(clientEntry.Key)) { warpCache.Add(clientEntry.Key); } } } //Players missing subspace or warp entries List <string> unknownPlayers = new List <string>(); //Process locked players foreach (KeyValuePair <int, List <string> > subspaceEntry in nonWarpCache) { if (timeSyncer.SubspaceExists(subspaceEntry.Key)) { SubspaceDisplayEntry sde; if (!cacheGetSubspaceDisplayEntriesSubspaceDict.ContainsKey(subspaceEntry.Key)) { cacheGetSubspaceDisplayEntriesSubspaceDict.Add(subspaceEntry.Key, new SubspaceDisplayEntry()); } sde = cacheGetSubspaceDisplayEntriesSubspaceDict[subspaceEntry.Key]; sde.subspaceID = subspaceEntry.Key; sde.subspaceEntry = timeSyncer.GetSubspace(subspaceEntry.Key); subspaceEntry.Value.Sort(PlayerSorter); sde.isUs = subspaceEntry.Value.Contains(dmpSettings.playerName); sde.players = subspaceEntry.Value.ToArray(); if (usedCacheEntries < cacheGetSubspaceDisplayEntriesSubspace.Length) { cacheGetSubspaceDisplayEntriesSubspace[usedCacheEntries] = sde; usedCacheEntries++; } } else { foreach (string unknownPlayer in subspaceEntry.Value) { unknownPlayers.Add(unknownPlayer); } } } //Process warping players foreach (string warpingPlayer in warpCache) { if (clientWarpList.ContainsKey(warpingPlayer)) { if (!cacheUnknownGetSubspaceDisplayEntriesSubspaceDict.ContainsKey(warpingPlayer)) { cacheUnknownGetSubspaceDisplayEntriesSubspaceDict.Add(warpingPlayer, new SubspaceDisplayEntry()); } SubspaceDisplayEntry sde = cacheUnknownGetSubspaceDisplayEntriesSubspaceDict[warpingPlayer]; sde.warpingEntry = clientWarpList[warpingPlayer]; sde.players = new string[] { warpingPlayer }; sde.isUs = (warpingPlayer == dmpSettings.playerName); sde.isWarping = true; sde.isUnknown = false; sde.subspaceID = 0; if (usedCacheEntries < cacheGetSubspaceDisplayEntriesSubspace.Length) { cacheGetSubspaceDisplayEntriesSubspace[usedCacheEntries] = sde; usedCacheEntries++; } } else { unknownPlayers.Add(warpingPlayer); } } for (int i = usedCacheEntries; i < cacheGetSubspaceDisplayEntriesSubspace.Length; i++) { cacheGetSubspaceDisplayEntriesSubspace[i] = null; } Array.Sort(cacheGetSubspaceDisplayEntriesSubspace, SubpaceDisplayEntrySorter); if (unknownPlayers.Count > 0) { foreach (string playerName in unknownPlayers) { if (!cacheUnknownGetSubspaceDisplayEntriesSubspaceDict.ContainsKey(playerName)) { cacheUnknownGetSubspaceDisplayEntriesSubspaceDict[playerName] = new SubspaceDisplayEntry(); } SubspaceDisplayEntry sde = cacheUnknownGetSubspaceDisplayEntriesSubspaceDict[playerName]; sde.players = unknownPlayers.ToArray(); sde.isUs = unknownPlayers.Contains(dmpSettings.playerName); sde.isUnknown = true; sde.isWarping = false; sde.subspaceID = 0; if (usedCacheEntries < cacheGetSubspaceDisplayEntriesSubspace.Length) { cacheGetSubspaceDisplayEntriesSubspace[usedCacheEntries] = sde; usedCacheEntries++; } } } return(new Tuple <SubspaceDisplayEntry[], int>(cacheGetSubspaceDisplayEntriesSubspace, usedCacheEntries)); }
private SubspaceDisplayEntry[] GetSubspaceDisplayEntriesSubspace() { //Subspace/subspace simple mode Dictionary <int, List <string> > nonWarpCache = new Dictionary <int, List <string> >(); List <string> warpCache = new List <string>(); //Add us if (timeSyncer.currentSubspace != -1) { List <string> newList = new List <string>(); newList.Add(dmpSettings.playerName); nonWarpCache.Add(timeSyncer.currentSubspace, newList); } else { warpCache.Add(dmpSettings.playerName); } //Add other players foreach (KeyValuePair <string, int> clientEntry in clientSubspaceList) { if (clientEntry.Value != -1) { if (!nonWarpCache.ContainsKey(clientEntry.Value)) { nonWarpCache.Add(clientEntry.Value, new List <string>()); } if (!nonWarpCache[clientEntry.Value].Contains(clientEntry.Key)) { nonWarpCache[clientEntry.Value].Add(clientEntry.Key); } } else { if (!warpCache.Contains(clientEntry.Key)) { warpCache.Add(clientEntry.Key); } } } //Players missing subspace or warp entries List <string> unknownPlayers = new List <string>(); //Return list List <SubspaceDisplayEntry> returnList = new List <SubspaceDisplayEntry>(); //Process locked players foreach (KeyValuePair <int, List <string> > subspaceEntry in nonWarpCache) { if (timeSyncer.SubspaceExists(subspaceEntry.Key)) { SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.subspaceID = subspaceEntry.Key; sde.subspaceEntry = timeSyncer.GetSubspace(subspaceEntry.Key); subspaceEntry.Value.Sort(PlayerSorter); sde.isUs = subspaceEntry.Value.Contains(dmpSettings.playerName); sde.players = subspaceEntry.Value.ToArray(); returnList.Add(sde); } else { foreach (string unknownPlayer in subspaceEntry.Value) { unknownPlayers.Add(unknownPlayer); } } } //Process warping players foreach (string warpingPlayer in warpCache) { if (clientWarpList.ContainsKey(warpingPlayer)) { SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.warpingEntry = clientWarpList[warpingPlayer]; sde.players = new string[] { warpingPlayer }; sde.isUs = (warpingPlayer == dmpSettings.playerName); sde.isWarping = true; returnList.Add(sde); } else { unknownPlayers.Add(warpingPlayer); } } returnList.Sort(SubpaceDisplayEntrySorter); if (unknownPlayers.Count > 0) { SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.players = unknownPlayers.ToArray(); sde.isUs = unknownPlayers.Contains(dmpSettings.playerName); returnList.Add(sde); } return(returnList.ToArray()); }
private int SubpaceDisplayEntrySorter(SubspaceDisplayEntry lhs, SubspaceDisplayEntry rhs) { long serverClock = TimeSyncer.fetch.GetServerClock(); double subspace1Time = double.MinValue; double subspace2Time = double.MinValue; //LHS time if (lhs.isWarping) { if (lhs.warpingEntry != null) { float[] warpRates = TimeWarp.fetch.warpRates; if (lhs.warpingEntry.isPhysWarp) { warpRates = TimeWarp.fetch.physicsWarpRates; } long serverClockDiff = serverClock - lhs.warpingEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace1Time = lhs.warpingEntry.planetTime + (warpRates[lhs.warpingEntry.rateIndex] * secondsDiff); } } else { if (lhs.subspaceEntry != null) { long serverClockDiff = serverClock - lhs.subspaceEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace1Time = lhs.subspaceEntry.planetTime + (lhs.subspaceEntry.subspaceSpeed * secondsDiff); } } //RHS time if (rhs.isWarping) { if (rhs.warpingEntry != null) { float[] warpRates = TimeWarp.fetch.warpRates; if (rhs.warpingEntry.isPhysWarp) { warpRates = TimeWarp.fetch.physicsWarpRates; } long serverClockDiff = serverClock - rhs.warpingEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace2Time = rhs.warpingEntry.planetTime + (warpRates[rhs.warpingEntry.rateIndex] * secondsDiff); } } else { if (rhs.subspaceEntry != null) { long serverClockDiff = serverClock - rhs.subspaceEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; subspace2Time = rhs.subspaceEntry.planetTime + (rhs.subspaceEntry.subspaceSpeed * secondsDiff); } } if (subspace1Time > subspace2Time) { return -1; } if (subspace1Time == subspace2Time) { return 0; } return 1; }
private SubspaceDisplayEntry[] GetSubspaceDisplayEntriesSubspace() { //Subspace/subspace simple mode Dictionary<int, List<string>> nonWarpCache = new Dictionary<int, List<string>>(); List<string> warpCache = new List<string>(); //Add us if (TimeSyncer.fetch.currentSubspace != -1) { List<string> newList = new List<string>(); newList.Add(Settings.fetch.playerName); nonWarpCache.Add(TimeSyncer.fetch.currentSubspace, newList); } else { warpCache.Add(Settings.fetch.playerName); } //Add other players foreach (KeyValuePair<string, int> clientEntry in clientSubspaceList) { if (clientEntry.Value != -1) { if (!nonWarpCache.ContainsKey(clientEntry.Value)) { nonWarpCache.Add(clientEntry.Value, new List<string>()); } if (!nonWarpCache[clientEntry.Value].Contains(clientEntry.Key)) { nonWarpCache[clientEntry.Value].Add(clientEntry.Key); } } else { if (!warpCache.Contains(clientEntry.Key)) { warpCache.Add(clientEntry.Key); } } } //Players missing subspace or warp entries List<string> unknownPlayers = new List<string>(); //Return list List<SubspaceDisplayEntry> returnList = new List<SubspaceDisplayEntry>(); //Process locked players foreach (KeyValuePair<int, List<string>> subspaceEntry in nonWarpCache) { if (TimeSyncer.fetch.SubspaceExists(subspaceEntry.Key)) { SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.subspaceID = subspaceEntry.Key; sde.subspaceEntry = TimeSyncer.fetch.GetSubspace(subspaceEntry.Key); subspaceEntry.Value.Sort(PlayerSorter); sde.isUs = subspaceEntry.Value.Contains(Settings.fetch.playerName); sde.players = subspaceEntry.Value.ToArray(); returnList.Add(sde); } else { foreach (string unknownPlayer in subspaceEntry.Value) { unknownPlayers.Add(unknownPlayer); } } } //Process warping players foreach (string warpingPlayer in warpCache) { if (clientWarpList.ContainsKey(warpingPlayer)) { SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.warpingEntry = clientWarpList[warpingPlayer]; sde.players = new string[] { warpingPlayer }; sde.isUs = (warpingPlayer == Settings.fetch.playerName); sde.isWarping = true; returnList.Add(sde); } else { unknownPlayers.Add(warpingPlayer); } } returnList.Sort(SubpaceDisplayEntrySorter); if (unknownPlayers.Count > 0) { SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.players = unknownPlayers.ToArray(); sde.isUs = unknownPlayers.Contains(Settings.fetch.playerName); returnList.Add(sde); } return returnList.ToArray(); }
private SubspaceDisplayEntry[] GetSubspaceDisplayEntriesMCWNone() { int currentSubspace = TimeSyncer.fetch.currentSubspace; List<string> allPlayers = new List<string>(); allPlayers.Add(Settings.fetch.playerName); allPlayers.AddRange(clientSubspaceList.Keys); allPlayers.Sort(PlayerSorter); SubspaceDisplayEntry sde = new SubspaceDisplayEntry(); sde.players = allPlayers.ToArray(); sde.isUs = true; if (currentSubspace != -1) { sde.subspaceID = TimeSyncer.fetch.currentSubspace; sde.subspaceEntry = TimeSyncer.fetch.GetSubspace(currentSubspace); } else { sde.isWarping = true; if (clientWarpList.ContainsKey(Settings.fetch.playerName)) { sde.warpingEntry = clientWarpList[Settings.fetch.playerName]; } } return new SubspaceDisplayEntry[] { sde }; }
private void DrawContent(int windowID) { GUILayout.BeginVertical(); GUI.DragWindow(moveRect); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUIStyle chatButtonStyle = buttonStyle; if (chatWorker.chatButtonHighlighted) { chatButtonStyle = highlightStyle; } chatWorker.display = GUILayout.Toggle(chatWorker.display, "Chat", chatButtonStyle); craftLibraryWorker.display = GUILayout.Toggle(craftLibraryWorker.display, "Craft", buttonStyle); groupsWindow.display = GUILayout.Toggle(groupsWindow.display, "Group", buttonStyle); permissionsWindow.display = GUILayout.Toggle(permissionsWindow.display, "Permissions", buttonStyle); GUIStyle screenshotButtonStyle = buttonStyle; if (screenshotWorker.screenshotButtonHighlighted) { screenshotButtonStyle = highlightStyle; } screenshotWorker.display = GUILayout.Toggle(screenshotWorker.display, "Screenshot", screenshotButtonStyle); if (GUILayout.Button("-", buttonStyle)) { minmized = true; minWindowRect.x = windowRect.xMax - minWindowRect.width; minWindowRect.y = windowRect.y; } GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, scrollStyle); //Draw subspaces double ourTime = timeSyncer.locked ? timeSyncer.GetUniverseTime() : Planetarium.GetUniversalTime(); long serverClock = timeSyncer.GetServerClock(); bool updateSubspace = false; if (lastUpdateTime != (int)Client.realtimeSinceStartup) { updateSubspace = true; lastUpdateTime = (int)Client.realtimeSinceStartup; } for (int i = 0; i < subspaceDisplay.Item2; i++) { SubspaceDisplayEntry currentEntry = subspaceDisplay.Item1[i]; int diffTime = 0; if (updateSubspace || currentEntry.relativeTimeDisplay == null) { int currentTime = 0; currentEntry.showSyncButton = false; if (!currentEntry.isUnknown) { if (!currentEntry.isUs) { if (!currentEntry.isWarping) { //Subspace entry if (currentEntry.subspaceEntry != null) { long serverClockDiff = serverClock - currentEntry.subspaceEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; currentTime = (int)(currentEntry.subspaceEntry.planetTime + (currentEntry.subspaceEntry.subspaceSpeed * secondsDiff)); diffTime = (int)(currentTime - ourTime); if (diffTime > 0) { currentEntry.showSyncButton = true; currentEntry.relativeTimeDisplay = String.Format("T+ {0} - {1} in the future", SecondsToString(currentTime, 1), SecondsToString(diffTime, 0)); } if (diffTime < 0) { currentEntry.relativeTimeDisplay = String.Format("T+ {0} - {1} in the past", SecondsToString(currentTime, 1), SecondsToString(-diffTime, 0)); } if (diffTime == 0) { currentEntry.relativeTimeDisplay = String.Format("T+ {0} - NOW", SecondsToString(currentTime, 1)); } } } else { //Warp entry if (currentEntry.warpingEntry != null) { float[] warpRates = TimeWarp.fetch.warpRates; if (currentEntry.warpingEntry.isPhysWarp) { warpRates = TimeWarp.fetch.physicsWarpRates; } long serverClockDiff = serverClock - currentEntry.warpingEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; currentTime = (int)(currentEntry.warpingEntry.planetTime + (warpRates[currentEntry.warpingEntry.rateIndex] * secondsDiff)); diffTime = (int)(currentTime - ourTime); if (diffTime > 0) { currentEntry.relativeTimeDisplay = String.Format("T+ {0} - {1} in the future", SecondsToString(currentTime, 1), SecondsToString(diffTime, 0)); } if (diffTime < 0) { currentEntry.relativeTimeDisplay = String.Format("T+ {0} - {1} in the past", SecondsToString(currentTime, 1), SecondsToString(-diffTime, 0)); } if (diffTime == 0) { currentEntry.relativeTimeDisplay = String.Format("T+ {0} - NOW", SecondsToString(currentTime, 1)); } } } } else { currentTime = (int)ourTime; currentEntry.relativeTimeDisplay = String.Format("T+ {0} - NOW", SecondsToString(currentTime, 1)); } } else { currentEntry.relativeTimeDisplay = "Unknown"; } } //Draw the subspace black bar. GUILayout.BeginHorizontal(subspaceStyle); GUILayout.Label(currentEntry.relativeTimeDisplay); GUILayout.FlexibleSpace(); //Draw the sync button if needed #if !DEBUG if ((warpWorker.warpMode == WarpMode.SUBSPACE) && !currentEntry.isUs && !currentEntry.isWarping && (currentEntry.subspaceEntry != null) && currentEntry.showSyncButton) #else if ((warpWorker.warpMode == WarpMode.SUBSPACE) && !currentEntry.isUs && !currentEntry.isWarping && (currentEntry.subspaceEntry != null)) #endif { if (GUILayout.Button("Sync", buttonStyle)) { timeSyncer.LockSubspace(currentEntry.subspaceID); } } GUILayout.EndHorizontal(); foreach (string currentPlayer in currentEntry.players) { if (currentPlayer == dmpSettings.playerName) { DrawPlayerEntry(playerStatusWorker.myPlayerStatus, playerColorWorker.GetPlayerColor(currentPlayer)); } else { DrawPlayerEntry(playerStatusWorker.GetPlayerStatus(currentPlayer), playerColorWorker.GetPlayerColor(currentPlayer)); } } } if (DateTime.Now.Day == 1 && DateTime.Now.Month == 4) { PlayerStatus easterEgg = new PlayerStatus(); easterEgg.playerName = "Princess Luna"; easterEgg.statusText = "Stranded on the Mün"; easterEgg.vesselText = ""; DrawPlayerEntry(easterEgg, new Color(0.251f, 0.275f, 0.502f)); } GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Disconnect", buttonStyle)) { disconnectEventHandled = false; } optionsWindow.display = GUILayout.Toggle(optionsWindow.display, "Options", buttonStyle); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }