2021-12-14 22:53:53 +00:00
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Tools.FlashlightTool;
|
2021-07-26 22:55:09 +01:00
|
|
|
|
using QSB.Tools.ProbeLauncherTool;
|
2021-11-09 17:46:46 +00:00
|
|
|
|
using QSB.Tools.SignalscopeTool;
|
|
|
|
|
using QSB.Tools.TranslatorTool;
|
2021-11-12 10:06:51 +00:00
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using System;
|
2020-08-23 13:12:18 +01:00
|
|
|
|
using System.Linq;
|
2020-07-28 00:13:43 +01:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2020-07-30 22:27:14 +02:00
|
|
|
|
namespace QSB.Tools
|
2020-07-28 00:13:43 +01:00
|
|
|
|
{
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public class PlayerToolsManager
|
|
|
|
|
{
|
2021-11-09 17:46:46 +00:00
|
|
|
|
public static Transform StowTransform;
|
|
|
|
|
public static Transform HoldTransform;
|
2020-12-02 21:23:01 +00:00
|
|
|
|
|
2021-11-09 17:46:46 +00:00
|
|
|
|
public static Material Props_HEA_PlayerTool_mat;
|
|
|
|
|
public static Material Props_HEA_Lightbulb_mat;
|
|
|
|
|
public static Material Props_HEA_Lightbulb_OFF_mat;
|
2021-11-10 09:12:05 +00:00
|
|
|
|
public static Material Structure_HEA_PlayerShip_Screens_mat;
|
2020-12-02 21:23:01 +00:00
|
|
|
|
|
2021-12-14 22:53:53 +00:00
|
|
|
|
public static void InitRemote(PlayerInfo player)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-11-12 10:06:51 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2021-12-14 22:53:53 +00:00
|
|
|
|
CreateStowTransforms(player.CameraBody.transform);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
|
2022-01-01 22:12:10 +00:00
|
|
|
|
var surfaceData = Locator.GetSurfaceManager()._surfaceLookupAsset;
|
|
|
|
|
var metal = surfaceData.surfaceTypeGroups[15].materials;
|
|
|
|
|
var glass = surfaceData.surfaceTypeGroups[19].materials;
|
2021-11-12 10:06:51 +00:00
|
|
|
|
|
2022-01-01 22:12:10 +00:00
|
|
|
|
Props_HEA_PlayerTool_mat = metal[27];
|
|
|
|
|
Props_HEA_Lightbulb_mat = glass[47];
|
|
|
|
|
Props_HEA_Lightbulb_OFF_mat = glass[48];
|
|
|
|
|
Structure_HEA_PlayerShip_Screens_mat = glass[41];
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2021-11-12 10:06:51 +00:00
|
|
|
|
catch (Exception ex)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-11-12 10:06:51 +00:00
|
|
|
|
DebugLog.ToConsole($"Error when trying to find materials : {ex}", OWML.Common.MessageType.Error);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-02 11:58:00 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FlashlightCreator.CreateFlashlight(player);
|
|
|
|
|
SignalscopeCreator.CreateSignalscope(player);
|
|
|
|
|
ProbeLauncherCreator.CreateProbeLauncher(player);
|
|
|
|
|
TranslatorCreator.CreateTranslator(player);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Error when trying to create tools : {ex}", OWML.Common.MessageType.Error);
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-25 11:28:13 +00:00
|
|
|
|
public static void InitLocal()
|
|
|
|
|
{
|
|
|
|
|
var flashlight = Locator.GetFlashlight();
|
|
|
|
|
var spot = flashlight._illuminationCheckLight;
|
|
|
|
|
var lightLOD = spot.GetComponent<LightLOD>();
|
|
|
|
|
|
|
|
|
|
if (lightLOD != null)
|
|
|
|
|
{
|
|
|
|
|
UnityEngine.Object.Destroy(lightLOD);
|
|
|
|
|
spot.GetLight().shadows = LightShadows.Soft;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private static void CreateStowTransforms(Transform cameraBody)
|
|
|
|
|
{
|
2022-01-23 16:14:42 +00:00
|
|
|
|
StowTransform = cameraBody.Find("REMOTE_ToolStowTransform");
|
|
|
|
|
HoldTransform = cameraBody.Find("REMOTE_ToolHoldTransform");
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 17:46:46 +00:00
|
|
|
|
internal static MeshRenderer GetRenderer(GameObject root, string gameObjectName) =>
|
2020-12-14 21:20:53 +00:00
|
|
|
|
root.GetComponentsInChildren<MeshRenderer>(true).First(x => x.name == gameObjectName);
|
|
|
|
|
}
|
2020-08-07 20:39:07 +01:00
|
|
|
|
}
|