91 lines
2.6 KiB
C#
Raw Normal View History

2021-11-25 15:32:34 +00:00
using OWML.Utils;
using QSB.Events;
using QSB.Player;
using QSB.ShipSync;
using QSB.Utility.Events;
2021-11-25 15:32:34 +00:00
using System.Linq;
2020-12-08 09:31:29 +00:00
using UnityEngine;
using UnityEngine.InputSystem;
namespace QSB.Utility
{
2020-12-02 21:23:01 +00:00
public class DebugActions : MonoBehaviour
{
private void GoToVessel()
{
var spawnPoint = GameObject.Find("Spawn_Vessel").GetComponent<SpawnPoint>();
2020-12-02 21:23:01 +00:00
var playerBody = Locator.GetPlayerBody();
playerBody.WarpToPositionRotation(spawnPoint.transform.position, spawnPoint.transform.rotation);
playerBody.SetVelocity(spawnPoint.GetPointVelocity());
}
2020-12-02 21:23:01 +00:00
private void InsertWarpCore()
{
var warpCore = GameObject.Find("Prefab_NOM_WarpCoreVessel").GetComponent<WarpCoreItem>();
var socket = GameObject.Find("Interactibles_VesselBridge").GetComponentInChildren<WarpCoreSocket>();
socket.PlaceIntoSocket(warpCore);
2020-12-08 09:31:29 +00:00
var bridgeVolume = FindObjectOfType<VesselWarpController>().GetValue<OWTriggerVolume>("_bridgeVolume");
bridgeVolume.AddObjectToVolume(Locator.GetPlayerDetector());
bridgeVolume.AddObjectToVolume(Locator.GetPlayerCameraDetector());
2020-12-02 21:23:01 +00:00
}
2021-07-12 22:02:50 +01:00
private void DamageShipElectricalSystem() => ShipManager.Instance.ShipElectricalComponent.SetDamaged(true);
2020-12-14 21:41:56 +01:00
public void Update()
2020-12-02 21:23:01 +00:00
{
2020-12-14 16:24:52 +00:00
if (!QSBCore.DebugMode)
2020-12-02 21:23:01 +00:00
{
return;
}
2021-06-18 22:38:32 +01:00
if (Keyboard.current[Key.Numpad4].wasPressedThisFrame)
2021-08-08 19:48:48 +01:00
{
DamageShipElectricalSystem();
2021-08-08 19:48:48 +01:00
}
if (Keyboard.current[Key.Numpad5].wasPressedThisFrame)
{
QSBEventManager.FireEvent(EventNames.QSBDebugEvent, DebugEventEnum.TriggerSupernova);
}
if (Keyboard.current[Key.Numpad7].wasPressedThisFrame)
2020-12-02 21:23:01 +00:00
{
GoToVessel();
}
2021-06-18 22:38:32 +01:00
if (Keyboard.current[Key.Numpad8].wasPressedThisFrame)
2020-12-02 21:23:01 +00:00
{
InsertWarpCore();
}
2021-06-18 22:38:32 +01:00
if (Keyboard.current[Key.Numpad9].wasPressedThisFrame)
2020-12-02 21:23:01 +00:00
{
2021-10-26 18:56:36 +01:00
PlayerData.SaveWarpedToTheEye(60);
2020-12-14 21:41:56 +01:00
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToWhite);
2020-12-02 21:23:01 +00:00
}
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
{
var otherPlayer = QSBPlayerManager.PlayerList.FirstOrDefault(x => x.PlayerId != QSBPlayerManager.LocalPlayerId);
if (otherPlayer != null && otherPlayer.Body != null)
{
var playerBody = Locator.GetPlayerBody();
playerBody.WarpToPositionRotation(otherPlayer.Body.transform.position, otherPlayer.Body.transform.rotation);
var parentBody = otherPlayer.Body.GetAttachedOWRigidbody(true);
if (parentBody != null)
{
playerBody.SetVelocity(parentBody.GetVelocity());
playerBody.SetAngularVelocity(parentBody.GetAngularVelocity());
}
else
{
playerBody.SetVelocity(Vector3.zero);
playerBody.SetAngularVelocity(Vector3.zero);
}
}
}
2020-12-02 21:23:01 +00:00
}
}
}