public void Read_an_int_string_dictionary() { string xml = @" <node> <Pair Key='1' Value='red'/> <Pair Key='2' Value='texas'/> <Pair Key='3' Value='north'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof(IDictionary <int, string>)); //instance.ShouldBeOfType(typeof (SerializedInstance)); Assert.Fail("NWO"); // var collection = // (IDictionary<int, string>) instance.Build(typeof (IDictionary<int, string>), new StubBuildSession()); // // collection[1].ShouldEqual("red"); // collection[2].ShouldEqual("texas"); // collection[3].ShouldEqual("north"); }
public void Read_a_string_string_dictionary2() { string xml = @" <node> <Pair Key='color' Value='red'/> <Pair Key='state' Value='texas'/> <Pair Key='direction' Value='north'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof(Dictionary <string, string>)); //instance.ShouldBeOfType(typeof (SerializedInstance)); Assert.Fail("NWO"); // var collection = // (Dictionary<string, string>) instance.Build(typeof (Dictionary<string, string>), new StubBuildSession()); // // collection["color"].ShouldEqual("red"); // collection["state"].ShouldEqual("texas"); // collection["direction"].ShouldEqual("north"); }
public void OtherProtocolImportTest1() { var input = @" @import 'import/other-protocol-test.less'; "; var expected = @" .first { background-image: url('http://some.com/file.gif'); background-image: url('https://some.com/file.gif'); background-image: url('ftp://some.com/file.gif'); background-image: url('data:xxyhjgjshgjs'); } "; var parser = GetParser(); DictionaryReader dictionaryReader = (DictionaryReader)((Importer)parser.Importer).FileReader; AssertLess(input, expected, parser); // Calling the file reader with url's with a protocolis asking for trouble Assert.AreEqual(1, dictionaryReader.DoesFileExistCalls.Count, "We should not ask the file reader if a protocol file exists"); Assert.AreEqual(1, dictionaryReader.GetFileContentsCalls.Count, "We should not ask the file reader if a protocol file exists"); Assert.AreEqual(@"import/other-protocol-test.less", dictionaryReader.DoesFileExistCalls[0], "We should not ask the file reader if a protocol file exists"); Assert.AreEqual(@"import/other-protocol-test.less", dictionaryReader.GetFileContentsCalls[0], "We should not ask the file reader if a protocol file exists"); }
public Dictionary <K, V[]> GetParamDictionary2 <K, V>(object key) { Dictionary <Object, Object> input = (Dictionary <Object, Object>)GetParam(key); DictionaryReader <K, V> reader = new DictionaryReader <K, V>(); return(reader.read2(input)); }
public VoxelPlacementDefinition(MyObjectBuilder_VoxelMiningDefinition.MiningDef ob, NamedLogger log) { Material = MyDefinitionManager.Get <MyVoxelMaterialDefinition>(ob.VoxelMaterial); if (Material == null) { log.Warning($"Could not find voxel material definition {ob.VoxelMaterial}"); Material = MyVoxelMaterialDefinition.Default; } Volume = ob.VolumeAttribute; var replacementItems = new Dictionary <MyDefinitionId, int>(); foreach (var item in ob.MinedItems) { MyObjectBuilderType type; try { type = MyObjectBuilderType.Parse(item.Type); } catch { log.Warning($"Can not parse defined builder type {item.Type}"); continue; } var key = new MyDefinitionId(type, MyStringHash.GetOrCompute(item.Subtype)); replacementItems[key] = item.Amount; } Items = replacementItems; }
public void Read_a_string_string_dictionary() { string xml = @" <node> <Pair Key='color' Value='red'/> <Pair Key='state' Value='texas'/> <Pair Key='direction' Value='north'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof (IDictionary<string, string>)); //instance.ShouldBeOfType(typeof (SerializedInstance)); Assert.Fail("NWO"); // var collection = // (IDictionary<string, string>) // instance.Build(typeof (IDictionary<string, string>), new StubBuildSession()); // // collection["color"].ShouldEqual("red"); // collection["state"].ShouldEqual("texas"); // collection["direction"].ShouldEqual("north"); }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader<MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); if (componentDefinition == null) { MyPhysicalItemDefinition physicalDefinition = null; if (!MyDefinitionManager.Static.TryGetPhysicalItemDefinition(material.Key, out physicalDefinition)) continue; info.ComponentName = physicalDefinition.DisplayNameText; info.Icon = physicalDefinition.Icon; info.DefinitionId = physicalDefinition.Id; info.TotalCount = 1; } else { info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; } blockInfo.Components.Add(info); } if (merge) MergeSameComponents(blockInfo, definition); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); MyObjectBuilder_AsteroidGeneratorDefinition definition = (MyObjectBuilder_AsteroidGeneratorDefinition)builder; this.Version = int.Parse(definition.Id.SubtypeId); this.SubCells = definition.SubCells; this.ObjectSizeMax = definition.ObjectSizeMax; this.SubcellSize = 0x1000 + (definition.ObjectSizeMax * 2); this.ObjectSizeMin = definition.ObjectSizeMin; this.RotateAsteroids = definition.RotateAsteroids; this.UseGeneratorSeed = definition.UseGeneratorSeed; this.ObjectMaxInCluster = definition.ObjectMaxInCluster; this.ObjectDensityCluster = definition.ObjectDensityCluster; this.ObjectSizeMaxCluster = definition.ObjectSizeMaxCluster; this.ObjectSizeMinCluster = definition.ObjectSizeMinCluster; this.UseClusterVariableSize = definition.UseClusterVariableSize; this.UseClusterDefAsAsteroid = definition.UseClusterDefAsAsteroid; this.ClusterDispersionAbsolute = definition.ClusterDispersionAbsolute; this.ObjectMinDistanceInCluster = definition.ObjectMinDistanceInCluster; this.ObjectMaxDistanceInClusterMax = definition.ObjectMaxDistanceInClusterMax; this.ObjectMaxDistanceInClusterMin = definition.ObjectMaxDistanceInClusterMin; this.AllowPartialClusterObjectOverlap = definition.AllowPartialClusterObjectOverlap; this.UseLinearPowOfTwoSizeDistribution = definition.UseLinearPowOfTwoSizeDistribution; this.SeedTypeProbability = definition.SeedTypeProbability.Dictionary; this.SeedClusterTypeProbability = definition.SeedClusterTypeProbability.Dictionary; }
public static DictionaryReader Get() { if (_dictionaryReader == null) { var readerCommandHandler = TranslationWayToReaderCommandHandlerInitializer.Get(); _dictionaryReader = readerCommandHandler.GetDictionaryReader(Config.Instance.TranslationWay); } return(_dictionaryReader); }
public void Can_process_a_dictionary() { var reader = new DictionaryReader(); reader.CanProcess(typeof (IDictionary<string, string>)).ShouldBeTrue(); reader.CanProcess(typeof (IDictionary<int, string>)).ShouldBeTrue(); reader.CanProcess(typeof (IDictionary<string, int>)).ShouldBeTrue(); reader.CanProcess(typeof (Dictionary<string, string>)).ShouldBeTrue(); reader.CanProcess(typeof (Dictionary<int, string>)).ShouldBeTrue(); reader.CanProcess(typeof (Dictionary<string, int>)).ShouldBeTrue(); }
public void Register(TranslationWay translationWay, DictionaryReader dictionaryReader) { if (!_translationTypeToReaderMap.ContainsKey(translationWay)) { _translationTypeToReaderMap.Add(translationWay, dictionaryReader); } else { System.Console.WriteLine("Translation type {0} is already registered", translationWay); } }
public AreaData(int id, BoundingBoxD box, Dictionary<long, HashSet<int>> items) { Id = id; ForestBox = box; ItemIds = DictionaryReader<long, HashSetReader<int>>.Empty; var dictionary = new Dictionary<long, HashSetReader<int>>(); foreach (var pair in items) dictionary[pair.Key] = new HashSetReader<int>(pair.Value); ItemIds = new DictionaryReader<long, HashSetReader<int>>(dictionary); }
public void Can_process_a_dictionary() { var reader = new DictionaryReader(); reader.CanProcess(typeof(IDictionary <string, string>)).ShouldBeTrue(); reader.CanProcess(typeof(IDictionary <int, string>)).ShouldBeTrue(); reader.CanProcess(typeof(IDictionary <string, int>)).ShouldBeTrue(); reader.CanProcess(typeof(Dictionary <string, string>)).ShouldBeTrue(); reader.CanProcess(typeof(Dictionary <int, string>)).ShouldBeTrue(); reader.CanProcess(typeof(Dictionary <string, int>)).ShouldBeTrue(); }
static void Main(string[] args) { if (args.Length <= 0) { Console.WriteLine("invalid args"); return; } switch (args[0]) { case "check": if (args.Length <= 2) { Console.WriteLine("invalid args"); return; } Console.WriteLine("\"{0}\" and \"{1}\" are {2}anagrams", args[0], args[1], new AnagramChecker().isAnagram(args[1], args[2]) ? "" : "no "); break; case "getKnown": if (args.Length <= 1) { Console.WriteLine("invalid args"); return; } var config = new ConfigurationBuilder(); config.AddJsonFile("config.json"); config.AddEnvironmentVariables(); var dr = new DictionaryReader(config.Build()); var dict = dr.read(); var key = new AnagramChecker().sortLetters(args[1]); if (dict.ContainsKey(key)) { foreach (var str in dict[key]) { if (str.Equals(args[1])) { continue; } Console.WriteLine(str); } } else { Console.WriteLine("No known anagrams found"); } break; default: Console.WriteLine("invalid args"); break; } }
private Node(char letter, List <char> LetterList, String ParentWord) { data = letter; Word = ParentWord + data; if (DictionaryReader.DictionarySearch(Word)) { App.Current.Dispatcher.Invoke((System.Action) delegate { MainWindow.resultsList.Add(new ValidWord(Word, MainWindow.resultsList.Count + 1)); }); } CreateLevel(LetterList); }
protected override void Init(MyObjectBuilder_DefinitionBase def) { base.Init(def); var ob = (MyObjectBuilder_EquiEventModifierComponentDefinition)def; var eventToOps = new Dictionary <string, ListReader <ModifierOp> >(); var stateToOps = new Dictionary <MyStringHash, ListReader <ModifierOp> >(); if (ob.Binding != null) { foreach (var binding in ob.Binding) { if (binding.Operations == null || binding.Operations.Count == 0) { continue; } if ((binding.Events == null || binding.Events.Count == 0) && (binding.States == null || binding.States.Count == 0)) { continue; } var ops = new List <ModifierOp>(); foreach (var op in binding.Operations) { ops.Add(new ModifierOp(this, op)); } if (ops.Count == 0) { continue; } if (binding.Events != null) { foreach (var evt in binding.Events) { eventToOps[evt] = ops; } } if (binding.States != null) { foreach (var state in binding.States) { stateToOps[MyStringHash.GetOrCompute(state)] = ops; } } } } EventToOps = eventToOps; StateToOps = stateToOps; }
public void OtherProtocolImportTest2() { var input = @" @import url(http://fonts.googleapis.com/css?family=Open+Sans:regular,bold);"; var parser = GetParser(); DictionaryReader dictionaryReader = (DictionaryReader)((Importer)parser.Importer).FileReader; AssertLessUnchanged(input, parser); // Calling the file reader with url's with a protocolis asking for trouble Assert.AreEqual(0, dictionaryReader.DoesFileExistCalls.Count, "We should not ask the file reader if a protocol file exists"); Assert.AreEqual(0, dictionaryReader.GetFileContentsCalls.Count, "We should not ask the file reader if a protocol file exists"); }
private void Awake() { if (Instance == null) { DontDestroyOnLoad(gameObject); Instance = this; path = Application.dataPath + "/dictionary.json"; string jsonString = File.ReadAllText(path); dictionary = JsonConvert.DeserializeObject <Dictionary <string, string[]> >(jsonString); } else if (Instance != this) { Destroy(gameObject); } }
public void Test_DictionaryReader() { const string raw = "<</Key1/Value1/Key2 32 /Key3<</NestedKey1 (NestedValue1)>>>>"; var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw)); var reader = new DictionaryReader(stream, null); var obj = reader.Read(); Assert.IsNotNull(obj); Assert.AreEqual("Value1", ((NameObject) obj["Key1"]).Value); Assert.AreEqual(32, ((IntegerObject) obj["Key2"]).Value); obj = (DictionaryObject) obj["Key3"]; Assert.IsNotNull(obj); Assert.AreEqual("NestedValue1", ((StringObject) obj["NestedKey1"]).Value); stream.Dispose(); }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader<MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; blockInfo.Components.Add(info); } if (merge) MergeSameComponents(blockInfo, definition); }
public void Read_an_instance_for_NameValueCollection() { string xml = @" <node> <Pair Key='color' Value='red'/> <Pair Key='state' Value='texas'/> <Pair Key='direction' Value='north'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof (NameValueCollection)); instance.ShouldBeOfType(typeof (SerializedInstance)); var collection = (NameValueCollection) instance.Build(typeof (NameValueCollection), new StubBuildSession()); collection["color"].ShouldEqual("red"); collection["state"].ShouldEqual("texas"); collection["direction"].ShouldEqual("north"); }
public void Read_an_instance_for_NameValueCollection() { string xml = @" <node> <Pair Key='color' Value='red'/> <Pair Key='state' Value='texas'/> <Pair Key='direction' Value='north'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof(NameValueCollection)); instance.ShouldBeOfType(typeof(SerializedInstance)); var collection = (NameValueCollection)instance.Build(typeof(NameValueCollection), new StubBuildSession()); collection["color"].ShouldEqual("red"); collection["state"].ShouldEqual("texas"); collection["direction"].ShouldEqual("north"); }
public void Read_an_int_string_dictionary() { string xml = @" <node> <Pair Key='1' Value='red'/> <Pair Key='2' Value='texas'/> <Pair Key='3' Value='north'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof (IDictionary<int, string>)); instance.ShouldBeOfType(typeof (SerializedInstance)); var collection = (IDictionary<int, string>) instance.Build(typeof (IDictionary<int, string>), new StubBuildSession()); collection[1].ShouldEqual("red"); collection[2].ShouldEqual("texas"); collection[3].ShouldEqual("north"); }
public void Read_a_string_int_dictionary2() { string xml = @" <node> <Pair Key='color' Value='1'/> <Pair Key='state' Value='2'/> <Pair Key='direction' Value='3'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof(Dictionary <string, int>)); instance.ShouldBeOfType(typeof(SerializedInstance)); var collection = (Dictionary <string, int>)instance.Build(typeof(Dictionary <string, int>), new StubBuildSession()); collection["color"].ShouldEqual(1); collection["state"].ShouldEqual(2); collection["direction"].ShouldEqual(3); }
public void Read_a_string_int_dictionary2() { string xml = @" <node> <Pair Key='color' Value='1'/> <Pair Key='state' Value='2'/> <Pair Key='direction' Value='3'/> </node> "; Instance instance = new DictionaryReader().Read(DataMother.BuildDocument(xml).DocumentElement, typeof (Dictionary<string, int>)); //instance.ShouldBeOfType(typeof (SerializedInstance)); Assert.Fail("NWO"); // var collection = // (Dictionary<string, int>) instance.Build(typeof (Dictionary<string, int>), new StubBuildSession()); // // collection["color"].ShouldEqual(1); // collection["state"].ShouldEqual(2); // collection["direction"].ShouldEqual(3); }
public void CalculateCurve() { MyDefinitionManager.Static.EnvironmentDefinition.LargeShipMaxSpeed = SpeedLimit; MyDefinitionManager.Static.EnvironmentDefinition.SmallShipMaxSpeed = SpeedLimit; // parachute deploy hight code is taken directly from midspaces configurable speed mod. All credit goes to them. DictionaryReader <string, MyDropContainerDefinition> dropContainers = MyDefinitionManager.Static.GetDropContainerDefinitions(); foreach (var kvp in dropContainers) { foreach (MyObjectBuilder_CubeGrid grid in kvp.Value.Prefab.CubeGrids) { foreach (MyObjectBuilder_CubeBlock block in grid.CubeBlocks) { MyObjectBuilder_Parachute chute = block as MyObjectBuilder_Parachute; if (chute != null) { chute.DeployHeight = ParachuteDeployHeight; } } } } }
public void RemoveItemsCombined(MyInventoryBase inventory, DictionaryReader <MyDefinitionId, int> toRemove) { this.Clear(); foreach (KeyValuePair <MyDefinitionId, int> pair in toRemove) { int amount = 0; MyComponentGroupDefinition groupForComponent = MyDefinitionManager.Static.GetGroupForComponent(pair.Key, out amount); if (groupForComponent != null) { this.AddItem(groupForComponent.Id, amount, pair.Value); continue; } if ((MySessionComponentEquivalency.Static != null) && MySessionComponentEquivalency.Static.HasEquivalents(pair.Key)) { HashSet <MyDefinitionId> equivalents = MySessionComponentEquivalency.Static.GetEquivalents(pair.Key); if (equivalents == null) { continue; } int num2 = pair.Value; foreach (MyDefinitionId id in equivalents) { if (num2 <= 0) { break; } num2 -= (int)inventory.RemoveItemsOfType(num2, id, MyItemFlags.None, false); } continue; } inventory.RemoveItemsOfType(pair.Value, pair.Key, MyItemFlags.None, false); } inventory.CountItems(m_componentCounts); this.Solve(m_componentCounts); inventory.ApplyChanges(this.m_solution); }
public bool CanCombineItems(MyInventoryBase inventory, DictionaryReader<MyDefinitionId, int> items) { bool result = true; Clear(); inventory.CountItems(m_componentCounts); foreach (var item in items) { int itemValue = 0; int neededAmount = item.Value; var group = MyDefinitionManager.Static.GetGroupForComponent(item.Key, out itemValue); if (group == null) { MyFixedPoint itemAmount; if (!m_componentCounts.TryGetValue(item.Key, out itemAmount)) { result = false; break; } if (itemAmount < neededAmount) { result = false; break; } } else { AddItem(group.Id, itemValue, neededAmount); } } result &= Solve(m_componentCounts); if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { if (result == false) MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Can not build", Color.Red, 1.0f); else { List<MyComponentChange> solution = null; GetSolution(out solution); float yCoord = 0.0f; foreach (var change in solution) { string text = ""; if (change.IsAddition()) { text += "+ " + change.Amount.ToString() + "x" + change.ToAdd.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Green, 1.0f); yCoord += 20.0f; } else if (change.IsRemoval()) { text += "- " + change.Amount.ToString() + "x" + change.ToRemove.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Red, 1.0f); yCoord += 20.0f; } else { text += "- " + change.Amount.ToString() + "x" + change.ToRemove.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Orange, 1.0f); yCoord += 20.0f; text = ""; text += "+ " + change.Amount.ToString() + "x" + change.ToAdd.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Orange, 1.0f); yCoord += 20.0f; } } } } return result; }
public override void Init(MyObjectBuilder_SessionComponent sessionComponent) { if (Instance == null) { Instance = this; } try { // This Variables are already loaded by this point, but unaccessible because we need Utilities. // Need to create the Utilities, as it isn't yet created by the game at this point. //MyModAPIHelper.OnSessionLoaded(); if (MyAPIGateway.Utilities == null) { MyAPIGateway.Utilities = MyAPIUtilities.Static; } // MyAPIGateway.Utilities = new MyAPIUtilities(); MyDefinitionId missileId = new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "Missile"); MyMissileAmmoDefinition ammoDefinition = MyDefinitionManager.Static.GetAmmoDefinition(missileId) as MyMissileAmmoDefinition; DefaultDefinitionValues = new MidspaceEnvironmentComponent { LargeShipMaxSpeed = (decimal)MyDefinitionManager.Static.EnvironmentDefinition.LargeShipMaxSpeed, SmallShipMaxSpeed = (decimal)MyDefinitionManager.Static.EnvironmentDefinition.SmallShipMaxSpeed, MissileMinSpeed = (decimal)(ammoDefinition?.MissileInitialSpeed ?? 0), MissileMaxSpeed = (decimal)(ammoDefinition?.DesiredSpeed ?? 0), RemoteControlMaxSpeed = 100, // game hardcoded default in MyRemoteControl.CreateTerminalControls() ContainerDropDeployHeight = MessageConfig.DefaultContainerDropDeployHeight, RespawnShipDeployHeight = MessageConfig.DefaultRespawnShipDeployHeight }; // Load the speed on both server and client. string xmlValue; if (MyAPIGateway.Utilities.GetVariable("MidspaceEnvironmentComponent", out xmlValue)) { EnvironmentComponent = MyAPIGateway.Utilities.SerializeFromXML <MidspaceEnvironmentComponent>(xmlValue); if (EnvironmentComponent != null) { // Fix Defaults. if (EnvironmentComponent.Version == 0) { EnvironmentComponent.Version = SpeedConsts.ModCommunicationVersion; } if (EnvironmentComponent.ThrustRatio <= 0) { EnvironmentComponent.ThrustRatio = 1; } if (EnvironmentComponent.GyroPowerMod <= 0) { EnvironmentComponent.GyroPowerMod = 1; } if (EnvironmentComponent.IonAirEfficient < 0 || EnvironmentComponent.IonAirEfficient > 1) { EnvironmentComponent.IonAirEfficient = 0; } if (EnvironmentComponent.AtmosphereSpaceEfficient < 0 || EnvironmentComponent.AtmosphereSpaceEfficient > 1) { EnvironmentComponent.AtmosphereSpaceEfficient = 0; } if (EnvironmentComponent.MissileMinSpeed == 0) { EnvironmentComponent.MissileMinSpeed = DefaultDefinitionValues.MissileMinSpeed; } if (EnvironmentComponent.MissileMaxSpeed == 0) { EnvironmentComponent.MissileMaxSpeed = DefaultDefinitionValues.MissileMaxSpeed; } if (EnvironmentComponent.RemoteControlMaxSpeed == 0) { EnvironmentComponent.RemoteControlMaxSpeed = DefaultDefinitionValues.RemoteControlMaxSpeed; } if (EnvironmentComponent.ContainerDropDeployHeight == 0) { EnvironmentComponent.ContainerDropDeployHeight = MessageConfig.DefaultContainerDropDeployHeight; } if (EnvironmentComponent.RespawnShipDeployHeight == 0) { EnvironmentComponent.RespawnShipDeployHeight = MessageConfig.DefaultRespawnShipDeployHeight; } // Apply settings. if (EnvironmentComponent.LargeShipMaxSpeed > 0) { MyDefinitionManager.Static.EnvironmentDefinition.LargeShipMaxSpeed = (float)EnvironmentComponent.LargeShipMaxSpeed; } if (EnvironmentComponent.SmallShipMaxSpeed > 0) { MyDefinitionManager.Static.EnvironmentDefinition.SmallShipMaxSpeed = (float)EnvironmentComponent.SmallShipMaxSpeed; } if (EnvironmentComponent.EnableThrustRatio) { List <MyDefinitionBase> blocks = MyDefinitionManager.Static.GetAllDefinitions().Where(d => d is MyCubeBlockDefinition && (((MyCubeBlockDefinition)d).Id.TypeId == typeof(MyObjectBuilder_Thrust))).ToList(); foreach (var block in blocks) { MyThrustDefinition thrustBlock = (MyThrustDefinition)block; /* * // thrustBlock.ThrusterType == // this only affects the sound type. * * //thrustBlock.ResourceSinkGroup * * //if (thrustBlock.NeedsAtmosphereForInfluence) // ??? might be indicative of atmosphic thruster. * if (thrustBlock.PropellerUse) * { * // Is atmosphic thruster. * * // MinPlanetaryInfluence is the one to adjust. * // the default of 0.3 takes it down into the gravity well, somewhere below where Low Oxygen starts. * // at 0.0, it is at the cusp between Low Oxygen and No oxygen. * // at -0.3, it allows the atmosphic thruster to work in Space. * * //thrustBlock.MinPlanetaryInfluence = -0.3f; // 0.3 * //thrustBlock.MaxPlanetaryInfluence = 1f; // 1.0 * //thrustBlock.EffectivenessAtMinInfluence = 0f; // 0.0 * //thrustBlock.EffectivenessAtMaxInfluence = 1f; // 1.0 * //thrustBlock.NeedsAtmosphereForInfluence = true; // true * } * else * { * // Is Ion or Hydrogen thruster. * * //thrustBlock.FuelConverter != null // ??? Hydrogen or other fuel propellant. * * //thrustBlock.MinPlanetaryInfluence = 0.0f; // 0.0 * //thrustBlock.MaxPlanetaryInfluence = 0.3f; // 1.0 * //thrustBlock.EffectivenessAtMinInfluence = 1.0f; // 1.0 * //thrustBlock.EffectivenessAtMaxInfluence = 0.0f; // 0.3 * } */ thrustBlock.ForceMagnitude *= (float)EnvironmentComponent.ThrustRatio; } } /* * // if enabled Gyro boost. * { * List<MyDefinitionBase> blocks = MyDefinitionManager.Static.GetAllDefinitions().Where(d => d is MyCubeBlockDefinition && * (((MyCubeBlockDefinition) d).Id.TypeId == typeof (MyObjectBuilder_Gyro))).ToList(); * foreach (var block in blocks) * { * MyGyroDefinition gyroBlock = (MyGyroDefinition) block; * //gyroBlock.ForceMagnitude *= 100; // This works. * } * } */ if (ammoDefinition != null && EnvironmentComponent.MissileMinSpeed > 0) { ammoDefinition.MissileInitialSpeed = (float)EnvironmentComponent.MissileMinSpeed; } if (ammoDefinition != null && EnvironmentComponent.MissileMaxSpeed > 0) { ammoDefinition.DesiredSpeed = (float)EnvironmentComponent.MissileMaxSpeed; } #region ContainerDropDeployHeight // We're basically changing the ContainerDrop prefabs that are loaded in memory before any of them are spawned. // This is not my preferred approach, as these could be altered (by other mods) or reset (reload from disc by the game or mods). // The prefered approach is to modify the chute.DeployHeight after a container is spawned, but it is not whitelisted. DictionaryReader <string, MyDropContainerDefinition> dropContainers = MyDefinitionManager.Static.GetDropContainerDefinitions(); foreach (var kvp in dropContainers) { foreach (MyObjectBuilder_CubeGrid grid in kvp.Value.Prefab.CubeGrids) { foreach (MyObjectBuilder_CubeBlock block in grid.CubeBlocks) { MyObjectBuilder_Parachute chute = block as MyObjectBuilder_Parachute; if (chute != null) { if (chute.DeployHeight < (float)EnvironmentComponent.ContainerDropDeployHeight) { chute.DeployHeight = (float)EnvironmentComponent.ContainerDropDeployHeight; } } } } } #endregion #region RespawnShipDeployHeight DictionaryReader <string, MyRespawnShipDefinition> respawnShips = MyDefinitionManager.Static.GetRespawnShipDefinitions(); foreach (var kvp in respawnShips) { foreach (MyObjectBuilder_CubeGrid grid in kvp.Value.Prefab.CubeGrids) { foreach (MyObjectBuilder_CubeBlock block in grid.CubeBlocks) { MyObjectBuilder_Parachute chute = block as MyObjectBuilder_Parachute; if (chute != null) { if (chute.DeployHeight < (float)EnvironmentComponent.RespawnShipDeployHeight) { chute.DeployHeight = (float)EnvironmentComponent.RespawnShipDeployHeight; } } } } } #endregion OldEnvironmentComponent = EnvironmentComponent.Clone(); return; } } // creates a new EnvironmentComponent if one was not found in the game Variables. EnvironmentComponent = new MidspaceEnvironmentComponent { Version = SpeedConsts.ModCommunicationVersion, LargeShipMaxSpeed = (decimal)MyDefinitionManager.Static.EnvironmentDefinition.LargeShipMaxSpeed, SmallShipMaxSpeed = (decimal)MyDefinitionManager.Static.EnvironmentDefinition.SmallShipMaxSpeed, EnableThrustRatio = false, MissileMinSpeed = (decimal)(ammoDefinition?.MissileInitialSpeed ?? 0), MissileMaxSpeed = (decimal)(ammoDefinition?.DesiredSpeed ?? 0), ThrustRatio = 1, RemoteControlMaxSpeed = 100, ContainerDropDeployHeight = MessageConfig.DefaultContainerDropDeployHeight, RespawnShipDeployHeight = MessageConfig.DefaultRespawnShipDeployHeight }; OldEnvironmentComponent = EnvironmentComponent.Clone(); } catch (Exception ex) { VRage.Utils.MyLog.Default.WriteLine("##Mod## ERROR " + ex.Message); // The Loggers doesn't actually exist yet, as Init is called before UpdateBeforeSimulation. // TODO: should rework the code to change this. //ClientLogger.WriteException(ex); //ServerLogger.WriteException(ex); } }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader <MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); if (componentDefinition == null) { MyPhysicalItemDefinition physicalDefinition = null; if (!MyDefinitionManager.Static.TryGetPhysicalItemDefinition(material.Key, out physicalDefinition)) { continue; } info.ComponentName = physicalDefinition.DisplayNameText; info.Icon = physicalDefinition.Icon; info.DefinitionId = physicalDefinition.Id; info.TotalCount = 1; } else { info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; } blockInfo.Components.Add(info); } if (merge) { MergeSameComponents(blockInfo); } }
public DictionaryCreator(DictionaryReader reader, EntitiesFilter filter) { _reader = reader; _filter = filter; }
public void RemoveItemsCombined(MyInventoryBase inventory, DictionaryReader <MyDefinitionId, int> toRemove) { Clear(); foreach (var material in toRemove) // rename material to component { int groupAmount = 0; MyComponentGroupDefinition group = MyDefinitionManager.Static.GetGroupForComponent(material.Key, out groupAmount); // The component does not belong to any component group => we are looking exactly for the given component if (group == null) { MyComponentSubstitutionDefinition substitutionDefinition = null; if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(material.Key, out substitutionDefinition)) { int amountToRemove = material.Value; foreach (var entry in substitutionDefinition.ProvidingComponents) { if (amountToRemove > 0) { var removed = inventory.RemoveItemsOfType(amountToRemove * entry.Value, entry.Key); amountToRemove -= (int)removed; } else { break; } } if (amountToRemove > 0) { var removed = inventory.RemoveItemsOfType(amountToRemove, material.Key); amountToRemove -= (int)removed; } } else { inventory.RemoveItemsOfType(material.Value, material.Key); continue; } } else { AddItem(group.Id, groupAmount, material.Value); } } inventory.CountItems(m_componentCounts); bool success = Solve(m_componentCounts); Debug.Assert(success, "Could not combine required items!"); inventory.ApplyChanges(m_solution); /*CheckUpdate(); * * m_remainder.Clear(); * foreach (var material in toRemove) * { * m_remainder.Add(material.Key, material.Value); * } * * bool success = true; * * m_cuttingSolver.Clear(); * foreach (var material in m_remainder) * { * int groupAmount = 0; * MyComponentGroupDefinition group = MyDefinitionManager.Static.GetGroupForComponent(material.Key, out groupAmount); * * // The component does not belong to any component group => we are looking exactly for the given component * if (group == null) * { * success &= RemoveItemsOfTypeInternal(material.Key, material.Value); * Debug.Assert(success, "Could not find the required component although we were permitted to build!"); * continue; * } * else * { * m_cuttingSolver.AddItem(group.Id, groupAmount, material.Value); * } * * m_componentCounts.Clear(); * CollectItems(m_componentCounts); * success &= m_cuttingSolver.Solve(m_componentCounts); * * List<MyComponentCombiner.ComponentChange> changes = null; * m_cuttingSolver.GetSolution(out changes); * foreach (var change in changes) * { * if (change.IsRemoval()) * { * success &= RemoveItemsOfTypeInternal(change.ToRemove, change.Amount); * Debug.Assert(success, "Could not remove compnents, although the solver told us it should be possible!"); * } * else if (change.IsChange()) * { * ComponentInfo cInfo = null; * m_componentInfos.TryGetValue(change.ToRemove, out cInfo); * Debug.Assert(cInfo != null, "Could not find a component in MyAreaInventory!"); * * if (cInfo == null) continue; * * for (int i = 0; i < change.Amount; ++i) * { * int dummy = 0; * long entityId = cInfo.RemoveComponent(1, out dummy); * if (entityId == 0) break; * * var grid = TryGetComponent(entityId); * if (grid == null) * { * break; * } * * SpawnRemainingData spawnData = new SpawnRemainingData(); * PrepareSpawnRemainingMaterial(grid, ref spawnData); * * grid.Physics.Enabled = false; * grid.SyncObject.SendCloseRequest(); * * spawnData.DefId = change.ToAdd; * SpawnRemainingMaterial(ref spawnData); * } * } * } * } * * return success;*/ }
public void RemoveItemsCombined(MyInventoryBase inventory, DictionaryReader<MyDefinitionId, int> toRemove) { Clear(); foreach (var material in toRemove) // rename material to component { int groupAmount = 0; MyComponentGroupDefinition group = MyDefinitionManager.Static.GetGroupForComponent(material.Key, out groupAmount); // The component does not belong to any component group => we are looking exactly for the given component if (group == null) { if (MySessionComponentEquivalency.Static != null && MySessionComponentEquivalency.Static.HasEquivalents(material.Key)) { var eqGroup = MySessionComponentEquivalency.Static.GetEquivalents(material.Key); if (eqGroup != null) { int amountToRemove = material.Value; foreach (var element in eqGroup) { if (amountToRemove > 0) { var removed = inventory.RemoveItemsOfType(amountToRemove, element); amountToRemove -= (int)removed; } else { break; } } } } else { inventory.RemoveItemsOfType(material.Value, material.Key); continue; } //MyComponentSubstitutionDefinition substitutionDefinition = null; //if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(material.Key, out substitutionDefinition)) //{ // int amountToRemove = material.Value; // foreach (var entry in substitutionDefinition.ProvidingComponents) // { // if (amountToRemove > 0) // { // var removed = inventory.RemoveItemsOfType(amountToRemove * entry.Value, entry.Key); // amountToRemove -= (int)removed; // } // else // { // break; // } // } // if (amountToRemove > 0) // { // var removed = inventory.RemoveItemsOfType(amountToRemove, material.Key); // amountToRemove -= (int)removed; // } //} //else //{ // inventory.RemoveItemsOfType(material.Value, material.Key); // continue; //} } else { AddItem(group.Id, groupAmount, material.Value); } } inventory.CountItems(m_componentCounts); bool success = Solve(m_componentCounts); Debug.Assert(success, "Could not combine required items!"); inventory.ApplyChanges(m_solution); /*CheckUpdate(); m_remainder.Clear(); foreach (var material in toRemove) { m_remainder.Add(material.Key, material.Value); } bool success = true; m_cuttingSolver.Clear(); foreach (var material in m_remainder) { int groupAmount = 0; MyComponentGroupDefinition group = MyDefinitionManager.Static.GetGroupForComponent(material.Key, out groupAmount); // The component does not belong to any component group => we are looking exactly for the given component if (group == null) { success &= RemoveItemsOfTypeInternal(material.Key, material.Value); Debug.Assert(success, "Could not find the required component although we were permitted to build!"); continue; } else { m_cuttingSolver.AddItem(group.Id, groupAmount, material.Value); } m_componentCounts.Clear(); CollectItems(m_componentCounts); success &= m_cuttingSolver.Solve(m_componentCounts); List<MyComponentCombiner.ComponentChange> changes = null; m_cuttingSolver.GetSolution(out changes); foreach (var change in changes) { if (change.IsRemoval()) { success &= RemoveItemsOfTypeInternal(change.ToRemove, change.Amount); Debug.Assert(success, "Could not remove compnents, although the solver told us it should be possible!"); } else if (change.IsChange()) { ComponentInfo cInfo = null; m_componentInfos.TryGetValue(change.ToRemove, out cInfo); Debug.Assert(cInfo != null, "Could not find a component in MyAreaInventory!"); if (cInfo == null) continue; for (int i = 0; i < change.Amount; ++i) { int dummy = 0; long entityId = cInfo.RemoveComponent(1, out dummy); if (entityId == 0) break; var grid = TryGetComponent(entityId); if (grid == null) { break; } SpawnRemainingData spawnData = new SpawnRemainingData(); PrepareSpawnRemainingMaterial(grid, ref spawnData); grid.Physics.Enabled = false; grid.SyncObject.SendCloseRequest(); spawnData.DefId = change.ToAdd; SpawnRemainingMaterial(ref spawnData); } } } } return success;*/ }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader <MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; blockInfo.Components.Add(info); } if (merge) { MergeSameComponents(blockInfo, definition); } }
static public DictionaryReader CreateReader() { var reader = new DictionaryReader(TestSourcesResolver); return reader; }
public bool CanCombineItems(MyInventoryBase inventory, DictionaryReader <MyDefinitionId, int> items) { bool flag = true; this.Clear(); inventory.CountItems(m_componentCounts); foreach (KeyValuePair <MyDefinitionId, int> pair in items) { int amount = 0; int num2 = pair.Value; MyComponentGroupDefinition groupForComponent = null; groupForComponent = MyDefinitionManager.Static.GetGroupForComponent(pair.Key, out amount); if (groupForComponent != null) { this.AddItem(groupForComponent.Id, amount, num2); continue; } if ((MySessionComponentEquivalency.Static != null) && MySessionComponentEquivalency.Static.HasEquivalents(pair.Key)) { if (MySessionComponentEquivalency.Static.IsProvided(m_componentCounts, pair.Key, pair.Value)) { continue; } flag = false; } else { MyFixedPoint point; if (!m_componentCounts.TryGetValue(pair.Key, out point)) { flag = false; } else { if (point >= num2) { continue; } flag = false; } } break; } if (flag) { flag &= this.Solve(m_componentCounts); } if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { if (!flag) { MyRenderProxy.DebugDrawText2D(new Vector2(0f, 0f), "Can not build", Color.Red, 1f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); } else { List <MyComponentChange> changes = null; this.GetSolution(out changes); float y = 0f; foreach (MyComponentChange change in changes) { string text = ""; if (change.IsAddition()) { string[] textArray1 = new string[] { text, "+ ", change.Amount.ToString(), "x", change.ToAdd.ToString() }; text = string.Concat(textArray1); MyRenderProxy.DebugDrawText2D(new Vector2(0f, y), text, Color.Green, 1f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); y += 20f; continue; } if (change.IsRemoval()) { string[] textArray2 = new string[] { text, "- ", change.Amount.ToString(), "x", change.ToRemove.ToString() }; text = string.Concat(textArray2); MyRenderProxy.DebugDrawText2D(new Vector2(0f, y), text, Color.Red, 1f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); y += 20f; continue; } string[] textArray3 = new string[] { text, "- ", change.Amount.ToString(), "x", change.ToRemove.ToString() }; text = string.Concat(textArray3); MyRenderProxy.DebugDrawText2D(new Vector2(0f, y), text, Color.Orange, 1f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); y += 20f; text = ""; string[] textArray4 = new string[] { text, "+ ", change.Amount.ToString(), "x", change.ToAdd.ToString() }; text = string.Concat(textArray4); MyRenderProxy.DebugDrawText2D(new Vector2(0f, y), text, Color.Orange, 1f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); y += 20f; } } } return(flag); }
public VoxelPlacementDefinition(MyVoxelMaterialDefinition material, int volume, DictionaryReader <MyDefinitionId, int> items) { Material = material; Volume = volume; Items = items; }
static public DictionaryReader CreateReader() { var reader = new DictionaryReader(TestSourcesResolver); return(reader); }
public CommandNode(string name) { Subcommands = new DictionaryReader <string, CommandNode>(_subcommands); Name = name; }
public bool CanCombineItems(MyInventoryBase inventory, DictionaryReader<MyDefinitionId, int> items) { bool result = true; Clear(); inventory.CountItems(m_componentCounts); foreach (var item in items) { int itemValue = 0; int neededAmount = item.Value; MyComponentGroupDefinition group = null; group = MyDefinitionManager.Static.GetGroupForComponent(item.Key, out itemValue); if (group == null) { MyFixedPoint itemAmount; if (MySessionComponentEquivalency.Static != null && MySessionComponentEquivalency.Static.HasEquivalents(item.Key)) { if (!MySessionComponentEquivalency.Static.IsProvided(m_componentCounts, item.Key, item.Value)) { result = false; break; } } // Checking if this component is not provided by the group //MyComponentSubstitutionDefinition substitutions; //if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(item.Key, out substitutions)) //{ // int providedAmount; // if (!substitutions.IsProvidedByComponents(m_componentCounts, out providedAmount)) // { // result = false; // break; // } // else if (providedAmount < neededAmount) // { // result = false; // break; // } //} else if (!m_componentCounts.TryGetValue(item.Key, out itemAmount)) { result = false; break; } else if (itemAmount < neededAmount) { result = false; break; } } else { AddItem(group.Id, itemValue, neededAmount); } } if (result) { result &= Solve(m_componentCounts); } if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { if (result == false) MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Can not build", Color.Red, 1.0f); else { List<MyComponentChange> solution = null; GetSolution(out solution); float yCoord = 0.0f; foreach (var change in solution) { string text = ""; if (change.IsAddition()) { text += "+ " + change.Amount.ToString() + "x" + change.ToAdd.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Green, 1.0f); yCoord += 20.0f; } else if (change.IsRemoval()) { text += "- " + change.Amount.ToString() + "x" + change.ToRemove.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Red, 1.0f); yCoord += 20.0f; } else { text += "- " + change.Amount.ToString() + "x" + change.ToRemove.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Orange, 1.0f); yCoord += 20.0f; text = ""; text += "+ " + change.Amount.ToString() + "x" + change.ToAdd.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Orange, 1.0f); yCoord += 20.0f; } } } } return result; }
public CommandTree() { Root = new DictionaryReader <string, CommandNode>(_root); }
public bool CanCombineItems(MyInventoryBase inventory, DictionaryReader <MyDefinitionId, int> items) { bool result = true; Clear(); inventory.CountItems(m_componentCounts); foreach (var item in items) { int itemValue = 0; int neededAmount = item.Value; MyComponentGroupDefinition group = null; group = MyDefinitionManager.Static.GetGroupForComponent(item.Key, out itemValue); if (group == null) { MyFixedPoint itemAmount; // Checking if this component is not provided by the group MyComponentSubstitutionDefinition substitutions; if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(item.Key, out substitutions)) { int providedAmount; if (!substitutions.IsProvidedByComponents(m_componentCounts, out providedAmount)) { result = false; break; } else if (providedAmount < neededAmount) { result = false; break; } } else if (!m_componentCounts.TryGetValue(item.Key, out itemAmount)) { result = false; break; } else if (itemAmount < neededAmount) { result = false; break; } } else { AddItem(group.Id, itemValue, neededAmount); } } if (result) { result &= Solve(m_componentCounts); } if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { if (result == false) { MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Can not build", Color.Red, 1.0f); } else { List <MyComponentChange> solution = null; GetSolution(out solution); float yCoord = 0.0f; foreach (var change in solution) { string text = ""; if (change.IsAddition()) { text += "+ " + change.Amount.ToString() + "x" + change.ToAdd.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Green, 1.0f); yCoord += 20.0f; } else if (change.IsRemoval()) { text += "- " + change.Amount.ToString() + "x" + change.ToRemove.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Red, 1.0f); yCoord += 20.0f; } else { text += "- " + change.Amount.ToString() + "x" + change.ToRemove.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Orange, 1.0f); yCoord += 20.0f; text = ""; text += "+ " + change.Amount.ToString() + "x" + change.ToAdd.ToString(); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, yCoord), text, Color.Orange, 1.0f); yCoord += 20.0f; } } } } return(result); }
/// <summary> /// Modifies all matching definitions. /// </summary> /// <param name="dictionary">A dictionary with definition ids and icon paths.</param> /// <param name="definitions">All block, component and tool definitions.</param> /// <param name="blueprintDefinitions">All blueprint definitions.</param> /// <param name="groupDefinitions">All block groups definitions.</param> private void ModifyDefinitions(Dictionary <string, string> dictionary, ref DictionaryValuesReader <MyDefinitionId, MyDefinitionBase> definitions, ref DictionaryValuesReader <MyDefinitionId, MyBlueprintDefinitionBase> blueprintDefinitions, ref DictionaryReader <string, MyBlockVariantGroup> groupDefinitions) { foreach (var definitionPair in dictionary) { try { var definitionId = MyDefinitionId.Parse(definitionPair.Key); var iconPath = definitionPair.Value; if (definitionPair.Key.StartsWith("MyObjectBuilder_BlueprintDefinition/")) { MyBlueprintDefinitionBase blueprint; if (blueprintDefinitions.TryGetValue(definitionId, out blueprint)) { ChangeIcon(blueprint, iconPath); } } else if (definitionPair.Key.StartsWith("MyObjectBuilder_BlockVariantGroup/")) { MyBlockVariantGroup group; if (groupDefinitions.TryGetValue(definitionId.SubtypeName, out group)) { ChangeIcon(group, iconPath); } } else { MyDefinitionBase definition; if (definitions.TryGetValue(definitionId, out definition)) { ChangeIcon(definition, iconPath); } } } catch (ArgumentException e) { MyLog.Default.WriteLineAndConsole($"Failed to parse definition ID: {definitionPair.Key}, Message{e.Message}"); } } }