Ejemplo n.º 1
0
        public void Initialize(Rect guiRect)
        {
            var uiScaleMultiplier = GameSettings.UI_SCALE;

            // the supplied rect will have the UI scalar already factored in
            //
            // to respect the player's UI scale wishes, work out what the unscaled rect
            // would be. Then we'll apply the scale again in OnGUI so all of our GUILayout elements
            // will respect the multiplier
            var correctedRect = new Rect(guiRect.x, guiRect.y, guiRect.width / uiScaleMultiplier,
                                         guiRect.height / uiScaleMultiplier);

            _areaRect = correctedRect;

            _guiPivot  = new Vector2(_areaRect.x, _areaRect.y);
            _guiScalar = new Vector2(GameSettings.UI_SCALE, GameSettings.UI_SCALE);

            //var applicants = HighLogic.CurrentGame.CrewRoster.Applicants.ToList();
            var rand = new System.Random();

            for (int i = 0; i < 10; i++)
            {
                KNames[0, i] = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Male, rand);
                KNames[1, i] = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Female, rand);

                KNames2Gender[i] = (rand.Next() % 2 == 0 ? ProtoCrewMember.Gender.Male : ProtoCrewMember.Gender.Female);
                KNames[2, i]     = (KNames2Gender[i] == ProtoCrewMember.Gender.Male ? KNames[0, i] : KNames[1, i]);
            }

            enabled = true;

            traits = new Traits();
        }
Ejemplo n.º 2
0
        public void Initialize(Rect guiRect)
        {
            // the supplied rect will have the UI scalar already factored in
            var correctedRect = new Rect(guiRect.x, guiRect.y, guiRect.width, guiRect.height);

            _areaRect = correctedRect;

            _guiPivot = new Vector2(_areaRect.x, _areaRect.y);

            //var applicants = HighLogic.CurrentGame.CrewRoster.Applicants.ToList();
            var rand = new System.Random();

            for (int i = 0; i < MAX_HIRE_COUNT; i++)
            {
                KNames[0, i] = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Male, rand);
                KNames[1, i] = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Female, rand);

                KNames2Gender[i] = (rand.Next() % 2 == 0 ? ProtoCrewMember.Gender.Male : ProtoCrewMember.Gender.Female);
                KNames[2, i]     = (KNames2Gender[i] == ProtoCrewMember.Gender.Male ? KNames[0, i] : KNames[1, i]);
            }

            enabled = true;

            traits = new Traits();
        }
Ejemplo n.º 3
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);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 //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);
                 }
             }
         }
     }
 }
 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");
     }
 }
Ejemplo n.º 6
0
 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");
     }
 }
        private string GenerateKerbalName(CivPopKerbalGender gender)
        {
            string res;

            if (CivPopKerbalGender.MALE.Equals(gender))
            {
                res = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Male);
            }
            else
            {
                res = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Female);
            }
            return(res);
        }
Ejemplo n.º 8
0
        protected override bool Generate()
        {
            List <Resource> resList = new List <Resource>();

            resList.Add(new Resource("Steel", 2, 80208299));
            resList.Add(new Resource("Wood", 5, 2702029));
            resList.Add(new Resource("Diamond", 20, -975259340));
            resList.Add(new Resource("Liquid Fuel", 0.8, 374119730));
            resList.Add(new Resource("Oxydizer", 0.005, -1823983486));
            resList.Add(new Resource("Mono Propellant", 0.6, 2001413032));
            resList.Add(new Resource("Xenon Gas", 1.2, 1447111193));
            resource       = resList.ElementAt(UnityEngine.Random.Range(0, resList.Count));
            resourceAmount = UnityEngine.Random.Range(5, 50) * 100;

            List <string> ships = new List <string>
            {
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\DR1-LL3-R_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\freighter large ( long range)_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\freighter medium ( long range)_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\freighter Medium_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\freighter small_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\Kirk MKI_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\Kortana the asrtroid huntress_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\luna slave transport_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\S-7 Scientific Vessel_refuel.craft",
                "GameData\\KerbalKommander\\Assets\\ships\\refuelContract\\Slave-7_refuel.craft",
            };

            vesselName = CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Male);
            synopsis   = vesselName + " ran out of fuel, he need " + resourceAmount + " of " + resource + " in exchange of a reward.\nYou just need to carry the resources to his ship and dock whith it.";
            vesselName = vesselName + "'s ship";
            CelestialBody body  = FlightGlobals.Bodies[UnityEngine.Random.Range(1, FlightGlobals.Bodies.Count)];
            Orbit         orbit = new Orbit(UnityEngine.Random.Range(0, 360), UnityEngine.Random.Range(0, 0.3f), UnityEngine.Random.Range(Convert.ToSingle(body.Radius + body.atmosphereDepth), Convert.ToSingle(body.sphereOfInfluence)), UnityEngine.Random.Range(0, 360), 0000000000000000, 0, HighLogic.CurrentGame.UniversalTime, body);

            vessel = Tools.VesselSpawner.SpawnVessel(vesselName, ships.ElementAt(UnityEngine.Random.Range(0, ships.Count)), HighLogic.CurrentGame.flagURL, VesselType.Ship, Planetarium.fetch.Home, orbit, new List <ProtoCrewMember>());


            name   = "Refuel " + vessel.vesselName;
            reward = Convert.ToSingle(Math.Round(resourceAmount * resource.unitCost * 300));

            targetBody = Planetarium.fetch.Home;
            this.AddParameter(new refuelingParameter(resource, vessel, resourceAmount, reward));
            base.SetExpiry(25, 100);
            base.SetScience(0f, targetBody);
            base.SetDeadlineYears(10f, targetBody);
            base.SetReputation(0f, 0f, targetBody);
            base.SetFunds(0f, reward, 0f, targetBody);
            return(true);
        }
        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);
        }
