public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is VesselDockMsgData msgData)) { return; } LunaLog.Log("Docking message received!"); //Add the new vessel data to the store VesselsProtoStore.HandleVesselProtoData(msgData.FinalVesselData, msgData.NumBytes, msgData.DominantVesselId); if (FlightGlobals.ActiveVessel?.id == msgData.WeakVesselId) { LunaLog.Log($"Docking NOT detected. We DON'T OWN the dominant vessel. Switching to {msgData.DominantVesselId}"); SystemsContainer.Get <VesselRemoveSystem>().AddToKillList(FlightGlobals.ActiveVessel.id); SystemsContainer.Get <VesselSwitcherSystem>().SwitchToVessel(msgData.DominantVesselId); WarpSystem.WarpIfSubspaceIsMoreAdvanced(msgData.SubspaceId); } if (FlightGlobals.ActiveVessel?.id == msgData.DominantVesselId && !VesselCommon.IsSpectating) { var newProto = VesselSerializer.DeserializeVessel(msgData.FinalVesselData, msgData.NumBytes); /* This is a strange case were we didn't detect the docking on time and the weak vessel send the new definition... * Usually it happens when a vessel in a future subspace docks with a vessel in the past and the vessel in the past is the dominant vessel * The reason why is bad is because the ModuleDockingNode sent by the WEAK vessel will tell us that we are * NOT the dominant (because we received the vesselproto from the WEAK vessel) so we won't be able to undock properly... * This will be fixed if we go to the space center and reload again the vessel... */ LunaLog.Log("Docking NOT detected. We OWN the dominant vessel"); if (FlightGlobals.FindVessel(msgData.WeakVesselId) != null) { LunaLog.Log($"Weak vessel {msgData.WeakVesselId} still exists in our game. Removing it now"); SystemsContainer.Get <VesselRemoveSystem>().AddToKillList(msgData.WeakVesselId); SystemsContainer.Get <VesselRemoveSystem>().KillVessel(msgData.WeakVesselId); } /* We own the dominant vessel and dind't detected the docking event so we need to reload our OWN vessel * so if we send our own protovessel later, we send the updated definition */ LunaLog.Log($"Creating the missing parts in our own vessel. Current: {FlightGlobals.ActiveVessel.parts.Count} Expected: {newProto.protoPartSnapshots.Count}"); //ProtoToVesselRefresh.CreateMissingPartsInCurrentProtoVessel(FlightGlobals.ActiveVessel, newProto); VesselLoader.ReloadVessel(newProto); LunaLog.Log("Force sending the new proto vessel"); SystemsContainer.Get <VesselProtoSystem>().MessageSender.SendVesselMessage(FlightGlobals.ActiveVessel, true); WarpSystem.WarpIfSubspaceIsMoreAdvanced(msgData.SubspaceId); return; } //Some other 2 players docked so just remove the weak vessel. SystemsContainer.Get <VesselRemoveSystem>().AddToKillList(msgData.WeakVesselId); }
public void DrawContent(int windowId) { GUILayout.BeginVertical(); GUI.DragWindow(MoveRect); DisplayFast = GUILayout.Toggle(DisplayFast, "Fast debug update", ButtonStyle); DisplayVectors = GUILayout.Toggle(DisplayVectors, "Display vessel vectors", ButtonStyle); if (DisplayVectors) { GUILayout.Label(VectorText, LabelStyle); } DisplayOrbit = GUILayout.Toggle(DisplayOrbit, "Display orbit info", ButtonStyle); if (DisplayOrbit) { GUILayout.Label(OrbitText, LabelStyle); } DisplayVesselStoreData = GUILayout.Toggle(DisplayVesselStoreData, "Display vessel store data", ButtonStyle); if (DisplayVesselStoreData) { GUILayout.Label(VesselStoreText, LabelStyle); } DisplayNtp = GUILayout.Toggle(DisplayNtp, "Display NTP/Subspace statistics", ButtonStyle); if (DisplayNtp) { GUILayout.Label(NtpText, LabelStyle); } DisplayConnectionQueue = GUILayout.Toggle(DisplayConnectionQueue, "Display connection statistics", ButtonStyle); if (DisplayConnectionQueue) { GUILayout.Label(ConnectionText, LabelStyle); } if (GUILayout.Button("Reload all vessels", ButtonStyle)) { var protos = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.ProtoVessel); foreach (var proto in protos) { VesselLoader.ReloadVessel(proto); } } GUILayout.EndVertical(); }
private void ReloadSection() { _displayReloads = GUILayout.Toggle(_displayReloads, "Reload vessels", ButtonStyle); if (_displayReloads) { if (GUILayout.Button("Reload own vessel", ButtonStyle)) { VesselLoader.ReloadVessel(FlightGlobals.ActiveVessel?.protoVessel); } if (GUILayout.Button("Reload other vessels", ButtonStyle)) { var protos = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.ProtoVessel); foreach (var proto in protos) { if (FlightGlobals.ActiveVessel?.id == proto.vesselID) { continue; } VesselLoader.ReloadVessel(proto); } } } }
public void DrawContent(int windowId) { GUILayout.BeginVertical(); GUI.DragWindow(MoveRect); DisplayFast = GUILayout.Toggle(DisplayFast, "Fast debug update", ButtonStyle); DisplayVectors = GUILayout.Toggle(DisplayVectors, "Display vessel vectors", ButtonStyle); if (DisplayVectors) { GUILayout.Label(VectorText, LabelStyle); } DisplayOrbit = GUILayout.Toggle(DisplayOrbit, "Display orbit info", ButtonStyle); if (DisplayOrbit) { GUILayout.Label(OrbitText, LabelStyle); } DisplayVesselStoreData = GUILayout.Toggle(DisplayVesselStoreData, "Display vessel store data", ButtonStyle); if (DisplayVesselStoreData) { GUILayout.Label(VesselStoreText, LabelStyle); } DisplayNtp = GUILayout.Toggle(DisplayNtp, "Display NTP/Subspace statistics", ButtonStyle); if (DisplayNtp) { GUILayout.Label(NtpText, LabelStyle); } DisplayConnectionQueue = GUILayout.Toggle(DisplayConnectionQueue, "Display connection statistics", ButtonStyle); if (DisplayConnectionQueue) { GUILayout.Label(ConnectionText, LabelStyle); } if (GUILayout.Button("Reload all vessels", ButtonStyle)) { var protos = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.ProtoVessel); foreach (var proto in protos) { if (FlightGlobals.ActiveVessel?.id == proto.vesselID) { continue; } VesselLoader.ReloadVessel(proto); } } if (GUILayout.Button("Pack all vessels", ButtonStyle)) { var vessels = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.Vessel).Where(v => v != null); foreach (var vessel in vessels) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { continue; } vessel.vesselRanges = DebugUtils.PackRanges; } } if (GUILayout.Button("Unpack all vessels", ButtonStyle)) { var vessels = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.Vessel).Where(v => v != null); foreach (var vessel in vessels) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { continue; } vessel.vesselRanges = DebugUtils.UnPackRanges; } } if (GUILayout.Button("Reset ranges", ButtonStyle)) { var vessels = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.Vessel).Where(v => v != null); foreach (var vessel in vessels) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { continue; } vessel.vesselRanges = PhysicsGlobals.Instance.VesselRangesDefault; } } GUILayout.EndVertical(); }
public override void DrawWindowContent(int windowId) { GUILayout.BeginVertical(); GUI.DragWindow(MoveRect); var newVal = GUILayout.Toggle(_saveCurrentOrbitData, "Save orbit data to file", ButtonStyle); if (newVal != _saveCurrentOrbitData) { _saveCurrentOrbitData = newVal; if (newVal) { CreateNewOrbitDataFile(); } } if (GUILayout.Button("Force time sync", ButtonStyle)) { TimeSyncerSystem.Singleton.ForceTimeSync(); } if (GUILayout.Button("Reload own vessel", ButtonStyle)) { VesselLoader.ReloadVessel(FlightGlobals.ActiveVessel?.protoVessel); } if (GUILayout.Button("Reload other vessels", ButtonStyle)) { var protos = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.ProtoVessel); foreach (var proto in protos) { if (FlightGlobals.ActiveVessel?.id == proto.vesselID) { continue; } VesselLoader.ReloadVessel(proto); } } if (GUILayout.Button("Pack all vessels", ButtonStyle)) { var vessels = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.Vessel).Where(v => v != null); foreach (var vessel in vessels) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { continue; } vessel.vesselRanges = ToolsUtils.PackRanges; } } if (GUILayout.Button("Unpack all vessels", ButtonStyle)) { var vessels = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.Vessel).Where(v => v != null); foreach (var vessel in vessels) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { continue; } vessel.vesselRanges = ToolsUtils.UnPackRanges; } } if (GUILayout.Button("Reset ranges", ButtonStyle)) { var vessels = VesselsProtoStore.AllPlayerVessels.Values.Select(v => v.Vessel).Where(v => v != null); foreach (var vessel in vessels) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { continue; } vessel.vesselRanges = PhysicsGlobals.Instance.VesselRangesDefault; } } GUILayout.EndVertical(); }