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


C# ProtoCrewMember.Save方法代码示例

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


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

示例1: SendKerbalIfDifferent

 public void SendKerbalIfDifferent(ProtoCrewMember pcm)
 {
     if (pcm.type == ProtoCrewMember.KerbalType.Tourist)
     {
         //Don't send tourists
         DarkLog.Debug("Skipping sending of tourist: " + pcm.name);
         return;
     }
     ConfigNode kerbalNode = new ConfigNode();
     pcm.Save(kerbalNode);
     byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
     if (kerbalBytes == null || kerbalBytes.Length == 0)
     {
         DarkLog.Debug("VesselWorker: Error sending kerbal - bytes are null or 0");
         return;
     }
     string kerbalHash = Common.CalculateSHA256Hash(kerbalBytes);
     bool kerbalDifferent = false;
     if (!serverKerbals.ContainsKey(pcm.name))
     {
         //New kerbal
         DarkLog.Debug("Found new kerbal, sending...");
         kerbalDifferent = true;
     }
     else if (serverKerbals[pcm.name] != kerbalHash)
     {
         DarkLog.Debug("Found changed kerbal (" + pcm.name + "), sending...");
         kerbalDifferent = true;
     }
     if (kerbalDifferent)
     {
         serverKerbals[pcm.name] = kerbalHash;
         NetworkWorker.fetch.SendKerbalProtoMessage(pcm.name, kerbalBytes);
     }
 }
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:35,代码来源:VesselWorker.cs

示例2: LoadKerbal

 private void LoadKerbal(ConfigNode crewNode)
 {
     if (crewNode == null)
     {
         DarkLog.Debug("crewNode is null!");
         return;
     }
     ProtoCrewMember protoCrew = new ProtoCrewMember(HighLogic.CurrentGame.Mode, crewNode);
     if (protoCrew == null)
     {
         DarkLog.Debug("protoCrew is null!");
         return;
     }
     if (String.IsNullOrEmpty(protoCrew.name))
     {
         DarkLog.Debug("protoName is blank!");
         return;
     }
     protoCrew.type = ProtoCrewMember.KerbalType.Crew;
     if (!HighLogic.CurrentGame.CrewRoster.Exists(protoCrew.name))
     {
         AddCrewMemberToRoster(protoCrew);
         ConfigNode kerbalNode = new ConfigNode();
         protoCrew.Save(kerbalNode);
         byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
         if (kerbalBytes != null && kerbalBytes.Length != 0)
         {
             serverKerbals[protoCrew.name] = Common.CalculateSHA256Hash(kerbalBytes);
         }
     }
     else
     {
         ConfigNode careerLogNode = crewNode.GetNode("CAREER_LOG");
         if (careerLogNode != null)
         {
             //This method is broken. Thanks squad.
             HighLogic.CurrentGame.CrewRoster[protoCrew.name].careerLog.Load(careerLogNode);
         }
         else
         {
             DarkLog.Debug("Career log node for " + protoCrew.name + " is empty!");
         }
         ConfigNode flightLogNode = crewNode.GetNode("FLIGHT_LOG");
         if (careerLogNode != null)
         {
             //This method is broken. Thanks squad.
             HighLogic.CurrentGame.CrewRoster[protoCrew.name].flightLog.Load(flightLogNode);
         }
         else
         {
             DarkLog.Debug("Flight log node for " + protoCrew.name + " is empty!");
         }
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].courage = protoCrew.courage;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].experience = protoCrew.experience;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].experienceLevel = protoCrew.experienceLevel;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].gender = protoCrew.gender;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].hasToured = protoCrew.hasToured;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].isBadass = protoCrew.isBadass;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].rosterStatus = protoCrew.rosterStatus;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].seat = protoCrew.seat;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].seatIdx = protoCrew.seatIdx;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].stupidity = protoCrew.stupidity;
         HighLogic.CurrentGame.CrewRoster[protoCrew.name].UTaR = protoCrew.UTaR;
     }
 }
开发者ID:awdAvenger,项目名称:DarkMultiPlayer,代码行数:65,代码来源:VesselWorker.cs

