public void ParseStringToEnum_TestParameterizedInput(string inputFromCommand, Modules.Module translatedEnum) { Proxy.Setup(x => x.GetText(It.Is <string>(s => s == "moduleVariable"))).Returns(inputFromCommand); var result = EnumParser.ParseStringToEnum <Modules.Module>(Proxy.Object, "moduleVariable", typeof(Modules.Module)); Assert.Equal(translatedEnum, result); }
private NumberStyles GetAsNumberStyle(ITagAttribute styles, TagModel model, NumberStyles style) { if (Styles == null) { return(style); } string stylesAsString = GetAsString(Styles, model); if (stylesAsString != null) { bool first = true; string[] stylesStr = stylesAsString.Split(','); foreach (string styleStr in stylesStr) { if (first) { style = EnumParser <NumberStyles> .Parse(styleStr); } else { style = style | EnumParser <NumberStyles> .Parse(styleStr); } first = false; } } return(style); }
public static void AddDreamEnums() { EnumParser parser; Dictionary <Type, EnumParser> dictionary_ic = ParserFunctions.sCaseInsensitiveEnumParsers; Dictionary <Type, EnumParser> dictionary_c = ParserFunctions.sCaseSensitiveEnumParsers; string[] new_enum_names = { "play_in_water_echoweaver" }; object[] new_enum_values = { 0x0E0E0DB1 }; if (!dictionary_ic.TryGetValue(typeof(DreamNames), out parser)) { parser = new EnumParser(typeof(DreamNames), true); dictionary_ic.Add(typeof(DreamNames), parser); } for (int i = 0; i < new_enum_names.Length; i++) { parser.mLookup.Add(new_enum_names[i].ToLowerInvariant(), new_enum_values[i]); } if (!dictionary_c.TryGetValue(typeof(DreamNames), out parser)) { parser = new EnumParser(typeof(DreamNames), true); dictionary_c.Add(typeof(DreamNames), parser); } for (int i = 0; i < new_enum_names.Length; i++) { parser.mLookup.Add(new_enum_names[i], new_enum_values[i]); } }
protected override void LoadDatabaseAttributes() { using (SqlConnection conn = new SqlConnection(ConnectionStringBuilder.ConnectionString)) { conn.Open(); DataTable dbtables = conn.GetSchema(SqlClientMetaDataCollectionNames.Databases); foreach (DataRow dbrow in dbtables.Rows) { if (dbrow[0].Equals(this.Name)) { NodeAttribute idatt = new NodeAttribute { name = dbrow[1].ToString(), description = "Database Id", type = new AttributeType { name = EnumParser.GetValueName(DbClasses.Identifier) } }; NodeAttribute createdatt = new NodeAttribute { name = dbrow[2].ToString(), description = "Created Date", type = new AttributeType { name = EnumParser.GetValueName(DbColumnAttributes.DbDateTime) } }; Metadata.Add(idatt); Metadata.Add(createdatt); break; } } } }
/// <summary> /// Creates a new ScaledVersion Loader from the Injector context. /// </summary> public ScaledVersionLoader() { // Is this the parser context? if (!Injector.IsInPrefab) { throw new InvalidOperationException("Must be executed in Injector context."); } // Get the scaled version object Value = generatedBody.celestialBody; Value.scaledBody = generatedBody.scaledVersion; Body currentBody = Parser.GetState <Body>("Kopernicus:currentBody"); type = new EnumParser <BodyType>(currentBody.template?.type ?? BodyType.Atmospheric); // Ensure scaled version at least has a mesh filter and mesh renderer if (Value.scaledBody.GetComponent <MeshFilter>() == null) { Value.scaledBody.AddComponent <MeshFilter>(); } if (Value.scaledBody.GetComponent <MeshRenderer>() == null) { Value.scaledBody.AddComponent <MeshRenderer>(); Value.scaledBody.GetComponent <Renderer>().sharedMaterial = null; } if (options == null) { options = new PlanetTextureExporter.TextureOptions(); if (generatedBody.pqsVersion != null) { options.Resolution = generatedBody.pqsVersion.mapFilesize; } } }
protected override void SolveInstance(IGH_DataAccess DA) { string loadPosition = "top"; bool continuouslyRestrained = false; bool cantilever = false; if (!DA.GetData(0, ref loadPosition)) { // pass } if (!DA.GetData(1, ref continuouslyRestrained)) { // pass } if (!DA.GetData(2, ref cantilever)) { // pass } if (loadPosition == null) { return; } VerticalAlignment alignment = EnumParser.Parse <VerticalAlignment>(loadPosition); DA.SetData(0, FemDesign.Bars.Buckling.BucklingLength.LateralTorsional(alignment, continuouslyRestrained, cantilever)); }
protected override void SolveInstance(IGH_DataAccess DA) { double diameter = 0; FemDesign.Materials.Material material = null; string profile = "ribbed"; if (!DA.GetData("Diameter", ref diameter)) { return; } if (!DA.GetData("Material", ref material)) { return; } DA.GetData("Profile", ref profile); if (material == null || profile == null) { return; } WireProfileType _profile = EnumParser.Parse <WireProfileType>(profile); FemDesign.Reinforcement.Wire obj = new FemDesign.Reinforcement.Wire(diameter, material, _profile); DA.SetData(0, obj); }
/// <summary> /// Deserializes the property data. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">reader</exception> /// <exception cref="System.NotSupportedException"></exception> internal static Property Deserialize(XmlReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } var name = reader.GetAttribute("Name"); var dataType = EnumParser <DataTypeId> .Parse(reader.GetAttribute("Type")); var description = reader.GetAttribute("Description"); var stringValue = reader.ReadString(); switch (dataType) { case DataTypeId.DateTime: return(Create(name, XmlConvert.ToDateTime(stringValue, XmlDateTimeSerializationMode.RoundtripKind), description)); case DataTypeId.Double: return(Create(name, XmlConvert.ToDouble(stringValue), description)); case DataTypeId.Integer: return(Create(name, XmlConvert.ToInt64(stringValue), description)); case DataTypeId.String: return(Create(name, stringValue, description)); case DataTypeId.TimeSpan: return(Create(name, XmlConvert.ToTimeSpan(stringValue), description)); default: throw new NotSupportedException($"DataTypeId \"{dataType}\" is not supported"); } }
protected override void SolveInstance(IGH_DataAccess DA) { double beta = 1; string loadPosition = "top"; bool continuouslyRestrained = false; if (!DA.GetData(0, ref beta)) { // pass } if (!DA.GetData(1, ref loadPosition)) { // pass } if (!DA.GetData(2, ref continuouslyRestrained)) { // pass } if (loadPosition == null) { return; } VerticalAlignment alignment = EnumParser.Parse <VerticalAlignment>(loadPosition); DA.SetData(0, FemDesign.Bars.Buckling.BucklingLength.PressuredTopFlange(alignment, beta, continuouslyRestrained)); }
private void OnStatusChanged(PlayerResponse playerResponse) { if (visualizeFeedback == false) { return; } if (_changedFeedback == null) { return; } lock (_changedFeedback) { foreach (var status in playerResponse.Status) { var pos = EnumParser.ToPositionType(status.Key); var val = status.Value; byte[] result = new byte[val.Length]; for (int i = 0; i < val.Length; i++) { result[i] = (byte)val[i]; } var feedback = new HapticFeedback(pos, result); _changedFeedback.Add(feedback); } } }
void ICodedInputStream.ReadEnumArray <T>(uint fieldTag, string fieldName, ICollection <T> list, out ICollection <object> unknown) { unknown = null; List <object> array = new List <object>(); if (ReadEnumArray(fieldName, array)) { foreach (object rawValue in array) { T val = default(T); if (EnumParser <T> .TryConvert(rawValue, ref val)) { list.Add(val); } else { if (unknown == null) { unknown = new List <object>(); } unknown.Add(rawValue); } } } }
public static Either <TLeft, TEnum> ParseToEnum <TLeft, TEnum>( this Either <TLeft, string> source, bool ignoreCase, TLeft left) where TEnum : struct { return(source.FlatMap(x => EnumParser.Parse <TLeft, TEnum>(x, ignoreCase, left))); }
public static Either <TLeft, TEnum> ParseToEnum <TLeft, TEnum>( this string source, bool ignoreCase, TLeft left) where TEnum : struct { return(EnumParser.Parse <TLeft, TEnum>(source, ignoreCase, left)); }
public void EnumParser_ValidInputRequested_ReturnsCorrectEnumValue() { var returnElements = "requested"; var enumValue = EnumParser <ReturnElements> .GetEnum(returnElements); Assert.Equal(ReturnElements.Requested, enumValue); }
void Awake() { Subject.addObserver(new Observer("details", (message) => { //難易度変更 if (message.isMemberOf("difficultButton")) { if (mMusicData == null) { return; } changeDifficult(EnumParser.parse <ScoreDifficult>(message.name)); return; } //音声再生位置変更 if (message.name == "playPositionListButtonPushed") { playMusic(); return; } //難易度初期設定 if (message.name == "initialDifficult") { mDifficultToggle.memberPushed(message.getParameter <ScoreDifficult>("difficult").ToString()); return; } })); }
protected override void SolveInstance(IGH_DataAccess DA) { // Get indata string countryCode = "S"; DA.GetData("CountryCode", ref countryCode); List <FemDesign.GenericClasses.IStructureElement> elements = new List <FemDesign.GenericClasses.IStructureElement>(); DA.GetDataList("Structure Elements", elements); List <FemDesign.GenericClasses.ILoadElement> loads = new List <FemDesign.GenericClasses.ILoadElement>(); DA.GetDataList("Loads", loads); List <FemDesign.Loads.LoadCase> loadCases = new List <FemDesign.Loads.LoadCase>(); DA.GetDataList("LoadCases", loadCases); List <FemDesign.Loads.LoadCombination> loadCombinations = new List <FemDesign.Loads.LoadCombination>(); DA.GetDataList("LoadCombinations", loadCombinations); List <FemDesign.Loads.ModelGeneralLoadGroup> loadGroups = new List <FemDesign.Loads.ModelGeneralLoadGroup>(); DA.GetDataList("LoadGroups", loadGroups); // Create model Model model = new Model(EnumParser.Parse <Country>(countryCode), elements, loads, loadCases, loadCombinations, loadGroups); DA.SetData("FdModel", model); }
public static void InjectEnums <T>(string[] names, object[] values, bool convert) where T : struct, IConvertible { if (!typeof(T).IsEnum) { throw new ArgumentException("T must be an enumerated type"); } EnumParser parser; Dictionary <Type, EnumParser> dictionary_ic = ParserFunctions.sCaseInsensitiveEnumParsers; Dictionary <Type, EnumParser> dictionary_c = ParserFunctions.sCaseSensitiveEnumParsers; if (!dictionary_ic.TryGetValue(typeof(T), out parser)) { parser = new EnumParser(typeof(T), true); dictionary_ic.Add(typeof(T), parser); } for (int i = 0; i < names.Length; i++) { parser.mLookup.Add(names[i].ToLowerInvariant(), convert ? Convert.ToUInt32(values[i]) : values[i]); } if (!dictionary_c.TryGetValue(typeof(T), out parser)) { parser = new EnumParser(typeof(T), true); dictionary_c.Add(typeof(T), parser); } for (int i = 0; i < names.Length; i++) { parser.mLookup.Add(names[i], convert ? Convert.ToUInt32(values[i]) : values[i]); } }
private static Formplot?ReadFormplot(Stream metadataStream, Stream?pointDataStream, Version version, FormplotTypes[]?acceptedTypes) { using var reader = XmlReader.Create(metadataStream, CreateXmlReaderSettings()); reader.MoveToElement(); while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) { if (reader.Name != FormplotRootTag && reader.Name != PropertiesRootTag) { continue; } if (!EnumParser <FormplotTypes> .TryParse(reader.GetAttribute("Type") ?? "", out var plotType)) { plotType = FormplotTypes.None; // This code path is for Property Files (they don't have a form plot type) } if (acceptedTypes != null && !acceptedTypes.Contains(plotType)) { return(null); } var targetVersion = FormplotHelper.GetFileFormatVersion(plotType); if (version > targetVersion) { throw new NotSupportedException($"Invalid form plot file. Version {version} is not supported."); } return(CreateFormplot(pointDataStream, version, plotType, reader)); } return(null); }
public void EnumParserParsingTest2() { string testValue = "ItemNotIncluded"; EnumParser parser = new EnumParser(typeof(EnumParserTestEnum)); parser.GetValue(testValue); }
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var enumString = reader.GetString(); if (!EnumParser.TryParseCaseInsensitive(enumString, out T value)) { return(default);
/// <summary> /// Creates a new ScaledVersion Loader from the Injector context. /// </summary> public ScaledVersionLoader() { // Is this the parser context? if (!Injector.IsInPrefab) { throw new InvalidOperationException("Must be executed in Injector context."); } // Get the scaled version object Value = generatedBody.celestialBody; Value.scaledBody = generatedBody.scaledVersion; type = new EnumParser <BodyType>(Loader.currentBody.template == null ? BodyType.Atmospheric : Loader.currentBody.template.type); // Ensure scaled version at least has a mesh filter and mesh renderer if (Value.scaledBody.GetComponent <MeshFilter>() == null) { Value.scaledBody.AddComponent <MeshFilter>(); } if (Value.scaledBody.GetComponent <MeshRenderer>() == null) { Value.scaledBody.AddComponent <MeshRenderer>(); Value.scaledBody.GetComponent <Renderer>().material = null; } if (options == null) { options = new PlanetTextureExporter.TextureOptions(); } }
private static void SelectTranslatedLanguage( TranslateLanguages translatedLanguage, RemoteWebDriver driver) { var lang = EnumParser.GetString(translatedLanguage); var langItem = By.XPath( $"//*[contains(text(), '{lang}')]"); try { driver.FindElement(langItem); } catch (NoSuchElementException) { var moreButton = driver.FindElementById("gt-tl-gms"); moreButton.Click(); try { var traits = new List <By> { langItem, By.ClassName("goog-menuitem-content") }; var langOption = driver.FindElementByTraits(traits); langOption.Click(); } catch (NoSuchElementException) { driver.Quit(); TranslateEvent.OnTranslateFailed(); } } }
public RegularExpressionDateAttribute(string dateFormat) : base(_defaultDateErrorMessage) { if (dateFormat == "DD/MM/YYYY") { _datepattern = EnumParser.GetStringValueAttributeValue(EnumDateReqExp.DDMMYYYY); // EnumParser.GetAttributeValue(EnumDateReqExp.DDMMYY); } else if (dateFormat == "MM/DD/YYYY") { _datepattern = EnumParser.GetStringValueAttributeValue(EnumDateReqExp.MMDDYYYY); } else if (dateFormat == "DD/MM/YY") { _datepattern = EnumParser.GetStringValueAttributeValue(EnumDateReqExp.DDMMYY); } else if (dateFormat == "MM/DD/YY") { _datepattern = EnumParser.GetStringValueAttributeValue(EnumDateReqExp.MMDDYY); } else if (dateFormat == "DD MMM YYYY") { _datepattern = EnumParser.GetStringValueAttributeValue(EnumDateReqExp.DDMMYYYYWS); } ErrorMessage = _defaultDateErrorMessage; IsDateMandatory = true; _dateFormat = dateFormat; }
/// <summary> /// Define straight reinforcement layout for surface reinforcement. /// </summary> /// <remarks>Create</remarks> /// <param name="direction">"x"/"y"</param> /// <param name="space">Spacing between bars.</param> /// <param name="face">"top"/"bottom"</param> /// <param name="cover">Reinforcement concrete cover.</param> public Straight(string direction, double space, string face, double cover) { this.Direction = EnumParser.Parse <ReinforcementDirection>(direction); this.Space = space; this.Face = EnumParser.Parse <Face>(face); this.Cover = cover; }
/// <summary> /// 打印遍历节点名称 /// </summary> /// <param name="travelNodes"></param> /// <param name="travelType"></param> /// <param name="travelOrder"></param> /// <param name="arithmeticType"></param> public static void PrintTravelNodeNames(List <MTreeNode> travelNodes, EnumTravelType travelType, EnumTravelOrder travelOrder, EnumArithmeticType arithmeticType) { string names = string.Empty; string travelTypeName = string.Empty; string travelOrderName = string.Empty; string arithmeticTypeName = string.Empty; for (int i = 0; i < travelNodes.Count; i++) { if (i == 0) { names += string.Format("{0}", travelNodes[i].Name); } else { names += string.Format(",{0}", travelNodes[i].Name); } } LogHelper.GetInstance().WriteLog(string.Format("多叉树{0}优先{1}遍历({2}):{3}", EnumParser.ParseEnumTravelType(travelType), EnumParser.ParseEnumTravelOrder(travelOrder), EnumParser.ParseEnumArithmeticType(arithmeticType), names)); }
public void ParseAttr() { bar b = EnumParser.Parse <bar>("moo"); Assert.AreEqual(bar.bloo, b); b = EnumParser.Parse <bar>("bloo"); Assert.AreEqual(bar.bloo, b); }
public void ParsePlain() { foo f = EnumParser.Parse <foo>("bar"); Assert.AreEqual(foo.bar, f); f = EnumParser.Parse <foo>("blah"); Assert.AreEqual(foo.NONE, f); }
public void GetStatusFor_Success_ReturnsSuccess() { var statusToParse = "SUCCESS"; var parsedStatus = EnumParser.GetStatusFor(statusToParse); parsedStatus.Should().Be(Status.Success); }
public void GetStatusFor_Failure_ReturnsFailure() { var statusToParse = "FAILURE"; var parsedStatus = EnumParser.GetStatusFor(statusToParse); parsedStatus.Should().Be(Status.Failure); }
private static void RunEnumParserDemo() { bool ignoreCase = true; // set whether case will be ignored when parsing enum EnumParser parser = new EnumParser(ignoreCase); Seasons season = parser.ParseEnum<Seasons>("winTER"); // Converts to Seasons.Winter Seasons autumn = parser.ParseEnum<Seasons>("summer"); // Converts to Seasons.Summer }
private static void RunEnumParserDemo() { bool ignoreCase = true; // set whether case will be ignored when parsing enum var parser = new EnumParser <Seasons>(ignoreCase); var result1 = parser.Parse("winTER"); // Converts to Seasons.Winter var result2 = parser.Parse("summer"); // Converts to Seasons.Summer }
void SaveGroups() { foreach (ConfigNode Group in GroupsList.Values) { string name = Group.GetValue("name"); CelestialBody body = FlightGlobals.Bodies.First(b => b.transform.name == Group.GetValue("body")); if (string.IsNullOrEmpty(name) || body == null) continue; Vector3Parser center = new Vector3Parser(); if (Group.HasValue("CentralPQSCity")) { center = body.GetComponentsInChildren<PQSCity>(true).FirstOrDefault(p => p.name == Group.GetValue("CentralPQSCity")).repositionRadial; } else if (Group.HasValue("CentralPQSCity2")) { center = (Vector3)body.GetComponentsInChildren<PQSCity2>(true).First(p => p.name == Group.GetValue("CentralPQSCity2")).PlanetRelativePosition; } else if (Group.HasValue("CentralPosition")) { center.SetFromString(Group.GetValue("CentralPosition")); } else if (Group.HasValue("CentralLAT") && Group.HasValue("CentralLON")) { EnumParser<double> LAT = new EnumParser<double>(); EnumParser<double> LON = new EnumParser<double>(); LAT.SetFromString(Group.GetValue("CentralLAT")); LON.SetFromString(Group.GetValue("CentralLON")); center = Utility.LLAtoECEF(LAT, LON, 1, 1); } else if (Group.HasValue("PQSCity")) { center = body.GetComponentsInChildren<PQSCity>(true).FirstOrDefault(p => p.name == Group.GetValue("PQSCity")).repositionRadial; } else if (Group.HasValue("PQSCity2")) { center = (Vector3)body.GetComponentsInChildren<PQSCity2>(true).First(p => p.name == Group.GetValue("CentralPQSCity2")).PlanetRelativePosition; } else continue; if (!body.Has("PQSCityGroups")) body.Set("PQSCityGroups", new Dictionary<object, Vector3>()); Dictionary<object, Vector3> PQSList = body.Get<Dictionary<object, Vector3>>("PQSCityGroups"); foreach (string city in Group.GetValues("PQSCity")) { PQSCity mod = body.GetComponentsInChildren<PQSCity>(true).First(m => m.name == city); if (mod != null && !PQSList.ContainsKey(mod)) PQSList.Add(mod, center); } foreach (string city2 in Group.GetValues("PQSCity2")) { PQSCity2 mod = body.GetComponentsInChildren<PQSCity2>(true).First(m => m.name == city2); if (mod != null && !PQSList.ContainsKey(mod)) PQSList.Add(mod, center); } body.Set("PQSCityGroups", PQSList); } }
public static Parser CreateParser(NumberParser numberParser, DateTimeParser dateTimeParser, IEnumerable<Type> enumTypes = null, BooleanParser booleanParser = null, EnumParser enumParser = null, Dictionary<Type, Converter> otherConverters = null) { if(booleanParser == null) { booleanParser = new BooleanParser(); } if(enumParser == null) { enumParser = new EnumParser(); } Dictionary<Type, Converter> converters = new Dictionary<Type, Converter> { { CommonTypes.String, data => data }, { CommonTypes.Bool, data => booleanParser.ParseBoolean(data) }, { CommonTypes.Short, data => numberParser.ParseShort(data) }, { CommonTypes.Int, data => numberParser.ParseInteger(data) }, { CommonTypes.Long, data => numberParser.ParseLong(data) }, { CommonTypes.Float, data => numberParser.ParseFloat(data) }, { CommonTypes.Double, data => numberParser.ParseDouble(data) }, { CommonTypes.DateTime, data => dateTimeParser.ParseDateTime(data) } }; if(enumTypes != null) { foreach (Type enumType in enumTypes) { converters.Add(enumType, data => enumParser.ParseEnum(data, enumType)); } } if(otherConverters != null) { foreach(KeyValuePair<Type, Converter> entry in otherConverters) { converters.Add(entry.Key, entry.Value); } } return new Parser(converters); }
// Default constructor - takes the scaledVersion game object public ScaledVersionLoader() { // Get the scaled version object scaledVersion = generatedBody.scaledVersion; owner = generatedBody.celestialBody; type = new EnumParser<BodyType>(Loader.currentBody.template == null ? BodyType.Atmospheric : Loader.currentBody.template.type); // Ensure scaled version at least has a mesh filter and mesh renderer if(scaledVersion.GetComponent<MeshFilter>() == null) scaledVersion.AddComponent<MeshFilter>(); if(scaledVersion.GetComponent<MeshRenderer>() == null) { scaledVersion.AddComponent<MeshRenderer>(); scaledVersion.GetComponent<Renderer>().material = null; } }
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)); } } } } }