Beispiel #1
0
        public ValueInfo ReadValueInfo(byte formatByte, Stream stream)
        {
            if ((formatByte & 0xf0) == 0x80)
            {
                return(ValueInfo.ForChildContainer(0, (formatByte & 0x0f) * 2));
            }

            int headerSize;

            switch (formatByte)
            {
            case 0xde:
                headerSize = 2;
                break;

            case 0xdf:
                headerSize = 4;
                break;

            default:
                throw Exceptions.FormatByteNotSupported(formatByte);
            }

            var childCount = NumericParser.ReadInt32(stream, headerSize) * 2;

            return(ValueInfo.ForChildContainer(headerSize, childCount));
        }
Beispiel #2
0
        protected override void BuildDialog()
        {
            // Skin
            Skin = KittopiaTech.Skin;

            GUIVerticalLayout(() =>
            {
                NumericParser <Single> x = 0;
                NumericParser <Single> y = 0;

                // X
                Integrate(new SingleEditor("", () => Reference, () =>
                {
                    Vector2Parser parser = (Vector2Parser)GetValue();
                    return(x = parser.Value.x);
                }, v =>
                {
                    x = (NumericParser <Single>)v;
                    SetValue((Vector2Parser) new Vector2(x, y));
                }));

                // Y
                Integrate(new SingleEditor("", () => Reference, () =>
                {
                    Vector2Parser parser = (Vector2Parser)GetValue();
                    return(y = parser.Value.y);
                }, v =>
                {
                    y = (NumericParser <Single>)v;
                    SetValue((Vector2Parser) new Vector2(x, y));
                }));
            });
        }
Beispiel #3
0
 public ClockFormatLoader(string singular, string plural, string symbol, double value)
 {
     this.singular = singular;
     this.plural   = plural;
     this.symbol   = symbol;
     this.value    = value;
 }
 public TimeUnits(string singular, string plural, string symbol, double value, bool round = false)
 {
     this.singular = singular;
     this.plural   = plural;
     this.symbol   = symbol;
     this.value    = round ? Math.Round(value, 0) : value;
     this.round    = round;
 }
Beispiel #5
0
        public void HexNumeric_MustStartWith0x()
        {
            NumericParser parser = new NumericParser();
            string        token  = "f2";

            NumericNode node = (NumericNode)parser.Parse(token);

            Assert.IsNull(node);
        }
Beispiel #6
0
        public void HexNumeric_AllowsCapital()
        {
            NumericParser parser = new NumericParser();
            string        token  = "0xF2";

            NumericNode node = (NumericNode)parser.Parse(token);

            Assert.AreEqual(242, node.Value);
        }
Beispiel #7
0
        public void HexNumeric_StartWith0x()
        {
            NumericParser parser = new NumericParser();
            string        token  = "0xf2";

            NumericNode node = (NumericNode)parser.Parse(token);

            Assert.AreEqual(242, node.Value);
        }
 public DisplayLoader(double offsetTime, int offsetYear, int offsetDay, string displayDate, string displayTime, string displaySeconds)
 {
     this.offsetTime     = offsetTime;
     this.offsetYear     = offsetYear;
     this.offsetDay      = offsetDay;
     this.displayDate    = displayDate;
     this.displayTime    = displayTime;
     this.displaySeconds = displaySeconds;
 }
Beispiel #9
0
        void AddNumericTokens()
        {
            NumericParser np = new NumericParser();

            foreach (var item in codeTxtBox.Lines)
            {
                lstIdTokens = np.GenerateTokens(item);
            }
        }
Beispiel #10
0
 public TextureOptions()
 {
     ExportColor     = true;
     ExportHeight    = true;
     ExportNormal    = true;
     TransparentMaps = true;
     SaveToDisk      = true;
     ApplyToScaled   = true;
     NormalStrength  = 7;
 }
 public TextureOptions()
 {
     ExportColor     = true;
     ExportHeight    = true;
     ExportNormal    = true;
     TransparentMaps = true;
     SaveToDisk      = true;
     ApplyToScaled   = true;
     NormalStrength  = 10;
     Resolution      = 2048;
     TextureDelta    = 0;
 }
