public CultureParser AddCulture(String name) { if (name != "norse") { String oname = name; name = StarNames.SafeName(name); LanguageManager.instance.Add(name, oname); } ScriptScope scope = new ScriptScope(); scope.Name = name; Name = name; Scope.Add(scope); CultureParser r = new CultureParser(scope); CultureManager.instance.AllCultures.Add(r); Cultures.Add(r); CultureManager.instance.CultureMap[name] = r; r.Name = Name; r.Init(); Scope.SetChild(r.Scope); return r; }
public ReligionParser AddReligion(String name, String orig=null) { if (name != "pagan") { String oname = name; name = StarNames.SafeName(name); LanguageManager.instance.Add(name, oname); orig = oname; } ScriptScope scope = new ScriptScope(); scope.Name = name; Scope.Add(scope); ReligionParser r = new ReligionParser(scope); ReligionManager.instance.AllReligions.Add(r); if (orig != null) { r.LanguageName = orig; } Religions.Add(r); ReligionManager.instance.ReligionMap[name] = r; return r; }
public void Save() { Script s = new Script(); s.Name = Globals.GameDir + "map\\geographical_region.txt"; s.Root = new ScriptScope(); foreach (var region in regions) { ScriptScope ss = new ScriptScope(); String duchieList = ""; foreach (var titleParser in region.duchies) { duchieList = duchieList + " " + titleParser.Name; } ss.Name = StarNames.SafeName(region.name); ss.Do(@" duchies = { " + duchieList + @" } "); s.Root.Add(ss); } s.Save(); }
private void ExamineEvent(ScriptScope node) { for (int index = 0; index < node.Children.Count; index++) { var child = node.Children[index]; if (child is ScriptScope) ExamineEvent(child as ScriptScope); if (child is ScriptCommand) { ScriptCommand c = child as ScriptCommand; if(c.Name == "id" && node.Name == "character_event") { if (!LinkedEventIDs.Contains(c.Value.ToString())) { var e = (EventManager.instance.GetEvent(c.Value.ToString())); if (e != null) { LinkedEvents.Add(e); LinkedEventIDs.Add(c.Value.ToString()); } } } } } }
public EventParser(ScriptScope scope) : base(scope) { Trigger = scope.Find("trigger") as ScriptScope; MeanTime = scope.Find("mean_time_to_happen") as ScriptScope; }
public ScriptCommand(string name, object val, ScriptScope parent) { this.Parent = parent; Name = name; Value = val; if (val == null || val.ToString().Length == 0) Value = "\"\""; }
public ReligionParser BranchReligion(String name) { ScriptScope scope = new ScriptScope(); scope.Name = name; Group.Scope.Add(scope); ReligionParser r = new ReligionParser(scope); ReligionManager.instance.AllReligions.Add(r); return r; }
public ReligionGroupParser(ScriptScope scope) : base(scope) { foreach (var scriptScope in scope.Scopes) { if (ReligionManager.instance.ReligionMap.ContainsKey(scriptScope.Name)) Religions.Add(ReligionManager.instance.ReligionMap[scriptScope.Name]); } }
public void AddGovernment(Government government) { var scope = new ScriptScope(); scope.Name = "spriteType"; scope.Do(@" name = ""GFX_icon_" + government.name + @" texturefile = gfx\\interface\\government_icon_" + government.name.Replace("_government", "")+".dds" ); spriteTypes.Add(scope); }
public Dynasty GetDynasty(CultureParser culture) { ScriptScope scope = new ScriptScope(); scope.Name = ID.ToString(); ID++; scope.Add(new ScriptCommand("name", culture.dna.GetDynastyName(), scope)); scope.Add(new ScriptCommand("culture", culture.Name, scope)); script.Root.Add(scope); var d = new Dynasty() {ID = ID - 1, Scope = scope}; DynastyMap[ID - 1] = d; culture.Dynasties.Add(d); return d; }
public ReligionGroupParser AddReligionGroup(String name) { ScriptScope scope = new ScriptScope(); scope.Name = name; script.Root.Add(scope); ReligionGroupParser r = new ReligionGroupParser(scope); r.Init(); GroupMap[name] = r; AllReligionGroups.Add(r); return r; }
public void AddTraitSprite(String name, String relFilename) { var scope = new ScriptScope(); scope.Name = "spriteType"; scope.Do(@" name = ""GFX_trait_" + name + @" texturefile = " + relFilename + @" noOfFrames = 1 norefcount = yes effectFile = ""gfx/FX/buttonstate.lua"""); spriteTypes.Add(scope); }
public Parser(ScriptScope scope) { this.Scope = scope; int line = 0; foreach (var child in scope.Children) { if (child is ScriptCommand) { string name = (child as ScriptCommand).Name; RegisterProperty(line, name, child); } line++; } }
private void RemoveDeathDates(ScriptScope scope) { foreach (var child in scope.Children) { if (child is ScriptScope) { ScriptScope c = (ScriptScope)child; if (c.Children[0] is ScriptCommand && (c.Children[0] as ScriptCommand).Name == "death") { c.Parent.Remove(c); return; } } } }
public void Save() { Script s = new Script(); s.Name = Globals.ModDir + "events\\gen_" + name + "_events.txt"; s.Root = new ScriptScope(); s.Root.Add(new ScriptCommand("namespace", nameSpace, s.Root)); foreach (var scriptScope in Events) { scriptScope.Value.Name = "character_event"; s.Root.Add(scriptScope.Value); } s.Save(); s = new Script(); s.Name = Globals.ModDir + "decisions\\gen_" + name + "_decisions.txt"; s.Root = new ScriptScope(); ScriptScope ss = new ScriptScope(); s.Root.Add(ss); ss.Name = "decisions"; // s.Root.Add(new ScriptCommand("namespace", nameSpace, s.Root)); foreach (var scriptScope in Decisions) { ScriptScope e = new ScriptScope(); scriptScope.Value.Name = scriptScope.Key; ss.Add(scriptScope.Value); } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\traits\\03_zz_gen_" + name + "_traits.txt"; s.Root = new ScriptScope(); // s.Root.Add(new ScriptCommand("namespace", nameSpace, s.Root)); foreach (var scriptScope in Traits) { scriptScope.Value.Name = scriptScope.Key; s.Root.Add(scriptScope.Value); } s.Save(); }
public void Init() { if (!Directory.Exists(Globals.ModDir + "interface")) Directory.CreateDirectory(Globals.ModDir + "interface"); var files = Directory.GetFiles(Globals.ModDir + "interface"); foreach (var file in files) { File.Delete(file); } script.Root = new ScriptScope(); var s = new ScriptScope(); s.Name = "spriteTypes"; spriteTypes = s; script.Root.Add(s); script.Name = Globals.ModDir + "interface\\genGraphics.gfx"; }
public CultureGroupParser(ScriptScope scope) : base(scope) { if (scope.UnsavedData.ContainsKey("color")) { var col = ( Color)Scope.UnsavedData["color"]; r = col.R; g = col.G; b = col.B; } foreach (var scriptScope in scope.Scopes) { if (CultureManager.instance.CultureMap.ContainsKey(scriptScope.Name)) Cultures.Add(CultureManager.instance.CultureMap[scriptScope.Name]); } }
public CultureParser(ScriptScope scope) : base(scope) { }
private void RemoveAllReligionTests(ScriptScope node) { for (int index = 0; index < node.Children.Count; index++) { var child = node.Children[index]; if (child is ScriptScope) RemoveAllReligionTests(child as ScriptScope); if (child is ScriptCommand) { ScriptCommand c = (ScriptCommand)child; if (c.Name == "religion" || c.Name == "religion_group") { if (c.Value.ToString().ToUpper() == "FROM" || c.Value.ToString().ToUpper() == "ROOT" || c.Value.ToString().ToUpper().Contains("PREV")) { } else { node.Remove(child); index--; } continue; } if (c.Name == "culture" || c.Name == "culture_group") { if (c.Value.ToString().ToUpper() == "FROM" || c.Value.ToString().ToUpper() == "ROOT" || c.Value.ToString().ToUpper().Contains("PREV")) { } else { node.Remove(child); index--; } continue; } } } }
public TitleParser CreateTitle() { this.title = this.Name; // string n = culture.dna.GetPlaceName(); // String sn = StarNames.SafeName(n); // this.Name = "c_" + sn; var scope = new ScriptScope(); scope.Name = this.title; var c = new TitleParser(scope); c.capital = this.id; c.CapitalProvince = this; TitleManager.instance.AddTitle(c); return c; }
public void Save() { foreach (var cultureParser in CultureManager.instance.AllCultures) { if (cultureParser.Governments.Count == 0) { var gov = GovernmentManager.instance.CreateNewGovernment(cultureParser); } foreach (var government in cultureParser.Governments) { if (government.cultureAllow.Count == 0) { government.cultureAllow.Add(cultureParser.Name); } } if (!Government.cultureDone.Contains(cultureParser.Name)) { cultureParser.Governments.Add(GovernmentManager.instance.CreateNewGovernment(cultureParser)); } } if (!Directory.Exists(Globals.ModDir + "gfx\\interface\\")) Directory.CreateDirectory(Globals.ModDir + "gfx\\interface\\"); var files = Directory.GetFiles(Globals.ModDir + "gfx\\interface\\"); foreach (var file in files) { File.Delete(file); } foreach (var government in governments) { switch (government.type) { case "nomadic": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_nomadic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "tribal": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_tribal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "feudal": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_feudal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "theocracy": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_theocracy.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "republic": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_republic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; } } Script s = new Script(); s.Name = Globals.ModDir + "common\\governments\\nomadic_governments.txt"; s.Root = new ScriptScope(); var scope = new ScriptScope(); scope.Name = "nomadic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "nomadic" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\feudal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "feudal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "feudal" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\theocracy_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "theocracy_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "theocracy" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\republic_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "republic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "republic" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\tribal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "tribal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "tribal" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); }
public CultureGroupParser AddCultureGroup(string name, CultureGroupParser group = null) { ScriptScope scope = new ScriptScope(); scope.Name = name; script.Root.Add(scope); CultureGroupParser r = new CultureGroupParser(scope); r.Init(); if (group != null) { r.chosenGfx = GetRelatedCultureGfx(group); } GroupMap[name] = r; AllCultureGroups.Add(r); r.chosenGfx = scope.Scopes[0].Data; return r; }
public TitleParser CreateKingScriptScope(ProvinceParser capital, String name = null) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; if (name == null) scope.Name = "k_" + capital.Title.Name.Substring(2); else scope.Name = "k_" + name; //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); AddTitle(title); // now place the counties into it... if (title.capital != 0) title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; return title; }
public TitleParser(ScriptScope scope) : base(scope) { String newName = ""; Name = scope.Name; if (Name.StartsWith("b_")) { // newName = LanguageManager.instance.Add(Name, StarNames.Generate(culture)); Rank = 0; } if (Name.StartsWith("c_")) { // newName = LanguageManager.instance.Add(Name, StarNames.Generate(culture)); Rank = 1; } if (Name.StartsWith("d_")) { // newName = LanguageManager.instance.Add(Name, StarNames.Generate(culture)); Rank = 2; } if (Name.StartsWith("k_")) { // newName = LanguageManager.instance.Add(Name, StarNames.Generate(culture)); Rank = 3; } if (Name.StartsWith("e_")) { // newName = LanguageManager.instance.Add(Name, StarNames.Generate(culture) + " Empire"); Rank = 4; } if (TitleManager.instance.TitleMap.ContainsKey(Name)) { } TitleManager.instance.TitleMap[Name] = this; TitleManager.instance.Titles.Add(this); int line = 0; foreach (var child in scope.Children) { if (child is ScriptCommand) { RegisterProperty(line, ((child as ScriptCommand).Name), child); } line++; if (child is ScriptScope) { var subscope = (child as ScriptScope); if (subscope.Name == "OR" || subscope.Name == "NOT" || subscope.Name == "AND" || subscope.Name == "allow" || subscope.Name == "male_names" || subscope.Name == "coat_of_arms") continue; SubTitles[subscope.Name] = new TitleParser(subscope); SubTitles[subscope.Name].Liege = this; if (subscope.Name.StartsWith("b_")) { MapManager.instance.RegisterBarony(subscope.Name, SubTitles[subscope.Name]); } } } if (capital != 0) { if (MapManager.instance.ProvinceIDMap.ContainsKey(capital)) { ProvinceParser provinceParser = MapManager.instance.ProvinceIDMap[capital]; CapitalProvince = provinceParser; if (Name.StartsWith("c_")) { Owns.Add(CapitalProvince); CapitalProvince.title = this.Name; } } } else if (MapManager.instance.ProvinceMap.ContainsKey(Name) && Rank == 1) { ProvinceParser provinceParser = MapManager.instance.ProvinceMap[Name]; CapitalProvince = provinceParser; if (!Name.StartsWith("d_")) { Owns.Add(CapitalProvince); CapitalProvince.title = this.Name; } } }
public void SaveTitles() { foreach (var titleParser in Titles) { if (titleParser.culture == null) continue; String tit = titleParser.Culture.dna.kingTitle; switch (titleParser.Rank) { case 0: tit = titleParser.Culture.dna.baronTitle; break; case 1: tit = titleParser.Culture.dna.countTitle; break; case 2: tit = titleParser.Culture.dna.dukeTitle; break; case 3: tit = titleParser.Culture.dna.kingTitle; break; case 4: tit = titleParser.Culture.dna.empTitle; break; } titleParser.Scope.Add(new ScriptCommand() { Name = "culture", Value = titleParser.culture }); titleParser.Scope.Do( @" title=" + tit + @" title_female=" + tit + @" " ); } foreach (var religionParser in ReligionManager.instance.AllReligions) { if (religionParser.Believers.Count > 0 && religionParser.hasLeader) { religionParser.DoLeader(religionParser.Believers[Rand.Next(religionParser.Believers.Count)]); } } if(!Directory.Exists(Globals.ModDir + "history\\titles\\")) Directory.CreateDirectory(Globals.ModDir + "history\\titles\\"); var files = Directory.GetFiles(Globals.ModDir + "history\\titles\\"); foreach (var file in files) { File.Delete(file); } foreach (var title in Titles) { if (!title.Active) continue; if (title.Religious) { } Script titleScript = ScriptLoader.instance.Load(Globals.GameDir + "history\\titles\\" + title + ".txt"); titleScript.Root.Clear(); { if (titleScript.Root.HasNamed("767.1.1")) { titleScript.Root.Delete("767.1.1"); titleScript.Root.Delete("768.1.1"); } { ScriptScope thing = new ScriptScope(); thing.Name = "767.1.1"; titleScript.Root.SetChild(thing); if (title.Culture.dna.horde) thing.Add(new ScriptCommand() { Name = "historical_nomad", Value = true }); if (title.Liege != null) { thing.Add(new ScriptCommand() { Name = "liege", Value = title.Liege.Name }); } if (title.Holder != null) { thing.Add(new ScriptCommand() { Name = "holder", Value = title.Holder.ID }); // title.Holder.MakeAlive(); }else if (title.SubTitles.Count > 0 && title.Rank >= 2 && title.Holder == null) { thing.Add(new ScriptCommand() { Name = "holder", Value = title.SubTitles.Values.ToArray()[0].Holder.ID }); // title.SubTitles.Values.ToArray()[0].Holder.MakeAlive(); } thing = new ScriptScope(); thing.Name = "768.1.1"; titleScript.Root.SetChild(thing); if (title.CurrentHolder != null) { thing.Add(new ScriptCommand() { Name = "holder", Value = title.CurrentHolder.ID }); } } } titleScript.Save(); } }
public ProvinceParser(ScriptScope scope) : base(scope) { int line = 0; foreach (var child in scope.Children) { if (child is ScriptCommand) { RegisterProperty(line, ((child as ScriptCommand).Name), child); } line++; if (child is ScriptScope) { var subscope = (child as ScriptScope); } } }
private void ExporeDecisions(ScriptScope node) { for (int index = 0; index < node.Children.Count; index++) { var child = node.Children[index]; if (child is ScriptScope) { if(!IncludeDecision((child as ScriptScope).Name)) { node.Remove(child); index--; continue; } // RemoveAllReligionTests(child as ScriptScope); } } }
public ScriptScope GetNewCreatedCharacter() { var scope = new ScriptScope(); scope.Name = CharacterParser.IDMax.ToString(); scope.Add("name", "Bob"); scope.Add("culture", "norse"); scope.Add("religion", "pagan"); var born = scope.AddScope("730.1.1"); var died = scope.AddScope("790.1.1"); born.Add("birth", "730.1.1"); died.Add("death", "790.1.1"); //scope.SetChild(CharactersScript.Root); return scope; }
public ReligionParser(ScriptScope scope) : base(scope) { Name = scope.Name; }
public void SetAllDates(int birth, int death, ScriptScope scope) { foreach (var child in scope.Children) { if (child is ScriptCommand) { ScriptCommand c = (ScriptCommand)child; if (c.Name == "birth") { // if (c.Value.ToString().Split('.').Length == 3) { c.Value = birth + ".1.1"; scope.Name = c.Value.ToString(); } } if (c.Name == "death") { // if (c.Value.ToString().Split('.').Length == 3) { c.Value = death + ".2.1"; scope.Name = c.Value.ToString(); } } } if (child is ScriptScope) { ScriptScope c = (ScriptScope)child; SetAllDates(birth, death, c); } } }
public CultureParser(ScriptScope scope, CultureGroupParser group) : base(scope) { this.group = group; }