Ejemplo n.º 10
0
        static void Postfix(SimGameState __instance)
        {
            foreach (Pilot pilot in __instance.PilotRoster)
            {
                if (pilot.pilotDef.IsFree && pilot.pilotDef.IsImmortal)
                {
                    continue;                                                     // player character, skip
                }
                // Initialize new details for the pre-generated pilots
                Mod.Log.Info?.Write($"Creating details for career-default pilot: {pilot.Name}");

                // TODO: Randomize founders across all pilots

                CrewDetails details = CrewGenerator.GenerateDetailsForVanillaMechwarrior(pilot.pilotDef, true);
                Mod.Log.Info?.Write($"  -- pilot will have GUID: {details.GUID}");
            }
        }
Ejemplo n.º 11
0
        public static string KerbalName(ProtoCrewMember.Gender gender)
        {
            string defaultKerbalName = "";

            do
            {
                defaultKerbalName = CrewGenerator.GetRandomName(gender, random);
            }while (nameCache.ContainsKey(defaultKerbalName));

            string kerbalName = "";

            do
            {
                kerbalName = DraftTwitchViewers.KerbalName(defaultKerbalName);
            }while (nameCache.ContainsKey(kerbalName));

            nameCache.Add(kerbalName, 0);
            return(kerbalName);
        }
Ejemplo n.º 12
0
 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        public static RMKerbal CreateKerbal(ProtoCrewMember.KerbalType kerbalType)
        {
            ProtoCrewMember kerbal = CrewGenerator.RandomCrewMemberPrototype(kerbalType);

            return(new RMKerbal(Planetarium.GetUniversalTime(), kerbal, true, false));
        }