Beispiel #12
0
        private IntVector4 Get4(string s)
        {
            int t, b, l, r;

            if (s.Contains("top"))
            {
                t = NumericParser.getIntByDelimiters(s, "top", ';');
            }
            else
            {
                t = 0;
            }
            if (s.Contains("bottom"))
            {
                b = NumericParser.getIntByDelimiters(s, "bottom", ';');
            }
            else
            {
                b = 0;
            }
            if (s.Contains("left"))
            {
                l = NumericParser.getIntByDelimiters(s, "left", ';');
            }
            else
            {
                l = 0;
            }
            if (s.Contains("right"))
            {
                r = NumericParser.getIntByDelimiters(s, "right", ';');
            }
            else
            {
                r = 0;
            }
            return(new IntVector4(t, b, l, r));
        }
Beispiel #13
0
        bool GetSetting(string name, bool Default)
        {
            bool output = Default;

            foreach (ConfigNode Settings in GameDatabase.Instance.GetConfigNodes("SASSLoadingScreen"))
            {
                if (Settings.HasValue(name))
                {
                    NumericParser <bool> userSetting = new NumericParser <bool>();
                    userSetting.SetFromString(Settings.GetValue(name));
                    if (userSetting.value == Default)
                    {
                        return(Default);
                    }
                    else
                    {
                        output = !Default;
                    }
                }
            }

            return(output);
        }
 Vector3?GetCenter(ConfigNode node, CelestialBody body)
 {
     if (node.HasValue("CentralPQSCity"))
     {
         return(body.GetComponentsInChildren <PQSCity>(true).FirstOrDefault(p => p.name == node.GetValue("CentralPQSCity")).repositionRadial);
     }
     else if (node.HasValue("CentralPQSCity2"))
     {
         return(body.GetComponentsInChildren <PQSCity2>(true).First(p => p.name == node.GetValue("CentralPQSCity2")).PlanetRelativePosition);
     }
     else if (node.HasValue("CentralPosition"))
     {
         Vector3Parser v = new Vector3Parser();
         v.SetFromString(node.GetValue("CentralPosition"));
         return(v);
     }
     else if (node.HasValue("CentralLAT") && node.HasValue("CentralLON"))
     {
         NumericParser <double> LAT = new NumericParser <double>();
         NumericParser <double> LON = new NumericParser <double>();
         LAT.SetFromString(node.GetValue("CentralLAT"));
         LON.SetFromString(node.GetValue("CentralLON"));
         return(Utility.LLAtoECEF(LAT, LON, 1, 1));
     }
     else if (node.HasValue("PQSCity"))
     {
         return(body.GetComponentsInChildren <PQSCity>(true).FirstOrDefault(p => p.name == node.GetValue("PQSCity")).repositionRadial);
     }
     else if (node.HasValue("PQSCity2"))
     {
         return(body.GetComponentsInChildren <PQSCity2>(true).First(p => p.name == node.GetValue("PQSCity2")).PlanetRelativePosition);
     }
     else
     {
         return(null);
     }
 }
Beispiel #15
0
        void IParserEventSubscriber.PostApply(ConfigNode node)
        {
            // Apply changes to the Material
            Material material = generatedBody.scaledVersion.GetComponent <Renderer>()?.sharedMaterial;

            if (material != null)
            {
                if (emitColor0?.value != null)
                {
                    Color color = Pick(emitColor0);

                    material.SetColor("_EmitColor0", color);

                    if (emitColorMult != null)
                    {
                        material.SetColor("_EmitColor1", color * emitColorMult);
                    }

                    if (rimColorMult != null)
                    {
                        material.SetColor("_RimColor", color * rimColorMult);
                    }
                }

                if (emitColor1 != null)
                {
                    material.SetColor("_EmitColor1", Pick(emitColor1));
                }

                if (sunspotColor == null)
                {
                    sunspotColor = emitColor0;
                }

                if (sunspotTemp == null)
                {
                    sunspotTemp = temperature;
                }

                material.SetColor("_SunspotColor", Pick(sunspotColor, sunspotTemp) * sunspotColorMult);

                if (type == StarType.WhiteDwarf)
                {
                    material.SetColor("_EmitColor0", new Color(0.9f, 0.9f, 0.9f, 1));
                    material.SetColor("_EmitColor1", material.GetColor("_EmitColor1") * 0.925f);
                }
            }


            // Apply changes to the LightShifter
            LightShifter light = generatedBody.scaledVersion.GetComponentInChildren <LightShifter>();

            if (light != null)
            {
                if (lightColors == null)
                {
                    lightColors = emitColor0;
                }

                Color color = Pick(lightColors) * lightColorMult;

                light.ambientLightColor   = new Color(0, 0, 0, 1);
                light.IVASunColor         = color;
                light.scaledSunlightColor = color;
                light.sunlightColor       = color;
            }


            // Set Orbit Color
            if (setOrbit.value && emitColor0 != null)
            {
                generatedBody.orbitRenderer.SetColor(Pick(emitColor0));
            }
        }
