public static void InitConfig() { CompatibilitySettings = new CompatibilitySettings() { XorbarexCleaveExists = false, }; SubModuleInfo info = new SubModuleInfo(); SubModuleInfoContents = info.DeserializeSubModule(); if (configExists) { try { ConfigSettings = JsonConvert.DeserializeObject <ConfigSettings>(File.ReadAllText(ConfigFilePath)); ConfigLoadedSuccessfully = true; return; } catch { } } ConfigLoadedSuccessfully = false; ConfigSettings = new ConfigSettings() { CleaveEnabled = true, AdditionalCleaveForTroopsInShieldWall = true, AdditionalCleaveForTroopsInShieldWallAngleRestriction = 60, CleaveEnabledForAllUnits = true, StandardizedFlinchOnEnemiesEnabled = true, HyperArmorEnabledForHeros = true, HyperArmorEnabledForAllUnits = true, HyperArmorDuration = 1, HPOnKillEnabledForHeros = true, HPOnKillForAI = true, HPOnKillMedicineLevelScalePercentage = 0.1f, HPOnKillAmount = 20f, ProjectileBalancingEnabled = true, ProjectileStunPercentageThreshold = 40f, HorseProjectileCrippleEnabled = true, HorseHeadshotRearingEnabled = true, HorseProjectileCrippleDuration = 1, OrderVoiceCommandQueuing = true, OrderControllerCameraImprovementsEnable = true, MurderEnabled = false, SimplifiedSurrenderLogic = true, TrueFriendlyFireEnabled = false, }; }
public SubModuleContents DeserializeSubModule() { try { string fileName = "SubModule.xml"; var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var path = Path.Combine(location, @"..\..\", fileName); XmlRootAttribute root = new XmlRootAttribute("Module"); XmlSerializer serializer = new XmlSerializer(typeof(SubModuleContents), root); StreamReader reader = new StreamReader(path); SubModuleContents contents = (SubModuleContents)serializer.Deserialize(reader); reader.Close(); return(contents); } catch (Exception) { return(null); } }