//Defends against bug #172
 private void CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(ConfigNode progressTrackingNode)
 {
     foreach (ConfigNode possibleNode in progressTrackingNode.nodes)
     {
         //Recursion (noun): See Recursion.
         CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(possibleNode);
     }
     //The kerbals are kept in a ConfigNode named 'crew', with 'crews' as a comma space delimited array of names.
     if (progressTrackingNode.name == "crew")
     {
         string kerbalNames = progressTrackingNode.GetValue("crews");
         if (!String.IsNullOrEmpty(kerbalNames))
         {
             string[] kerbalNamesSplit = kerbalNames.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
             foreach (string kerbalName in kerbalNamesSplit)
             {
                 if (!HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
                 {
                     DarkLog.Debug("Generating missing kerbal from ProgressTracking: " + kerbalName);
                     ProtoCrewMember pcm = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Crew);
                     pcm.ChangeName(kerbalName);
                     HighLogic.CurrentGame.CrewRoster.AddCrewMember(pcm);
                     //Also send it off to the server
                     vesselWorker.SendKerbalIfDifferent(pcm);
                 }
             }
         }
     }
 }
示例#2
0
        private static void CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(ConfigNode progressTrackingNode)
        {
            foreach (var possibleNode in progressTrackingNode.nodes)
            {
                CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(possibleNode as ConfigNode);
            }

            //The kerbals are kept in a ConfigNode named 'crew', with 'crews' as a comma space delimited array of names.
            if (progressTrackingNode.name == "crew")
            {
                var kerbalNames = progressTrackingNode.GetValue("crews");
                if (!string.IsNullOrEmpty(kerbalNames))
                {
                    var kerbalNamesSplit = kerbalNames.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var kerbalName in kerbalNamesSplit.Where(k => !HighLogic.CurrentGame.CrewRoster.Exists(k)))
                    {
                        LunaLog.Log($"[LMP]: Generating missing kerbal from ProgressTracking: {kerbalName}");
                        var pcm = CrewGenerator.RandomCrewMemberPrototype();
                        pcm.ChangeName(kerbalName);
                        HighLogic.CurrentGame.CrewRoster.AddCrewMember(pcm);

                        //Also send it off to the server
                        KerbalSystem.Singleton.MessageSender.SendKerbal(pcm);
                    }
                }
            }
        }
 public void CreateKerbalIfMissing(string kerbalName, Guid vesselID)
 {
     if (!HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
     {
         ProtoCrewMember pcm = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Crew);
         pcm.ChangeName(kerbalName);
         pcm.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
         HighLogic.CurrentGame.CrewRoster.AddCrewMember(pcm);
         DarkLog.Debug("Created kerbal " + pcm.name + " for vessel " + vesselID + ", Kerbal was missing");
     }
 }
 public void CreateKerbalIfMissing(string kerbalName, Guid vesselId)
 {
     if (!HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
     {
         var pcm = CrewGenerator.RandomCrewMemberPrototype();
         pcm.ChangeName(kerbalName);
         pcm.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
         HighLogic.CurrentGame.CrewRoster.AddCrewMember(pcm);
         Debug.Log($"[LMP]: Created kerbal {pcm.name} for vessel {vesselId}, Kerbal was missing");
     }
 }
        protected override bool Generate()
        //System.Type contractType, Contract.ContractPrestige difficulty, int seed, State state)
        {
            KourageousTouristsAddOn.printDebug("skydive generate");

            targetBody = selectNextCelestialBody();
            if (targetBody == null)
            {
                KourageousTouristsAddOn.printDebug("target body is null");
                return(false);
            }

            numTourists = UnityEngine.Random.Range(1, 6);
            KourageousTouristsAddOn.printDebug("num tourists: " + numTourists);
            for (int i = 0; i < this.numTourists; i++)
            {
                ProtoCrewMember tourist = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Tourist);

                tourists.Add(tourist);
                KourageousTouristsAddOn.printDebug("generated: " + tourist.name);

                KourageousSkydiveJumpParameter jumpParameter = new KourageousSkydiveJumpParameter(targetBody, tourist.name);
                jumpParameter.FundsCompletion      = 0.0;
                jumpParameter.FundsFailure         = 0.0;
                jumpParameter.ReputationCompletion = 0.0f;
                jumpParameter.ReputationFailure    = 0.0f;
                jumpParameter.ScienceCompletion    = 0.0f;
                AddParameter(jumpParameter);

                KourageousSkydiveLandParameter landParameter = new KourageousSkydiveLandParameter(targetBody, tourist.name);
                landParameter.FundsCompletion      = 1000.0;
                landParameter.FundsFailure         = 0.0;
                landParameter.ReputationCompletion = 0.0f;
                landParameter.ReputationFailure    = 0.0f;
                landParameter.ScienceCompletion    = 0.0f;
                AddParameter(landParameter);
            }

            GenerateHashString();

            SetExpiry();
            SetScience(0.0f, targetBody);
            SetDeadlineYears(1, targetBody);
            SetReputation(2, 5, targetBody);
            SetFunds(500, 2000, 15000, targetBody);

            return(true);
        }
 public void CreateKerbalIfMissing(string kerbalName, Guid vesselID)
 {
     if (!HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
     {
         if (AddCrewMemberToRoster == null)
         {
             MethodInfo addMemberToCrewRosterMethod = typeof(KerbalRoster).GetMethod("AddCrewMember", BindingFlags.Public | BindingFlags.Instance);
             AddCrewMemberToRoster = (AddCrewMemberToRosterDelegate)Delegate.CreateDelegate(typeof(AddCrewMemberToRosterDelegate), HighLogic.CurrentGame.CrewRoster, addMemberToCrewRosterMethod);
             if (AddCrewMemberToRoster == null)
             {
                 throw new Exception("Failed to load AddCrewMember delegate!");
             }
         }
         ProtoCrewMember pcm = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Crew);
         pcm.ChangeName(kerbalName);
         pcm.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
         AddCrewMemberToRoster(pcm);
         DarkLog.Debug("Created kerbal " + pcm.name + " for vessel " + vesselID + ", Kerbal was missing");
     }
 }
 //Defends against bug #172
 private void CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(ConfigNode progressTrackingNode)
 {
     foreach (ConfigNode possibleNode in progressTrackingNode.nodes)
     {
         //Recursion (noun): See Recursion.
         CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(possibleNode);
     }
     //The kerbals are kept in a ConfigNode named 'crew', with 'crews' as a comma space delimited array of names.
     if (progressTrackingNode.name == "crew")
     {
         string kerbalNames = progressTrackingNode.GetValue("crews");
         if (!String.IsNullOrEmpty(kerbalNames))
         {
             string[] kerbalNamesSplit = kerbalNames.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
             foreach (string kerbalName in kerbalNamesSplit)
             {
                 if (!HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
                 {
                     if (AddCrewMemberToRoster == null)
                     {
                         MethodInfo addMemberToCrewRosterMethod = typeof(KerbalRoster).GetMethod("AddCrewMember", BindingFlags.NonPublic | BindingFlags.Instance);
                         AddCrewMemberToRoster = (AddCrewMemberToRosterDelegate)Delegate.CreateDelegate(typeof(AddCrewMemberToRosterDelegate), HighLogic.CurrentGame.CrewRoster, addMemberToCrewRosterMethod);
                     }
                     if (AddCrewMemberToRoster == null)
                     {
                         throw new Exception("Failed to initialize AddCrewMemberToRoster for #172 ProgressTracking fix.");
                     }
                     DarkLog.Debug("Generating missing kerbal from ProgressTracking: " + kerbalName);
                     ProtoCrewMember pcm = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Crew);
                     pcm.name = kerbalName;
                     AddCrewMemberToRoster(pcm);
                     //Also send it off to the server
                     NetworkWorker.fetch.SendKerbalProtoMessage(pcm);
                 }
             }
         }
     }
 }