Beispiel #16
0
 // Create a loader from given values
 public RandomRangeLoader(Single minValue, Single maxValue)
 {
     MaxValue = maxValue;
     MinValue = minValue;
 }
Beispiel #17
0
 // Create a loader from given values
 public RandomRangeLoader()
 {
     MaxValue = 1;
     MinValue = 0;
 }
Beispiel #18
0
 // Create a loader from given values
 public RandomRangeLoader()
 {
     this.maxValue = 1;
     this.minValue = 0;
 }
 public Month()
 {
     name   = "";
     symbol = "";
     days   = 0;
 }
 public Month(string name, string symbol, int days)
 {
     this.name   = name;
     this.symbol = symbol;
     this.days   = days;
 }
 public void BeforeEachTest()
 {
     NumericParser = new NumericParser();
 }
Beispiel #22
0
        private void Start()
        {
            //  FIX BODIES MOVED POST SPAWN  //
            Boolean postSpawnChanges = false;

            // Replaced 'foreach' with 'for' to improve performance
            CelestialBody[] postSpawnBodies = PSystemManager.Instance.localBodies.Where(b => b.Has("orbitPatches")).ToArray();

            for (Int32 i = 0; i < postSpawnBodies.Length; i++)
            {
                CelestialBody cb = postSpawnBodies[i];

                // Fix position if the body gets moved PostSpawn
                ConfigNode patch = cb.Get <ConfigNode>("orbitPatches");
                if (patch == null)
                {
                    continue;
                }
                if (patch.GetValue("referenceBody") == null && patch.GetValue("semiMajorAxis") == null)
                {
                    continue;
                }
                if (cb.orbitDriver == null)
                {
                    continue;
                }

                // Get the body
                PSystemBody body = PSystemManager.Instance.systemPrefab.GetComponentsInChildren <PSystemBody>(true).FirstOrDefault(b => b.name == cb.transform.name);
                if (body == null)
                {
                    Debug.Log("[Kopernicus]: RnDFixer: Could not find PSystemBody => " + cb.transform.name);
                    continue;
                }

                // Get the parent
                PSystemBody oldParent = PSystemManager.Instance.systemPrefab.GetComponentsInChildren <PSystemBody>(true).FirstOrDefault(b => b.children.Contains(body));
                if (oldParent == null)
                {
                    Debug.Log("[Kopernicus]: RnDFixer: Could not find referenceBody of CelestialBody => " + cb.transform.name);
                    continue;
                }

                // Check if PostSpawnOrbit changes referenceBody
                PSystemBody newParent = oldParent;
                if (patch.GetValue("referenceBody") != null)
                {
                    newParent = PSystemManager.Instance.systemPrefab.GetComponentsInChildren <PSystemBody>(true)
                                .FirstOrDefault(b => b.name == patch.GetValue("referenceBody"));
                }
                if (oldParent == null)
                {
                    Debug.Log("[Kopernicus]: RnDFixer: Could not find PostSpawn referenceBody of CelestialBody => " + cb.transform.name);
                    newParent = oldParent;
                }
                NumericParser <Double> newSemiMajorAxis = body.orbitDriver.orbit.semiMajorAxis;
                if (patch.GetValue("semiMajorAxis") != null)
                {
                    newSemiMajorAxis.SetFromString(patch.GetValue("semiMajorAxis"));
                }

                // Remove the body from oldParent.children
                oldParent.children.Remove(body);

                // Find the index of the body in newParent.children
                if (newParent != null)
                {
                    Int32 index = newParent.children.FindAll(c => c.orbitDriver.orbit.semiMajorAxis < newSemiMajorAxis.Value).Count;

                    // Add the body to newParent.children
                    if (index > newParent.children.Count)
                    {
                        newParent.children.Add(body);
                    }
                    else
                    {
                        newParent.children.Insert(index, body);
                    }
                }

                // Signal that the system has PostSpawn changes
                postSpawnChanges = true;
            }

            // Rebuild Archives
            if (postSpawnChanges)
            {
                AddPlanets();
            }



            //  RDVisibility = HIDDEN  //  RDVisibility = SKIP  //

            // Create a list with body to hide and their parent
            List <KeyValuePair <PSystemBody, KeyValuePair <PSystemBody, Int32> > > hideList = new List <KeyValuePair <PSystemBody, KeyValuePair <PSystemBody, Int32> > >();

            // Create a list with body to skip and their parent
            List <KeyValuePair <PSystemBody, PSystemBody> > skipList = new List <KeyValuePair <PSystemBody, PSystemBody> >();

            // Replaced 'foreach' with 'for' to improve performance
            PSystemBody[]   bodies     = PSystemManager.Instance.systemPrefab.GetComponentsInChildren <PSystemBody>(true);
            CelestialBody[] hideBodies = PSystemManager.Instance.localBodies.Where(cb => cb.Has("hiddenRnD")).ToArray();

            for (Int32 i = 0; i < hideBodies.Length; i++)
            {
                CelestialBody body = hideBodies[i];
                PropertiesLoader.RnDVisibility visibility = body.Get <PropertiesLoader.RnDVisibility>("hiddenRnD");

                if (visibility != PropertiesLoader.RnDVisibility.Hidden &&
                    visibility != PropertiesLoader.RnDVisibility.Skip)
                {
                    continue;
                }

                PSystemBody hidden =
                    Utility.FindBody(PSystemManager.Instance.systemPrefab.rootBody, body.transform.name);
                PSystemBody parent = bodies.FirstOrDefault(b => b.children.Contains(hidden));
                if (parent == null)
                {
                    continue;
                }

                // Hide
                if (hidden.children.Count == 0 || visibility == PropertiesLoader.RnDVisibility.Hidden)
                {
                    body.Set("hiddenRnd", PropertiesLoader.RnDVisibility.Hidden);
                    hideList.Add(new KeyValuePair <PSystemBody, KeyValuePair <PSystemBody, Int32> >(hidden,
                                                                                                    new KeyValuePair <PSystemBody, Int32>(parent, 0)));
                }
                // Skip
                else
                {
                    if (skipList.Any(b => b.Key == parent))
                    {
                        Int32 index = skipList.IndexOf(skipList.FirstOrDefault(b => b.Key == parent));
                        skipList.Insert(index, new KeyValuePair <PSystemBody, PSystemBody>(hidden, parent));
                    }
                    else
                    {
                        skipList.Add(new KeyValuePair <PSystemBody, PSystemBody>(hidden, parent));
                    }
                }
            }

            // Skip bodies
            for (Int32 i = 0; i < skipList.Count; i++)
            {
                KeyValuePair <PSystemBody, PSystemBody> pair = skipList[i];

                // Get hidden body and parent
                PSystemBody hidden = pair.Key;
                PSystemBody parent = pair.Value;

                // Find where the hidden body is
                Int32 index = parent.children.IndexOf(hidden);

                // Remove the hidden body from its parent's children list so it won't show up when clicking the parent
                parent.children.Remove(hidden);

                // Put its children in its place
                parent.children.InsertRange(index, hidden.children);
            }

            // Hide bodies
            for (Int32 i = 0; i < hideList.Count; i++)
            {
                KeyValuePair <PSystemBody, KeyValuePair <PSystemBody, Int32> > pair = hideList[i];

                // Get hidden body and parent
                PSystemBody hidden = pair.Key;
                PSystemBody parent = bodies.FirstOrDefault(b => b.children.Contains(hidden));

                if (parent == null)
                {
                    continue;
                }

                // Find where the hidden body is
                Int32 index = parent.children.IndexOf(hidden);

                // Remove the hidden body from its parent's children list so it won't show up when clicking the parent
                parent.children.Remove(hidden);

                // Save the position in the hideList
                hideList[i] = new KeyValuePair <PSystemBody, KeyValuePair <PSystemBody, Int32> >(hidden, new KeyValuePair <PSystemBody, Int32>(parent, index));
            }

            // Apply changes and revert to the original PSystem
            if (hideList.Count > 0 || skipList.Count > 0)
            {
                // Rebuild Archives
                AddPlanets();

                // Undo the changes to the PSystem (hide)
                for (Int32 i = hideList.Count - 1; i > -1; i--)
                {
                    PSystemBody hidden   = hideList[i].Key;
                    PSystemBody parent   = hideList[i].Value.Key;
                    Int32       oldIndex = hideList[i].Value.Value;
                    parent.children.Insert(oldIndex, hidden);
                }
                // Undo the changes to the PSystem (skip)
                for (Int32 i = skipList.Count - 1; i > -1; i--)
                {
                    PSystemBody hidden   = skipList[i].Key;
                    PSystemBody parent   = skipList[i].Value;
                    Int32       oldIndex = parent.children.IndexOf(hidden.children.FirstOrDefault());
                    parent.children.Insert(oldIndex, hidden);

                    for (Int32 j = 0; j < hidden.children.Count; j++)
                    {
                        PSystemBody child = hidden.children[j];

                        if (parent.children.Contains(child))
                        {
                            parent.children.Remove(child);
                        }
                    }
                }
            }



            //  RDVisibility = NOICON  //  Kill Rotation //
            // Loop through the Containers
            RDPlanetListItemContainer[] containers = Resources.FindObjectsOfTypeAll <RDPlanetListItemContainer>().Where(i => i.label_planetName.text != "Planet name").ToArray();
            for (Int32 i = 0; i < containers.Length; i++)
            {
                RDPlanetListItemContainer planetItem = containers[i];

                // The label text is set from the CelestialBody's displayName
                CelestialBody body = PSystemManager.Instance.localBodies.FirstOrDefault(cb => cb.transform.name == planetItem.name);
                if (body == null)
                {
                    Debug.Log("[Kopernicus]: RnDFixer: Could not find CelestialBody for the label => " + planetItem.name);
                    continue;
                }

                // Barycenter
                if (body.Has("barycenter") || !body.Get("selectable", true))
                {
                    planetItem.planet.SetActive(false);
                    planetItem.label_planetName.alignment = TextAlignmentOptions.MidlineLeft;
                }

                // RD Visibility
                if (body.Has("hiddenRnD"))
                {
                    PropertiesLoader.RnDVisibility visibility = body.Get <PropertiesLoader.RnDVisibility>("hiddenRnD");
                    if (visibility == PropertiesLoader.RnDVisibility.Noicon)
                    {
                        planetItem.planet.SetActive(false);
                        planetItem.label_planetName.alignment = TextAlignmentOptions.MidlineLeft;
                    }
                    else
                    {
                        planetItem.planet.SetActive(true);
                        planetItem.label_planetName.alignment = TextAlignmentOptions.MidlineRight;
                    }
                }

                // Add planetItems to 'RnDRotationKill'
                if (planetItem.planet.transform == null)
                {
                    continue;
                }
                if (body.Has("RnDRotation") ? !body.Get <Boolean>("RnDRotation") : body.scaledBody.GetComponentInChildren <SunCoronas>(true) != null)
                {
                    RnDRotationKill.Add(planetItem);
                }
            }
        }
