예제 #1
0
 internal static Vector2?Pick(this List <Vector2?> list, ProtoCrewMember kerbal, bool useGameSeed, string name = "")
 {
     if (list?.Count > 1 && kerbal != null)
     {
         return(list[kerbal.Hash(useGameSeed) % list.Count]);
     }
     else if (list?.Count > 0)
     {
         return(list[name.Hash(useGameSeed) % list.Count]);
     }
     else
     {
         return(null);
     }
 }
예제 #2
0
            internal override void LoadFor(ProtoCrewMember kerbal)
            {
                Debug.Log("CustomNavBall.LoadFor", "kerbal = " + kerbal);

                Info.hash = "";
                int?   useChance  = null;
                string collection = "";

                for (int i = 0; i < NavBallInfo.DataBase?.Count; i++)
                {
                    NavBallInfo info = (NavBallInfo)NavBallInfo.DataBase[i].GetFor(kerbal);

                    Debug.Log("CustomNavBall.LoadFor", "NavBallInfo.DataBase[" + i + "]");
                    if (info != null)
                    {
                        Debug.Log("CustomNavBall.LoadFor", "Matching navball collection = " + info.collection + " to current collection = " + collection);
                        if (string.IsNullOrEmpty(collection) || collection == info.collection)
                        {
                            if (useChance == null && info.useChance != 1)
                            {
                                useChance = kerbal.Hash(info.useGameSeed) % 100;
                            }

                            Debug.Log("CustomNavBall.LoadFor", "Matching navball useChance = " + info.useChance + " to generated chance = " + useChance + " %");
                            if (info.useChance == 1 || useChance < info.useChance * 100)
                            {
                                Debug.Log("CustomNavBall.LoadFor", "Loading NavBallInfo.DataBase[" + i + "]");

                                // Collection
                                collection = info.collection;

                                // Colors and Textures
                                Pick(info, kerbal);

                                continue;
                            }
                        }
                    }

                    Debug.Log("CustomNavBall.LoadFor", "Ignoring NavBallInfo.DataBase[" + i + "]");
                }
            }
예제 #3
0
            // Load informations
            void LoadFor(ProtoCrewMember kerbal)
            {
                Debug.Log("CustomDescription.LoadFor", "kerbal = " + kerbal);

                Info.hash = "";
                string collection = "";

                displayName  = "";
                tooltipName  = "";
                informations = "";
                sprite       = null;
                int index       = 0;
                int?indexChance = null;

                for (int i = 0; i < DescriptionInfo.DataBase?.Count; i++)
                {
                    DescriptionInfo info = (DescriptionInfo)DescriptionInfo.DataBase[i].GetFor(kerbal);

                    if (info != null)
                    {
                        Debug.Log("CustomDescription.LoadFor", "Matching description index = " + info.index + " to current index = " + index);

                        if (info.index == null || info.index == index)
                        {
                            Debug.Log("CustomDescription.LoadFor", "Matching description collection = " + info.collection + " to current collection = " + collection);

                            if (string.IsNullOrEmpty(collection) || collection == info.collection)
                            {
                                if (info.useChance != 1 && indexChance == null)
                                {
                                    indexChance = kerbal.Hash(info.useGameSeed) % 100;
                                }

                                Debug.Log("CustomDescription.LoadFor", "Matching description useChance = " + info.useChance + " to current index chance = " + indexChance + " %");

                                if (info.useChance == 1 || indexChance < info.useChance * 100)
                                {
                                    Debug.Log("CustomDescription.LoadFor", "Matched all requirements.");

                                    // Collection
                                    collection = info.collection;
                                    Debug.Log("CustomDescription.LoadFor", "Current collection = " + collection);


                                    // Unique
                                    if (info.unique)
                                    {
                                        displayName = tooltipName = informations = "";
                                        sprite      = null;
                                    }

                                    // displayName
                                    if (string.IsNullOrEmpty(displayName))
                                    {
                                        displayName = info.displayName;
                                    }

                                    // tooltipName
                                    if (string.IsNullOrEmpty(tooltipName))
                                    {
                                        tooltipName = info.tooltipName;
                                    }

                                    // sprite
                                    sprite = sprite ?? info.sprite;

                                    // informations
                                    if (info.informations?.Length > 0)
                                    {
                                        Debug.Log("CustomDescription.LoadFor", "Adding text to informations field, index = " + index);

                                        if (info.informations.Length == 1)
                                        {
                                            informations += info.informations[0];
                                        }
                                        else
                                        {
                                            informations += info.informations[kerbal.Hash(info.useGameSeed) % info.informations.Length];
                                        }

                                        Debug.Log("CustomDescription.LoadFor", "Updated informations field = " + informations);
                                    }

                                    if (info.unique || info.last)
                                    {
                                        break;
                                    }

                                    index++;
                                    indexChance = null;
                                    Debug.Log("CustomDescription.LoadFor", "Index bumped to = " + index);
                                }
                            }
                        }
                    }
                }
            }
