コード例 #1
0
        protected override void OnAccepted()
        {
            // Create all the passengers
            for (int i = 0; i < count; i++)
            {
                // Create the ProtoCrewMember
                ProtoCrewMember crewMember = null;

                // Try to get existing passenger
                if (kerbals.Count > i)
                {
                    crewMember = HighLogic.CurrentGame.CrewRoster.AllKerbals().Where(pcm => pcm.name == kerbals[i].name).FirstOrDefault();
                    if (crewMember != null)
                    {
                        crewMember.hasToured = false;
                    }
                }
                if (crewMember == null)
                {
                    // Generate the ProtoCrewMember
                    Kerbal kerbal = (i < kerbals.Count()) ? kerbals.ElementAt(i) : new Kerbal();
                    if (i >= kerbals.Count())
                    {
                        kerbal.kerbalType = ProtoCrewMember.KerbalType.Tourist;
                    }
                    kerbal.GenerateKerbal();
                    crewMember = kerbal.pcm;
                }

                passengers[crewMember] = false;
            }

            kerbals.Clear();
        }
コード例 #2
0
        protected void OnContractAccepted(Contract contract)
        {
            if (contract == Root && kerbals.Count == 0)
            {
                int count = this.count == 0 ? ((ConfiguredContract)contract).GetSpawnedKerbalCount() : this.count;
                for (int i = 0; i < count; i++)
                {
                    Kerbal kerbal = ((ConfiguredContract)contract).GetSpawnedKerbal(index + i);
                    kerbals.Add(kerbal);
                    recovered[kerbal.name] = false;
                }

                foreach (Kerbal kerbal in kerbals)
                {
                    // Instantiate the kerbals if necessary
                    if (kerbal.pcm == null)
                    {
                        kerbal.GenerateKerbal();
                    }
                }

                CreateDelegates();
            }
        }