当前位置: 首页>>代码示例>>C#>>正文


C# ProtoVessel.Save方法代码示例

本文整理汇总了C#中ProtoVessel.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoVessel.Save方法的具体用法?C# ProtoVessel.Save怎么用?C# ProtoVessel.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProtoVessel的用法示例。


在下文中一共展示了ProtoVessel.Save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Save

 public void Save()
 {
     if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (FlightGlobals.fetch.activeVessel != null))
     {
         if (FlightGlobals.fetch.activeVessel.loaded && !FlightGlobals.fetch.activeVessel.packed)
         {
             if (FlightGlobals.fetch.activeVessel.situation != Vessel.Situations.FLYING)
             {
                 savedVessel = new ConfigNode();
                 ProtoVessel tempVessel = new ProtoVessel(FlightGlobals.fetch.activeVessel);
                 tempVessel.Save(savedVessel);
                 savedSubspace = new Subspace();
                 savedSubspace.planetTime = Planetarium.GetUniversalTime();
                 savedSubspace.serverClock = TimeSyncer.fetch.GetServerClock();
                 savedSubspace.subspaceSpeed = 1f;
                 ScreenMessages.PostScreenMessage("Quicksaved!", 3f, ScreenMessageStyle.UPPER_CENTER);
             }
             else
             {
                 ScreenMessages.PostScreenMessage("Cannot quicksave - Active vessel is in flight!", 3f, ScreenMessageStyle.UPPER_CENTER);
             }
         }
         else
         {
             ScreenMessages.PostScreenMessage("Cannot quicksave - Active vessel is not loaded!", 3f, ScreenMessageStyle.UPPER_CENTER);
         }
     }
     else
     {
         ScreenMessages.PostScreenMessage("Cannot quicksave - Not in flight!", 3f, ScreenMessageStyle.UPPER_CENTER);
     }
 }
开发者ID:martindevans,项目名称:DarkMultiPlayer,代码行数:32,代码来源:QuickSaveLoader.cs

示例2: vesselSnapshot

 public static ConfigNode vesselSnapshot(Vessel vessel)
 {
     ProtoVessel snapshot = new ProtoVessel(vessel);
     ConfigNode node = new ConfigNode("VESSEL");
     snapshot.Save(node);
     return node;
 }
开发者ID:Amorymeltzer,项目名称:KIS,代码行数:7,代码来源:KIS_Shared.cs

示例3: isProtoVesselInSafetyBubble

 private bool isProtoVesselInSafetyBubble(ProtoVessel protovessel)
 {
     //When vessels are landed, position is 0,0,0 - So we need to check lat/long
     ConfigNode protoVesselNode = new ConfigNode();
     protovessel.Save(protoVesselNode);
     CelestialBody kerbinBody = FlightGlobals.Bodies.Find (b => b.name == "Kerbin");
     //If not kerbin, we aren't in the safety bubble.
     if (protoVesselNode.GetNode("ORBIT").GetValue("REF") != "1") {
         return false;
     }
     //If we aren't landed, use the vector3 check above.
     if (!protovessel.landed) {
         return isInSafetyBubble (protovessel.position, kerbinBody, protovessel.altitude);
     }
     //Check our distance
     double protoVesselLat;
     double protoVesselLong;
     Double.TryParse(protoVesselNode.GetValue("lat"), out protoVesselLat);
     Double.TryParse(protoVesselNode.GetValue("long"), out protoVesselLong);
     Vector3d kscPosition = kerbinBody.GetWorldSurfacePosition(-0.102668048654,-74.5753856554,60);
     Vector3d protoVesselPosition = kerbinBody.GetWorldSurfacePosition(protoVesselLat, protoVesselLong, protovessel.altitude);
     double vesselDistance = Vector3d.Distance(kscPosition, protoVesselPosition);
     return vesselDistance < safetyBubbleRadius;
 }
开发者ID:ruarai,项目名称:KerbalMultiPlayer,代码行数:24,代码来源:KMPManager.cs