예제 #4
0
            internal override void LoadFor(ProtoCrewMember kerbal)
            {
                Debug.Log("CustomHead.LoadFor", "kerbal = " + kerbal);

                if (kerbal == null)
                {
                    return;
                }

                Info.hash = "";
                int?   useChance  = null;
                string collection = "";

                for (int i = 0; i < HeadInfo.DataBase?.Count; i++)
                {
                    HeadInfo info = (HeadInfo)HeadInfo.DataBase[i].GetFor(kerbal);

                    Debug.Log("CustomHead.LoadFor", "HeadInfo.DataBase[" + i + "] = " + info);
                    if (info != null)
                    {
                        Debug.Log("CustomHead.LoadFor", "Matching head collection = " + info.collection + " to current collection = " + collection);
                        if (string.IsNullOrEmpty(collection) || collection == info.collection)
                        {
                            if (useChance == null && info.useChance != 1)
                            {
                                useChance = kerbal.Hash(info.useGameSeed) % 100;
                            }

                            Debug.Log("CustomHead.LoadFor", "Matching head useChance = " + info.useChance + " to generated chance = " + useChance + " %");
                            if (info.useChance == 1 || useChance < info.useChance * 100)
                            {
                                Debug.Log("CustomHead.LoadFor", "Loading HeadInfo.DataBase[" + i + "] = " + info);

                                // Collection
                                collection = info.collection;

                                // Colors
                                pupilLeft    = pupilLeft ?? info.pupilLeft.Pick(kerbal, info.useGameSeed);
                                pupilRight   = pupilRight ?? info.pupilRight.At(pupilLeft, info.pupilLeft, kerbal, info.useGameSeed);
                                eyeballLeft  = eyeballLeft ?? info.eyeballLeft.Pick(kerbal, info.useGameSeed);
                                eyeballRight = eyeballRight ?? info.eyeballRight.At(eyeballLeft, info.eyeballLeft, kerbal, info.useGameSeed);
                                upTeeth01    = upTeeth01 ?? info.upTeeth01.Pick(kerbal, info.useGameSeed);
                                upTeeth02    = upTeeth02 ?? info.upTeeth02.At(upTeeth01, info.upTeeth01, kerbal, info.useGameSeed);
                                tongue       = tongue ?? info.tongue.Pick(kerbal, info.useGameSeed);
                                head         = head ?? info.head.Pick(kerbal, info.useGameSeed);
                                hair         = hair ?? info.hair.At(head, info.head, kerbal, info.useGameSeed) ?? head;
                                arm          = arm ?? info.arm.At(head, info.head, kerbal, info.useGameSeed) ?? head;

                                // Textures
                                pupilLeftTex    = pupilLeftTex ?? info.pupilLeftTex.Pick(kerbal, info.useGameSeed);
                                pupilRightTex   = pupilRightTex ?? info.pupilRightTex.At(pupilLeftTex, info.pupilLeftTex, kerbal, info.useGameSeed);
                                eyeballLeftTex  = eyeballLeftTex ?? info.eyeballLeftTex.Pick(kerbal, info.useGameSeed);
                                eyeballRightTex = eyeballRightTex ?? info.eyeballRightTex.At(eyeballLeftTex, info.eyeballLeftTex, kerbal, info.useGameSeed);
                                upTeeth01Tex    = upTeeth01Tex ?? info.upTeeth01Tex.Pick(kerbal, info.useGameSeed);
                                upTeeth02Tex    = upTeeth02Tex ?? info.upTeeth02Tex.At(upTeeth01Tex, info.upTeeth01Tex, kerbal, info.useGameSeed);
                                tongueTex       = tongueTex ?? info.tongueTex.Pick(kerbal, info.useGameSeed);
                                headTex         = headTex ?? info.headTex.Pick(kerbal, info.useGameSeed);
                                hairTex         = hairTex ?? info.hairTex.At(headTex, info.headTex, kerbal, info.useGameSeed);
                                armTex          = armTex ?? info.armTex.At(headTex, info.headTex, kerbal, info.useGameSeed);

                                // Normals
                                pupilLeftNrm    = pupilLeftNrm ?? info.pupilLeftNrm.At(pupilLeftTex, info.pupilLeftTex, kerbal, info.useGameSeed);
                                pupilRightNrm   = pupilRightNrm ?? info.pupilRightNrm.At(pupilRightTex, info.pupilRightTex, kerbal, info.useGameSeed);
                                eyeballLeftNrm  = eyeballLeftNrm ?? info.eyeballLeftNrm.At(eyeballLeftTex, info.eyeballLeftTex, kerbal, info.useGameSeed);
                                eyeballRightNrm = eyeballRightNrm ?? info.eyeballRightNrm.At(eyeballRightTex, info.eyeballRightTex, kerbal, info.useGameSeed);
                                upTeeth01Nrm    = upTeeth01Nrm ?? info.upTeeth01Nrm.At(upTeeth01Tex, info.upTeeth01Tex, kerbal, info.useGameSeed);
                                upTeeth02Nrm    = upTeeth02Nrm ?? info.upTeeth02Nrm.At(upTeeth02Tex, info.upTeeth02Tex, kerbal, info.useGameSeed);
                                tongueNrm       = tongueNrm ?? info.tongueNrm.At(tongueTex, info.tongueTex, kerbal, info.useGameSeed);
                                headNrm         = headNrm ?? info.headNrm.At(headTex, info.headTex, kerbal, info.useGameSeed);
                                hairNrm         = hairNrm ?? info.hairNrm.At(hairTex, info.hairTex, kerbal, info.useGameSeed);
                                armNrm          = armNrm ?? info.armNrm.At(armTex, info.armTex, kerbal, info.useGameSeed);

                                continue;
                            }
                        }
                    }

                    Debug.Log("CustomHead.LoadFor", "Ignoring HeadInfo.DataBase[" + i + "] = " + info);
                }
            }
