state("Card Shop Simulator Prologue") {} state("Card Shop Simulator") {} startup { #region ASL Helper & Var Setup //Load asl-help binary and instantiate it - will inject code into the asl in the background Assembly.Load(File.ReadAllBytes("Components/asl-help")).CreateInstance("Unity"); vars.Helper.AlertRealTime(); vars.SplitCooldownTimer = new Stopwatch(); //Setting Game Name and toggling alert to ensure runner is comparing against Game TIme vars.Helper.GameName = "TCG Card Shop Simulator"; //Other Vars vars.completedSplits = new List(); #endregion #region setting creation //Autosplitter Settings Creation dynamic[,] _settings = { {"Split Options" , true, "Various Autosplitting Options" , null}, {"ESLevels" , true, "Every Shop Level" ,"Split Options"}, {"CSLevels" , true, "Category Shop Levels Only" ,"Split Options"}, {"GameInfo" , true, "Print various Game Info to LiveSplit layout" , null}, {"Shop Name" , true, "Shop Name" ,"GameInfo"}, {"Day" , true, "Day" ,"GameInfo"}, {"Shop Level" , true, "Shop Level" ,"GameInfo"}, {"ShopRenamerActive", false, "ShopRenamerActive" ,"GameInfo"}, {"placeholder" , false, "placeholder" ,"GameInfo"}, }; vars.Helper.Settings.Create(_settings); #endregion #region TextComponent vars.lcCache = new Dictionary(); vars.SetText = (Action)((text1, text2) => { const string FileName = "LiveSplit.Text.dll"; LiveSplit.UI.Components.ILayoutComponent lc; if (!vars.lcCache.TryGetValue(text1, out lc)) { lc = timer.Layout.LayoutComponents.Reverse().Cast() .FirstOrDefault(llc => llc.Path.EndsWith(FileName) && llc.Component.Settings.Text1 == text1) ?? LiveSplit.UI.Components.ComponentManager.LoadLayoutComponent(FileName, timer); vars.lcCache.Add(text1, lc); } if (!timer.Layout.LayoutComponents.Contains(lc)) timer.Layout.LayoutComponents.Add(lc); dynamic tc = lc.Component; tc.Settings.Text1 = text1; tc.Settings.Text2 = text2.ToString(); }); vars.RemoveText = (Action)(text1 => { LiveSplit.UI.Components.ILayoutComponent lc; if (vars.lcCache.TryGetValue(text1, out lc)) { timer.Layout.LayoutComponents.Remove(lc); vars.lcCache.Remove(text1); } }); vars.RemoveAllTexts = (Action)(() => { foreach (var lc in vars.lcCache.Values) timer.Layout.LayoutComponents.Remove(lc); vars.lcCache.Clear(); }); #endregion } init { #region More Var Setup //You cant use current.anything in startup, so we gotta do this here vars.SplitCooldownTimer.Start(); current.ShopName = ""; current.correctedShopLevel = 0; current.correctedDay = 0; current.ShopRenamerActive = false; #endregion //2nd step in the Text Component Generator, if a setting is enabled for a text, then spawn the text vars.SetTextIfEnabled = (Action)((text1, text2) => { if (settings[text1]) vars.SetText(text1, text2); else vars.RemoveText(text1); }); #region Hooking up Custom Properties //This is where we will load custom properties from the code vars.Helper.TryLoad = (Func)(mono => {; vars.Helper["placeholder"] = mono.Make("TutorialManager", 1, "instance", "m_ShopRenamer", "m_IsInArea"); vars.Helper["ShopLevel"] = mono.Make("CPlayerData", "m_ShopLevel"); vars.Helper["ShopName"] = mono.MakeString("CPlayerData", "m_PlayerName"); vars.Helper["Day"] = mono.Make("CPlayerData", "m_CurrentDay"); vars.Helper["ShopRenamerActive"] = mono.Make("TutorialManager", 1, "instance", "m_ShopRenamer", "m_IsTutorial"); //for some reason we need to go up 1 level beyond Tutorial Manager, potentially to CSingleton? Otherwise nothing works inside Tut Man //vars.Helper["IsInLevel"] = mono.Make("CGameManager", "instance", "m_IsGameLevel"); return true; }); #endregion } update { vars.Helper.Update(); vars.Helper.MapPointers(); current.correctedShopLevel = current.ShopLevel + 1; // the level custom property I have is one behind for some reason, so just gonna correct it here current.correctedDay = current.Day + 1; //Generating the text for the text components vars.SetTextIfEnabled("placeholder",current.placeholder); vars.SetTextIfEnabled("Shop Level",(current.correctedShopLevel)); vars.SetTextIfEnabled("Shop Name",current.ShopName); vars.SetTextIfEnabled("ShopRenamerActive",current.ShopRenamerActive); vars.SetTextIfEnabled("Day",current.correctedDay); } start { return old.ShopRenamerActive == true && current.ShopRenamerActive == false; } split { if(vars.SplitCooldownTimer.Elapsed.TotalSeconds < 10) {return false;} if ( settings["CSLevels"] && (old.correctedShopLevel != 2 && current.correctedShopLevel == 2) || (old.correctedShopLevel != 5 && current.correctedShopLevel == 5) || (old.correctedShopLevel != 10 && current.correctedShopLevel == 10) || (old.correctedShopLevel != 15 && current.correctedShopLevel == 15) || (old.correctedShopLevel != 20 && current.correctedShopLevel == 20) || (old.correctedShopLevel != 50 && current.correctedShopLevel == 50) || (old.correctedShopLevel != 80 && current.correctedShopLevel == 80) ) {vars.SplitCooldownTimer.Restart(); return true;} if ( settings["ESLevels"] && old.correctedShopLevel != current.correctedShopLevel) {vars.SplitCooldownTimer.Restart(); return true;} }