示例4: LoadVesselsIntoGame

 //Called from main
 public void LoadVesselsIntoGame()
 {
     DarkLog.Debug("Loading vessels into game");
     foreach (KeyValuePair<string, Queue<VesselProtoUpdate>> vesselQueue in vesselProtoQueue)
     {
         while (vesselQueue.Value.Count > 0)
         {
             ConfigNode currentNode = vesselQueue.Value.Dequeue().vesselNode;
             if (currentNode != null)
             {
                 DodgeVesselActionGroups(currentNode);
                 DodgeVesselCrewValues(currentNode);
                 RemoveManeuverNodesFromProtoVessel(currentNode);
                 ProtoVessel pv = new ProtoVessel(currentNode, HighLogic.CurrentGame);
                 if (pv != null)
                 {
                     bool protovesselIsOk = true;
                     try
                     {
                         ConfigNode cn = new ConfigNode();
                         pv.Save(cn);
                     }
                     catch
                     {
                         DarkLog.Debug("WARNING: Protovessel " + pv.vesselID + ", name: " + pv.vesselName + " is DAMAGED!. Skipping load.");
                         ChatWorker.fetch.PMMessageServer("WARNING: Protovessel " + pv.vesselID + ", name: " + pv.vesselName + " is DAMAGED!. Skipping load.");
                         protovesselIsOk = false;
                     }
                     if (protovesselIsOk)
                     {
                         RegisterServerVessel(pv.vesselID.ToString());
                         RegisterServerAsteriodIfVesselIsAsteroid(pv);
                         HighLogic.CurrentGame.flightState.protoVessels.Add(pv);
                     }
                 }
             }
         }
     }
     DarkLog.Debug("Vessels loaded into game");
 }
开发者ID:martindevans,项目名称:DarkMultiPlayer,代码行数:41,代码来源:VesselWorker.cs

