/// <summary> /// Checks and sends if we took a screenshot /// </summary> public void CheckScreenshots() { if (GameSettings.TAKE_SCREENSHOT.GetKeyDown()) { if (TimeUtil.IsInInterval(ref _lastTakenScreenshot, SettingsSystem.ServerSettings.MinScreenshotIntervalMs)) { var path = CommonUtil.CombinePaths(MainSystem.KspPath, "Screenshots"); CoroutineUtil.StartDelayedRoutine(nameof(CheckScreenshots), () => { var photo = new DirectoryInfo(path).GetFiles().OrderByDescending(f => f.LastWriteTime).FirstOrDefault(); if (photo != null) { var imageData = ScaleScreenshot(File.ReadAllBytes(photo.FullName), 800, 600); TaskFactory.StartNew(() => { MessageSender.SendScreenshot(imageData); }); LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.ScreenshotTaken, 10f, ScreenMessageStyle.UPPER_CENTER); } }, 0.3f); } else { var msg = LocalizationContainer.ScreenText.ScreenshotInterval.Replace("$1", TimeSpan.FromMilliseconds(SettingsSystem.ServerSettings.MinScreenshotIntervalMs).TotalSeconds .ToString(CultureInfo.InvariantCulture)); LunaScreenMsg.PostScreenMessage(msg, 20f, ScreenMessageStyle.UPPER_CENTER); } } }
/// <summary> /// Sends our vessel just when we start the flight /// </summary> public void FlightReady() { if (!VesselCommon.IsSpectating && FlightGlobals.ActiveVessel != null) { if (!System.CheckVessel(FlightGlobals.ActiveVessel)) { VesselRemoveSystem.Singleton.AddToKillList(FlightGlobals.ActiveVessel.id, "Vessel check not passed"); VesselRemoveSystem.Singleton.KillVessel(FlightGlobals.ActiveVessel.id, "Vessel check not passed"); return; } CoroutineUtil.StartDelayedRoutine(nameof(FlightReady), () => { if (VesselCommon.IsSpectating || FlightGlobals.ActiveVessel == null || FlightGlobals.ActiveVessel.id == Guid.Empty) { return; } System.MessageSender.SendVesselMessage(FlightGlobals.ActiveVessel, true, false); }, 5f); //Only show safety bubble text if safety bubble is active and player is spawning a new vessel if (SettingsSystem.ServerSettings.SafetyBubbleDistance > 0 && FlightGlobals.ActiveVessel.vesselSpawning) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SafetyBubble, 10f, ScreenMessageStyle.UPPER_CENTER); } } }
private static void SwitchVesselIfSpectating(Vessel killVessel) { if (FlightGlobals.ActiveVessel?.id == killVessel.id) { //Try to switch to a nearby loaded vessel... var otherVessel = FlightGlobals.VesselsLoaded.FirstOrDefault(v => v.id != killVessel.id); //No nearby vessel detected... Get a random vessel and switch to it if exists, otherwise go to spacecenter if (otherVessel == null) { otherVessel = FlightGlobals.Vessels.FirstOrDefault(v => v.id != killVessel.id); } if (otherVessel != null) { FlightGlobals.ForceSetActiveVessel(otherVessel); } else { HighLogic.LoadScene(GameScenes.SPACECENTER); } LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SpectatingRemoved, 10f, ScreenMessageStyle.UPPER_CENTER); } }
public void CheckCommonStockParts() { var missingPartsCount = 0; LunaLog.Log("[LMP]: Missing parts start"); var modFile = new ModControlStructure(); modFile.SetDefaultAllowedParts(); var missingParts = PartLoader.LoadedPartsList.Where(p => !modFile.AllowedParts.Contains(p.name)); foreach (var part in missingParts) { missingPartsCount++; LunaLog.Log($"[LMP]: Missing '{part.name}'"); } LunaLog.Log("[LMP]: Missing parts end"); LunaScreenMsg.PostScreenMessage( missingPartsCount > 0 ? $"{missingPartsCount} missing part(s) from Common.dll printed to debug log ({PartLoader.LoadedPartsList.Count} total)" : $"No missing parts out of from Common.dll ({PartLoader.LoadedPartsList.Count} total)", 5f, ScreenMessageStyle.UPPER_CENTER); }
private void NotifyDownloadedCrafts() { while (DownloadedCraftsNotification.TryDequeue(out var message)) { LunaScreenMsg.PostScreenMessage($"({message}) {LocalizationContainer.ScreenText.CraftSaved}", 5f, ScreenMessageStyle.UPPER_CENTER); } }
//If the scene field is blank, KSP will throw an error while starting the game, meaning players will be unable to join the server. private static void CheckForBlankSceneSoTheGameDoesntBugOut(ScenarioEntry scenarioEntry) { if (scenarioEntry.ScenarioNode.GetValue("scene") == string.Empty) { var nodeName = scenarioEntry.ScenarioModule; LunaScreenMsg.PostScreenMessage($"{nodeName} is badly behaved!", 3, ScreenMessageStyle.UPPER_CENTER); LunaLog.Log($"[LMP]: {nodeName} is badly behaved!"); scenarioEntry.ScenarioNode.SetValue("scene", "7, 8, 5, 6, 9"); } }
private static bool PrefixQuickLoad() { if (MainSystem.NetworkState < ClientState.Connected) { return(true); } LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.CannotLoadGames, 5f, ScreenMessageStyle.UPPER_CENTER); return(false); }
/// <summary> /// Checks if the protovessel has resources, parts that you don't have or that they are banned /// </summary> public static bool HasInvalidParts(this ProtoVessel pv, bool verboseErrors) { foreach (var pps in pv.protoPartSnapshots) { if (ModSystem.Singleton.ModControl && !ModSystem.Singleton.AllowedParts.Contains(pps.partName)) { if (verboseErrors) { var msg = $"Protovessel {pv.vesselID} ({pv.vesselName}) contains the BANNED PART '{pps.partName}'. Skipping load."; LunaLog.LogWarning(msg); ChatSystem.Singleton.PmMessageServer(msg); } return(true); } var invalidResources = pps.resources.Select(r => r.resourceName).Except(ModSystem.Singleton.AllowedResources).ToArray(); if (ModSystem.Singleton.ModControl && invalidResources.Any()) { if (verboseErrors) { var msg = $"Protovessel {pv.vesselID} ({pv.vesselName}) contains the BANNED RESOURCE/S '{string.Join(", ", invalidResources)}'. Skipping load."; LunaLog.LogWarning(msg); ChatSystem.Singleton.PmMessageServer(msg); } return(true); } if (pps.partInfo == null) { if (verboseErrors) { LunaLog.LogWarning($"Protovessel {pv.vesselID} ({pv.vesselName}) contains the MISSING PART '{pps.partName}'. Skipping load."); LunaScreenMsg.PostScreenMessage($"Cannot load '{pv.vesselName}' - missing part: {pps.partName}", 10f, ScreenMessageStyle.UPPER_CENTER); } return(true); } var missingResource = pps.resources.FirstOrDefault(r => !PartResourceLibrary.Instance.resourceDefinitions.Contains(r.resourceName)); if (missingResource != null && verboseErrors) { var msg = $"Protovessel {pv.vesselID} ({pv.vesselName}) contains the MISSING RESOURCE '{missingResource.resourceName}'."; LunaLog.LogWarning(msg); ChatSystem.Singleton.PmMessageServer(msg); LunaScreenMsg.PostScreenMessage($"Vessel '{pv.vesselName}' contains the modded RESOURCE: {pps.partName}", 10f, ScreenMessageStyle.UPPER_CENTER); //We allow loading of vessels that have missing resources. They will be removed by the player with the lock tough... } } return(false); }
private static bool PrefixQuickLoad() { if (MainSystem.NetworkState < ClientState.Connected) { return(true); } LunaScreenMsg.PostScreenMessage("Cannot load games in LMP!", 5f, ScreenMessageStyle.UPPER_CENTER); return(false); }
private static void ShowDisconnectMessage() { if (HighLogic.LoadedScene < GameScenes.SPACECENTER) { DisplayDisconnectMessage = false; } if (DisplayDisconnectMessage) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.Disconected, 2f, ScreenMessageStyle.UPPER_CENTER); } }
public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is MotdReplyMsgData msgData)) { return; } if (!string.IsNullOrEmpty(msgData.MessageOfTheDay)) { LunaScreenMsg.PostScreenMessage(msgData.MessageOfTheDay, 30f, ScreenMessageStyle.UPPER_CENTER); } }
/// <summary> /// Creates a protovessel from a ConfigNode /// </summary> public static ProtoVessel CreateSafeProtoVesselFromConfigNode(ConfigNode inputNode, Guid protoVesselId) { try { //Cannot create a protovessel if HighLogic.CurrentGame is null as we don't have a CrewRoster //and the protopartsnapshot constructor needs it if (HighLogic.CurrentGame == null) { return(null); } //Cannot reuse the Protovessel to save memory garbage as it does not have any clear method :( var pv = new ProtoVessel(inputNode, HighLogic.CurrentGame); foreach (var pps in pv.protoPartSnapshots) { if (ModSystem.Singleton.ModControl && !ModSystem.Singleton.AllowedParts.Contains(pps.partName)) { var msg = $"Protovessel {protoVesselId} ({pv.vesselName}) contains the BANNED PART '{pps.partName}'. Skipping load."; LunaLog.LogWarning(msg); ChatSystem.Singleton.PmMessageServer(msg); return(null); } if (pps.partInfo == null) { LunaLog.LogWarning($"WARNING: Protovessel {protoVesselId} ({pv.vesselName}) contains the MISSING PART '{pps.partName}'. Skipping load."); LunaScreenMsg.PostScreenMessage($"Cannot load '{pv.vesselName}' - missing {pps.partName}", 10f, ScreenMessageStyle.UPPER_CENTER); return(null); } var missingeResource = pps.resources.FirstOrDefault(r => !PartResourceLibrary.Instance.resourceDefinitions.Contains(r.resourceName)); if (missingeResource != null) { var msg = $"WARNING: Protovessel {protoVesselId} ({pv.vesselName}) contains the MISSING RESOURCE '{missingeResource.resourceName}'. Skipping load."; LunaLog.LogWarning(msg); ChatSystem.Singleton.PmMessageServer(msg); LunaScreenMsg.PostScreenMessage($"Cannot load '{pv.vesselName}' - missing resource {missingeResource.resourceName}", 10f, ScreenMessageStyle.UPPER_CENTER); return(null); } } return(pv); } catch (Exception e) { LunaLog.LogError($"[LMP]: Damaged vessel {protoVesselId}, exception: {e}"); return(null); } }
/// <summary> /// Request a craft to the server if possible /// </summary> public void RequestCraft(CraftBasicEntry craft) { if (TimeUtil.IsInInterval(ref _lastRequest, SettingsSystem.ServerSettings.MinCraftLibraryRequestIntervalMs)) { MessageSender.SendRequestCraftMsg(craft); } else { var msg = LocalizationContainer.ScreenText.CraftLibraryInterval.Replace("$1", TimeSpan.FromMilliseconds(SettingsSystem.ServerSettings.MinCraftLibraryRequestIntervalMs).TotalSeconds.ToString(CultureInfo.InvariantCulture)); LunaScreenMsg.PostScreenMessage(msg, 20f, ScreenMessageStyle.UPPER_CENTER); } }
/// <summary> /// Saves the requested image to disk /// </summary> public void SaveImage(string folder, long dateTaken) { if (DownloadedImages.TryGetValue(folder, out var downloadedImages) && downloadedImages.TryGetValue(dateTaken, out var image)) { var folderPath = CommonUtil.CombinePaths(ScreenshotsFolder, folder); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } var filePath = CommonUtil.CombinePaths(folderPath, $"{dateTaken}.png"); File.WriteAllBytes(filePath, image.Data); LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.ImageSaved, 20f, ScreenMessageStyle.UPPER_CENTER); } }
/// <summary> /// Sends a craft to the server if possible /// </summary> public void SendCraft(CraftEntry craft) { if (DateTime.Now - _lastRequest > TimeSpan.FromMilliseconds(SettingsSystem.ServerSettings.MinCraftLibraryRequestIntervalMs)) { _lastRequest = DateTime.Now; MessageSender.SendCraftMsg(craft); LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.CraftUploaded, 10f, ScreenMessageStyle.UPPER_CENTER); } else { var msg = LocalizationContainer.ScreenText.CraftLibraryInterval.Replace("$1", TimeSpan.FromMilliseconds(SettingsSystem.ServerSettings.MinCraftLibraryRequestIntervalMs).TotalSeconds.ToString(CultureInfo.InvariantCulture)); LunaScreenMsg.PostScreenMessage(msg, 20f, ScreenMessageStyle.UPPER_CENTER); } }
/// <summary> /// This event is called when vessel is terminated from track station /// </summary> public void OnVesselTerminated(ProtoVessel terminatedVessel) { if (!LockSystem.LockQuery.CanRecoverOrTerminateTheVessel(terminatedVessel.vesselID, SettingsSystem.CurrentSettings.PlayerName)) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.CannotTerminate, 5f, ScreenMessageStyle.UPPER_CENTER); return; } _recoveringTerminatingVesselId = terminatedVessel.vesselID; LunaLog.Log($"[LMP]: Removing vessel {terminatedVessel.vesselID}, Name: {terminatedVessel.vesselName} from the server: Terminated"); System.MessageSender.SendVesselRemove(terminatedVessel.vesselID); //Vessel is terminated so remove locks LockSystem.Singleton.ReleaseAllVesselLocks(terminatedVessel.GetVesselCrew().Select(c => c.name), terminatedVessel.vesselID); }
private static bool PrefixSackAvailable(KerbalRoster __instance, ProtoCrewMember ap) { if (MainSystem.NetworkState < ClientState.Connected) { return(true); } if (!SettingsSystem.ServerSettings.AllowSackKerbals) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SackingKerbalsNotAllowed, 10, ScreenMessageStyle.UPPER_CENTER); KerbalSystem.Singleton.RefreshCrewDialog(); return(false); } return(true); }
/// <summary> /// This event is triggered when we hire a kerbal (previous type was applicant, new is crew) /// Also triggered when we sack a kerbal (previous type was crew, new is applicant) /// </summary> public void TypeChange(ProtoCrewMember kerbal, ProtoCrewMember.KerbalType previousType, ProtoCrewMember.KerbalType newType) { if (previousType != newType) { if (LockSystem.LockQuery.KerbalLockExists(kerbal.name) && !LockSystem.LockQuery.KerbalLockBelongsToPlayer(kerbal.name, SettingsSystem.CurrentSettings.PlayerName)) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.KerbalNotYours, 5f, ScreenMessageStyle.UPPER_CENTER); System.SetKerbalTypeWithoutTriggeringEvent(kerbal, ProtoCrewMember.KerbalType.Crew); return; } System.SetKerbalTypeWithoutTriggeringEvent(kerbal, newType); System.MessageSender.SendKerbal(kerbal); System.RefreshCrewDialog(); } }
public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is MotdReplyMsgData msgData)) { return; } if (!string.IsNullOrEmpty(msgData.MessageOfTheDay)) { if (SettingsSystem.ServerSettings.PrintMotdInChat) { ChatSystem.Singleton.PrintToChat(msgData.MessageOfTheDay); } LunaScreenMsg.PostScreenMessage(msgData.MessageOfTheDay, 30f, ScreenMessageStyle.UPPER_CENTER); } }
public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is AdminBaseMsgData msgData)) { return; } switch (msgData.AdminMessageType) { case AdminMessageType.Reply: LunaScreenMsg.PostScreenMessage($"Admin command reply: {((AdminReplyMsgData)msgData).Response}", 5f, ScreenMessageStyle.UPPER_RIGHT); break; default: throw new ArgumentOutOfRangeException(); } }
public void CheckCommonStockParts() { var missingPartsCount = 0; var missingResourcesCount = 0; var modFile = new ModControlStructure(); modFile.SetDefaultAllowedParts(); modFile.SetDefaultAllowedResources(); LunaLog.Log("[LMP]: Missing parts start"); foreach (var part in PartLoader.LoadedPartsList.Where(p => !modFile.AllowedParts.Contains(p.name))) { missingPartsCount++; LunaLog.Log($"[LMP]: Missing part: '{part.name}'"); } LunaLog.Log("[LMP]: Missing parts end"); LunaLog.Log("[LMP]: Missing resources start"); foreach (var resource in PartResourceLibrary.Instance.resourceDefinitions.Cast <PartResourceDefinition>().Select(r => r.name) .Where(r => !modFile.AllowedResources.Contains(r))) { missingResourcesCount++; LunaLog.Log($"[LMP]: Missing resource: '{resource}'"); } LunaLog.Log("[LMP]: Missing resources end"); if (missingPartsCount > 0 && missingResourcesCount <= 0) { LunaScreenMsg.PostScreenMessage($"{missingPartsCount} missing part(s) from Common.dll printed to log ({PartLoader.LoadedPartsList.Count} total)", 5f, ScreenMessageStyle.UPPER_CENTER); } else if (missingPartsCount <= 0 && missingResourcesCount <= 0) { LunaScreenMsg.PostScreenMessage("No missing parts/resources from Common.dll", 5f, ScreenMessageStyle.UPPER_CENTER); } else if (missingPartsCount <= 0 && missingResourcesCount > 0) { LunaScreenMsg.PostScreenMessage($"{missingResourcesCount} missing resources from Common.dll printed to log ({PartResourceLibrary.Instance.resourceDefinitions.Count} total)", 5f, ScreenMessageStyle.UPPER_CENTER); } else { LunaScreenMsg.PostScreenMessage($"{missingPartsCount} missing part(s) from Common.dll printed to log ({PartLoader.LoadedPartsList.Count} total). " + $"{missingResourcesCount} missing resources from Common.dll printed to log ({PartResourceLibrary.Instance.resourceDefinitions.Count} total)", 5f, ScreenMessageStyle.UPPER_CENTER); } }
public void FlightReady() { //Only show safety bubble text if safety bubble is active and player is spawning a new vessel if (VesselCommon.IsSpectating || FlightGlobals.ActiveVessel == null || !FlightGlobals.ActiveVessel.vesselSpawning || SettingsSystem.ServerSettings.SafetyBubbleDistance <= 0) { return; } if (System.IsInSafetyBubble(FlightGlobals.ActiveVessel) && FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH) { System.DrawSafetyBubble(); } if (FlightGlobals.ActiveVessel.vesselSpawning) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SafetyBubble, 10f, ScreenMessageStyle.UPPER_CENTER); } }
private static void HandleLoad(QuicksaveLoadReplyMsgData data) { // Make sure that the quicksave corresponds to current vessel if (data.QuicksaveInfo.VesselId != FlightGlobals.ActiveVessel.id) { LunaScreenMsg.PostScreenMessage("Got quicksave for wrong vessel!", 5, ScreenMessageStyle.UPPER_CENTER); LunaLog.LogError( $"[LMP]: Got quicksave for wrong vessel. Got id: {data.QuicksaveInfo.VesselId}. Current vessel id: {FlightGlobals.ActiveVessel.id}"); return; } // Construct the ProtoVessel using the loaded byte data var vesselProto = new VesselProto { GameTime = data.QuicksaveInfo.GameTime, VesselId = data.QuicksaveInfo.VesselId, NumBytes = data.QuicksaveInfo.NumBytes, ForceReload = true, RawData = new byte[data.QuicksaveInfo.NumBytes] }; Array.Copy(data.QuicksaveInfo.Data, vesselProto.RawData, data.QuicksaveInfo.NumBytes); var protoVessel = vesselProto.CreateProtoVessel(); // Try to reload the vessel if (VesselLoader.LoadVessel(protoVessel, true)) { // Create a new subspace with the loaded vessel's time TimeSyncSystem.Singleton.SetGameTime(protoVessel.launchTime + protoVessel.missionTime); WarpSystem.Singleton.WaitingSubspaceIdFromServer = true; WarpSystem.Singleton.MessageSender.SendNewSubspace(); LunaScreenMsg.PostScreenMessage($"Loaded {data.QuicksaveInfo.Name}!", 5, ScreenMessageStyle.UPPER_CENTER); } else { LunaScreenMsg.PostScreenMessage("Could not load quicksave!", 5, ScreenMessageStyle.UPPER_CENTER); LunaLog.LogError( $"[LMP]: Could not load quicksave {data.QuicksaveInfo.Name} for {data.QuicksaveInfo.VesselId}"); } }
/// <summary> /// This event is called when the vessel is recovered /// </summary> public void OnVesselRecovered(ProtoVessel recoveredVessel, bool quick) { //quick == true when you press "space center" from the inflight menu if (!LockSystem.LockQuery.CanRecoverOrTerminateTheVessel(recoveredVessel.vesselID, SettingsSystem.CurrentSettings.PlayerName)) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.CannotRecover, 5f, ScreenMessageStyle.UPPER_CENTER); return; } _recoveringTerminatingVesselId = recoveredVessel.vesselID; LunaLog.Log($"[LMP]: Removing vessel {recoveredVessel.vesselID}, Name: {recoveredVessel.vesselName} from the server: Recovered"); KerbalSystem.Singleton.ProcessKerbalsInVessel(recoveredVessel); System.MessageSender.SendVesselRemove(recoveredVessel.vesselID); //Vessel is recovered so remove the locks LockSystem.Singleton.ReleaseAllVesselLocks(recoveredVessel.GetVesselCrew().Select(c => c.name), recoveredVessel.vesselID); }
/// <summary> /// Show a message on the screen if we are spectating /// </summary> private void UpdateOnScreenSpectateMessage() { if (VesselCommon.IsSpectating) { if (_spectateMessage != null) { _spectateMessage.duration = 0f; } _spectateMessage = LunaScreenMsg.PostScreenMessage(SpectatingMessage, 1000 * 2, ScreenMessageStyle.UPPER_CENTER); } else { if (_spectateMessage != null) { _spectateMessage.duration = 0f; _spectateMessage = null; } } }
private static void SwitchVesselIfKillingActiveVessel(Vessel killVessel) { if (FlightGlobals.ActiveVessel && FlightGlobals.ActiveVessel.id == killVessel.id) { FlightGlobals.fetch.SetVesselTarget(null); //Try to switch to a nearby loaded vessel... var otherVessel = FlightGlobals.FindNearestControllableVessel(killVessel); if (otherVessel != null) { FlightGlobals.ForceSetActiveVessel(otherVessel); } else { HighLogic.LoadScene(GameScenes.SPACECENTER); } LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SpectatingRemoved, 10f, ScreenMessageStyle.UPPER_CENTER); } }
/// <summary> /// This event is called when vessel is terminated from track station /// </summary> public void OnVesselTerminated(ProtoVessel terminatedVessel) { if (!LockSystem.LockQuery.CanRecoverOrTerminateTheVessel(terminatedVessel.vesselID, SettingsSystem.CurrentSettings.PlayerName)) { LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.CannotTerminate, 5f, ScreenMessageStyle.UPPER_CENTER); return; } _recoveringTerminatingVesselId = terminatedVessel.vesselID; LunaLog.Log($"[LMP]: Removing vessel {terminatedVessel.vesselID}, Name: {terminatedVessel.vesselName} from the server: Terminated"); System.MessageSender.SendVesselRemove(terminatedVessel.vesselID); //Vessel is terminated so remove locks Do not remove the kerbal locks as that's done in the Kerbal system LockSystem.Singleton.ReleaseAllVesselLocks(null, terminatedVessel.vesselID, 1000); //We consider this vessel removed but we let KSP do the remove of the vessel System.RemovedVessels.TryAdd(terminatedVessel.vesselID, DateTime.Now); RemoveEvent.onLmpRecoveredVessel.Fire(terminatedVessel); }
private void ProcessReceivedMessages() { if (Enabled) { while (NewChatMessages.TryDequeue(out var chatMsg)) { NewMessageReceived = true; if (!ChatWindow.Singleton.Display) { LunaScreenMsg.PostScreenMessage($"{chatMsg.Item1}: {chatMsg.Item2}", 5f, ScreenMessageStyle.UPPER_LEFT); } else { ChatWindow.Singleton.ScrollToBottom(); } ChatMessages.Add(chatMsg); } } }
public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is PlayerConnectionBaseMsgData msgData)) { return; } var playerName = msgData.PlayerName; switch (msgData.PlayerConnectionMessageType) { case PlayerConnectionMessageType.Join: LunaScreenMsg.PostScreenMessage($"{playerName} has joined the server", 3f, ScreenMessageStyle.UPPER_CENTER); break; case PlayerConnectionMessageType.Leave: WarpSystem.Singleton.RemovePlayer(playerName); StatusSystem.Singleton.RemovePlayer(playerName); LunaScreenMsg.PostScreenMessage($"{playerName} has left the server", 3f, ScreenMessageStyle.UPPER_CENTER); break; } }
/// <summary> /// This event is triggered when we hire a kerbal (previous type was applicant, new is crew) /// Also triggered when we sack a kerbal (previous type was crew, new is applicant) /// </summary> public void TypeChange(ProtoCrewMember kerbal, ProtoCrewMember.KerbalType previousType, ProtoCrewMember.KerbalType newType) { if (previousType != newType) { if (!LockSystem.LockQuery.CanEditKerbal(kerbal.name, SettingsSystem.CurrentSettings.PlayerName)) { LunaScreenMsg.PostScreenMessage("This kerbal does not belongs you", 5f, ScreenMessageStyle.UPPER_CENTER); System.SetKerbalTypeWithoutTriggeringEvent(kerbal, ProtoCrewMember.KerbalType.Crew); return; } if (previousType == ProtoCrewMember.KerbalType.Crew && newType == ProtoCrewMember.KerbalType.Applicant && !SettingsSystem.ServerSettings.AllowSackKerbals) { //This means that we sacked the crew and we are not allowed to do it System.SetKerbalTypeWithoutTriggeringEvent(kerbal, ProtoCrewMember.KerbalType.Crew); return; } System.SetKerbalTypeWithoutTriggeringEvent(kerbal, newType); System.MessageSender.SendKerbal(kerbal); } }