private void Update() { MainThreadQueue.ProcessQueue(); if (Input.GetKey(KeyCode.Escape)) { InputInterceptor.EnableInput(); TwitchGame.ModuleCameras?.DisableCameraWall(); } if (Input.GetKeyDown(DebugSequence[_debugSequenceIndex].ToString())) { _debugSequenceIndex++; if (_debugSequenceIndex != DebugSequence.Length) { return; } TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled; TwitchPlaySettings.WriteDataToFile(); chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled); _debugSequenceIndex = 0; UserAccess.AddUser("_TPDEBUG".ToLowerInvariant(), AccessLevel.Streamer | AccessLevel.SuperUser | AccessLevel.Admin | AccessLevel.Mod); UserAccess.WriteAccessList(); } else if (Input.anyKeyDown) { _debugSequenceIndex = 0; } }
public WebSocketService(SignalBus signalBus, MainThreadQueue mainThreadQueue, URLReader urlReader) { Debug.Log("WebSocketService ahoy!"); _signalBus = signalBus; _mainThreadQueue = mainThreadQueue; var browerUri = new UriBuilder(urlReader.ReadURL()); var baseUri = new UriBuilder(WEBSOCKET_PROTOCOL, browerUri.Host, browerUri.Port, browerUri.Path).Uri; var fullUri = new Uri(baseUri, WEBSOCKET_URL_PATH); Debug.Log("Trying to connect to " + fullUri); var url = fullUri.ToString(); //uncomment following line to connect to the deployed server //url = "ws://ggj.sqeezy.tech/socket"; _webSocket = WebSocketFactory.CreateInstance(url); _webSocket.OnOpen += OnOpen; _webSocket.OnMessage += OnMessage; _webSocket.OnError += OnError; _webSocket.OnClose += OnClose; _signalBus.Subscribe <NetworkEvent>(m => Send(m.ToJson())); Connect(); }
private AudioClip GetAudioClip(String name) { var wavFile = GetWavFile(name); if (wavFile == null) { return(null); } var signal = new AutoResetEvent(false); AudioClip audioClip = null; MainThreadQueue.Add(() => { var position = 0; audioClip = AudioClip.Create(name, wavFile.AudioData.Length / wavFile.NumChannels, wavFile.NumChannels, wavFile.SampleRate, true, data => { // this or UnityEngine.Debug.Log is needed to prevent a crash. // Why? impossible to say ... //UnityEngine.Debug.LogWarning("."); var length = Math.Min(data.Length, wavFile.AudioData.Length); Array.Copy(wavFile.AudioData, position, data, 0, length); position += length; }, p => position = p); DontDestroyOnLoad(audioClip); signal.Set(); }); signal.WaitOne(); return(audioClip); }
private void TestInitialize() { if (Application.isPlaying) { MainThreadQueue.Instantiate(); } Locator.Provide(new ContentManager("demo-world")); Locator.Provide(new TextureManager("demo-world")); InventoryItems = new ObservableList <ItemInstance>(); var cm = Locator.Get <ContentManager>(); NumItemsInInventory = 50; for (int i = 0; i < NumItemsInInventory; i++) { InventoryItems.Add(new ItemInstance(cm.GetItem(i))); } ToolbarItems = new ObservableList <ItemInstance>(); for (int i = 0; i < NumItemsInToolbar; i++) { ToolbarItems.Add(InventoryItems[i]); } }
public void RemoveCreature(int id) { TileMap.RemoveCreature(id); MainThreadQueue.Add(() => GameObject.Destroy(GameObject.Find("Creature " + id))); if (_driver.SelectedCreature != null && _driver.SelectedCreature.Id == id) { _driver.SelectedCreature = null; } }
public override void Enter(StateMachine stateMachine) { MainThreadQueue.Add(() => { go = GameObject.Instantiate(Resources.Load("Bar")) as GameObject; begun = true; }); Locator.Get <GridiaDriver>().TabbedGui.Visible = false; }
public void Update() { MainThreadQueue.ProcessQueue(); if (CurrentState == KMGameInfo.State.Setup && SettingWarningEnabled && Input.GetKeyDown(KeyCode.F2)) { StartCoroutine(DemandBasedLoading.EnterAndLeaveModManager()); } }
public void CreateCreature(int id, String name, CreatureImage image, int x, int y, int z) { var cre = TileMap.CreateCreature(id, name, image, x, y, z); if (cre != null) { MainThreadQueue.Add(() => _driver.AddCreature(cre)); } }
public static void Instantiate() { if (_instance == null) { var gameObject = new GameObject(); gameObject.name = "MainThreadQueue"; _instance = gameObject.AddComponent <MainThreadQueue>(); DontDestroyOnLoad(gameObject); DontDestroyOnLoad(_instance); } }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(this); _mainThreadID = Thread.CurrentThread.ManagedThreadId; } else { Destroy(this); } }
protected override void Handle(ConnectionToGridiaServerHandler connection, JObject data) { var game = connection.GetGame(); var id = (int)data["id"]; UnityEngine.Debug.Log(data); var backToJson = JsonConvert.SerializeObject(data["image"]); // :( var image = JsonConvert.DeserializeObject <CreatureImage>(backToJson, new CreatureImageConverter()); game.TileMap.GetCreature(id).Image = image; MainThreadQueue.Add(() => GameObject.Find("Creature " + id).GetComponent <CreatureScript>().ClearImage()); }
protected override void Handle(ConnectionToGridiaServerHandler connection, JObject data) { var user = (String)data["user"]; var text = (String)data["text"]; var x = (int)data["loc"]["x"]; // :( var y = (int)data["loc"]["y"]; var z = (int)data["loc"]["z"]; var chat = Locator.Get <ChatWindow>(); MainThreadQueue.Add(() => chat.Append(user, text)); Locator.Get <GridiaDriver>().FloatingTexts.Add(new FloatingText(new Vector3(x, y, z), " " + text)); }
protected override void Handle(ConnectionToGridiaServerHandler connection, JObject data) { var id = (int)data["id"]; var index = (int)data["index"]; var item = (int)data["item"]; var quantity = (int)data["quantity"]; var itemInstance = Locator.Get <ContentManager>().GetItem(item).GetInstance(quantity); MainThreadQueue.Add(() => { GameState.Instance.SetContainerItem(id, itemInstance, index); }); }
public void PlayMusic(String name) { Debug.Log("Song: " + name); StartingMusic = true; new Thread(() => { CurrentSongName = name; var clip = GetAudioClip(name); MainThreadQueue.Add(() => { MusicAudio.clip = clip; MusicAudio.Play(); StartingMusic = false; }); }).Start(); }
private void Start() { Instance = this; transform.Find("Prefabs").gameObject.SetActive(false); twitchGame = GetComponentInChildren <TwitchGame>(true); twitchGame.twitchBombPrefab = GetComponentInChildren <TwitchBomb>(true); twitchGame.twitchModulePrefab = GetComponentInChildren <TwitchModule>(true); twitchGame.moduleCamerasPrefab = GetComponentInChildren <ModuleCameras>(true); TwitchGame.Instance = twitchGame; GameRoom.InitializeSecondaryCamera(); _gameInfo = GetComponent <KMGameInfo>(); _gameInfo.OnStateChange += OnStateChange; CoroutineQueue = GetComponent <CoroutineQueue>(); Leaderboard.Instance.LoadDataFromFile(); LeaderboardController.Install(); ModuleData.LoadDataFromFile(); ModuleData.WriteDataToFile(); AuditLog.SetupLog(); MainThreadQueue.Initialize(); TwitchPlaySettings.LoadDataFromFile(); MusicPlayer.LoadMusic(); IRCConnection.Instance.OnMessageReceived.AddListener(OnMessageReceived); twitchGame.ParentService = this; GameObject infoObject = new GameObject("TwitchPlays_Info"); infoObject.transform.parent = gameObject.transform; _publicProperties = infoObject.AddComponent <TwitchPlaysProperties>(); _publicProperties.TwitchPlaysService = this; // TODO: Useless variable? if (TwitchPlaySettings.data.SkipModManagerInstructionScreen || IRCConnection.Instance.State == IRCConnectionState.Connected) { ModManagerManualInstructionScreen.HasShownOnce = true; } UpdateUiHue(); SetupChatSimulator(); }
protected override void OnFirstCallback() { base.OnFirstCallback(); // initialise workflow _workflow.Initialise(_workContext); // subscribe to curve definitions _curveSubs = IntClient.Target.Subscribe <QuotedAssetSet>( Expr.BoolAND( Expr.IsEQU(CurveProp.Function, FunctionProp.QuotedAssetSet.ToString()), Expr.IsEQU(CurveProp.Market, CurveConst.QR_LIVE), Expr.IsNull(CurveProp.MarketDate)), (subscription, item) => { MainThreadQueue?.Dispatch(item, BaseCurveCallback); }, null); }
protected override void OnFirstCallback() { // subscribe to import rules _ruleCache = IntClient.Target.CreateCache(delegate(CacheChangeData update) { Interlocked.Increment(ref _dispatchedEventCount); MainThreadQueue.Dispatch(update, ProcessRuleUpdate); }, null); _ruleCache.Subscribe <AlertRule>( RuleObject.MakeRuleFilter( EnvHelper.EnvName(IntClient.Target.ClientInfo.ConfigEnv), IntClient.Target.ClientInfo.HostName, AppName, IntClient.Target.ClientInfo.UserName)); // start a 30 second timer to periodically check the rules _timer = new Timer(RecvTimerEvent, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)); }
protected override void OnFirstCallback() { // subscribe to import rules _importRuleSet = IntClient.Target.CreateCache(delegate(CacheChangeData update) { Interlocked.Increment(ref _updateRequestsDispatched); MainThreadQueue.Dispatch(update, ProcessRuleUpdate); }, null); _importRuleSet.Subscribe <FileImportRule>( RuleObject.MakeRuleFilter( EnvHelper.EnvName(IntClient.Target.ClientInfo.ConfigEnv), IntClient.Target.ClientInfo.HostName, AppName, IntClient.Target.ClientInfo.UserName)); // start a 1 minute timer to periodically check the rules _timer = new Timer(RecvTimerEvent, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1)); }
protected override void Handle(ConnectionToGridiaServerHandler connection, JObject data) { var id = (int)data["id"]; var currentHealth = (int)data["currentLife"]; var maxHealth = (int)data["maxLife"]; MainThreadQueue.Add(() => { var cre = GameObject.Find("Creature " + id); var sc = cre.GetComponent <StatusCircle>(); var takeDamage = sc.IsActive() && currentHealth < sc.CurrentHealth; sc.MaxHealth = maxHealth; sc.CurrentHealth = currentHealth; if (takeDamage) { iTween.ColorFrom(cre, Color.red, 1f); } }); }
protected override void OnFirstCallback() { // subscribe to portfolio valuation requests and results // note: load results first _resultSubs = IntClient.Target.SubscribeNoWait <HandlerResponse>( Expr.ALL, delegate(ISubscription subs, ICoreItem item) { var pvRes = (HandlerResponse)item.Data; _manageThreadQueue.Dispatch(pvRes, ReceivePortfolioValuationResult); }, null); _requestSubs = IntClient.Target.SubscribeNoWait <PortfolioValuationRequest>( Expr.ALL, (subs, pvReqItem) => _manageThreadQueue.Dispatch(pvReqItem, ReceivePortfolioValuationRequest), null); _cancelSubs = IntClient.Target.SubscribeNoWait <CancellationRequest>( Expr.ALL, (subs, pvReqItem) => _manageThreadQueue.Dispatch(pvReqItem, ReceiveCancellationRequest), null); // start timers // - request queue manager // - request scheduler _timerRequestManager = new Timer( notUsed => MainThreadQueue.Dispatch <object>(null, RequestManagerTimeout), null, _requestManagerPeriod, _requestManagerPeriod); // hack - start the daily 4am portfolio reval schedule // todo - attach this as a workflow step to the daily file/trade import process DateTime dtNow = DateTime.Now; DateTime dtDue = DateTime.Today.Add(TimeSpan.FromHours(4)); if (dtDue <= dtNow) { dtDue += TimeSpan.FromDays(1); } //TimeSpan tsDue = dtDue - dtNow; //_TimerRequestScheduler = new Timer( // (notUsed) => _MainThreadQueue.Dispatch<object>(null, RequestSchedulerTimeout), // null, tsDue, TimeSpan.FromDays(1)); }
public void PlaySfx(String name, float volume = 1.0f) { #if UNITY_WEBPLAYER if (Application.loadedLevelName != "Main") { return; } #endif if (MuteSfx) { return; } new Thread(() => { var clip = GetAudioClip(name); MainThreadQueue.Add(() => { SfxAudio.PlayOneShot(clip, volume); }); }).Start(); }
public void UpdateSettingWarnings() => MainThreadQueue.Enqueue(() => { if (SettingWarning == null) { return; } bool demandSettingChanged = DemandBasedSettingCache != settings.DemandBasedModLoading; bool demandModsDisabled = DemandBasedLoading.DisabledModsCount >= 50; bool warningsEnabled = CurrentState == KMGameInfo.State.Setup && modConfig.SuccessfulRead; CaseGeneratorWarning.SetActive(warningsEnabled && CaseGeneratorSettingCache != settings.CaseGenerator); DBMLWarning.SetActive(warningsEnabled && (demandSettingChanged || demandModsDisabled)); DBMLWarning.Traverse <Text>("WarningText").text = $"The { (demandSettingChanged ? "change to the setting \"DemandBasedModLoading\"" : "") + (demandSettingChanged && demandModsDisabled ? " and " : "") + (demandModsDisabled ? $"{DemandBasedLoading.DisabledModsCount} mod{(DemandBasedLoading.DisabledModsCount == 1 ? "" : "s")} that were automatically disabled" : "") } will only take effect once you enter the Mod Manager. <i>Press \"F2\" to do that automatically!</i>"; HoldablesWarning.SetActive(warningsEnabled && HoldablesSettingCache.Count != settings.Holdables.Count || HoldablesSettingCache.Except(settings.Holdables).Any()); SettingWarningEnabled = new[] { CaseGeneratorWarning, DBMLWarning, HoldablesWarning }.Any(warning => warning.activeSelf); });
protected override void OnFirstCallback() { // initialise workflow _workflow.Initialise(_workContext); // subscribe to all base curves _baseCurveSubs = IntClient.Target.Subscribe <Market>( Expr.BoolAND( //Expr.BoolOR( Expr.IsEQU(CurveProp.Market, CurveConst.QR_LIVE), //Expr.IsEQU(CurveProp.Market, CurveConst.QR_EOD), //Expr.IsEQU(CurveProp.Market, CurveConst.NAB_EOD)), Expr.IsEQU(EnvironmentProp.Function, FunctionProp.Market.ToString()), Expr.IsNull(CurveProp.MarketDate), Expr.IsNull(CurveProp.StressName) //Expr.StartsWith(Expr.SysPropItemName, "Highlander.Market.") ), (subscription, item) => { MainThreadQueue?.Dispatch(item, BaseCurveCallback); }, null); }
public override void Initialize() { base.Initialize(); if (Application.isPlaying) { MainThreadQueue.Instantiate(); GridiaConstants.InitializeGuiStuff(); GridiaConstants.InitializeSoundPlayer(); } var cursorTexture = Resources.Load <Texture2D>("GUI Components/cursorHand_grey"); Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto); Servers = new ObservableList <ServerDetails>(); { var server = new ServerDetails(); server.Name = "Local"; server.Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"; server.PlayersOnline = 5; server.Address = "localhost"; server.Port = 1044; Servers.Add(server); } { var server = new ServerDetails(); server.Name = "hotengames.com"; server.Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"; server.PlayersOnline = 5; server.Address = "www.hotengames.com"; server.Port = 1044; Servers.Add(server); } HostServerButton.IsActive.Value = LocalServer.CanHostLocally(); }
protected override void Handle(ConnectionToGridiaServerHandler connection, JObject data) { var backToJson = JsonConvert.SerializeObject(data["items"]); // :( var items = JsonConvert.DeserializeObject <List <ItemInstance> >(backToJson, new ItemInstanceConverter()); var id = (int)data["id"]; var type = (String)data["type"]; var tabGfxItemId = (int)data["tabGfxItemId"]; if (type == "Inventory" && GameState.Instance.InventoryContainerId == 0) { // TODO for some reason this is getting reset. check server for why. GameState.Instance.InventoryContainerId = id; } if (type == "Equipment") { GameState.Instance.EquipmentContainerId = id; } MainThreadQueue.Add(() => { GameState.Instance.SetContainerItems(id, items); }); }
protected override void OnFirstCallback() { // subscribe to Trade valuation requests and results // note: load results first _resultSubs = IntClient.Target.SubscribeNoWait <HandlerResponse>( Expr.ALL, delegate(ISubscription subs, ICoreItem item) { var pvRes = (HandlerResponse)item.Data; _manageThreadQueue.Dispatch(pvRes, ReceiveTradeValuationResult); }, null); _requestSubs = IntClient.Target.SubscribeNoWait <TradeValuationRequest>( Expr.ALL, (subs, pvReqItem) => _manageThreadQueue.Dispatch(pvReqItem, ReceiveTradeValuationRequest), null); // start timers // - request queue manager // - request scheduler _timerRequestManager = new Timer( notUsed => MainThreadQueue.Dispatch <object>(null, RequestManagerTimeout), null, _requestManagerPeriod, _requestManagerPeriod); }
private void Start() { Instance = this; transform.Find("Prefabs").gameObject.SetActive(false); twitchGame = GetComponentInChildren <TwitchGame>(true); twitchGame.twitchBombPrefab = GetComponentInChildren <TwitchBomb>(true); twitchGame.twitchModulePrefab = GetComponentInChildren <TwitchModule>(true); twitchGame.moduleCamerasPrefab = GetComponentInChildren <ModuleCameras>(true); TwitchGame.Instance = twitchGame; GameRoom.InitializeSecondaryCamera(); _gameInfo = GetComponent <KMGameInfo>(); _gameInfo.OnStateChange += OnStateChange; CoroutineQueue = GetComponent <CoroutineQueue>(); Leaderboard.Instance.LoadDataFromFile(); LeaderboardController.Install(); ModuleData.LoadDataFromFile(); ModuleData.WriteDataToFile(); AuditLog.SetupLog(); MainThreadQueue.Initialize(); TwitchPlaySettings.LoadDataFromFile(); MusicPlayer.LoadMusic(); IRCConnection.Instance.OnMessageReceived.AddListener(OnMessageReceived); twitchGame.ParentService = this; TwitchPlaysAPI.Setup(); GameObject infoObject = new GameObject("TwitchPlays_Info"); infoObject.transform.parent = gameObject.transform; _publicProperties = infoObject.AddComponent <TwitchPlaysProperties>(); _publicProperties.TwitchPlaysService = this; // TODO: Useless variable? if (TwitchPlaySettings.data.SkipModManagerInstructionScreen || IRCConnection.Instance.State == IRCConnectionState.Connected) { ModManagerManualInstructionScreen.HasShownOnce = true; } UpdateUiHue(); if (TwitchPlaySettings.data.DarkMode) { HeaderBackground.color = new Color32(0x0E, 0x0E, 0x10, 0xFF); HeaderText.color = new Color32(0xEF, 0xEF, 0xEC, 0xFF); MessagesBackground.color = new Color32(0x3A, 0x3A, 0x3D, 0xFF); } else { HeaderBackground.color = new Color32(0xEE, 0xEE, 0xEE, 0xFF); HeaderText.color = new Color32(0x4F, 0x4F, 0x4F, 0xFF); MessagesBackground.color = new Color32(0xD8, 0xD8, 0xD8, 0xFF); } SetupChatSimulator(); // Delete the steam_appid.txt since it was created for a one-time steam boot. // Steam will have initialized before this. if (File.Exists("steam_appid.txt")) { File.Delete("steam_appid.txt"); } }
public void Awake() { Instance = this; MainThreadQueue.Initialize(); GameInfo = GetComponent <KMGameInfo>(); SettingWarning = gameObject.Traverse("UI", "SettingWarning"); AdvantageousWarning = gameObject.Traverse("UI", "AdvantageousWarning"); Tips.TipMessage = gameObject.Traverse("UI", "TipMessage"); BetterCasePicker.BombCaseGenerator = GetComponentInChildren <BombCaseGenerator>(); DemandBasedLoading.LoadingScreen = gameObject.Traverse <CanvasGroup>("UI", "LoadingModules"); CaseGeneratorWarning = MakeSettingWarning("CaseGenerator"); DBMLWarning = MakeSettingWarning("DemandBasedModLoading"); HoldablesWarning = MakeSettingWarning("Holdables"); modConfig = new ModConfig <TweakSettings>("TweakSettings", OnReadError); UpdateSettings(); StartCoroutine(Modes.LoadDefaultSettings()); DemandBasedLoading.EverLoadedModules = !settings.DemandBasedModLoading; DemandBasedSettingCache = settings.DemandBasedModLoading; HoldablesSettingCache = settings.Holdables; bool changeFadeTime = settings.FadeTime >= 0; FreeplayDevice.MAX_SECONDS_TO_SOLVE = float.MaxValue; FreeplayDevice.MIN_MODULE_COUNT = 1; if (settings.EnableModsOnlyKey) { var lastFreeplaySettings = FreeplaySettings.CreateDefaultFreeplaySettings(); lastFreeplaySettings.OnlyMods = true; ProgressionManager.Instance.RecordLastFreeplaySettings(lastFreeplaySettings); } UpdateSettingWarnings(); AdvantageousWarning.SetActive(false); // Setup API/properties other mods to interact with GameObject infoObject = new GameObject("Tweaks_Info", typeof(TweaksProperties)); infoObject.transform.parent = gameObject.transform; TweaksAPI.Setup(); // Watch the TweakSettings file for Time Mode state being changed in the office. FileSystemWatcher watcher = new FileSystemWatcher(Path.Combine(Application.persistentDataPath, "Modsettings"), "TweakSettings.json") { NotifyFilter = NotifyFilters.LastWrite }; watcher.Changed += (object source, FileSystemEventArgs e) => { if (ModConfig <TweakSettings> .SerializeSettings(userSettings) == ModConfig <TweakSettings> .SerializeSettings(modConfig.Read())) { return; } UpdateSettings(); UpdateSettingWarnings(); MainThreadQueue.Enqueue(() => StartCoroutine(ModifyFreeplayDevice(false))); }; // Setup the leaderboard controller to block the leaderboard submission requests. LeaderboardController.Install(); GetTweaks(); // Create a fake case with a bunch of anchors to trick the game when using CaseGenerator. TweaksCaseGeneratorCase = new GameObject("TweaksCaseGenerator"); TweaksCaseGeneratorCase.transform.SetParent(transform); var kmBomb = TweaksCaseGeneratorCase.AddComponent <KMBomb>(); kmBomb.IsHoldable = false; kmBomb.WidgetAreas = new List <GameObject>(); kmBomb.visualTransform = transform; kmBomb.Faces = new List <KMBombFace>(); TweaksCaseGeneratorCase.AddComponent <ModBomb>(); var kmBombFace = TweaksCaseGeneratorCase.AddComponent <KMBombFace>(); kmBombFace.Anchors = new List <Transform>(); kmBomb.Faces.Add(kmBombFace); for (int i = 0; i <= 9001; i++) { kmBombFace.Anchors.Add(transform); } // Handle scene changes UnityEngine.SceneManagement.SceneManager.sceneLoaded += (Scene scene, LoadSceneMode _) => { UpdateSettings(); UpdateSettingWarnings(); Modes.settings = Modes.modConfig.Read(); Modes.modConfig.Write(Modes.settings); if ((scene.name == "mainScene" || scene.name == "gameplayScene") && changeFadeTime) { SceneManager.Instance.RapidFadeInTime = settings.FadeTime; } switch (scene.name) { case "mainScene": if (changeFadeTime) { SceneManager.Instance.SetupState.FadeInTime = SceneManager.Instance.SetupState.FadeOutTime = SceneManager.Instance.UnlockState.FadeInTime = settings.FadeTime; } break; case "gameplayLoadingScene": var gameplayLoadingManager = FindObjectOfType <GameplayLoadingManager>(); if (settings.InstantSkip) { gameplayLoadingManager.MinTotalLoadTime = 0; } if (changeFadeTime) { gameplayLoadingManager.FadeInTime = gameplayLoadingManager.FadeOutTime = settings.FadeTime; } ReflectedTypes.UpdateTypes(); ReflectedTypes.CurrencyAPIEndpointField?.SetValue(null, settings.FixFER ? "http://api.exchangeratesapi.io" : "http://api.fixer.io"); if ( AdvantageousFeaturesEnabled && GameplayState.MissionToLoad != Assets.Scripts.Missions.FreeplayMissionGenerator.FREEPLAY_MISSION_ID && GameplayState.MissionToLoad != ModMission.CUSTOM_MISSION_ID ) { StartCoroutine(ShowAdvantageousWarning()); } break; case "gameplayScene": if (changeFadeTime) { SceneManager.Instance.GameplayState.FadeInTime = SceneManager.Instance.GameplayState.FadeOutTime = settings.FadeTime; } break; } }; // Handle state changes GameInfo.OnStateChange += (KMGameInfo.State state) => { OnStateChanged(CurrentState, state); // Transitioning away from another state if (state == KMGameInfo.State.Transitioning) { if (CurrentState == KMGameInfo.State.Setup) { DemandBasedLoading.DisabledModsCount = 0; } if (CurrentState != KMGameInfo.State.Gameplay) { DemandBasedLoading.HandleTransitioning(); } } CurrentState = state; watcher.EnableRaisingEvents = state == KMGameInfo.State.Setup; if (state == KMGameInfo.State.Gameplay) { if (AdvantageousFeaturesEnabled) { LeaderboardController.DisableLeaderboards(); } TwitchPlaysActiveCache = TwitchPlaysActive; CurrentModeCache = CurrentMode; BombStatus.Instance.widgetsActivated = false; BombStatus.Instance.HUD.SetActive(settings.BombHUD); BombStatus.Instance.ConfidencePrefab.gameObject.SetActive(CurrentMode != Mode.Zen); BombStatus.Instance.StrikesPrefab.color = CurrentMode == Mode.Time ? Color.yellow : Color.red; Modes.Multiplier = Modes.settings.TimeModeStartingMultiplier; BombStatus.Instance.UpdateMultiplier(); bombWrappers.Clear(); StartCoroutine(CheckForBombs()); if (GameplayState.BombSeedToUse == -1) { GameplayState.BombSeedToUse = settings.MissionSeed; } } else if (state == KMGameInfo.State.Setup) { if (ReflectedTypes.LoadedModsField.GetValue(ModManager.Instance) is Dictionary <string, Mod> loadedMods) { Mod tweaksMod = loadedMods.Values.FirstOrDefault(mod => mod.ModID == "Tweaks"); if (tweaksMod != null && CaseGeneratorSettingCache != settings.CaseGenerator) { if (settings.CaseGenerator) { tweaksMod.ModObjects.Add(TweaksCaseGeneratorCase); } else { tweaksMod.ModObjects.Remove(TweaksCaseGeneratorCase); } CaseGeneratorSettingCache = settings.CaseGenerator; } } StartCoroutine(Tips.ShowTip()); StartCoroutine(ModifyFreeplayDevice(true)); StartCoroutine(ModifyHoldables()); GetComponentInChildren <ModSelectorExtension>().FindAPI(); TweaksAPI.SetTPProperties(!TwitchPlaysActive); Patching.EnsurePatch("LogfileViewerHotkey", typeof(LogfileUploaderPatch)); GameplayState.BombSeedToUse = -1; UpdateSettingWarnings(); UpdateBombCreator(); } else if (state == KMGameInfo.State.Transitioning) { // Because the settings are checked on a scene change and there is no scene change from exiting the gameplay room, // we need to update the settings here in case the user changed their HideTOC settings. UpdateSettings(); bool modified = false; var ModMissionToCs = ModManager.Instance.ModMissionToCs; foreach (var metaData in ModMissionToCs) { modified |= ModToCMetaData.Add(metaData); } var unloadedMods = (Dictionary <string, Mod>)ReflectedTypes.UnloadedModsField.GetValue(ModManager.Instance); if (unloadedMods != null) { foreach (var unloadedMod in unloadedMods.Values) { var tocs = (List <ModTableOfContentsMetaData>)ReflectedTypes.TocsField.GetValue(unloadedMod); if (tocs != null) { foreach (var metaData in tocs) { modified |= ModToCMetaData.Remove(metaData); } } } } var newToCs = ModToCMetaData.Where(metaData => !settings.HideTOC.Any(pattern => Localization.GetLocalizedString(metaData.DisplayNameTerm).Like(pattern))); modified |= newToCs.Count() != ModMissionToCs.Count || !newToCs.All(ModMissionToCs.Contains); ModMissionToCs.Clear(); ModMissionToCs.AddRange(newToCs); if (modified) { SetupState.LastBombBinderTOCIndex = 0; SetupState.LastBombBinderTOCPage = 0; } } }; }
public static void LoadScene(String sceneName, Hashtable sceneArguments = null) { _sceneArguments = sceneArguments; MainThreadQueue.Add(() => Application.LoadLevel(sceneName)); }
private void RecvTimerEvent(object notUsed) { Interlocked.Increment(ref _dispatchedEventCount); MainThreadQueue.Dispatch <CacheChangeData>(null, ProcessRuleUpdate); }