using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace huluobolightutility;
public class Config
{
public static ConfigEntry<bool> Usesthedefaultlightposition;
public static ConfigEntry<bool> Modifythepositionoftheoriginallights;
public Config(ConfigFile cfg)
{
Usesthedefaultlightposition = cfg.Bind<bool>("global", "Uses the default light position", true, "Uses the default light position?");
Modifythepositionoftheoriginallights = cfg.Bind<bool>("global", "Modify the position of the original lights", false, "Modify the position of the original lights?");
}
}
[BepInPlugin("hlb.lightutility", "huluobolightutility", "1.0.3")]
public class Huluobolightutility : BaseUnityPlugin
{
private const string GUID = "hlb.lightutility";
private const string Name = "huluobolightutility";
private const string Version = "1.0.3";
private Harmony harmony;
private static AssetBundle bundle;
private static Transform Lighttransform;
public static Config LightutilityConfig { get; internal set; }
private void Awake()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "0lightmod"));
LightutilityConfig = new Config(((BaseUnityPlugin)this).Config);
harmony = new Harmony("hlb.lightutility");
harmony.PatchAll(typeof(Huluobolightutility));
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
public static void Playerlight(PlayerControllerB __instance)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
Lighttransform = ((Component)((Component)__instance.helmetLight).transform.parent).transform;
if (Config.Modifythepositionoftheoriginallights.Value)
{
((Component)__instance.allHelmetLights[0]).transform.localPosition = new Vector3(0f, 0.545f, 0.791f);
((Component)__instance.allHelmetLights[1]).transform.localPosition = new Vector3(0f, 0.545f, 0.791f);
}
Light[] array = (Light[])(object)new Light[4]
{
CreateLight("promaxLight"),
CreateLight("EliteFlashlight"),
CreateLight("promaxplusLight"),
CreateLight("promaxplusultraLight")
};
Light[] array2 = (Light[])(object)new Light[__instance.allHelmetLights.Length + array.Length];
Array.Copy(__instance.allHelmetLights, array2, __instance.allHelmetLights.Length);
Array.Copy(array, 0, array2, __instance.allHelmetLights.Length, array.Length);
__instance.allHelmetLights = array2;
}
private static Light CreateLight(string obj)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(bundle.LoadAsset<GameObject>("Assets/0lightmod/" + obj + ".prefab"), Lighttransform);
if (!Config.Usesthedefaultlightposition.Value)
{
val.transform.localPosition = new Vector3(0f, 0.545f, 0.791f);
val.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
}
else
{
val.transform.localPosition = new Vector3(0.207f, -0.526f, 0.475f);
val.transform.localEulerAngles = new Vector3(0f, -2.391f, 0f);
}
return val.GetComponent<Light>();
}
}