Ejemplo n.º 16
0
        public static ModKerbal CreateKerbal()
        {
            ProtoCrewMember kerbal = CrewGenerator.RandomCrewMemberPrototype();

            return(new ModKerbal(kerbal, true));
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        // TODO: Manipulate # of pilots by planet tags
        // TODO: Manipulate # of ronin by planet tags
        // TODO: Check for Allow flags by each type
        static bool Prefix(StarSystem __instance, int count)
        {
            int systemDiff = __instance.Def.GetDifficulty(SimGameState.SimGameType.CAREER);

            Mod.Log.Info?.Write($"Generating pilots for system: {__instance.Name} with difficulty: {systemDiff}");

            PlanetScarcity scarcity = __instance.GetScarcityForPlanet();

            int aerospace = scarcity.Aerospace.Upper > 0 ?
                            Math.Max(0, Mod.Random.Next(scarcity.Aerospace.Lower, scarcity.Aerospace.Upper)) : 0;
            int mechTechs = scarcity.MechTechs.Upper > 0 ?
                            Math.Max(0, Mod.Random.Next(scarcity.MechTechs.Lower, scarcity.MechTechs.Upper)) : 0;
            int mechWarriors = scarcity.MechWarriors.Upper > 0 ?
                               Math.Max(0, Mod.Random.Next(scarcity.MechWarriors.Lower, scarcity.MechWarriors.Upper)) : 0;
            int medTechs = scarcity.MedTechs.Upper > 0 ?
                           Math.Max(0, Mod.Random.Next(scarcity.MedTechs.Lower, scarcity.MedTechs.Upper)) : 0;
            int vehicleCrews = scarcity.Vehicles.Upper > 0 ?
                               Math.Max(0, Mod.Random.Next(scarcity.Vehicles.Lower, scarcity.Vehicles.Upper)) : 0;

            Mod.Log.Debug?.Write($"Generated mechwarriors: {mechWarriors}  vehicleCrews: {vehicleCrews}  " +
                                 $"mechTechs: {mechTechs}  medTechs: {medTechs}  aerospace: {aerospace}");

            // Generate pilots and crews
            if (mechWarriors > 0)
            {
                __instance.AvailablePilots.Clear();

                if (Mod.Config.DebugCommands)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        PilotDef unusedRonin = ModState.SimGameState.GetUnusedRonin();

                        if (!ModState.SimGameState.UsedRoninIDs.Contains(unusedRonin.Description.Id))
                        {
                            Mod.Log.Debug?.Write($"Added ronin: {unusedRonin.Description.DisplayName} to available pilots.");

                            PilotDef upgradedDef = CrewGenerator.UpgradeRonin(__instance, unusedRonin);
                            __instance.AvailablePilots.Add(upgradedDef);
                        }
                        else
                        {
                            Mod.Log.Debug?.Write($"Ronin: {unusedRonin.Description.DisplayName} already in use, skipping.");
                        }
                    }
                }

                // Ronin DO NOT count against the system limits. Just add them, if the roll passes.
                double roninRoll = Mod.Random.NextDouble();
                if (roninRoll <= Mod.Config.HiringHall.RoninChance)
                {
                    Mod.Log.Debug?.Write($"Ronin roll of {roninRoll} <= roninChance: {Mod.Config.HiringHall.RoninChance}. Adding one Ronin to hiring hall.");
                    PilotDef unusedRonin = ModState.SimGameState.GetUnusedRonin();

                    if (!ModState.SimGameState.UsedRoninIDs.Contains(unusedRonin.Description.Id))
                    {
                        Mod.Log.Debug?.Write($"Added ronin: {unusedRonin.Description.DisplayName} to available pilots.");

                        PilotDef upgradedDef = CrewGenerator.UpgradeRonin(__instance, unusedRonin);
                        __instance.AvailablePilots.Add(upgradedDef);
                    }
                    else
                    {
                        Mod.Log.Debug?.Write($"Ronin: {unusedRonin.Description.DisplayName} already in use, skipping.");
                    }
                }

                for (int i = 0; i < mechWarriors; i++)
                {
                    PilotDef pDef = CrewGenerator.GenerateMechWarrior(__instance);
                    __instance.AvailablePilots.Add(pDef);
                }
            }

            if (Mod.Config.HiringHall.AerospaceWings.Enabled)
            {
                for (int i = 0; i < aerospace; i++)
                {
                    PilotDef pDef = CrewGenerator.GenerateAerospaceCrew(__instance);
                    __instance.AvailablePilots.Add(pDef);
                }
            }

            if (Mod.Config.HiringHall.MechTechCrews.Enabled)
            {
                for (int i = 0; i < mechTechs; i++)
                {
                    PilotDef pDef = CrewGenerator.GenerateMechTechCrew(__instance);
                    __instance.AvailablePilots.Add(pDef);
                }
            }

            if (Mod.Config.HiringHall.MedTechCrews.Enabled)
            {
                for (int i = 0; i < medTechs; i++)
                {
                    PilotDef pDef = CrewGenerator.GenerateMedTechCrew(__instance);
                    __instance.AvailablePilots.Add(pDef);
                }
            }

            if (Mod.Config.HiringHall.VehicleCrews.Enabled)
            {
                for (int i = 0; i < vehicleCrews; i++)
                {
                    PilotDef pDef = CrewGenerator.GenerateVehicleCrew(__instance);
                    __instance.AvailablePilots.Add(pDef);
                }
            }
            return(false);
        }