示例5: CreateSafeProtoVesselFromConfigNode

        private ProtoVessel CreateSafeProtoVesselFromConfigNode(ConfigNode inputNode, Guid protovesselID)
        {
            ProtoVessel pv = null;
            try
            {
                DodgeVesselActionGroups(inputNode);
                RemoveManeuverNodesFromProtoVessel(inputNode);
                DodgeVesselLandedStatus(inputNode);
                KerbalReassigner.fetch.DodgeKerbals(inputNode, protovesselID);
                pv = new ProtoVessel(inputNode, HighLogic.CurrentGame);
                ConfigNode cn = new ConfigNode();
                pv.Save(cn);
                List<string> partsList = null;
                PartResourceLibrary partResourceLibrary = PartResourceLibrary.Instance;
                if (ModWorker.fetch.modControl != ModControlMode.DISABLED)
                {
                    partsList = ModWorker.fetch.GetAllowedPartsList();
                }

                foreach (ProtoPartSnapshot pps in pv.protoPartSnapshots)
                {
                    if (ModWorker.fetch.modControl != ModControlMode.DISABLED)
                    {
                        if (!partsList.Contains(pps.partName))
                        {
                            DarkLog.Debug("WARNING: Protovessel " + protovesselID + " (" + pv.vesselName + ") contains the banned part '" + pps.partName + "'!. Skipping load.");
                            ChatWorker.fetch.PMMessageServer("WARNING: Protovessel " + protovesselID + " (" + pv.vesselName + ") contains the banned part '" + pps.partName + "'!. Skipping load.");
                            pv = null;
                            break;
                        }
                    }
                    if (pps.partInfo == null)
                    {
                        DarkLog.Debug("WARNING: Protovessel " + protovesselID + " (" + pv.vesselName + ") contains the missing part '" + pps.partName + "'!. Skipping load.");
                        ChatWorker.fetch.PMMessageServer("WARNING: Protovessel " + protovesselID + " (" + pv.vesselName + ") contains the missing part '" + pps.partName + "'!. Skipping load.");
                        ScreenMessages.PostScreenMessage("Cannot load '" + pv.vesselName + "' - you are missing " + pps.partName, 10f, ScreenMessageStyle.UPPER_CENTER);
                        pv = null;
                        break;
                    }
                    foreach (ProtoPartResourceSnapshot resource in pps.resources)
                    {
                        if (!partResourceLibrary.resourceDefinitions.Contains(resource.resourceName))
                        {
                            DarkLog.Debug("WARNING: Protovessel " + protovesselID + " (" + pv.vesselName + ") contains the missing resource '" + resource.resourceName + "'!. Skipping load.");
                            ChatWorker.fetch.PMMessageServer("WARNING: Protovessel " + protovesselID + " (" + pv.vesselName + ") contains the missing resource '" + resource.resourceName + "'!. Skipping load.");
                            ScreenMessages.PostScreenMessage("Cannot load '" + pv.vesselName + "' - you are missing the resource " + resource.resourceName, 10f, ScreenMessageStyle.UPPER_CENTER);
                            pv = null;
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                DarkLog.Debug("Damaged vessel " + protovesselID + ", exception: " + e);
                pv = null;
            }
            return pv;
        }
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:59,代码来源:VesselWorker.cs

示例6: SendVesselProtoMessage

        //Called from vesselWorker
        public void SendVesselProtoMessage(ProtoVessel vessel, bool isDockingUpdate, bool isFlyingUpdate)
        {
            ConfigNode vesselNode = new ConfigNode();
            ClientMessage newMessage = new ClientMessage();
            newMessage.type = ClientMessageType.VESSEL_PROTO;
            vessel.Save(vesselNode);

            byte[] vesselBytes = ConfigNodeSerializer.fetch.Serialize(vesselNode);

            if (vesselBytes != null && vesselBytes.Length > 0)
            {
                UniverseSyncCache.fetch.SaveToCache(vesselBytes);
                using (MessageWriter mw = new MessageWriter())
                {
                    mw.Write<double>(Planetarium.GetUniversalTime());
                    mw.Write<string>(vessel.vesselID.ToString());
                    mw.Write<bool>(isDockingUpdate);
                    mw.Write<bool>(isFlyingUpdate);
                    mw.Write<byte[]>(vesselBytes);
                    newMessage.data = mw.GetMessageBytes();
                }
                DarkLog.Debug("Sending vessel " + vessel.vesselID + ", name " + vessel.vesselName + ", type: " + vessel.vesselType + ", size: " + newMessage.data.Length);
                QueueOutgoingMessage(newMessage, false);
            }
            else
            {
                DarkLog.Debug("Failed to create byte[] data for " + vessel.vesselID);
            }
        }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:30,代码来源:NetworkWorker.cs

示例7: SendVesselProtoMessage

 //Called from vesselWorker
 public void SendVesselProtoMessage(ProtoVessel vessel, bool isDockingUpdate, bool isFlyingUpdate)
 {
     //Defend against NaN orbits
     if (VesselHasNaNPosition(vessel))
     {
         DarkLog.Debug("Vessel " + vessel.vesselID + " has NaN position");
         return;
     }
     foreach (ProtoPartSnapshot pps in vessel.protoPartSnapshots)
     {
         foreach (ProtoCrewMember pcm in pps.protoModuleCrew.ToArray())
         {
             if (pcm.type == ProtoCrewMember.KerbalType.Tourist)
             {
                 pps.protoModuleCrew.Remove(pcm);
             }
         }
     }
     ConfigNode vesselNode = new ConfigNode();
     vessel.Save(vesselNode);
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.VESSEL_PROTO;
     byte[] vesselBytes = ConfigNodeSerializer.fetch.Serialize(vesselNode);
     File.WriteAllBytes(Path.Combine(KSPUtil.ApplicationRootPath, "lastVessel.txt"), vesselBytes);
     if (vesselBytes != null && vesselBytes.Length > 0)
     {
         UniverseSyncCache.fetch.QueueToCache(vesselBytes);
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<string>(vessel.vesselID.ToString());
             mw.Write<bool>(isDockingUpdate);
             mw.Write<bool>(isFlyingUpdate);
             mw.Write<byte[]>(Compression.CompressIfNeeded(vesselBytes));
             newMessage.data = mw.GetMessageBytes();
         }
         DarkLog.Debug("Sending vessel " + vessel.vesselID + ", name " + vessel.vesselName + ", type: " + vessel.vesselType + ", size: " + newMessage.data.Length);
         QueueOutgoingMessage(newMessage, false);
     }
     else
     {
         DarkLog.Debug("Failed to create byte[] data for " + vessel.vesselID);
     }
 }
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:45,代码来源:NetworkWorker.cs

示例8: SendVesselProtoMessage

 //Called from vesselWorker
 public void SendVesselProtoMessage(ProtoVessel vessel, bool isDockingUpdate)
 {
     ConfigNode currentNode = new ConfigNode();
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.VESSEL_PROTO;
     vessel.Save(currentNode);
     string tempFile = Path.GetTempFileName();
     currentNode.Save(tempFile);
     using (StreamReader sr = new StreamReader(tempFile))
     {
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<int>(TimeSyncer.fetch.currentSubspace);
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<string>(vessel.vesselID.ToString());
             mw.Write<bool>(isDockingUpdate);
             mw.Write<byte[]>(File.ReadAllBytes(tempFile));
             newMessage.data = mw.GetMessageBytes();
         }
     }
     File.Delete(tempFile);
     DarkLog.Debug("Sending vessel " + vessel.vesselID + ", name " + vessel.vesselName + ", type: " + vessel.vesselType + ", size: " + newMessage.data.Length);
     sendMessageQueueLow.Enqueue(newMessage);
 }
开发者ID:Norgg,项目名称:DarkMultiPlayer,代码行数:25,代码来源:NetworkWorker.cs

示例9: ProtoVesselToCraftFile

        /**
         * Don't actually use this!
         * */
        public static ConfigNode ProtoVesselToCraftFile(ProtoVessel vessel)
        {
            ConfigNode craft = new ConfigNode("ShipNode");
            ConfigNode pvNode = new ConfigNode();
            vessel.Save(pvNode);
            //KCTDebug.Log(pvNode);

            craft.AddValue("ship", pvNode.GetValue("name"));
            craft.AddValue("version", Versioning.GetVersionString());
            craft.AddValue("description", "Craft file converted automatically by Kerbal Construction Time.");
            craft.AddValue("type", "VAB");
            ConfigNode[] parts = pvNode.GetNodes("PART");
            foreach (ConfigNode part in parts)
            {
                ConfigNode newPart = new ConfigNode("PART");
                newPart.AddValue("part", part.GetValue("name") + "_" + part.GetValue("uid"));
                newPart.AddValue("partName", "Part");
                newPart.AddValue("pos", part.GetValue("position"));
                newPart.AddValue("rot", part.GetValue("rotation"));
                newPart.AddValue("attRot", part.GetValue("rotation"));
                newPart.AddValue("mir", part.GetValue("mirror"));
                newPart.AddValue("istg", part.GetValue("istg"));
                newPart.AddValue("dstg", part.GetValue("dstg"));
                newPart.AddValue("sidx", part.GetValue("sidx"));
                newPart.AddValue("sqor", part.GetValue("sqor"));
                newPart.AddValue("attm", part.GetValue("attm"));
                newPart.AddValue("modCost", part.GetValue("modCost"));

                foreach (string attn in part.GetValues("attN"))
                {
                    string attach_point = attn.Split(',')[0];
                    if (attach_point == "None")
                        continue;
                    int attachedIndex = int.Parse(attn.Split(',')[1]);
                    string attached = parts[attachedIndex].GetValue("name") + "_" + parts[attachedIndex].GetValue("uid");
                    newPart.AddValue("link", attached);
                    newPart.AddValue("attN", attach_point + "," + attached);
                }

                newPart.AddNode(part.GetNode("EVENTS"));
                newPart.AddNode(part.GetNode("ACTIONS"));
                foreach (ConfigNode mod in part.GetNodes("MODULE"))
                    newPart.AddNode(mod);
                foreach (ConfigNode rsc in part.GetNodes("RESOURCE"))
                    newPart.AddNode(rsc);
                craft.AddNode(newPart);
            }

            return craft;
        }
开发者ID:Kerbas-ad-astra,项目名称:KCT,代码行数:53,代码来源:KCT_Utilities.cs

示例10: InitKMPVesselUpdate

 private void InitKMPVesselUpdate(Vessel _vessel, bool includeProtoVessel)
 {
     pos = new float[3];
     dir = new float[3];
     vel = new float[3];
     o_vel = new double[3];
     s_vel = new double[3];
     w_pos = new double[3];
     rot = new float[4];
     id = _vessel.id;
     if (_vessel.packed)
     {
         flightCtrlState = new KMPFlightCtrlState(new FlightCtrlState());
     }
     else
     {
         flightCtrlState = new KMPFlightCtrlState(_vessel.ctrlState);
     }
     if (includeProtoVessel)
     {
         protoVesselNode = new ConfigNode();
         ProtoVessel proto;
         try
         {
             proto = new ProtoVessel(_vessel);
         }
         catch (Exception e)
         {
             Log.Debug("Exception thrown in InitKMPVesselUpdate(), catch 1, Exception: {0}", e.ToString());
             proto = null;
         }
         if (proto != null)
         {
             foreach (ProtoCrewMember crewMember in proto.GetVesselCrew())
             {
                 crewMember.KerbalRef = null;
             }
             proto.Save(protoVesselNode);
         }
     }
 }
开发者ID:TehGimp,项目名称:KerbalMultiPlayer,代码行数:41,代码来源:KMPVesselUpdate.cs

示例11: SendVesselProtoMessage

 //Called from vesselWorker
 public void SendVesselProtoMessage(ProtoVessel vessel, bool isDockingUpdate)
 {
     ConfigNode vesselNode = new ConfigNode();
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.VESSEL_PROTO;
     vessel.Save(vesselNode);
     byte[] vesselBytes = ConvertConfigNodeToByteArray(vesselNode);
     if (vesselBytes != null)
     {
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<int>(TimeSyncer.fetch.currentSubspace);
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<string>(vessel.vesselID.ToString());
             mw.Write<bool>(isDockingUpdate);
             mw.Write<byte[]>(vesselBytes);
             newMessage.data = mw.GetMessageBytes();
         }
         DarkLog.Debug("Sending vessel " + vessel.vesselID + ", name " + vessel.vesselName + ", type: " + vessel.vesselType + ", size: " + newMessage.data.Length);
         sendMessageQueueLow.Enqueue(newMessage);
     }
     else
     {
         DarkLog.Debug("Failed to create byte[] data for " + vessel.vesselID);
     }
 }
