diff --git a/Assets/qsbfps b/Assets/qsbfps index 04f2bfe..8feebcc 100644 Binary files a/Assets/qsbfps and b/Assets/qsbfps differ diff --git a/Assets/qsbfps.manifest b/Assets/qsbfps.manifest index 434c6a0..ba3d682 100644 --- a/Assets/qsbfps.manifest +++ b/Assets/qsbfps.manifest @@ -1,12 +1,12 @@ ManifestFileVersion: 0 -CRC: 3373664368 +CRC: 3621837169 Hashes: AssetFileHash: serializedVersion: 2 - Hash: e796a6b7bf0777e10b4fb7f665e89a38 + Hash: 7ce287bb3fa77bc25ea4b513e459d05f TypeTreeHash: serializedVersion: 2 - Hash: 187df04bf3dc213e6613fff963004cbf + Hash: 37909b8f29aa7a9b679671daba82561e HashAppended: 0 ClassTypes: - Class: 1 @@ -39,6 +39,8 @@ ClassTypes: Script: {instanceID: 0} - Class: 108 Script: {instanceID: 0} +- Class: 114 + Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} - Class: 114 Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - Class: 114 @@ -47,18 +49,20 @@ ClassTypes: Script: {fileID: 11500000, guid: 3c40262156d82f34a77fd77af5176011, type: 3} - Class: 114 Script: {fileID: 11500000, guid: fbb2498122f7e23a2e87544333cb528f, type: 3} +- Class: 114 + Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - Class: 114 Script: {fileID: 11500000, guid: dab2fbc1d63988697a57c20e75208116, type: 3} - Class: 114 Script: {fileID: 11500000, guid: 8c0ac0a2d9d317025f60b61313425f54, type: 3} -- Class: 114 - Script: {fileID: 11500000, guid: b916c1d32b4d92e1af466758266b9b36, type: 3} - Class: 114 Script: {fileID: 11500000, guid: d3e77ae3309b6f323de07b456da83fb0, type: 3} - Class: 114 Script: {fileID: 11500000, guid: a223d69493f03f4a8e6bda998c52d250, type: 3} - Class: 114 Script: {fileID: 11500000, guid: f913c288c393f80a7e923fc1c775f4fb, type: 3} +- Class: 114 + Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - Class: 114 Script: {fileID: 11500000, guid: 6b78346a5a700308ccb7bbeeb31f9d5b, type: 3} - Class: 114 @@ -73,6 +77,8 @@ ClassTypes: Script: {fileID: 11500000, guid: 5e47f4857704e9e479d099179463c3a7, type: 3} - Class: 115 Script: {instanceID: 0} +- Class: 128 + Script: {instanceID: 0} - Class: 135 Script: {instanceID: 0} - Class: 198 @@ -92,6 +98,7 @@ Assets: - Assets/qsbFPS/Particles Offset Parent.prefab - Assets/qsbFPS/OW_PvpArena.fbx - Assets/qsbFPS/OW_PvpArena.prefab +- Assets/qsbFPS/ReadyUpScreen.prefab - Assets/qsbFPS/GunPlayerHitEffect.prefab - Assets/qsbFPS/GunPivot.prefab - Assets/qsbFPS/Gun.controller @@ -103,9 +110,13 @@ Assets: - Assets/qsbFPS/GunFireEffect.prefab - Assets/qsbFPS/GunGroundHitEffect.prefab - Assets/qsbFPS/GunHUD.prefab +- Assets/qsbFPS/FilledCheckbox.png +- Assets/qsbFPS/JoinedPlayerName.prefab - Assets/Low Poly Guns/Models/Guns/assault1/assault1.mat - Assets/Low Poly Guns/Models/Guns/assault1/assault1.fbx - Assets/Low Poly Guns/Models/Guns/assault1/assault1_normal.png - Assets/Spags Assets/Textures/Demo/white_hip.png - Assets/qsbFPS/Smoke.mat +- Assets/qsbFPS/Asteroid.fbx +- Assets/qsbFPS/EmptyCheckbox.png Dependencies: [] diff --git a/GunController.cs b/GunController.cs index 5f98a30..07ece0c 100644 --- a/GunController.cs +++ b/GunController.cs @@ -1,10 +1,7 @@ using UnityEngine; using OWML.Common; using UnityEngine.UI; -using QSB.Player.Messages; using System.Collections.Generic; -using QSB.Messaging; -using QSB.API; namespace QSBFPS; @@ -31,6 +28,11 @@ public class GunController : MonoBehaviour private void Update() { + if (!qsbFPS.Instance.gunHUD.enabled) + { + return; + } + //Detect button press if (qsbFPS.inSolarSystem && canFire) { diff --git a/PlayerDamageMessage.cs b/PlayerDamageMessage.cs deleted file mode 100644 index 2415910..0000000 --- a/PlayerDamageMessage.cs +++ /dev/null @@ -1,22 +0,0 @@ -using UnityEngine; -using QSB.Messaging; -using QSBFPS; - -namespace QSB.Player.Messages; - -public class PlayerDamageMessage : QSBMessage<(uint playerID, int damage)> -{ - public PlayerDamageMessage(uint playerID, int damage) : base((playerID, damage)) { } - - public override void OnReceiveLocal() => OnReceiveRemote(); - - public override void OnReceiveRemote() - { - qsbFPS.Instance.ModHelper.Console.WriteLine($"Player ID: {Data.playerID}, Damage: {Data.damage}", OWML.Common.MessageType.Success); - - if (Data.playerID == QSBPlayerManager.LocalPlayerId) - { - qsbFPS.Instance.DealDamage(Data.damage); - } - } -} \ No newline at end of file diff --git a/UpdateDictMessage.cs b/UpdateDictMessage.cs deleted file mode 100644 index c565faa..0000000 --- a/UpdateDictMessage.cs +++ /dev/null @@ -1,24 +0,0 @@ -using QSB.Messaging; -using QSBFPS; -using System.Collections.Generic; -using UnityEngine; - -namespace QSB.Player.Messages; - -public class UpdateDictMessage : QSBMessage<(uint, KeyValuePair)> -{ - public UpdateDictMessage(uint playerID, KeyValuePair dictPair) : base((playerID, dictPair)) { } - - public override void OnReceiveLocal() => OnReceiveRemote(); - - - public override void OnReceiveRemote() - { - qsbFPS.Instance.ModHelper.Console.WriteLine("Recieved dictionary data!"); - - if (Data.Item1 == QSBPlayerManager.LocalPlayerId) - { - qsbFPS.Instance.idToGameObjects.Add(Data.Item2.Key, Data.Item2.Value); - } - } -} \ No newline at end of file diff --git a/WakeUpScreenPatch.cs b/WakeUpScreenPatch.cs new file mode 100644 index 0000000..172da34 --- /dev/null +++ b/WakeUpScreenPatch.cs @@ -0,0 +1,112 @@ +using HarmonyLib; +using QSB; +using QSB.HUD; +using QSB.Player.Messages; +using QSBFPS; +using System; +using System.Reflection; +using UnityEngine; + +[HarmonyPatch] +public class WakeUpScreenPatch : MonoBehaviour +{ + /*[HarmonyPrefix] + [HarmonyPatch(typeof(PlayerCameraEffectController), nameof(PlayerCameraEffectController.OnStartOfTimeLoop))] + public static bool PlayerCameraEffectController_OnStartOfTimeLoop_Prefix(PlayerCameraEffectController __instance) + { + if (__instance.gameObject.CompareTag("MainCamera") && LoadManager.GetCurrentScene() != OWScene.EyeOfTheUniverse) + { + if (LoadManager.GetPreviousScene() == OWScene.TitleScreen) + { + qsbFPS.Instance.SpawnReadyUpCanvas(); + __instance._owCamera.postProcessingSettings.eyeMask.openness = 0f; + __instance._owCamera.postProcessingSettings.bloom.threshold = 0f; + __instance._owCamera.postProcessingSettings.eyeMaskEnabled = true; + //Wake input is going to be manually called + __instance._waitForWakeInput = false; + __instance._wakePrompt = new ScreenPrompt(InputLibrary.interact, UITextLibrary.GetString(UITextType.WakeUpPrompt), 0, ScreenPrompt.DisplayState.Normal, false); + __instance._wakePrompt.SetVisibility(false); + //Locator.GetPromptManager().AddScreenPrompt(__instance._wakePrompt, PromptPosition.Center, false); + OWTime.Pause(OWTime.PauseType.Sleeping); + //Locator.GetPauseCommandListener().AddPauseCommandLock(); + return false; + } + __instance.WakeUp(); + } + + return false; + }*/ + + [HarmonyPrefix] + [HarmonyPatch(typeof(CursorManager), nameof(CursorManager.RefreshCursorState))] + public static bool CursorManager_RefreshCursorState_Prefix(CursorManager __instance) + { + if (qsbFPS.Instance.ignoreLockCursor) + { + Cursor.lockState = CursorLockMode.None; + Cursor.visible = true; + return false; + } + + bool flag = false; + + CursorLockMode cursorLockMode = CursorLockMode.Locked; + if (__instance._isPaused || !__instance._hasFocus || (OWInput.IsInputMode(InputMode.Menu | InputMode.Rebinding | InputMode.KeyboardInput) && !OWInput.IsChangePending() && !OWInput.UsingGamepad())) + { + flag = true; + cursorLockMode = CursorLockMode.None; + } + if (Cursor.visible != flag) + { + Cursor.visible = flag; + } + if (Cursor.lockState != cursorLockMode) + { + Cursor.lockState = cursorLockMode; + } + return false; + } + + /*[HarmonyPrefix] + [HarmonyPatch(typeof(MultiplayerHUDManager), nameof(MultiplayerHUDManager.WriteSystemMessage))] + public static void MultiplayerHUDManager_WriteSystemMessage_Postfix(MultiplayerHUDManager __instance) + { + FieldInfo[] field; + Type classType = typeof(MultiplayerHUDManager); + field = classType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); + + for (int i = 0; i < field.Length; i++) + { + if (field[i].Name == "_textChat") + { + qsbFPS.Instance.ModHelper.Console.WriteLine("_textChat: " + (Transform)field[i].GetValue(__instance)); + } + } + }*/ + + [HarmonyPrefix] + [HarmonyPatch(typeof(MultiplayerHUDManager), nameof(MultiplayerHUDManager.WriteMessage))] + public static bool CheckTextChat(MultiplayerHUDManager __instance) + { + FieldInfo[] field; + Type classType = typeof(MultiplayerHUDManager); + field = classType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); + Transform textChat = null; + + for (int i = 0; i < field.Length; i++) + { + if (field[i].Name == "_textChat") + { + qsbFPS.Instance.ModHelper.Console.WriteLine("_textChat: " + field[i].GetValue(__instance)); + textChat = (Transform)field[i].GetValue(__instance); + } + } + + if (textChat == null) + { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index e18c420..424a126 100644 --- a/manifest.json +++ b/manifest.json @@ -2,9 +2,9 @@ "$schema": "https://raw.githubusercontent.com/ow-mods/owml/master/schemas/manifest_schema.json", "filename": "qsb-fps.dll", "author": "Etherpod", - "name": "QSB First Person Shooter", + "name": "Quantum Space Shooters", "uniqueName": "Etherpod.qsb-fps", "version": "0.1.0", "owmlVersion": "2.9.6", - "dependencies": [] + "dependencies": ["Raicuparta.QuantumSpaceBuddies"] } diff --git a/qsb-fps.cs b/qsb-fps.cs index 40ab311..2c5309a 100644 --- a/qsb-fps.cs +++ b/qsb-fps.cs @@ -9,6 +9,9 @@ using System.Collections.Generic; using QSB.RespawnSync; using System.Linq; +using QSB; +using QSB.Player; +using QSB.Player.TransformSync; namespace QSBFPS; @@ -24,9 +27,12 @@ public class qsbFPS : ModBehaviour GameObject scriptHandler; Transform particlesOffset; - Canvas overlayHUD; + public Canvas gunHUD { private set; get; } + Canvas readyUpCanvas; Image hitReticle; GameObject gunObject; + float nameYOffset = 0; + public bool ignoreLockCursor { private set; get; } public Dictionary idToGameObjects = new Dictionary(); public GameObject lastJoinedObject; @@ -42,15 +48,19 @@ private void Start() { qsbAPI = ModHelper.Interaction.TryGetModApi("Raicuparta.QuantumSpaceBuddies"); menuFrameworkAPI = ModHelper.Interaction.TryGetModApi("_nebula.MenuFramework"); - qsbAPI.RegisterRequiredForAllPlayers(this); LoadManager.OnCompleteSceneLoad += (scene, loadScene) => { if (loadScene != OWScene.SolarSystem) return; - OnSystemLoad(); + //OnSystemLoad(); }; } + private void Update() + { + //ModHelper.Console.WriteLine("Mouse enabled: " + Cursor.visible); + } + private void OnSystemLoad() { inSolarSystem = true; @@ -65,12 +75,15 @@ private void OnSystemLoad() particlesOffset.gameObject.SetActive(true); scriptHandler.GetComponent().particlesOffset = particlesOffset; - QSB.QSBCore.DebugSettings.DisableLoopDeath = true; + QSBCore.DebugSettings.DisableLoopDeath = true; qsbAPI.OnPlayerJoin().AddListener((uint playerID) => { ModHelper.Console.WriteLine($"{playerID} joined the game!", MessageType.Success); - //StartCoroutine(WaitForLocalInstance(playerID)); + /*if (!qsbAPI.GetIsHost()) + { + AddPlayerNameToList(qsbAPI.GetPlayerName(playerID)); + }*/ }); qsbAPI.OnPlayerLeave().AddListener((uint playerId) => ModHelper.Console.WriteLine($"{playerId} left the game!", MessageType.Success)); @@ -80,41 +93,20 @@ private void OnSystemLoad() StartCoroutine(EquipSuitDelay()); } - private IEnumerator WaitForLocalInstance(uint playerID) - { - ModHelper.Console.WriteLine("Waiting for local instance..."); - yield return new WaitUntil(() => QSB.Player.TransformSync.PlayerTransformSync.LocalInstance != null); - - ModHelper.Console.WriteLine("Local instance found!"); - - if (playerID == qsbAPI.GetLocalPlayerID()) - { - ModHelper.Console.WriteLine($"It was just me ({playerID}) who joined... :("); - yield break; - } - - ModHelper.Console.WriteLine("New player joined! ID: " + playerID); - /* new UpdateDictMessage(playerID, new KeyValuePair(qsbAPI.GetLocalPlayerID(), - idToGameObjects[qsbAPI.GetLocalPlayerID()])).Send();*/ - - //lastJoinedID = playerID; - //StartCoroutine(RegisterIdObjectPair()); - } + /* private IEnumerator RegisterIdObjectPair() + { + ModHelper.Console.WriteLine("Saved playerID"); - private IEnumerator RegisterIdObjectPair() - { - ModHelper.Console.WriteLine("Saved playerID"); + if (lastJoinedObject == null) + { + ModHelper.Console.WriteLine("Player object is null"); + yield return new WaitUntil(() => lastJoinedObject != null); + } - if (lastJoinedObject == null) - { - ModHelper.Console.WriteLine("Player object is null"); - yield return new WaitUntil(() => lastJoinedObject != null); - } - - idToGameObjects.Add(lastJoinedID, lastJoinedObject); - ModHelper.Console.WriteLine("ID-object added"); - lastJoinedObject = null; - } + idToGameObjects.Add(lastJoinedID, lastJoinedObject); + ModHelper.Console.WriteLine("ID-object added"); + lastJoinedObject = null; + }*/ private IEnumerator EquipSuitDelay() { @@ -127,7 +119,7 @@ public IEnumerator RespawnDelay() FieldInfo field = typeof(RespawnManager).GetField("_playersPendingRespawn", BindingFlags.NonPublic | BindingFlags.Instance); List _playersPendingRespawn = (List)field.GetValue(RespawnManager.Instance); - if (_playersPendingRespawn == null) + if (_playersPendingRespawn == null) { ModHelper.Console.WriteLine("Didn't find the list somehow?", MessageType.Error); yield break; @@ -143,20 +135,18 @@ private void SpawnArena() GameObject prefabArena = AssetBundleUtilities.LoadPrefab("Assets/qsbfps", "Assets/qsbFPS/OW_PvpArena.prefab", this); GameObject instantiatedArena = Instantiate(prefabArena, new Vector3(10000, 10000, 0), Quaternion.identity); instantiatedArena.SetActive(true); - - GameObject respawner = instantiatedArena.GetComponentInChildren().gameObject; - respawner.AddComponent(); } private void SpawnGunHUD() { GameObject prefabHUD = AssetBundleUtilities.LoadPrefab("Assets/qsbfps", "Assets/qsbFPS/GunHUD.prefab", this); - overlayHUD = Instantiate(prefabHUD, Vector3.zero, Quaternion.identity).GetComponent(); - hitReticle = overlayHUD.transform.GetChild(0).GetComponent(); + gunHUD = Instantiate(prefabHUD, Vector3.zero, Quaternion.identity).GetComponent(); + hitReticle = gunHUD.transform.GetChild(0).GetComponent(); scriptHandler.GetComponent().hitReticle = hitReticle; - overlayHUD.gameObject.SetActive(true); + gunHUD.gameObject.SetActive(true); hitReticle.enabled = false; + gunHUD.enabled = false; GameObject prefabGun = AssetBundleUtilities.LoadPrefab("Assets/qsbfps", "Assets/qsbFPS/GunPivot.prefab", this); PlayerCameraController playerCam = FindObjectOfType(); @@ -167,6 +157,67 @@ private void SpawnGunHUD() gunObject.SetActive(true); } + /*private void AddPlayerNameToList(string name) + { + GameObject namePrefab = AssetBundleUtilities.LoadPrefab("Assets/qsbfps", "Assets/qsbFPS/JoinedPlayerName.prefab", this); + GameObject instantiated = Instantiate(namePrefab, Vector3.zero, Quaternion.identity, readyUpCanvas.transform.GetChild(2)); + nameYOffset -= 70f; + instantiated.GetComponent().position = new Vector2(Screen.width / 2, Screen.height / 2 + nameYOffset); + + Sprite sprite = AssetBundleUtilities.Load("Assets/qsbfps", "Assets/qsbFPS/EmptyCheckbox.png", this); + instantiated.GetComponentInChildren().sprite = sprite; + instantiated.GetComponentInChildren().text = name; + instantiated.SetActive(true); + }*/ + + /*public void SpawnReadyUpCanvas() + { + GameObject prefabCanvas = AssetBundleUtilities.LoadPrefab("Assets/qsbfps", "Assets/qsbFPS/ReadyUpScreen.prefab", this); + readyUpCanvas = Instantiate(prefabCanvas, Vector3.zero, Quaternion.identity).GetComponent(); + readyUpCanvas.gameObject.SetActive(true); + ignoreLockCursor = true; + readyUpCanvas.GetComponentInChildren