Exemplo n.º 1
0
        /// <summary>
        /// This method is called from the Main system to load all the kerbals we received
        /// when connecting to a server into the game
        /// </summary>
        public void LoadKerbalsIntoGame()
        {
            LunaLog.Log("[LMP]: Loading kerbals into game");
            while (KerbalQueue.Count > 0)
            {
                LoadKerbal(KerbalQueue.Dequeue());
            }

            //Server is new and don't have kerbals at all
            if (ServerKerbals.Count == 0)
            {
                var newRoster = KerbalRoster.GenerateInitialCrewRoster(HighLogic.CurrentGame.Mode);
                foreach (var pcm in newRoster.Crew)
                {
                    HighLogic.CurrentGame.CrewRoster.AddCrewMember(pcm);
                    MessageSender.SendKerbalIfDifferent(pcm);
                }
            }
            else
            {
                //Server has less than 20 kerbals so generate some
                var generateKerbals = ServerKerbals.Count < 20 ? 20 - ServerKerbals.Count : 0;
                if (generateKerbals > 0)
                {
                    LunaLog.Log($"[LMP]: Generating {generateKerbals} new kerbals");
                    for (var i = 0; i < generateKerbals; i++)
                    {
                        var protoKerbal = HighLogic.CurrentGame.CrewRoster.GetNewKerbal();
                        MessageSender.SendKerbalIfDifferent(protoKerbal);
                    }
                }
            }

            LunaLog.Log("[LMP]: Kerbals loaded");
        }
Exemplo n.º 2
0
 protected override void OnDisabled()
 {
     base.OnDisabled();
     KerbalQueue.Clear();
     ServerKerbals.Clear();
 }