开发者ID:nevercast,项目名称:DarkMultiPlayer,代码行数:27,代码来源:NetworkWorker.cs

示例12: SendVesselProtoMessage

        //Called from vesselWorker
        public void SendVesselProtoMessage(ProtoVessel vessel, bool isDockingUpdate, bool isFlyingUpdate)
        {
            //Defend against NaN orbits
            if (VesselHasNaNPosition(vessel))
            {
                DarkLog.Debug("Vessel " + vessel.vesselID + " has NaN position");
                return;
            }

            bool isContractVessel = false;
            foreach (ProtoPartSnapshot pps in vessel.protoPartSnapshots)
            {
                foreach (ProtoCrewMember pcm in pps.protoModuleCrew.ToArray())
                {
                    if (pcm.type == ProtoCrewMember.KerbalType.Tourist)
                    {
                        isContractVessel = true;
                    }
                }
            }
            if (!AsteroidWorker.fetch.VesselIsAsteroid(vessel) && (DiscoveryLevels)Int32.Parse(vessel.discoveryInfo.GetValue("state")) != DiscoveryLevels.Owned)
            {
                isContractVessel = true;
            }
            ConfigNode vesselNode = new ConfigNode();
            vessel.Save(vesselNode);
            if (isContractVessel)
            {
                ConfigNode dmpNode = new ConfigNode();
                dmpNode.AddValue("contractOwner", Settings.fetch.playerPublicKey);
                vesselNode.AddNode("DarkMultiPlayer", dmpNode);
            }

            ClientMessage newMessage = new ClientMessage();
            newMessage.type = ClientMessageType.VESSEL_PROTO;
            byte[] vesselBytes = ConfigNodeSerializer.fetch.Serialize(vesselNode);
            File.WriteAllBytes(Path.Combine(KSPUtil.ApplicationRootPath, "lastVessel.txt"), vesselBytes);
            if (vesselBytes != null && vesselBytes.Length > 0)
            {
                UniverseSyncCache.fetch.QueueToCache(vesselBytes);
                using (MessageWriter mw = new MessageWriter())
                {
                    mw.Write<double>(Planetarium.GetUniversalTime());
                    mw.Write<string>(vessel.vesselID.ToString());
                    mw.Write<bool>(isDockingUpdate);
                    mw.Write<bool>(isFlyingUpdate);
                    mw.Write<byte[]>(Compression.CompressIfNeeded(vesselBytes));
                    newMessage.data = mw.GetMessageBytes();
                }
                DarkLog.Debug("Sending vessel " + vessel.vesselID + ", name " + vessel.vesselName + ", type: " + vessel.vesselType + ", size: " + newMessage.data.Length);
                QueueOutgoingMessage(newMessage, false);
            }
            else
            {
                DarkLog.Debug("Failed to create byte[] data for " + vessel.vesselID);
            }
        }
开发者ID:citruspress,项目名称:DarkMultiPlayer,代码行数:58,代码来源:NetworkWorker.cs


注:本文中的ProtoVessel.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。