示例3: SendKerbalProtoMessage

 //Called from vesselWorker
 public void SendKerbalProtoMessage(ProtoCrewMember kerbal)
 {
     ConfigNode kerbalNode = new ConfigNode();
     kerbal.Save(kerbalNode);
     byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
     if (kerbalBytes != null && kerbalBytes.Length > 0)
     {
         ClientMessage newMessage = new ClientMessage();
         newMessage.type = ClientMessageType.KERBAL_PROTO;
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<string>(kerbal.name);
             mw.Write<byte[]>(kerbalBytes);
             newMessage.data = mw.GetMessageBytes();
         }
         DarkLog.Debug("Sending kerbal " + kerbal.name + ", size: " + newMessage.data.Length);
         QueueOutgoingMessage(newMessage, false);
     }
     else
     {
         DarkLog.Debug("Failed to create byte[] data for kerbal " + kerbal.name);
     }
 }
开发者ID:GrantTaylor,项目名称:DarkMultiPlayer,代码行数:25,代码来源:NetworkWorker.cs

示例4: LoadKerbal

        private void LoadKerbal(ConfigNode crewNode)
        {
            if (crewNode == null)
            {
                DarkLog.Debug("crewNode is null!");
                return;
            }

            if (crewNode.GetValue("type") == "Tourist")
            {
                ConfigNode dmpNode = null;
                if (crewNode.TryGetNode("DarkMultiPlayer", ref dmpNode))
                {
                    string dmpOwner = null;
                    if (dmpNode.TryGetValue("touristOwner", ref dmpOwner))
                    {
                        if (dmpOwner != Settings.fetch.playerPublicKey)
                        {
                            DarkLog.Debug("Skipping load of tourist that belongs to another player");
                            return;
                        }
                    }
                }
            }

            ProtoCrewMember protoCrew = new ProtoCrewMember(HighLogic.CurrentGame.Mode, crewNode);
            if (protoCrew == null)
            {
                DarkLog.Debug("protoCrew is null!");
                return;
            }
            if (string.IsNullOrEmpty(protoCrew.name))
            {
                DarkLog.Debug("protoName is blank!");
                return;
            }
            if (!HighLogic.CurrentGame.CrewRoster.Exists(protoCrew.name))
            {
                AddCrewMemberToRoster(protoCrew);
                ConfigNode kerbalNode = new ConfigNode();
                protoCrew.Save(kerbalNode);
                byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
                if (kerbalBytes != null && kerbalBytes.Length != 0)
                {
                    serverKerbals[protoCrew.name] = Common.CalculateSHA256Hash(kerbalBytes);
                }
            }
            else
            {
                ConfigNode careerLogNode = crewNode.GetNode("CAREER_LOG");
                if (careerLogNode != null)
                {
                    //Insert wolf howling at the moon here
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].careerLog.Entries.Clear();
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].careerLog.Load(careerLogNode);
                }
                else
                {
                    DarkLog.Debug("Career log node for " + protoCrew.name + " is empty!");
                }

                ConfigNode flightLogNode = crewNode.GetNode("FLIGHT_LOG");
                if (flightLogNode != null)
                {
                    //And here. Someone "cannot into" lists and how to protect them.
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].flightLog.Entries.Clear();
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].flightLog.Load(flightLogNode);
                }

                HighLogic.CurrentGame.CrewRoster[protoCrew.name].courage = protoCrew.courage;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].experience = protoCrew.experience;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].experienceLevel = protoCrew.experienceLevel;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].experienceTrait = protoCrew.experienceTrait;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].gender = protoCrew.gender;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].gExperienced = protoCrew.gExperienced;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].hasToured = protoCrew.hasToured;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].isBadass = protoCrew.isBadass;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].KerbalRef = protoCrew.KerbalRef;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].outDueToG = protoCrew.outDueToG;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].rosterStatus = protoCrew.rosterStatus;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].seat = protoCrew.seat;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].seatIdx = protoCrew.seatIdx;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].stupidity = protoCrew.stupidity;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].trait = protoCrew.trait;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].type = protoCrew.type;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].UTaR = protoCrew.UTaR;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].veteran = protoCrew.veteran;
            }
        }
