139 lines
4.5 KiB
C#
Raw Normal View History

using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Player;
2022-01-26 17:14:26 -08:00
using QSB.RespawnSync;
using QSB.ShipSync;
using QSB.Utility.Messages;
using QSB.WorldSync;
2021-12-23 17:07:29 -08:00
using System.Linq;
2020-12-08 09:31:29 +00:00
using UnityEngine;
using UnityEngine.InputSystem;
2022-03-02 19:46:33 -08:00
namespace QSB.Utility;
public class DebugActions : MonoBehaviour, IAddComponentOnStart
{
private static void GoToVessel()
{
2022-03-02 19:46:33 -08:00
var spawnPoint = GameObject.Find("Spawn_Vessel").GetComponent<SpawnPoint>();
var playerBody = Locator.GetPlayerBody();
playerBody.WarpToPositionRotation(spawnPoint.transform.position, spawnPoint.transform.rotation);
playerBody.SetVelocity(spawnPoint.GetPointVelocity());
var bridgeVolume = FindObjectOfType<VesselWarpController>()._bridgeVolume;
bridgeVolume.AddObjectToVolume(Locator.GetPlayerDetector());
bridgeVolume.AddObjectToVolume(Locator.GetPlayerCameraDetector());
}
private static void InsertWarpCore()
2022-03-02 19:46:33 -08:00
{
var warpCore = GameObject.Find("Prefab_NOM_WarpCoreVessel").GetComponent<WarpCoreItem>();
var socket = GameObject.Find("Interactibles_VesselBridge").GetComponentInChildren<WarpCoreSocket>();
socket.PlaceIntoSocket(warpCore);
}
2021-12-21 21:24:31 +00:00
private static void DamageShipElectricalSystem() =>
ShipManager.Instance.ShipElectricalComponent.SetDamaged(true);
2021-12-21 21:24:31 +00:00
2022-03-02 19:46:33 -08:00
private void Awake() => enabled = QSBCore.DebugSettings.DebugMode;
2021-12-27 21:05:11 +00:00
2022-03-02 19:46:33 -08:00
private int _otherPlayerToTeleportTo;
2021-08-08 19:48:48 +01:00
2022-03-02 19:46:33 -08:00
public void Update()
{
if (!Keyboard.current[Key.Q].isPressed)
{
2022-03-02 19:46:33 -08:00
return;
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
{
var otherPlayers = QSBPlayerManager.PlayerList.Where(x => !x.IsLocalPlayer).ToList();
_otherPlayerToTeleportTo = (_otherPlayerToTeleportTo + 1) % otherPlayers.Count;
var otherPlayer = otherPlayers[_otherPlayerToTeleportTo];
new DebugRequestTeleportInfoMessage(otherPlayer.PlayerId).Send();
}
2022-01-12 10:52:11 +00:00
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad2].wasPressedThisFrame)
{
if (!QSBPlayerManager.LocalPlayer.InDreamWorld)
{
var relativeLocation = new RelativeLocationData(Vector3.up * 2 + Vector3.forward * 2, Quaternion.identity, Vector3.zero);
var location = Keyboard.current[Key.LeftShift].isPressed ? DreamArrivalPoint.Location.Zone4 : DreamArrivalPoint.Location.Zone3;
var arrivalPoint = Locator.GetDreamArrivalPoint(location);
var dreamCampfire = Locator.GetDreamCampfire(location);
if (Locator.GetToolModeSwapper().GetItemCarryTool().GetHeldItemType() != ItemType.DreamLantern)
{
var dreamLanternItem = QSBWorldSync.GetWorldObjects<QSBDreamLanternItem>().First(x =>
x.AttachedObject._lanternType == DreamLanternType.Functioning &&
QSBPlayerManager.PlayerList.All(y => y.HeldItem != x)
).AttachedObject;
Locator.GetToolModeSwapper().GetItemCarryTool().PickUpItemInstantly(dreamLanternItem);
}
Locator.GetDreamWorldController().EnterDreamWorld(dreamCampfire, arrivalPoint, relativeLocation);
}
else
{
if (Locator.GetToolModeSwapper().GetItemCarryTool().GetHeldItemType() != ItemType.DreamLantern)
{
var dreamLanternItem = QSBPlayerManager.LocalPlayer.AssignedSimulationLantern.AttachedObject;
Locator.GetToolModeSwapper().GetItemCarryTool().PickUpItemInstantly(dreamLanternItem);
}
}
2022-03-02 19:46:33 -08:00
}
2021-06-18 22:38:32 +01:00
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad3].wasPressedThisFrame)
{
2022-05-03 08:48:24 +01:00
var sarcoController = QSBWorldSync.GetUnityObject<SarcophagusController>();
sarcoController.firstSealProjector.SetLit(false);
sarcoController.secondSealProjector.SetLit(false);
sarcoController.thirdSealProjector.SetLit(false);
sarcoController._attemptOpenAfterDelay = true;
sarcoController._openAttemptTime = Time.time + 0.5f;
sarcoController.enabled = true;
2022-03-02 19:46:33 -08:00
}
2021-06-18 22:38:32 +01:00
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad4].wasPressedThisFrame)
{
DamageShipElectricalSystem();
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad5].wasPressedThisFrame)
{
new DebugTriggerSupernovaMessage().Send();
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad6].wasPressedThisFrame)
{
PlayerData.SetPersistentCondition("MET_SOLANUM", true);
PlayerData.SetPersistentCondition("MET_PRISONER", true);
DialogueConditionManager.SharedInstance.SetConditionState("MET_SOLANUM", true);
DialogueConditionManager.SharedInstance.SetConditionState("MET_PRISONER", true);
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad7].wasPressedThisFrame)
{
GoToVessel();
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad8].wasPressedThisFrame)
{
InsertWarpCore();
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad9].wasPressedThisFrame)
{
new DebugChangeSceneMessage(Keyboard.current[Key.LeftShift].isPressed).Send();
}
2022-03-02 19:46:33 -08:00
if (Keyboard.current[Key.Numpad0].wasPressedThisFrame)
{
RespawnManager.Instance.RespawnSomePlayer();
}
2020-12-02 21:23:01 +00:00
}
}