using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Packer.Packers_Green_Screen
{
[BepInPlugin("Packer.Packers_Green_Screen", "Packers_Green_Screen", "0.1.5")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
public class Packers_Green_ScreenPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Packer.Packers_Green_Screen");
AtlasPlugin.RegisterScene(Path.Combine(BasePath, "greenscreen"));
}
}
}
namespace Packer
{
public class CameraMatManager : MonoBehaviour
{
private void OnPreRender()
{
GreenScreenManager.instance.DisplayPlayerScreen();
}
private void OnPostRender()
{
GreenScreenManager.instance.DisplayCameraScreen();
}
}
public class ColorButton : MonoBehaviour
{
public int index = 1;
public void SetCameraDisplay()
{
GreenScreenManager.instance.SetCameraScreen(index);
}
public void SetPlayerDisplay()
{
GreenScreenManager.instance.SetPlayerScreen(index);
}
}
public class GreenScreenManager : MonoBehaviour
{
public static GreenScreenManager instance;
public Material greenscreenMaterial;
public ScreenSet playerScreen;
public ScreenSet cameraScreen;
public MeshRenderer[] meshRender;
[Header("World Light")]
public FVRPhysicalObject sunDirection;
public Transform worldGizmo;
public GameObject[] pageList;
private CameraMatManager mainCamera;
private Camera[] cameras;
[Header("Lights")]
public Light sunLight;
public Slider sunIntensitySlider;
public Slider sunR;
public Slider sunG;
public Slider sunB;
public Image sunPreview;
public ScreenSet[] screenSets;
public GameObject buttonPrefab;
public Transform playerTab;
public Transform cameraTab;
private void Start()
{
instance = this;
OpenPage(0);
UpdateSunRGB();
UpdateSunSlider();
GenerateButtons();
SetPlayerScreen(1);
SetCameraScreen(1);
}
private void Update()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)mainCamera == (Object)null)
{
SetupCamera();
}
if (!((FVRInteractiveObject)sunDirection).IsHeld)
{
((Component)sunDirection).transform.rotation = ((Component)sunLight).transform.rotation;
}
else
{
((Component)sunLight).transform.rotation = ((Component)sunDirection).gameObject.transform.rotation;
}
((Component)sunDirection).transform.position = ((Component)worldGizmo).transform.position;
worldGizmo.rotation = Quaternion.identity;
}
public void OpenPage(int i)
{
CloseAllPages();
pageList[i].SetActive(true);
}
public void CloseAllPages()
{
for (int i = 0; i < pageList.Length; i++)
{
pageList[i].SetActive(false);
}
}
public void SetPlayerScreen(int input)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
SM.PlayGlobalUISound((GlobalUISound)0, ((Component)this).transform.position);
playerScreen = screenSets[input];
}
public void SetCameraScreen(int input)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
SM.PlayGlobalUISound((GlobalUISound)0, ((Component)this).transform.position);
cameraScreen = screenSets[input];
}
public void DisplayPlayerScreen()
{
if (playerScreen != null)
{
SetScreen(playerScreen);
}
}
public void DisplayCameraScreen()
{
if (cameraScreen != null)
{
SetScreen(cameraScreen);
}
}
public void GenerateButtons()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < screenSets.Length; i++)
{
Button component = Object.Instantiate<GameObject>(buttonPrefab, playerTab).GetComponent<Button>();
((Component)component).gameObject.SetActive(true);
ColorButton colorBtn = ((Component)component).gameObject.AddComponent<ColorButton>();
colorBtn.index = i;
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
colorBtn.SetPlayerDisplay();
});
if ((Object)(object)screenSets[i].texture != (Object)null)
{
((Selectable)component).image.sprite = Sprite.Create(screenSets[i].texture, new Rect(0f, 0f, (float)((Texture)screenSets[i].texture).width, (float)((Texture)screenSets[i].texture).height), new Vector2(0f, 0f), 100f);
}
((Graphic)((Selectable)component).image).color = screenSets[i].color;
FVRPointableButton component2 = ((Component)component).GetComponent<FVRPointableButton>();
component2.ColorSelected = screenSets[i].color;
component2.ColorUnselected = screenSets[i].color;
}
for (int j = 0; j < screenSets.Length; j++)
{
Button component3 = Object.Instantiate<GameObject>(buttonPrefab, cameraTab).GetComponent<Button>();
((Component)component3).gameObject.SetActive(true);
ColorButton colorBtn2 = ((Component)component3).gameObject.AddComponent<ColorButton>();
colorBtn2.index = j;
((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
{
colorBtn2.SetCameraDisplay();
});
if ((Object)(object)screenSets[j].texture != (Object)null)
{
((Selectable)component3).image.sprite = Sprite.Create(screenSets[j].texture, new Rect(0f, 0f, (float)((Texture)screenSets[j].texture).width, (float)((Texture)screenSets[j].texture).height), new Vector2(0f, 0f), 100f);
}
((Graphic)((Selectable)component3).image).color = screenSets[j].color;
FVRPointableButton component4 = ((Component)component3).GetComponent<FVRPointableButton>();
component4.ColorSelected = screenSets[j].color;
component4.ColorUnselected = screenSets[j].color;
}
}
private void SetScreen(ScreenSet input)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
greenscreenMaterial.SetColor("_Color", input.color);
greenscreenMaterial.SetTexture("_MainTex", (Texture)(object)input.texture);
for (int i = 0; i < meshRender.Length; i++)
{
((Renderer)meshRender[i]).materials[0].SetColor("_Color", input.color);
((Renderer)meshRender[i]).materials[0].SetTexture("_MainTex", (Texture)(object)input.texture);
}
}
private void SetupCamera()
{
cameras = Object.FindObjectsOfType<Camera>();
if (cameras.Length > 0)
{
Debug.Log((object)"Green screen Camera found!");
mainCamera = ((Component)cameras[0]).gameObject.AddComponent<CameraMatManager>();
}
}
public void AdjustIntensity(float amount)
{
Slider obj = sunIntensitySlider;
obj.value += amount;
UpdateSunSlider();
}
public void AdjustR(float amount)
{
Slider obj = sunR;
obj.value += amount;
UpdateSunRGB();
}
public void AdjustG(float amount)
{
Slider obj = sunG;
obj.value += amount;
UpdateSunRGB();
}
public void AdjustB(float amount)
{
Slider obj = sunB;
obj.value += amount;
UpdateSunRGB();
}
public void UpdateSunRGB()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
sunLight.color = new Color(sunR.value, sunG.value, sunB.value);
((Graphic)sunPreview).color = sunLight.color;
}
public void UpdateSunSlider()
{
sunLight.intensity = sunIntensitySlider.value;
}
}
[Serializable]
public class ScreenSet
{
public Texture2D texture;
public Color color = Color.white;
}
}