Beispiel #23
0
 // Create a loader from given values
 public RandomRangeLoader(Single minValue, Single maxValue)
 {
     this.maxValue = maxValue;
     this.minValue = minValue;
 }
Beispiel #24
0
 // Create a loader from given values
 public RandomRangeLoader(float minValue, float maxValue)
 {
     this.maxValue = maxValue;
     this.minValue = minValue;
 }
Beispiel #25
0
        public static void TextureFixer(Body body1, Body body2, List<Body> list)
        {
            if (!SigmaBinary.IamSad)
            {
                if (DateTime.Today.Day == 26 && DateTime.Today.Month == 1)
                {
                    foreach (Body b in list)
                    {
                        b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(b.generatedBody.scaledVersion.GetComponent<Renderer>().material.GetTextureScale("_MainTex").x, -b.generatedBody.scaledVersion.GetComponent<Renderer>().material.GetTextureScale("_MainTex").y));
                        b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureScale("_BumpMap", new Vector2(b.generatedBody.scaledVersion.GetComponent<Renderer>().material.GetTextureScale("_BumpMap").x, -b.generatedBody.scaledVersion.GetComponent<Renderer>().material.GetTextureScale("_BumpMap").y));
                    }
                }
                if (DateTime.Today.Day == 14 && DateTime.Today.Month == 2)
                {
                    Texture2D MainTex = Resources.FindObjectsOfTypeAll<Texture>().Where(tex => tex.name == "NewMunSurfaceMapDiffuse").FirstOrDefault() as Texture2D;
                    Texture2D BumpMap = Resources.FindObjectsOfTypeAll<Texture>().Where(tex => tex.name == "NewMunSurfaceMapNormals").FirstOrDefault() as Texture2D;

                    foreach (Body b in list)
                    {
                        EnumParser<BodyType> type = new EnumParser<BodyType>(b.template == null ? BodyType.Atmospheric : b.template.type);

                        if (type != BodyType.Star)
                        {
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTexture("_MainTex", MainTex);
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTexture("_BumpMap", BumpMap);

                            if (OnDemandStorage.useOnDemand)
                            {
                                ScaledSpaceDemand demand = b.generatedBody.scaledVersion.GetComponent<ScaledSpaceDemand>();
                                demand.texture = MainTex.name;
                                demand.normals = BumpMap.name;
                            }

                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, 0));
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(1, 1));
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureOffset("_BumpMap", new Vector2(0, 0));
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureScale("_BumpMap", new Vector2(1, 1));
                        }
                    }
                }
                if (SigmaBinary.ListOfBinaries.Count == 0 && DateTime.Today.Day == 14 && DateTime.Today.Month == 3)
                {
                    string[] P = new string[] { "92653", "58979", "32384", "62643", "38327", "95028", "84197", "16939", "93751", "05820", "97494", "45923", "07816", "40628", "62089", "98628", "03482", "53421", "17067", "98214" };
                    Dictionary<CelestialBody, double> pList = new Dictionary<CelestialBody, double>();

                    foreach (Body pBody in SigmaBinary.ListOfBodies)
                    {
                        if (pBody.name == "Sun")
                        {
                            if (!pBody.generatedBody.celestialBody.GetComponent<NameChanger>())
                            {
                                NameChanger changer = pBody.generatedBody.celestialBody.gameObject.AddComponent<NameChanger>();
                                changer.oldName = pBody.name;
                                changer.newName = "3.1415";
                            }
                            else
                                pBody.generatedBody.celestialBody.gameObject.AddComponent<NameChanger>().newName = "3.1415";
                        }
                        else if (pBody.generatedBody.celestialBody.Has("orbitPatches") && pBody.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches").GetValue("referenceBody") == "Sun")
                        {
                            pList.Add(pBody.generatedBody.celestialBody, pBody.generatedBody.orbitDriver.orbit.semiMajorAxis);
                        }
                        else if (pBody.orbit.referenceBody == "Sun" && !(pBody.generatedBody.celestialBody.Has("orbitPatches") && pBody.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches").GetValue("referenceBody") != "Sun"))
                        {
                            if (!(pBody.name == "Kerbin" && SigmaBinary.kerbinFixer != "Sun"))
                            {
                                pList.Add(pBody.generatedBody.celestialBody, pBody.generatedBody.orbitDriver.orbit.semiMajorAxis);
                            }
                        }

                        if (pList.ContainsKey(pBody.generatedBody.celestialBody) && pBody.generatedBody.celestialBody.Has("orbitPatches") && pBody.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches").GetValue("semiMajorAxis") != null)
                        {
                            NumericParser<double> sma = new NumericParser<double>();
                            sma.SetFromString(pBody.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches").GetValue("semiMajorAxis"));
                            pList[pBody.generatedBody.celestialBody] = sma.value;
                        }
                    }

                    foreach (string pSBP in SigmaBinary.archivesFixerList.Keys)
                    {
                        if (pSBP == "Kerbin")
                        {
                            CelestialBody pKF = pList.Keys.ToList().Find(KF => KF.name == SigmaBinary.kerbinFixer);
                            if (pKF != null)
                            {
                                pList.Add(SigmaBinary.ListOfBodies.Find(SBP => SBP.name == pSBP).generatedBody.celestialBody, pList[pKF]);
                                pList.Remove(pKF);
                            }
                        }
                        else
                        {
                            CelestialBody pSBB = pList.Keys.ToList().Find(pREF => pREF.name == SigmaBinary.ListOfBodies.Find(SBP => SBP.name == pSBP).orbit.referenceBody);
                            if (pSBB != null)
                            {
                                pList.Add(SigmaBinary.ListOfBodies.Find(SBP => SBP.name == pSBP).generatedBody.celestialBody, pList[pSBB]);
                                pList.Remove(pSBB);
                            }
                        }
                    }

                    int pCount = 0;
                    foreach (KeyValuePair<CelestialBody, double> pFix in pList.OrderBy(pKey => pKey.Value))
                    {
                        if (pCount < 20)
                        {
                            if (!pFix.Key.GetComponent<NameChanger>())
                            {
                                NameChanger changer = pFix.Key.gameObject.AddComponent<NameChanger>();
                                changer.oldName = pFix.Key.name;
                                changer.newName = P[pCount];
                            }
                            else
                                pFix.Key.gameObject.GetComponent<NameChanger>().newName = P[pCount];
                            pCount++;
                        }
                    }
                }
                if (DateTime.Today.Day == 1 && DateTime.Today.Month == 4)
                {
                    EnumParser<BodyType> type1 = new EnumParser<BodyType>(body1.template == null ? BodyType.Atmospheric : body1.template.type);
                    EnumParser<BodyType> type2 = new EnumParser<BodyType>(body2.template == null ? BodyType.Atmospheric : body2.template.type);

                    if (type1.value != BodyType.Star && type2.value != BodyType.Star)
                    {
                        Material material1 = new Material(body1.generatedBody.scaledVersion.GetComponent<Renderer>().material);
                        Material material2 = new Material(body2.generatedBody.scaledVersion.GetComponent<Renderer>().material);
                        body1.generatedBody.scaledVersion.GetComponent<Renderer>().material = material2;
                        body2.generatedBody.scaledVersion.GetComponent<Renderer>().material = material1;

                        if (OnDemandStorage.useOnDemand)
                        {
                            ScaledSpaceDemand demand1 = body1.generatedBody.scaledVersion.GetComponent<ScaledSpaceDemand>();
                            ScaledSpaceDemand demand2 = body2.generatedBody.scaledVersion.GetComponent<ScaledSpaceDemand>();
                            demand1.texture = material2.GetTexture("_MainTex").name;
                            demand1.normals = material2.GetTexture("_BumpMap").name;
                            demand2.texture = material1.GetTexture("_MainTex").name;
                            demand2.normals = material1.GetTexture("_BumpMap").name;
                        }
                    }
                }
                if (DateTime.Today.Day == 22 && DateTime.Today.Month == 4)
                {
                    Texture2D MainTex = Resources.FindObjectsOfTypeAll<Texture>().Where(tex => tex.name == "KerbinScaledSpace300").FirstOrDefault() as Texture2D;
                    Texture2D BumpMap = Resources.FindObjectsOfTypeAll<Texture>().Where(tex => tex.name == "KerbinScaledSpace401").FirstOrDefault() as Texture2D;

                    foreach (Body b in list)
                    {

                        EnumParser<BodyType> type = new EnumParser<BodyType>(b.template == null ? BodyType.Atmospheric : b.template.type);

                        if (type != BodyType.Star)
                        {
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTexture("_MainTex", MainTex);
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTexture("_BumpMap", BumpMap);

                            if (OnDemandStorage.useOnDemand)
                            {
                                ScaledSpaceDemand demand = b.generatedBody.scaledVersion.GetComponent<ScaledSpaceDemand>();
                                demand.texture = MainTex.name;
                                demand.normals = BumpMap.name;
                            }

                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, 0));
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(1, 1));
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureOffset("_BumpMap", new Vector2(0, 0));
                            b.generatedBody.scaledVersion.GetComponent<Renderer>().material.SetTextureScale("_BumpMap", new Vector2(1, 1));
                        }
                    }
                }
                if (DateTime.Today.Day == 25 && DateTime.Today.Month == 05)
                {
                    list.Find(x => x.name == "Sun").generatedBody.celestialBody.bodyDescription = "\n\n\n                        DON'T\n                        PANIC";
                    list.Find(x => x.name == "Kerbin").generatedBody.celestialBody.bodyDescription = "Mostly harmless.";
                }
                if (DateTime.Today.Day == 31 && DateTime.Today.Month == 10)
                {
                    foreach (Body b in list)
                    {
                        if (b.generatedBody.orbitRenderer != null)
                        {
                            b.generatedBody.orbitRenderer.SetColor(new Color(0.5f, 0.25f, 0f, 1f));
                        }
                    }
                }
            }
        }
 // Default Constructor
 public PositionParser()
 {
     latitude  = new NumericParser <Double>(0);
     longitude = new NumericParser <Double>(0);
     altitude  = new NumericParser <Double>(0);
 }