Ejemplo n.º 19
0
        private KerbalModel CreateKerbal()
        {
            ProtoCrewMember kerbal = CrewGenerator.RandomCrewMemberPrototype();

            return(new KerbalModel(kerbal, true));
        }
        void DrawGUISlaves(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Hello! When trafficking slaves, make sure the police don't find out!", HighLogic.Skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Male  " + "      Price: " + slavePrice.ToString(), HighLogic.Skin.label);
            if (GUILayout.Button("Buy Slave", HighLogic.Skin.button))
            {
                if (Funding.Instance.Funds < 1000)
                {
                    ScreenMessages.PostScreenMessage("Not enough eunds", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }
                else
                {
                    Funding.Instance.AddFunds(-slavePrice, TransactionReasons.CrewRecruited);
                    ProtoCrewMember slave = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Tourist);
                    slave.ChangeName(CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Male) + " (slave)");
                    slave.gender    = ProtoCrewMember.Gender.Male;
                    slave.courage   = 1;
                    slave.stupidity = 1;
                    slave.isBadass  = true;
                    foreach (Part CrewPart in vessel.Parts)
                    {
                        if (CrewPart.protoModuleCrew.Count < CrewPart.CrewCapacity)
                        {
                            CrewPart.AddCrewmemberAt(slave, CrewPart.protoModuleCrew.Count);
                            CrewPart.SpawnIVA();
                            if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.Flight)
                            {
                                CameraManager.Instance.SetCameraMap();
                                CameraManager.Instance.SetCameraFlight();
                            }

                            break;
                        }
                    }

                    ScreenMessages.PostScreenMessage("New Slave Added (male)", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Female" + "      Price: " + slavePrice.ToString(), HighLogic.Skin.label);
            if (GUILayout.Button("Buy Slave", HighLogic.Skin.button))
            {
                if (Funding.Instance.Funds < 900)
                {
                    ScreenMessages.PostScreenMessage("Not enough funds", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }
                else
                {
                    Funding.Instance.AddFunds(-slavePrice, TransactionReasons.CrewRecruited);
                    ProtoCrewMember slave = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Tourist);
                    slave.type = ProtoCrewMember.KerbalType.Tourist;
                    slave.ChangeName(CrewGenerator.GetRandomName(ProtoCrewMember.Gender.Female) + " (slave)");
                    slave.gender    = ProtoCrewMember.Gender.Female;
                    slave.courage   = 1;
                    slave.stupidity = 1;
                    slave.isBadass  = true;
                    foreach (Part CrewPart in vessel.Parts)
                    {
                        if (CrewPart.protoModuleCrew.Count < CrewPart.CrewCapacity)
                        {
                            CrewPart.AddCrewmemberAt(slave, CrewPart.protoModuleCrew.Count);
                            CrewPart.SpawnIVA();
                            if (CameraManager.Instance.currentCameraMode != CameraManager.CameraMode.Flight)
                            {
                                CameraManager.Instance.SetCameraFlight();
                            }
                            CameraManager.Instance.SetCameraMap();
                            CameraManager.Instance.SetCameraFlight();

                            break;
                        }
                    }
                    ScreenMessages.PostScreenMessage("New Slave Added (female)", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Sell Slaves:", HighLogic.Skin.label);

            scrollPos = GUILayout.BeginScrollView(scrollPos, HighLogic.Skin.scrollView);
            foreach (Part vPart in vessel.Parts)
            {
                foreach (ProtoCrewMember slaves in vPart.protoModuleCrew)
                {
                    if (slaves.type == ProtoCrewMember.KerbalType.Tourist)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Name: " + slaves.name, HighLogic.Skin.label);
                        GUILayout.Label("Gender: " + slaves.gender.ToString());
                        GUILayout.Label("Price: " + slavePrice.ToString());
                        if (GUILayout.Button("Sell", HighLogic.Skin.button))
                        {
                            ScreenMessages.PostScreenMessage("Slave selled", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                            Funding.Instance.AddFunds(slavePrice, TransactionReasons.CrewRecruited);
                            vPart.protoModuleCrew.Remove(slaves);
                            vPart.DespawnIVA();
                            if (CameraManager.Instance.currentCameraMode != CameraManager.CameraMode.Flight)
                            {
                                CameraManager.Instance.SetCameraFlight();
                            }
                            CameraManager.Instance.SetCameraMap();
                            CameraManager.Instance.SetCameraFlight();
                            vPart.SpawnIVA();
                            if (CameraManager.Instance.currentCameraMode != CameraManager.CameraMode.Flight)
                            {
                                CameraManager.Instance.SetCameraFlight();
                            }
                            CameraManager.Instance.SetCameraMap();
                            CameraManager.Instance.SetCameraFlight();
                            break;
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            }

            GUILayout.EndScrollView();
            if (GUILayout.Button("Close", HighLogic.Skin.button))
            {
                slaveWindow         = false;
                MainMenu.menuWindow = true;
                foreach (Part parts in vessel.Parts)
                {
                    parts.SpawnIVA();
                    if (CameraManager.Instance.currentCameraMode != CameraManager.CameraMode.Flight)
                    {
                        CameraManager.Instance.SetCameraFlight();
                    }
                    CameraManager.Instance.SetCameraMap();
                    CameraManager.Instance.SetCameraFlight();
                }
            }
            GUILayout.EndVertical();
        }