public void LoadData() { govs.Clear(); lookup.Clear(); RankList.Clear(); permissionList.Clear(); var data = Interface.GetMod().DataFileSystem.GetDatafile(GovernmentDataFilename); var settings = Interface.GetMod().DataFileSystem.GetDatafile(GovernmentSettingsFilename); // Load Rank List if (settings["ranks"] != null) { var rankList = (List<object>)Convert.ChangeType(settings["ranks"], typeof(List<object>)); foreach (var irank in rankList) { RankList.Add((string)irank); } } // Load Permissions List if (settings["permissions"] != null) { var permissionData = (Dictionary<string, object>)Convert.ChangeType(settings["permissions"], typeof(Dictionary<string, object>)); foreach (var ipermission in permissionData) { var permitList = (List<object>)Convert.ChangeType(ipermission.Value, typeof(List<object>)); var newPermitList = new List<string>(); foreach (var permit in permitList) newPermitList.Add((string)permit); permissionList.Add(ipermission.Key, newPermitList); } } else { } // Load Damage Scale Types Table if(settings["damageScales"] != null) { var damageScaleData = (Dictionary<string, object>)Convert.ChangeType(settings["damageScales"], typeof(Dictionary<string, object>)); foreach(var attackerData in damageScaleData) { var attackerRank = attackerData.Key; var victimData = (Dictionary<string, object>)attackerData.Value; var victims = new Dictionary<string, float>(); foreach(var victim in victimData) { var victimRank = victim.Key; var damageScaleValue = (float) Convert.ChangeType(victim.Value, typeof(float)); victims.Add(victimRank, damageScaleValue); } damageScaleTable.Add(attackerRank, victims); } } else { } // Load Government Data if (data["governments"] != null) { var govsData = (Dictionary<string, object>)Convert.ChangeType(data["governments"], typeof(Dictionary<string, object>)); foreach (var igov in govsData) { var gov = (Dictionary<string, object>)igov.Value; var tag = (string)igov.Key; var name = (string)gov["name"]; var membersData = (Dictionary<string, object>)gov["members"]; var members = new Dictionary<string, string>(); foreach (var imember in membersData) { var memberID = (string)imember.Key; var memberRank = (string)imember.Value; members.Add(memberID, memberRank); } var guestsData = (List<object>)gov["guests"]; var guests = new List<string>(); foreach (var iguest in guestsData) { guests.Add(iguest.ToString()); } var invitedsData = (List<object>)gov["inviteds"]; var inviteds = new List<string>(); foreach (var iinvited in invitedsData) { inviteds.Add(iinvited.ToString()); } var newGov = new Government() { Tag = tag, Name = name}; foreach (var m in members) newGov.AddMember(m.Key, m.Value); newGov.Guests = guests; newGov.Inviteds = inviteds; govs.Add(tag, newGov); } } Puts("Successfully loaded (" + govs.Count + ") governments."); }
private void CreateGovernment(string tag, string name, string creatorID) { var newGov = new Government() { Tag = tag, Name = name }; govs.Add(tag, newGov); newGov.AddMember(creatorID, Rank("DICTATOR")); }