private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self) { orig(self); List <Hero> localHeroes = Hero.LocalPlayerActiveRecruitedHeroes; foreach (Hero h in localHeroes) { // First need to confirm that the hero is done with all of their current actions so that the next action can be accomplished if (!h.MoverCpnt.IsMoving && h.MoverCpnt.CanMove && h.IsUsable && new DynData <Hero>(h).Get <Item>("gatheringItem") == null) // or need to check to see if i just opened a door, cause then i can pop from the queue. { // Then need to confirm that the hero has a queue if (queue.ContainsKey(h)) { if (queue[h] == null) { mod.Log("Null hero list... This should never happen!"); continue; } if (queue[h].Count == 0) { // There are no actions in the queue continue; } PopQueue(h); } } } }
private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self) { KeyCode key = (KeyCode)Enum.Parse(typeof(KeyCode), (mod.settings as PingSettings).Key); if (Input.GetKeyDown(key)) { // First, find the mouse position as a unity vector // Next, spawn something there that lasts for x seconds // Finally, remove it after those seconds pass IGameCameraService gameCameraManager = Services.GetService <IGameCameraService>(); GameNetworkManager net = GameObject.FindObjectOfType <GameNetworkManager>(); IMessageBox msgBox = new DynData <GameNetworkManager>(net).Get <IMessageBox>("messageBox"); RaycastHit[] array = Physics.RaycastAll(gameCameraManager.ScreenPointToRay(Input.mousePosition), float.PositiveInfinity); Array.Sort <RaycastHit>(array, (RaycastHit hitInfo1, RaycastHit hitInfo2) => hitInfo1.distance.CompareTo(hitInfo2.distance)); // In theory the first raycast hit should be the best? // Not sure if this is the case... Vector3 mousePos = array[0].point; mod.Log("Raycast hits:"); foreach (RaycastHit ra in array) { mod.Log("Dist: " + ra.distance + " with pos: " + ra.point); } mod.Log("Mouse pos: " + mousePos.ToString()); bool assert = (bool)typeof(GameNetworkManager).GetMethod("AssertMessageBoxIsSet", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(net, new object[0]); if (assert && msgBox != null && net != null) { PingMessage pm = new PingMessage(); pm.SetPos(mousePos); Message m = pm as Message; mod.Log("Assertion: " + assert); mod.Log("Net: " + net.name); mod.Log("MSG BOX: " + msgBox.ToString()); EP2PSend temp = msgBox.SteamNetworkingSendMode; msgBox.SteamNetworkingSendMode = EP2PSend.k_EP2PSendReliable; msgBox.SendMessage(ref m, net.GetLobbyPlayerIDs()); msgBox.SteamNetworkingSendMode = temp; mod.Log("Attempting to display!"); } else { GameObject obj = new GameObject("PING OBJECT"); PingScript p = obj.AddComponent <PingScript>(); p.pos = mousePos; mod.Log("It seems the game is not in multiplayer, attempting to create a local ping!"); } } orig(self); }
private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self) { orig(self); Dungeon d = SingletonManager.Get <Dungeon>(false); if (!overwriteWrapper.Value) { SeedCollection.UnLoad(); } else { if (!SeedCollection.Loaded) { mod.Log("Reinitializing SeedCollection because it isn't loaded!"); SeedCollection.ReadAll(); } } if (d == null) { return; } if (Input.GetKeyUp((KeyCode)Enum.Parse(typeof(KeyCode), saveKeyWrapper.Value))) { mod.Log("Saving SeedData to SeedCollection!"); SeedCollection best = SeedCollection.GetMostCurrentSeeds(d.ShipName, d.Level); if (best == null) { mod.Log("Creating new SeedCollection because there were no matching SeedCollections!"); best = SeedCollection.Create(); } SeedData data = new SeedData(); d.EnqueueNotification("Saved SeedData: " + data + " to: " + best.ReadFrom); best.Add(d.ShipName, d.Level, data); SeedCollection.WriteAll(); mod.Log("Wrote SeedCollection to: " + best.ReadFrom); } if (Input.GetKeyUp((KeyCode)Enum.Parse(typeof(KeyCode), createNewSeedKeyWrapper.Value))) { mod.Log("Created new SeedCollection!"); SeedCollection best = SeedCollection.Create(); SeedData data = new SeedData(); best.Add(d.ShipName, d.Level, data); SeedCollection.WriteAll(); d.EnqueueNotification("Saved SeedData: " + data + " to new: " + best.ReadFrom); mod.Log("Wrote SeedCollection to: " + best.ReadFrom); } }
private void InputManager_Update(On.InputManager.orig_Update orig, InputManager self) { // Do the recording, pausing, resetting, and playing here. // Updates the state UpdateState(); // Performs an action depending on the state if (SingletonManager.Get <Dungeon>(false) == null) { // We don't have a Dungeon to work with yet! // This should be removed soon and instead of having levels, have time stamps or something else. // That would allow for TAS in menus (without a Dungeon) orig(self); return; } int level = SingletonManager.Get <Dungeon>(false).Level; if (HasFlag(State.Pausing)) { // Need to find some way of doing standard processing except for actually updating the game } if (HasFlag(State.Playing) && !HasFlag(State.Pausing)) { // Read Inputs from file/RAM and perform them if (TASInput.HasNext(level)) { TASInputPlayer.Update(TASInput.GetNext(level)); mod.Log("Playing input: " + TASInputPlayer.Current); } else { mod.Log("Completed input playback!"); ToggleState(State.Playing); } } if (HasFlag(State.Recording)) { // Read Inputs from real action into file/RAM // Assumes the current level exists. TASInput.CreateAndAdd(level); // Also make sure that the seed is correctly set mod.Log("Recording input: " + TASInput.inputs[level][TASInput.inputs[level].Count - 1].ToString()); // TODO: REMOVE LINE BELOW ToggleState(State.Recording); } if (HasFlag(State.Saving)) { // Save the current floor as a start point (somehow) // Probably just save the SeedData and do a "generateForLevel" or something SaveKey = GameSave.GenerateSaveKey(); SingletonManager.Get <Dungeon>(false).SaveGameData(SaveKey); mod.Log("Saved Key: " + SaveKey + " saved successfully!"); ToggleState(State.Saving); } if (HasFlag(State.SavingToFile)) { // Assume the Dungeon exists, use it to determine the level to write the TAS for. mod.Log("Writing files with *" + tasFileExtensionWrapper.Value); TASIO.WriteTAS(TASInput.inputs, tasFileExtensionWrapper.Value); ToggleState(State.SavingToFile); } if (HasFlag(State.ReadingFromFiles)) { // Don't assume that the Dungeon exists, but read the many information things from the TAS file. // The trick with this is that the seed also needs to be read. TASInput.Clear(); mod.Log("Reading from *" + tasFileExtensionWrapper.Value + " files..."); foreach (string file in System.IO.Directory.GetFiles(".", "*" + tasFileExtensionWrapper.Value)) { // Let's just load all of the info into the TASInput RAM mod.Log("Reading file: " + file); TASIO.ReadTAS(file); } ToggleState(State.ReadingFromFiles); } if (HasFlag(State.Resetting)) { // Reset to the current save point (whatever floor it is) // Probably just do a "generateForLevel" or something (make the game think the data was saved in a certain way) mod.Log("Attempting to load SaveKey: " + SaveKey); if (SaveKey.Length > 0) { // Only now can we load valid data. mod.Log("Preparing Dungeon for SaveKey!"); Dungeon.PrepareForSavedGame(SaveKey, false); } ToggleState(State.Resetting); } if (HasFlag(State.Clearing)) { // Clear the data for this level TASInput.ClearForLevel(level); mod.Log("Cleared all TAS data for level: " + level); ToggleState(State.Clearing); } orig(self); }