示例#8
0
        protected override bool Generate()
        //System.Type contractType, Contract.ContractPrestige difficulty, int seed, State state)
        {
            Log.dbg("entered KourageousWalkContract Generate");

            targetBody = selectNextCelestialBody();
            if (targetBody == null)
            {
                return(false);
            }

            this.numTourists = UnityEngine.Random.Range(1, 5);
            Log.dbg("num tourists: {0}", numTourists);
            for (int i = 0; i < this.numTourists; i++)
            {
                ProtoCrewMember tourist = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Tourist);

                tourists.Add(tourist);
                Log.dbg("generated: {0}", tourist.name);

                // TODO: Add support for gender for 1.3 build
                KerbalTourParameter itinerary = new KerbalTourParameter(tourist.name, tourist.gender);
                // TODO: Add difficulty multiplier
                itinerary.FundsCompletion      = 25000.0;
                itinerary.ReputationCompletion = 0.0f;
                itinerary.ReputationFailure    = 0.0f;
                itinerary.ScienceCompletion    = 0.0f;
                this.AddParameter(itinerary);

                KerbalDestinationParameter dstParameter = new KerbalDestinationParameter(
                    targetBody, FlightLog.EntryType.Land, tourist.name
                    );
                dstParameter.FundsCompletion      = 1000.0f;
                dstParameter.FundsFailure         = 0.0f;
                dstParameter.ReputationCompletion = 0.0f;
                dstParameter.ReputationFailure    = 0.0f;
                dstParameter.ScienceCompletion    = 0.0f;

                /*dstParameter.NestToParent (itinerary);
                 * dstParameter.CreateID ();
                 * dstParameter.AddParameter (new Contracts.Parameters.LandOnBody (targetBody));*/
                itinerary.AddParameter(dstParameter);

                KourageousWalkParameter walkParameter = new KourageousWalkParameter(targetBody, tourist.name);
                walkParameter.FundsCompletion      = 3000.0;
                walkParameter.FundsFailure         = 0.0;
                walkParameter.ReputationCompletion = 0.0f;
                walkParameter.ReputationFailure    = 0.0f;
                walkParameter.ScienceCompletion    = 0.0f;
                itinerary.AddParameter(walkParameter);
            }

            GenerateHashString();

            base.SetExpiry();
            base.SetScience(0.0f, targetBody);
            base.SetDeadlineYears(1, targetBody);
            base.SetReputation(2, 5, targetBody);
            base.SetFunds(2000, 7000, 18000, targetBody);


            return(true);
        }
