Exemplo n.º 1
0
        /// <summary>
        /// In this method we get the new vessel data and set it to the dictionary of all the player vessels.
        /// We set it as UNLOADED as perhaps vessel data has changed.
        /// </summary>
        public void HandleVesselProtoData(byte[] vesselData, Guid vesselId)
        {
            TaskFactory.StartNew(() =>
            {
                UniverseSyncCache.QueueToCache(vesselData);
                var vesselNode = ConfigNodeSerializer.Deserialize(vesselData);
                if (vesselNode != null && vesselId == Common.ConvertConfigStringToGuid(vesselNode.GetValue("pid")))
                {
                    var vesselProtoUpdate = new VesselProtoUpdate(vesselNode, vesselId);
                    if (vesselProtoUpdate.ProtoVessel == null)
                    {
                        return;
                    }

                    if (!AllPlayerVessels.TryGetValue(vesselId, out var existingProtoData))
                    {
                        AllPlayerVessels.TryAdd(vesselId, vesselProtoUpdate);
                    }
                    else if (VesselCommon.ProtoVesselHasChanges(existingProtoData.ProtoVessel, vesselProtoUpdate.ProtoVessel))
                    {
                        //Vessel exists and contain changes so replace it
                        AllPlayerVessels.TryUpdate(vesselId, vesselProtoUpdate, existingProtoData);
                    }
                }
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sets a vessel as unloaded so it can be recreated later.
 /// For example if you leave a subspace the vessel must still be in the system but it should be unloaded
 /// </summary>
 public void UnloadVesselFromLoadingSystem(Guid vesselId)
 {
     if (AllPlayerVessels.TryGetValue(vesselId, out var existingProtoUpdate))
     {
         AllPlayerVessels.TryUpdate(vesselId, new VesselProtoUpdate(existingProtoUpdate), existingProtoUpdate);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the vesselProto from the dictionary in a thread safe manner
 /// </summary>
 private void UpdateVesselProtoInDictionary(VesselProtoUpdate vesselProto)
 {
     AllPlayerVessels.TryGetValue(vesselProto.VesselId, out var existingVesselProto);
     if (existingVesselProto != null)
     {
         AllPlayerVessels.TryUpdate(vesselProto.VesselId, vesselProto, existingVesselProto);
     }
 }