开发者ID:citruspress,项目名称:DarkMultiPlayer,代码行数:89,代码来源:VesselWorker.cs

示例5: SendKerbalProtoMessage

 //Called from vesselWorker
 public void SendKerbalProtoMessage(int kerbalID, ProtoCrewMember kerbal)
 {
     ConfigNode currentNode = new ConfigNode();
     ClientMessage newMessage = new ClientMessage();
     newMessage.type = ClientMessageType.KERBAL_PROTO;
     kerbal.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<int>(kerbalID);
             mw.Write<byte[]>(File.ReadAllBytes(tempFile));
             newMessage.data = mw.GetMessageBytes();
         }
     }
     File.Delete(tempFile);
     DarkLog.Debug("Sending kerbal " + kerbal.name + ", size: " + newMessage.data.Length);
     sendMessageQueueLow.Enqueue(newMessage);
 }
开发者ID:Norgg,项目名称:DarkMultiPlayer,代码行数:24,代码来源:NetworkWorker.cs

示例6: SendKerbalProtoMessage

 //Called from vesselWorker
 public void SendKerbalProtoMessage(int kerbalID, ProtoCrewMember kerbal)
 {
     ConfigNode kerbalNode = new ConfigNode();
     //Dodge the available status - Too many kerbals are getting created.
     kerbal.rosterStatus = ProtoCrewMember.RosterStatus.AVAILABLE;
     kerbal.Save(kerbalNode);
     byte[] kerbalBytes = ConvertConfigNodeToByteArray(kerbalNode);
     if (kerbalBytes != null)
     {
         ClientMessage newMessage = new ClientMessage();
         newMessage.type = ClientMessageType.KERBAL_PROTO;
         using (MessageWriter mw = new MessageWriter())
         {
             mw.Write<int>(TimeSyncer.fetch.currentSubspace);
             mw.Write<double>(Planetarium.GetUniversalTime());
             mw.Write<int>(kerbalID);
             mw.Write<byte[]>(kerbalBytes);
             newMessage.data = mw.GetMessageBytes();
         }
         DarkLog.Debug("Sending kerbal " + kerbal.name + ", size: " + newMessage.data.Length);
         sendMessageQueueLow.Enqueue(newMessage);
     }
     else
     {
         DarkLog.Debug("Failed to create byte[] data for kerbal " + kerbalID);
     }
 }
开发者ID:nevercast,项目名称:DarkMultiPlayer,代码行数:28,代码来源:NetworkWorker.cs

示例7: SendKerbalIfDifferent

 public void SendKerbalIfDifferent(ProtoCrewMember pcm)
 {
     ConfigNode kerbalNode = new ConfigNode();
     pcm.Save(kerbalNode);
     if (pcm.type == ProtoCrewMember.KerbalType.Tourist || pcm.type == ProtoCrewMember.KerbalType.Unowned)
     {
         ConfigNode dmpNode = new ConfigNode();
         dmpNode.AddValue("contractOwner", Settings.fetch.playerPublicKey);
         kerbalNode.AddNode("DarkMultiPlayer", dmpNode);
     }
     byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
     if (kerbalBytes == null || kerbalBytes.Length == 0)
     {
         DarkLog.Debug("VesselWorker: Error sending kerbal - bytes are null or 0");
         return;
     }
     string kerbalHash = Common.CalculateSHA256Hash(kerbalBytes);
     bool kerbalDifferent = false;
     if (!serverKerbals.ContainsKey(pcm.name))
     {
         //New kerbal
         DarkLog.Debug("Found new kerbal, sending...");
         kerbalDifferent = true;
     }
     else if (serverKerbals[pcm.name] != kerbalHash)
     {
         DarkLog.Debug("Found changed kerbal (" + pcm.name + "), sending...");
         kerbalDifferent = true;
     }
     if (kerbalDifferent)
     {
         serverKerbals[pcm.name] = kerbalHash;
         NetworkWorker.fetch.SendKerbalProtoMessage(pcm.name, kerbalBytes);
     }
 }
开发者ID:RockyTV,项目名称:DarkMultiPlayer,代码行数:35,代码来源:VesselWorker.cs


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