2021-12-14 22:53:53 +00:00
|
|
|
|
using QSB.Player;
|
|
|
|
|
using UnityEngine;
|
2021-11-09 17:46:46 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.Tools.FlashlightTool
|
|
|
|
|
{
|
2021-11-09 19:39:56 +00:00
|
|
|
|
internal static class FlashlightCreator
|
2021-11-09 17:46:46 +00:00
|
|
|
|
{
|
2021-11-20 19:49:50 +00:00
|
|
|
|
private static readonly Vector3 FlashlightOffset = new(0.7196316f, -0.2697681f, 0.3769455f);
|
2021-11-09 17:46:46 +00:00
|
|
|
|
|
2021-12-14 22:53:53 +00:00
|
|
|
|
internal static void CreateFlashlight(PlayerInfo player)
|
2021-11-09 17:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
var flashlightRoot = Object.Instantiate(GameObject.Find("FlashlightRoot"));
|
|
|
|
|
flashlightRoot.name = "REMOTE_FlashlightRoot";
|
|
|
|
|
flashlightRoot.SetActive(false);
|
|
|
|
|
var oldComponent = flashlightRoot.GetComponent<Flashlight>();
|
|
|
|
|
var component = flashlightRoot.AddComponent<QSBFlashlight>();
|
|
|
|
|
|
2021-12-14 22:56:54 +00:00
|
|
|
|
component.Player = player;
|
2021-11-09 17:46:46 +00:00
|
|
|
|
component.Init(oldComponent);
|
2021-12-14 22:56:54 +00:00
|
|
|
|
|
2021-11-09 17:46:46 +00:00
|
|
|
|
oldComponent.enabled = false;
|
|
|
|
|
|
2021-12-14 22:53:53 +00:00
|
|
|
|
flashlightRoot.transform.parent = player.CameraBody.transform;
|
2021-11-09 17:46:46 +00:00
|
|
|
|
flashlightRoot.transform.localPosition = FlashlightOffset;
|
|
|
|
|
flashlightRoot.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|