using System.Collections.Generic; using System.Xml; namespace TeslaConsole.RedPlanet; public class Scenario { private string mKey; private string mName; private Dictionary mMaps = new Dictionary(); private Dictionary mVehicles = new Dictionary(); private Dictionary mTimesOfDay = new Dictionary(); private Dictionary mWeather = new Dictionary(); public string Key => mKey; public string Name => mName; public Dictionary Maps => mMaps; public Dictionary Vehicles => mVehicles; public Dictionary TimesOfDay => mTimesOfDay; public Dictionary Weather => mWeather; internal Scenario(XmlNode scenarioNode) { mKey = scenarioNode.Name; mName = scenarioNode.Attributes["name"].InnerText; List> list = new List>(); foreach (XmlNode childNode in scenarioNode.ChildNodes) { if (childNode.Name == "invalid") { list.Add(new KeyValuePair(childNode.Attributes["type"].InnerText, childNode.Attributes["key"].InnerText)); } } foreach (RPMap value in RPConfig.Maps.Values) { if (!IsInvalid("map", value.Key, list)) { mMaps.Add(value.Key, value); } } foreach (RPVehicle value2 in RPConfig.Vehicles.Values) { if (!IsInvalid("vehicle", value2.Key, list)) { mVehicles.Add(value2.Key, value2); } } foreach (KeyValuePair item in RPConfig.TimesOfDay) { if (!IsInvalid("time", item.Key, list)) { mTimesOfDay.Add(item.Key, item.Value); } } foreach (KeyValuePair item2 in RPConfig.Weather) { if (!IsInvalid("weather", item2.Key, list)) { mWeather.Add(item2.Key, item2.Value); } } } private static bool IsInvalid(string type, string value, List> invalid) { foreach (KeyValuePair item in invalid) { if (item.Key == type && item.Value == value) { return true; } } return false; } }