quantum-space-buddies/QSB/Tools/FlashlightTool/FlashlightCreator.cs

26 lines
784 B
C#
Raw Normal View History

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