using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Glowsticks.Patches;
using HarmonyLib;
using LC_API.BundleAPI;
using TerminalApi;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Glowsticks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Glowsticks")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("69f89880-00f8-4394-b403-a594cfeb3a04")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class GlowstickItem : GrabbableObject
{
public bool useLifetime = true;
public int life = 300;
private Light glowstickLight;
private float intensityInterval;
private float rangeInterval;
public override void Start()
{
glowstickLight = ((Component)this).GetComponent<Light>();
intensityInterval = glowstickLight.intensity / (float)life / 10f;
rangeInterval = glowstickLight.range / (float)life / 10f;
if (useLifetime)
{
((MonoBehaviour)this).InvokeRepeating("LightInterval", 30f, 0.1f);
}
((GrabbableObject)this).Start();
}
public void LightInterval()
{
Light obj = glowstickLight;
obj.intensity -= intensityInterval;
Light obj2 = glowstickLight;
obj2.range -= rangeInterval;
if (glowstickLight.intensity <= 0f)
{
((MonoBehaviour)this).CancelInvoke("LightInterval");
}
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).ItemActivate(used, buttonDown);
base.playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetGlowstickDestination(), true);
}
public Vector3 GetGlowstickDestination()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)this).transform.position;
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward);
RaycastHit val2 = default(RaycastHit);
position = ((!Physics.Raycast(val, ref val2, 12f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) ? ((Ray)(ref val)).GetPoint(10f) : ((Ray)(ref val)).GetPoint(((RaycastHit)(ref val2)).distance - 0.05f));
((Ray)(ref val))..ctor(position, Vector3.down);
if (Physics.Raycast(val, ref val2, 30f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
{
return ((RaycastHit)(ref val2)).point + Vector3.up * 0.05f;
}
return ((Ray)(ref val)).GetPoint(30f);
}
public override void PocketItem()
{
((Behaviour)glowstickLight).enabled = false;
((GrabbableObject)this).PocketItem();
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
}
public override void EquipItem()
{
((Behaviour)glowstickLight).enabled = true;
((GrabbableObject)this).EquipItem();
}
public override void Update()
{
((GrabbableObject)this).Update();
}
}
namespace Glowsticks
{
[BepInPlugin("Asylud.Glowsticks", "Glowsticks", "1.1.0")]
public class GlowsticksBase : BaseUnityPlugin
{
private const string modGUID = "Asylud.Glowsticks";
private const string modName = "Glowsticks";
private const string modVersion = "1.1.0";
private readonly Harmony harmony = new Harmony("Asylud.Glowsticks");
private static GlowsticksBase Instance;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
harmony.PatchAll(typeof(GlowsticksBase));
harmony.PatchAll(typeof(GlowsticksTerminalPatch));
harmony.PatchAll(typeof(GlowsticksMenuManagerPatch));
}
}
}
namespace Glowsticks.Patches
{
public static class PrefabPrep
{
public static void Init(Vector3 colour, int cost, int lightIntensity, int lightRange, float glowIntensity, bool useLifetime, int lifeLength)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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)
Item loadedAsset = BundleLoader.GetLoadedAsset<Item>("Assets/Glowstick/GlowstickItem.asset");
GameObject loadedAsset2 = BundleLoader.GetLoadedAsset<GameObject>("Assets/Glowstick/Glowstick.prefab");
Material loadedAsset3 = BundleLoader.GetLoadedAsset<Material>("Assets/Glowstick/Glow.mat");
Material loadedAsset4 = BundleLoader.GetLoadedAsset<Material>("Assets/Glowstick/GlowEnds.mat");
Shader shader = (loadedAsset3.shader = Shader.Find("HDRP/Lit"));
loadedAsset4.shader = shader;
Light component = loadedAsset2.GetComponent<Light>();
component.color = new Color(colour.x, colour.y, colour.z);
component.intensity = lightIntensity;
component.range = lightRange;
loadedAsset3.SetColor("_BaseColor", new Color(colour.x, colour.y, colour.z));
loadedAsset3.SetColor("_EmissiveColor", new Color(colour.x, colour.y, colour.z));
loadedAsset3.SetFloat("_EmissiveIntensity", glowIntensity);
loadedAsset2.GetComponent<Renderer>().materials = (Material[])(object)new Material[2] { loadedAsset3, loadedAsset4 };
GlowstickItem glowstickItem = loadedAsset2.AddComponent<GlowstickItem>();
glowstickItem.useLifetime = useLifetime;
glowstickItem.life = lifeLength;
((GrabbableObject)glowstickItem).grabbable = true;
((GrabbableObject)glowstickItem).grabbableToEnemies = true;
((GrabbableObject)glowstickItem).itemProperties = loadedAsset;
loadedAsset.creditsWorth = cost;
loadedAsset.spawnPrefab = loadedAsset2;
}
}
[HarmonyPatch(typeof(Terminal))]
public class GlowsticksTerminalPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
public static void TerminalGlowstickPatch(Terminal __instance)
{
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_016f: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Expected O, but got Unknown
//IL_01a0: Expected O, but got Unknown
Item loadedAsset = BundleLoader.GetLoadedAsset<Item>("Assets/Glowstick/GlowstickItem.asset");
List<Item> list = __instance.buyableItemsList.ToList();
Array.Resize(ref __instance.buyableItemsList, list.Count());
list.Add(loadedAsset);
int buyItemIndex = list.IndexOf(loadedAsset);
__instance.buyableItemsList = list.ToArray();
TerminalKeyword val = TerminalApi.CreateTerminalKeyword("glowstick", true, (TerminalNode)null);
TerminalKeyword val2 = (val.defaultVerb = TerminalApi.GetKeyword("buy"));
val.isVerb = false;
TerminalExtenstionMethods.AddCompatibleNoun(val2, val, "You have requested to order glowsticks. Amount: [variableAmount]. \r\nTotal cost of items: [totalCost].\r\n\r\nPlease CONFIRM or DENY.\r\n\r\n", false);
((Object)val2.compatibleNouns.Last().noun).name = "Glowstick";
((Object)val2.compatibleNouns.Last().result).name = "buyGlowstick";
val2.compatibleNouns.Last().result.buyItemIndex = buyItemIndex;
val2.compatibleNouns.Last().result.isConfirmationNode = true;
val2.compatibleNouns.Last().result.overrideOptions = true;
val2.compatibleNouns.Last().result.clearPreviousText = true;
TerminalKeyword keyword = TerminalApi.GetKeyword("confirm");
CompatibleNoun val3 = new CompatibleNoun
{
noun = keyword,
result = new TerminalNode
{
buyItemIndex = buyItemIndex,
itemCost = loadedAsset.creditsWorth,
name = "buyGlowstick2",
clearPreviousText = true,
playSyncedClip = 0,
displayText = "Ordered [variableAmount] glowsticks. Your new balance is [playerCredits].\r\n\r\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n"
}
};
TerminalKeyword keyword2 = TerminalApi.GetKeyword("deny");
CompatibleNoun val4 = new CompatibleNoun
{
noun = keyword2,
result = new TerminalNode
{
displayText = "Cancelled order.\r\n"
}
};
val2.compatibleNouns.Last().result.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { val3, val4 };
TerminalApi.AddTerminalKeyword(val);
}
}
[HarmonyPatch(typeof(MenuManager))]
public class GlowsticksMenuManagerPatch
{
private static ConfigFile configFile;
private static ConfigEntry<Vector3> glowstickColor;
private static ConfigEntry<int> glowstickPrice;
private static ConfigEntry<int> glowstickLightIntensity;
private static ConfigEntry<int> glowstickLightRange;
private static ConfigEntry<int> glowstickGlowIntensity;
private static ConfigEntry<bool> glowstickUseLifetime;
private static ConfigEntry<int> glowstickLifeLength;
[HarmonyPatch("Awake")]
[HarmonyPrefix]
public static void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "glowstick.cfg"), true);
glowstickColor = configFile.Bind<Vector3>("Glowstick", "Glowstick Color", new Vector3(0f, 1f, 0f), "This uses a Vector3 for the glowstick colour where X = Red, Y = Green and Z = Blue. These values can range from 0.0 - 1.0. ");
glowstickPrice = configFile.Bind<int>("Glowstick", "Glowstick Price", 5, "The number of credits to charge for a glowstick purchased via the store.");
glowstickLightIntensity = configFile.Bind<int>("Glowstick", "Glowstick Light Intensity", 35, "The strength of the light emitted from the glowstick.");
glowstickLightRange = configFile.Bind<int>("Glowstick", "Glowstick Light Range", 10, "The distance the light from the glowstick can reach.");
glowstickGlowIntensity = configFile.Bind<int>("Glowstick", "Glowstick Glow Intensity", 10, "The intensity of the glowing effect from the glowstick material.");
glowstickUseLifetime = configFile.Bind<bool>("Glowstick", "Glowstick Use Lifetime", true, "Whether to enable the limited lifetime of a glowstick light. If enabled, after 30 seconds the glowsticks lifetime will begin to decrease and it will provide less light with a smaller range over time until it expires. Settings this value to false will cause glowsticks to provide light indefinitely.");
glowstickLifeLength = configFile.Bind<int>("Glowstick", "Glowstick Life Length", 300, "How long a glowstick should provide light for in seconds. The countdown will only begin after the initial 30 seconds of stable light, after which point it will begin decreasing.");
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void NetworkManagerGlowstickPrefabPatch(MenuManager __instance)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs.Select((NetworkPrefab pref) => ((Object)pref.Prefab).name).Contains("Glowstick"))
{
PrefabPrep.Init(glowstickColor.Value, glowstickPrice.Value, glowstickLightIntensity.Value, glowstickLightRange.Value, glowstickGlowIntensity.Value, glowstickUseLifetime.Value, glowstickLifeLength.Value);
GameObject loadedAsset = BundleLoader.GetLoadedAsset<GameObject>("Assets/Glowstick/Glowstick.prefab");
NetworkManager.Singleton.AddNetworkPrefab(loadedAsset);
}
}
}
}