Beispiel #27
0
 public override void Apply(ConfigNode node)
 {
     noise = new LibNoise.Modifiers.ClampOutput(sourceModule.Noise);
     lower = noise.LowerBound;
     upper = noise.UpperBound;
 }
Beispiel #28
0
 // Create a loader from given values
 public RandomRangeLoader()
 {
     maxValue = 1;
     minValue = 0;
 }
Beispiel #29
0
            /**
             * Load data for ParserTarget field or property from a configuration node
             *
             * @param member Member to load data for
             * @param o Instance of the object which owns member
             * @param node Configuration node from which to load data
             **/
            public static void LoadObjectMemberFromConfigurationNode(MemberInfo member, object o, ConfigNode node, bool getChilds = true)
            {
                // Get the parser target, only one is allowed so it will be first
                ParserTarget target = (member.GetCustomAttributes(typeof(ParserTarget), true) as ParserTarget[]) [0];

                // Figure out if this field exists and if we care
                bool isNode  = node.HasNode(target.fieldName);
                bool isValue = node.HasValue(target.fieldName);

                // Obtain the type the member is (can only be field or property)
                Type   targetType  = null;
                object targetValue = null;

                if (member.MemberType == MemberTypes.Field)
                {
                    targetType = (member as FieldInfo).FieldType;
                    if (getChilds)
                    {
                        targetValue = (member as FieldInfo).GetValue(o);
                    }
                    else
                    {
                        targetValue = null;
                    }
                }
                else
                {
                    targetType = (member as PropertyInfo).PropertyType;
                    try
                    {
                        if ((member as PropertyInfo).CanRead && getChilds)
                        {
                            targetValue = (member as PropertyInfo).GetValue(o, null);
                        }
                        else
                        {
                            targetValue = null;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                // If there was no data found for this node
                if (!isNode && !isValue)
                {
                    if (!target.optional && !(target.allowMerge && targetValue != null))
                    {
                        // Error - non optional field is missing
                        throw new ParserTargetMissingException("Missing non-optional field: " + o.GetType() + "." + target.fieldName);
                    }

                    // Nothing to do, so DONT return!
                    return;
                }

                // If this object is a value (attempt no merge here)
                if (isValue)
                {
                    // The node value
                    string nodeValue = node.GetValue(target.fieldName);

                    // Merge all values of the node
                    if (target.getAll != null)
                    {
                        nodeValue = String.Join(target.getAll, node.GetValues(target.fieldName));
                    }

                    // If the target is a string, it works natively
                    if (targetType.Equals(typeof(string)))
                    {
                        targetValue = nodeValue;
                    }

                    // Figure out if this object is a parsable type
                    else if (typeof(IParsable).IsAssignableFrom(targetType))
                    {
                        // Create a new object
                        IParsable targetParsable = (IParsable)Activator.CreateInstance(targetType);
                        targetParsable.SetFromString(nodeValue);
                        targetValue = targetParsable;
                    }

                    // Throw exception or print error
                    else
                    {
                        return;
                    }
                }

                // If this object is a node (potentially merge)
                else
                {
                    // If the target type is a ConfigNode, this works natively
                    if (targetType == typeof(ConfigNode))
                    {
                        targetValue = node.GetNode(target.fieldName);
                    }

                    // Check for Ranges
                    else if (targetType == typeof(NumericParser <Double>))
                    {
                        targetValue = new NumericParser <Double>((Double)CreateObjectFromConfigNode <Range>(node.GetNode(target.fieldName)));
                    }

                    // We need to get an instance of the object we are trying to populate
                    // If we are not allowed to merge, or the object does not exist, make a new instance
                    else if (targetValue == null || !target.allowMerge)
                    {
                        targetValue = CreateObjectFromConfigNode(targetType, node.GetNode(target.fieldName), target.getChild);
                    }

                    // Otherwise we can merge this value
                    else
                    {
                        LoadObjectFromConfigurationNode(targetValue, node.GetNode(target.fieldName), target.getChild);
                    }
                }

                // If the member type is a field, set the value
                if (member.MemberType == MemberTypes.Field)
                {
                    (member as FieldInfo).SetValue(o, targetValue);
                }

                // If the member wasn't a field, it must be a property.  If the property is writable, set it.
                else if ((member as PropertyInfo).CanWrite)
                {
                    (member as PropertyInfo).SetValue(o, targetValue, null);
                }
            }
        private ValueInfo GetValueInfo(Stream stream, int headerSize)
        {
            var bytes = NumericParser.ReadInt32(stream, headerSize);

            return(ValueInfo.ForContent(headerSize, bytes));
        }
 // Default Constructor
 public PositionParser()
 {
     Latitude  = 0;
     Longitude = 0;
     Altitude  = 0;
 }
Beispiel #32
0
 // Create a loader from given values
 public RandomRangeLoader()
 {
     this.maxValue = 1;
     this.minValue = 0;
 }