예제 #5
0
            internal override void LoadFor(ProtoCrewMember kerbal)
            {
                Debug.Log("CustomSuit.LoadFor", "kerbal = " + kerbal);

                if (kerbal == null)
                {
                    return;
                }

                Info.hash = "";
                int?   useChance  = null;
                string collection = "";

                for (int i = 0; i < SuitInfo.DataBase?.Count; i++)
                {
                    SuitInfo info = (SuitInfo)SuitInfo.DataBase[i].GetFor(kerbal);

                    Debug.Log("CustomSuit.LoadFor", "SuitInfo.DataBase[" + i + "] = " + info);
                    if (info != null)
                    {
                        Type type = Type.IVA;
                        if (eva != null)
                        {
                            type = Type.EVA;
                        }
                        else if (kerbal is CrewMember && (kerbal as CrewMember)?.activity == 0)
                        {
                            type = Type.EVA;
                        }

                        Debug.Log("CustomSuit.LoadFor", "Matching suit type = " + info.type + " to current activity = " + type);
                        if (info.type != null && info.type != type)
                        {
                            continue;
                        }

                        bool useSuit = true;
                        if (info.situation != null || info.breathable != null || info.suitMinPressure != null || info.suitMaxPressure != null)
                        {
                            useSuit = false;
                            if (eva != null)
                            {
                                Debug.Log("CustomSuit.LoadFor", "Matching " + (info?.situation?.Length ?? 0) + " situation(s) to kerbal situation = " + situation);
                                if (info.situation == null || info.situation.Contains(situation))
                                {
                                    Debug.Log("CustomSuit.LoadFor", "Matching atmosphereContainsOxygen = " + eva?.vessel?.mainBody?.atmosphereContainsOxygen + " to suit breathable = " + info.breathable);
                                    if (info.breathable == null || info.breathable == eva?.vessel?.mainBody?.atmosphereContainsOxygen)
                                    {
                                        double pressure = FlightGlobals.getStaticPressure();
                                        useSuit = !(pressure < info.suitMinPressure) && !(pressure > info.suitMaxPressure);
                                        Debug.Log("CustomSuit.LoadFor", "Matching suitMinPressure = " + info.suitMinPressure + ", suitMaxPressure = " + info.suitMaxPressure + " to current atmospheric pressure = " + pressure + ". useSuit = " + useSuit);
                                    }
                                }
                            }
                        }

                        Debug.Log("CustomSuit.LoadFor", "Matching suit collection = " + info.collection + " to current collection = " + collection);
                        if (string.IsNullOrEmpty(collection) || collection == info.collection)
                        {
                            if (useChance == null && info.useChance != 1)
                            {
                                useChance = kerbal.Hash(info.useGameSeed) % 100;
                            }

                            Debug.Log("CustomSuit.LoadFor", "Matching suit useChance = " + info.useChance + " to generated chance = " + useChance + " %");
                            if (info.useChance == 1 || useChance < info.useChance * 100)
                            {
                                Debug.Log("CustomSuit.LoadFor", "Loading SuitInfo.DataBase[" + i + "]");

                                // Collection
                                collection = info.collection;

                                // Suit Specific Requirements
                                if (useSuit)
                                {
                                    helmetLowPressure  = helmetLowPressure ?? info.helmetLowPressure;
                                    helmetHighPressure = helmetHighPressure ?? info.helmetHighPressure;
                                    helmetDelay        = helmetDelay ?? info.helmetDelay;
                                }
                                jetpackMaxGravity = jetpackMaxGravity ?? info.jetpackMaxGravity;

                                // Colors
                                if (useSuit)
                                {
                                    body     = body ?? info.body.Pick(kerbal, info.useGameSeed);
                                    neckRing = neckRing ?? info.neckRing.Pick(kerbal, info.useGameSeed);
                                    helmet   = helmet ?? info.helmet.Pick(kerbal, info.useGameSeed);
                                    visor    = visor ?? info.visor.Pick(kerbal, info.useGameSeed);
                                    flares   = flares ?? info.flares.Pick(kerbal, info.useGameSeed);
                                    light    = light ?? info.light.Pick(kerbal, info.useGameSeed);
                                }
                                jetpack   = jetpack ?? info.jetpack.Pick(kerbal, info.useGameSeed);
                                parachute = parachute ?? info.parachute.Pick(kerbal, info.useGameSeed);
                                canopy    = canopy ?? info.canopy.Pick(kerbal, info.useGameSeed);
                                backpack  = backpack ?? info.backpack.Pick(kerbal, info.useGameSeed);
                                flag      = flag ?? info.flag.Pick(kerbal, info.useGameSeed);
                                gasjets   = gasjets ?? info.gasjets.Pick(kerbal, info.useGameSeed);
                                headset   = headset ?? info.headset.Pick(kerbal, info.useGameSeed);
                                mug       = mug ?? info.mug.Pick(kerbal, info.useGameSeed);
                                glasses   = glasses ?? info.glasses.Pick(kerbal, info.useGameSeed);
                                backdrop  = backdrop ?? info.backdrop.Pick(kerbal, info.useGameSeed);

                                // Textures
                                if (useSuit)
                                {
                                    bodyTex     = bodyTex ?? info.bodyTex.Pick(kerbal, info.useGameSeed);
                                    neckRingTex = neckRingTex ?? info.neckRingTex.At(bodyTex, info.bodyTex, kerbal, info.useGameSeed);
                                    helmetTex   = helmetTex ?? info.helmetTex.At(bodyTex, info.bodyTex, kerbal, info.useGameSeed);
                                    visorTex    = visorTex ?? info.visorTex.Pick(kerbal, info.useGameSeed);
                                    flaresTex   = flaresTex ?? info.flaresTex.Pick(kerbal, info.useGameSeed);
                                }
                                jetpackTex   = jetpackTex ?? info.jetpackTex.Pick(kerbal, info.useGameSeed);
                                parachuteTex = parachuteTex ?? info.parachuteTex.Pick(kerbal, info.useGameSeed);
                                canopyTex    = canopyTex ?? info.canopyTex.Pick(kerbal, info.useGameSeed);
                                backpackTex  = backpackTex ?? info.backpackTex.Pick(kerbal, info.useGameSeed);
                                flagTex      = flagTex ?? info.flagTex.Pick(kerbal, info.useGameSeed);
                                gasjetsTex   = gasjetsTex ?? info.gasjetsTex.Pick(kerbal, info.useGameSeed);
                                headsetTex   = headsetTex ?? info.headsetTex.Pick(kerbal, info.useGameSeed);
                                mugTex       = mugTex ?? info.mugTex.Pick(kerbal, info.useGameSeed);
                                glassesTex   = glassesTex ?? info.glassesTex.Pick(kerbal, info.useGameSeed);
                                backdropTex  = backdropTex ?? info.backdropTex.Pick(kerbal, info.useGameSeed);

                                // Normals
                                if (useSuit)
                                {
                                    bodyNrm     = bodyNrm ?? info.bodyNrm.At(bodyTex, info.bodyTex, kerbal, info.useGameSeed);
                                    neckRingNrm = neckRingNrm ?? info.neckRingNrm.At(neckRingTex, info.neckRingTex, kerbal, info.useGameSeed);
                                    helmetNrm   = helmetNrm ?? info.helmetNrm.At(helmetTex, info.helmetTex, kerbal, info.useGameSeed);
                                    visorNrm    = visorNrm ?? info.visorNrm.At(visorTex, info.visorTex, kerbal, info.useGameSeed);
                                }
                                jetpackNrm   = jetpackNrm ?? info.jetpackNrm.At(jetpackTex, info.jetpackTex, kerbal, info.useGameSeed);
                                parachuteNrm = parachuteNrm ?? info.parachuteNrm.At(parachuteTex, info.parachuteTex, kerbal, info.useGameSeed);
                                canopyNrm    = canopyNrm ?? info.canopyNrm.At(canopyTex, info.canopyTex, kerbal, info.useGameSeed);
                                backpackNrm  = backpackNrm ?? info.backpackNrm.At(backpackTex, info.backpackTex, kerbal, info.useGameSeed);
                                flagNrm      = flagNrm ?? info.flagNrm.At(flagTex, info.flagTex, kerbal, info.useGameSeed);
                                headsetNrm   = headsetNrm ?? info.headsetNrm.At(headsetTex, info.headsetTex, kerbal, info.useGameSeed);
                                mugNrm       = mugNrm ?? info.mugNrm.At(mugTex, info.mugTex, kerbal, info.useGameSeed);
                                glassesNrm   = glassesNrm ?? info.glassesNrm.At(glassesTex, info.glassesTex, kerbal, info.useGameSeed);
                                backdropNrm  = backdropNrm ?? info.backdropNrm.At(backdropTex, info.backdropTex, kerbal, info.useGameSeed);

                                continue;
                            }
                        }
                    }

                    Debug.Log("CustomSuit.LoadFor", "Ignoring SuitInfo.DataBase[" + i + "]");
                }

                helmetTime = helmetDelay ?? 1;
            }