示例#9
0
        public static ModKerbal CreateKerbal()
        {
            ProtoCrewMember kerbal = CrewGenerator.RandomCrewMemberPrototype();

            return(new ModKerbal(kerbal, true));
        }
示例#10
0
        private KerbalModel CreateKerbal()
        {
            ProtoCrewMember kerbal = CrewGenerator.RandomCrewMemberPrototype();

            return(new KerbalModel(kerbal, true));
        }
示例#11
0
        protected override bool Generate()
        //System.Type contractType, Contract.ContractPrestige difficulty, int seed, State state)
        {
            KourageousTouristsAddOn.printDebug("entered");

            targetBody = selectNextCelestialBody();
            if (targetBody == null)
            {
                return(false);
            }

            chosenAnomaly = chooseAnomaly(targetBody);
            if (chosenAnomaly == null)
            {
                return(false);
            }

            this.numTourists = UnityEngine.Random.Range(2, 5);
            KourageousTouristsAddOn.printDebug("num tourists: " + numTourists);
            for (int i = 0; i < this.numTourists; i++)
            {
                ProtoCrewMember tourist = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Tourist);

                this.tourists.Add(tourist);
                KourageousTouristsAddOn.printDebug("generated: " + tourist.name);

                // TODO: Add support for gender for 1.3 build
                KerbalTourParameter itinerary = new KerbalTourParameter(tourist.name, tourist.gender);
                // TODO: Add difficulty multiplier
                itinerary.FundsCompletion      = 25000.0;
                itinerary.ReputationCompletion = 0.0f;
                itinerary.ReputationFailure    = 0.0f;
                itinerary.ScienceCompletion    = 0.0f;
                this.AddParameter(itinerary);

                KerbalDestinationParameter dstParameter = new KerbalDestinationParameter(
                    targetBody, FlightLog.EntryType.Land, tourist.name
                    );
                dstParameter.FundsCompletion      = 1000.0f;
                dstParameter.FundsFailure         = 0.0f;
                dstParameter.ReputationCompletion = 0.0f;
                dstParameter.ReputationFailure    = 0.0f;
                dstParameter.ScienceCompletion    = 0.0f;

                /*dstParameter.NestToParent (itinerary);
                 * dstParameter.CreateID ();
                 * dstParameter.AddParameter (new Contracts.Parameters.LandOnBody (targetBody));*/
                itinerary.AddParameter(dstParameter);


                KourageousAnomalyParameter anomalyParameter = new KourageousAnomalyParameter(
                    targetBody, tourist.name, chosenAnomaly.name, chosenAnomaly.anomalyDescription
                    );
                anomalyParameter.FundsCompletion      = 1300.0;
                anomalyParameter.FundsFailure         = 0.0;
                anomalyParameter.ReputationCompletion = 1.0f;
                anomalyParameter.ReputationFailure    = 1.0f;
                anomalyParameter.ScienceCompletion    = 0.0f;
                itinerary.AddParameter(anomalyParameter);
            }

            GenerateHashString();

            base.SetExpiry();
            base.SetScience(0.0f, targetBody);
            base.SetDeadlineYears(1, targetBody);
            base.SetReputation(2, 5, targetBody);
            base.SetFunds(
                3000 * chosenAnomaly.payoutModifier,
                9000 * chosenAnomaly.payoutModifier,
                21000 * chosenAnomaly.payoutModifier,
                targetBody);

            return(true);
        }
示例#12
0
        public static RMKerbal CreateKerbal(ProtoCrewMember.KerbalType kerbalType)
        {
            ProtoCrewMember kerbal = CrewGenerator.RandomCrewMemberPrototype(kerbalType);

            return(new RMKerbal(Planetarium.GetUniversalTime(), kerbal, true, false));
        }