コード例 #1
0
 /// <summary>
 /// Removes a vessel from the loading system. If we receive a protovessel msg after this method is called it will be reloaded
 /// </summary>
 /// <param name="vesselId"></param>
 public void RemoveVesselFromLoadingSystem(Guid vesselId)
 {
     if (AllPlayerVessels.ContainsKey(vesselId))
     {
         AllPlayerVessels.TryRemove(vesselId, out var _);
     }
 }
コード例 #2
0
        /// <summary>
        /// Check vessels that must be loaded
        /// </summary>
        private void CheckVesselsToLoad()
        {
            try
            {
                if (ProtoSystemBasicReady)
                {
                    //Try to remove proto messages to own vessel
                    if (!VesselCommon.IsSpectating && FlightGlobals.ActiveVessel != null)
                    {
                        AllPlayerVessels.TryRemove(FlightGlobals.ActiveVessel.id, out _);
                    }

                    //Reload vessels that exist
                    var vesselsToReLoad = AllPlayerVessels
                                          .Where(v => !v.Value.Loaded && FlightGlobals.Vessels.Any(vl => vl.id == v.Value.VesselId))
                                          .ToArray();

                    foreach (var vesselProto in vesselsToReLoad)
                    {
                        bool vesselLoaded = VesselLoader.ReloadVesselIfChanged(vesselProto.Value);
                        if (vesselLoaded && !SettingsSystem.CurrentSettings.UseAlternativePositionSystem)
                        {
                            //TODO: This call will not put the vessel in the right position if a long time has elapsed between when the update was generated and when it's being applied, if in atmo.
                            //TODO: This is because positions are set via ballistic orbits, which don't extrapolate properly in atmo.
                            SystemsContainer.Get <VesselPositionSystem>().UpdateVesselPositionOnNextFixedUpdate(vesselProto.Value.VesselId);
                        }
                    }

                    //Load vessels that don't exist and are in our subspace
                    var vesselsToLoad = AllPlayerVessels
                                        .Where(v => !v.Value.Loaded && FlightGlobals.Vessels.All(vl => vl.id != v.Value.VesselId) &&
                                               (SettingsSystem.ServerSettings.ShowVesselsInThePast || !VesselCommon.VesselIsControlledAndInPastSubspace(v.Value.VesselId)))
                                        .ToArray();

                    foreach (var vesselProto in vesselsToLoad)
                    {
                        VesselLoader.LoadVessel(vesselProto.Value);

                        if (!SettingsSystem.CurrentSettings.UseAlternativePositionSystem)
                        {
                            //TODO: This call will not put the vessel in the right position if a long time has elapsed between when the update was generated and when it's being applied, if in atmo.
                            //TODO: This is because positions are set via ballistic orbits, which don't extrapolate properly in atmo.
                            SystemsContainer.Get <VesselPositionSystem>().UpdateVesselPositionOnNextFixedUpdate(vesselProto.Value.VesselId);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LunaLog.LogError($"[LMP]: Error in CheckVesselsToLoad {e}");
            }
        }
コード例 #3
0
 /// <summary>
 /// Removes a vessel from the loading system. If we receive a protovessel msg after this method is called it will be reloaded
 /// </summary>
 public void RemoveVesselFromLoadingSystem(Guid vesselId)
 {
     AllPlayerVessels.TryRemove(vesselId, out var _);
 }