Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Lily Utilities v1.0.3
BepInEx/plugins/Lily/Lily.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Lily.Config; using Lily.Scripts; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.VFX; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Lily")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Lily")] [assembly: AssemblyTitle("Lily")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Lily { [BepInPlugin("Entity378.Lily", "Lily", "1.0.3")] [BepInDependency("evaisa.lethallib", "0.14.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private Harmony harmony = new Harmony("Entity378.Lily"); private const string GUID = "Entity378.Lily"; private const string NAME = "Lily"; private const string VERSION = "1.0.3"; public static AssetBundle bundle; public static GameObject lilyProjectile; public static GameObject realmFilterContainer; public static GameObject realmFilter; public static bool cullFactory; private void Awake() { if (Chainloader.PluginInfos.ContainsKey("com.fumiko.CullFactory")) { cullFactory = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"LilyLog: CullFactory Founded"); } LilyConfigs.LoadConfig(((BaseUnityPlugin)this).Config); harmony.PatchAll(); harmony.PatchAll(typeof(LilyConfigs)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LilyLog: Config loaded"); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lily"); bundle = AssetBundle.LoadFromFile(text); lilyProjectile = bundle.LoadAsset<GameObject>("Assets/LethalCompany/Lily/Lily-Projectile.prefab"); lilyProjectile.AddComponent<Lily_ProjectileScript>(); Item val = bundle.LoadAsset<Item>("Assets/LethalCompany/Lily/Lily-Lantern-Item.asset"); AudioClip lilyLanternUseInside = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/Lily/LilyRealmUse.ogg"); AudioClip lilyLanternEndInside = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/Lily/LilyRealmEnd.ogg"); AudioClip lilyLanternError = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/Lily/LilyRealmError.ogg"); AudioClip lilyLanternUseOutside = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/Lily/LilyUseOutside.ogg"); AudioClip lilyLanternTeleportOutside = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/Lily/LilyTeleportOutside.ogg"); LilyLanternScript lilyLanternScript = val.spawnPrefab.AddComponent<LilyLanternScript>(); ((GrabbableObject)lilyLanternScript).itemProperties = val; lilyLanternScript.lilyLanternUseInside = lilyLanternUseInside; lilyLanternScript.lilyLanternEndInside = lilyLanternEndInside; lilyLanternScript.lilyLanternError = lilyLanternError; lilyLanternScript.lilyLanternUseOutside = lilyLanternUseOutside; lilyLanternScript.lilyLanternTeleportOutside = lilyLanternTeleportOutside; NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); Items.RegisterScrap(val, LilyConfigs.LilySpawnRate, (LevelTypes)(-1)); SceneManager.sceneLoaded += OnSceneRelayLoaded; } private void OnSceneRelayLoaded(Scene scene, LoadSceneMode loadMode) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) try { if (((Scene)(ref scene)).name == "SampleSceneRelay") { GameObject val = GameObject.Find("IngamePlayerHUD"); realmFilterContainer = new GameObject("RealmFilterContainer"); realmFilterContainer.AddComponent<CanvasGroup>(); RectTransform val2 = realmFilterContainer.AddComponent<RectTransform>(); ((Transform)val2).parent = val.transform; ((Transform)val2).localScale = Vector3.one; val2.anchoredPosition = Vector2.zero; ((Transform)val2).localPosition = Vector2.op_Implicit(new Vector2(0f, 0f)); val2.sizeDelta = Vector2.one; realmFilter = AddImageToHUD("Realm-Filter", scene); GameObject[] array = (GameObject[])(object)new GameObject[1] { realmFilter }; GameObject[] array2 = array; foreach (GameObject val3 in array2) { val3.transform.parent = realmFilterContainer.transform; val3.transform.localPosition = Vector2.op_Implicit(Vector2.zero); } } realmFilterContainer.SetActive(false); } catch { } } private GameObject AddImageToHUD(string imageName, Scene scene) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) Sprite val = bundle.LoadAsset<Sprite>("Assets/LethalCompany/Lily/" + imageName + ".png"); GameObject val2 = new GameObject(imageName); SceneManager.MoveGameObjectToScene(val2, scene); GameObject val3 = GameObject.Find("IngamePlayerHUD"); RectTransform val4 = val2.AddComponent<RectTransform>(); ((Transform)val4).parent = val3.transform; ((Transform)val4).localScale = Vector2.op_Implicit(Vector2.one); val4.anchoredPosition = Vector2.zero; ((Transform)val4).localPosition = Vector2.op_Implicit(Vector2.zero); Rect rect = val.rect; float width = ((Rect)(ref rect)).width; rect = val.rect; val4.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height); Image val5 = val2.AddComponent<Image>(); val5.sprite = val; CanvasRenderer val6 = val2.AddComponent<CanvasRenderer>(); return val2; } } public static class PluginInfo { public const string PLUGIN_GUID = "Lily"; public const string PLUGIN_NAME = "Lily"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Lily.Scripts { internal class LilyLanternScript : PhysicsProp { [CompilerGenerated] private sealed class <TeleportRealm>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float time; public LilyLanternScript <>4__this; private PlayerControllerB <playerInRealm>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TeleportRealm>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <playerInRealm>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <playerInRealm>5__1 = ((GrabbableObject)<>4__this).playerHeldBy; if (!((Component)<playerInRealm>5__1).GetComponent<Lily_PlayerRealmScript>().isInRealm) { if ((Object)(object)<playerInRealm>5__1 == (Object)(object)GameNetworkManager.Instance.localPlayerController) { <>4__this.audio.PlayOneShot(<>4__this.lilyLanternUseInside); Plugin.realmFilterContainer.SetActive(true); } else { PlaySoundForOtherPlayers(<>4__this.lilyLanternUseInside, ((Component)<playerInRealm>5__1).transform.position); } RealmTeleportPlayer(<playerInRealm>5__1); <>2__current = (object)new WaitForSeconds(time); <>1__state = 1; return true; } break; case 1: <>1__state = -1; RealmTeleportPlayer(<playerInRealm>5__1, enter: false); if ((Object)(object)<playerInRealm>5__1 == (Object)(object)GameNetworkManager.Instance.localPlayerController) { Plugin.realmFilterContainer.SetActive(false); } <>4__this.audio.PlayOneShot(<>4__this.lilyLanternEndInside); break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public float time = LilyConfigs.LilyRealmTime; public AudioSource audio; public AudioClip lilyLanternUseInside; public AudioClip lilyLanternEndInside; public AudioClip lilyLanternError; public AudioClip lilyLanternUseOutside; public AudioClip lilyLanternTeleportOutside; public float projectileSpeed = 20f; public override void Start() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown ((GrabbableObject)this).grabbable = true; ((GrabbableObject)this).grabbableToEnemies = false; ((GrabbableObject)this).insertedBattery = new Battery(false, 1f); ((GrabbableObject)this).mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>(); ((GrabbableObject)this).useCooldown = LilyConfigs.LilyCooldown; audio = ((Component)this).GetComponent<AudioSource>(); audio.bypassEffects = true; audio.bypassListenerEffects = true; audio.bypassReverbZones = true; ((GrabbableObject)this).Start(); } public override void DiscardItem() { ((GrabbableObject)this).DiscardItem(); } public override void PocketItem() { VisualEffect[] componentsInChildren = ((Component)this).GetComponentsInChildren<VisualEffect>(); Light[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Light>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Component)componentsInChildren[i]).gameObject.CompareTag("DoNotSet") && !((Component)componentsInChildren[i]).gameObject.CompareTag("InteractTrigger")) { ((Behaviour)componentsInChildren[i]).enabled = false; } } ((GrabbableObject)this).PocketItem(); } public override void EquipItem() { ((PhysicsProp)this).EquipItem(); VisualEffect[] componentsInChildren = ((Component)this).GetComponentsInChildren<VisualEffect>(); Light[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Light>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Component)componentsInChildren[i]).gameObject.CompareTag("DoNotSet") && !((Component)componentsInChildren[i]).gameObject.CompareTag("InteractTrigger")) { ((Behaviour)componentsInChildren[i]).enabled = true; } } } public override void GrabItem() { ((GrabbableObject)this).GrabItem(); } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).ItemActivate(used, buttonDown); if (!buttonDown || !((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null) || !((Object)(object)((Component)((GrabbableObject)this).playerHeldBy).GetComponent<Lily_PlayerRealmScript>() != (Object)null)) { return; } if (((GrabbableObject)this).insertedBattery.charge > 0f) { ((GrabbableObject)this).insertedBattery.charge = ((GrabbableObject)this).insertedBattery.charge - LilyConfigs.LilyBatteryUsage; if (((GrabbableObject)this).insertedBattery.charge < 0f) { ((GrabbableObject)this).insertedBattery.charge = 0f; } if (((GrabbableObject)this).playerHeldBy.isInsideFactory && !((Component)((GrabbableObject)this).playerHeldBy).GetComponent<Lily_PlayerRealmScript>().isInRealm) { ((MonoBehaviour)this).StartCoroutine(TeleportRealm(time)); } else if (!((GrabbableObject)this).playerHeldBy.isInsideFactory) { audio.PlayOneShot(lilyLanternUseOutside); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0.5f, 0f); Vector3 val2 = ((Component)this).gameObject.transform.position + val; Vector3 forward = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward; GameObject val3 = Object.Instantiate<GameObject>(Plugin.lilyProjectile, val2, Quaternion.identity); val3.GetComponent<Lily_ProjectileScript>().player = ((GrabbableObject)this).playerHeldBy; val3.GetComponent<Lily_ProjectileScript>().Item = ((Component)this).gameObject; Lily_ProjectileScript component = val3.GetComponent<Lily_ProjectileScript>(); if ((Object)(object)component != (Object)null) { component.player = ((GrabbableObject)this).playerHeldBy; component.Item = ((Component)this).gameObject; component.initialDirection = forward; component.initialSpeed = projectileSpeed; } } } else { audio.PlayOneShot(lilyLanternError); Debug.Log((object)"LilyLog: This item can't be used now"); } } [IteratorStateMachine(typeof(<TeleportRealm>d__14))] private IEnumerator TeleportRealm(float time) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TeleportRealm>d__14(0) { <>4__this = this, time = time }; } private static void RealmTeleportPlayer(PlayerControllerB playerInRealm, bool enter = true) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0.2f, -5000f); Vector3 val2 = ((Component)playerInRealm).transform.position + val; Vector3 val3 = ((Component)playerInRealm).transform.position - val; if (enter) { playerInRealm.TeleportPlayer(val2, false, 0f, false, true); ((Component)playerInRealm).GetComponent<Lily_PlayerRealmScript>().isInRealm = true; Debug.Log((object)("LilyLog: Player " + ((object)playerInRealm)?.ToString() + " is in the ShadowRealm")); } else { ((Component)playerInRealm).GetComponent<Lily_PlayerRealmScript>().isInRealm = false; playerInRealm.TeleportPlayer(val3, false, 0f, false, true); Debug.Log((object)("LilyLog: Player " + ((object)playerInRealm)?.ToString() + " leaved the ShadowRealm")); } } public static void PlaySoundForOtherPlayers(AudioClip clip, Vector3 position) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null) { Debug.LogWarning((object)"LilyLog: Missing AudioClip!"); return; } GameObject val = new GameObject("TempAudioSource"); val.transform.position = position; AudioSource val2 = val.AddComponent<AudioSource>(); val2.volume = 1f; val2.spatialBlend = 1f; val2.rolloffMode = (AudioRolloffMode)0; val2.bypassEffects = true; val2.bypassListenerEffects = true; val2.bypassReverbZones = true; val2.PlayOneShot(clip); Object.Destroy((Object)(object)val, clip.length + 0.1f); } } internal class Lily_PlayerRealmScript : MonoBehaviour { public bool isInRealm = false; } internal class Lily_ProjectileScript : MonoBehaviour { public PlayerControllerB player; public GameObject Item; public Vector3 initialDirection = Vector3.forward; public float initialSpeed = 12f; public float maxGravity = 9.8f; public float gravityRampUpTime = 1.5f; public float acceleration = 2f; private Vector3 velocity; private float timeAlive; private Rigidbody rb; private bool isTeleportInvalid = false; private void Start() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) rb = ((Component)this).GetComponent<Rigidbody>(); rb.useGravity = false; rb.isKinematic = false; rb.interpolation = (RigidbodyInterpolation)1; rb.collisionDetectionMode = (CollisionDetectionMode)2; velocity = ((Vector3)(ref initialDirection)).normalized * initialSpeed; Object.Destroy((Object)(object)((Component)this).gameObject, 15f); } private void FixedUpdate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0088: Unknown result type (might be due to invalid IL or missing references) timeAlive += Time.fixedDeltaTime; velocity += ((Vector3)(ref initialDirection)).normalized * acceleration * Time.fixedDeltaTime; float num = Mathf.Clamp01(timeAlive / gravityRampUpTime); float num2 = Mathf.Lerp(0f, maxGravity, num * num); velocity.y -= num2 * Time.fixedDeltaTime; rb.velocity = velocity; } private void OnCollisionEnter(Collision collision) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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) if ((Object)(object)player != (Object)null || isTeleportInvalid) { AudioSource component = Item.GetComponent<AudioSource>(); LilyLanternScript component2 = Item.GetComponent<LilyLanternScript>(); ContactPoint val = collision.contacts[0]; Vector3 point = ((ContactPoint)(ref val)).point; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, -0.1f, 0f); Vector3 val3 = point; Debug.Log((object)("LilyLog: Collision Point " + ((object)(Vector3)(ref val3)).ToString())); val3 = ((Component)this).gameObject.transform.position; Debug.Log((object)("LilyLog: GameObject Center " + ((object)(Vector3)(ref val3)).ToString())); Vector3 val4; if (Physics.Raycast(((Component)this).gameObject.transform.position + val2, Vector3.up, 1.25f, -1, (QueryTriggerInteraction)1)) { val3 = point; Debug.Log((object)("LilyLog: Ceiling detected" + ((object)(Vector3)(ref val3)).ToString())); if (Physics.Raycast(((Component)this).gameObject.transform.position + val2, Vector3.down, 1f, -1, (QueryTriggerInteraction)1)) { Debug.Log((object)"LilyLog: The final teleport position was deemed invalid"); component.PlayOneShot(component2.lilyLanternError); isTeleportInvalid = true; Object.Destroy((Object)(object)((Component)this).gameObject); return; } val4 = ((Component)this).gameObject.transform.position + Vector3.down; } else { val4 = ((Component)this).gameObject.transform.position + new Vector3(0f, 0.2f, 0f); } val3 = rb.velocity; Vector3 normalized = ((Vector3)(ref val3)).normalized; Vector3 val5 = -normalized; val5.y = 0f; val5 = ((Vector3)(ref val5)).normalized; float num = 0.2f; val4 += val5 * num; val3 = val4; Debug.Log((object)("LilyLog: Teleporting player to " + ((object)(Vector3)(ref val3)).ToString())); player.TeleportPlayer(val4, false, 0f, false, true); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component.Stop(); component.PlayOneShot(component2.lilyLanternTeleportOutside); } else { Debug.LogWarning((object)"LilyLog: AudioSource or LilyLanternScript is null"); } } Object.Destroy((Object)(object)((Component)this).gameObject); } } } namespace Lily.Patches { [HarmonyPatch(typeof(EntranceTeleport))] internal class EntranceTeleportPlayer_Patch { [HarmonyPrefix] [HarmonyPatch("TeleportPlayer")] public static bool EntranceTeleportPlayerPatch() { if (!Object.op_Implicit((Object)(object)((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<Lily_PlayerRealmScript>()) || ((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<Lily_PlayerRealmScript>().isInRealm) { Debug.Log((object)"LilyLog: Teleport Failed"); return false; } return true; } } [HarmonyPatch(typeof(StartOfRound))] internal class OpeningDoorsSequence_Patch { [CompilerGenerated] private sealed class <openingDoorsSequencePatch>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; private string <sceneName>5__1; private Scene <currentScene>5__2; private Vector3 <bonusCoord>5__3; private GameObject <levelGeneration>5__4; private GameObject[] <sceneObjects>5__5; private Vector3 <originCoord>5__6; private Quaternion <originRot>5__7; private Vector3 <finalCoord>5__8; private int <realmLights>5__9; private GameObject[] <>s__10; private int <>s__11; private GameObject <obj>5__12; private Vector3 <originCoord>5__13; private Quaternion <originRot>5__14; private Vector3 <finalCoord>5__15; private GameObject <door>5__16; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <openingDoorsSequencePatch>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <sceneName>5__1 = null; <levelGeneration>5__4 = null; <sceneObjects>5__5 = null; <>s__10 = null; <obj>5__12 = null; <door>5__16 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; <sceneName>5__1 = StartOfRound.Instance.currentLevel.sceneName; <currentScene>5__2 = SceneManager.GetSceneByName(<sceneName>5__1); <bonusCoord>5__3 = new Vector3(0f, 0f, -5000f); <levelGeneration>5__4 = GameObject.Find("/Systems/LevelGeneration/LevelGenerationRoot"); if (((Object)<levelGeneration>5__4).name == "LevelGenerationRoot") { <originCoord>5__6 = <levelGeneration>5__4.transform.position; <originRot>5__7 = <levelGeneration>5__4.transform.rotation; <finalCoord>5__8 = <originCoord>5__6 + <bonusCoord>5__3; RealmInsideLevel = Object.Instantiate<GameObject>(<levelGeneration>5__4, <finalCoord>5__8, <originRot>5__7); SceneManager.MoveGameObjectToScene(RealmInsideLevel, <currentScene>5__2); if (Plugin.cullFactory) { RemoveComponentInChildren(RealmInsideLevel, "CullingVisualizer"); RemoveComponentInChildren(RealmInsideLevel, "PortalOcclusionCuller"); RemoveComponentInChildren(RealmInsideLevel, "DepthCuller"); } <realmLights>5__9 = (LilyConfigs.LilyRealmLights ? 1 : 0); EnableLights(RealmInsideLevel, <realmLights>5__9); } <sceneObjects>5__5 = ((Scene)(ref <currentScene>5__2)).GetRootGameObjects(); <>s__10 = <sceneObjects>5__5; for (<>s__11 = 0; <>s__11 < <>s__10.Length; <>s__11++) { <obj>5__12 = <>s__10[<>s__11]; if (((Object)<obj>5__12).name.Contains("EntranceTeleport") || (Object)(object)<obj>5__12.GetComponent<EntranceTeleport>() != (Object)null) { <originCoord>5__13 = <obj>5__12.transform.position; <originRot>5__14 = <obj>5__12.transform.rotation; <finalCoord>5__15 = <originCoord>5__13 + <bonusCoord>5__3; <door>5__16 = Object.Instantiate<GameObject>(<obj>5__12, <finalCoord>5__15, <originRot>5__14); try { Object.Destroy((Object)(object)<door>5__16.GetComponent<EntranceTeleport>()); Object.Destroy((Object)(object)<door>5__16.GetComponent<InteractTrigger>()); SceneManager.MoveGameObjectToScene(<door>5__16, <currentScene>5__2); } catch { Debug.Log((object)("LilyLog: Door Components Error" + (object)<door>5__16)); } <door>5__16 = null; } <obj>5__12 = null; } <>s__10 = null; break; case 2: <>1__state = -1; break; } if (result.MoveNext()) { <>2__current = result.Current; <>1__state = 2; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static GameObject RealmInsideLevel; [IteratorStateMachine(typeof(<openingDoorsSequencePatch>d__1))] [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")] private static IEnumerator openingDoorsSequencePatch(IEnumerator result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <openingDoorsSequencePatch>d__1(0) { result = result }; } private static void RemoveComponentInChildren(GameObject root, string componentName) { try { Component[] componentsInChildren = root.GetComponentsInChildren<Component>(true); Component[] array = componentsInChildren; foreach (Component val in array) { if (((object)val).GetType().Name == componentName) { Object.Destroy((Object)(object)val); } } } catch { Debug.Log((object)("CLilyLog: omponents with the name " + componentName + " Error")); } } private static void EnableLights(GameObject root, int flag) { try { Light[] componentsInChildren = root.GetComponentsInChildren<Light>(true); Light[] array = componentsInChildren; foreach (Light val in array) { if (val.cullingMask != flag) { val.cullingMask = flag; } } } catch { Debug.Log((object)"LilyLog: Lights Error"); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBTeleportPlayer_Patch { [HarmonyPrefix] [HarmonyPatch("TeleportPlayer")] public static bool PlayerControllerBTeleportPlayerPatch(PlayerControllerB __instance) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<Lily_PlayerRealmScript>()) || ((Component)__instance).GetComponent<Lily_PlayerRealmScript>().isInRealm) { Debug.Log((object)"LilyLog: Teleport Failed"); return false; } return true; } } [HarmonyPatch(typeof(ShipTeleporter))] internal class PressTeleportButtonOnLocalClient_Patch { [HarmonyPrefix] [HarmonyPatch("PressTeleportButtonOnLocalClient")] public static bool PressTeleportButtonOnLocalClientPatch() { if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.mapScreen.targetedPlayer)) { PlayerControllerB targetedPlayer = StartOfRound.Instance.mapScreen.targetedPlayer; if (!Object.op_Implicit((Object)(object)((Component)targetedPlayer).GetComponent<Lily_PlayerRealmScript>()) || ((Component)targetedPlayer).GetComponent<Lily_PlayerRealmScript>().isInRealm) { Debug.Log((object)"LilyLog: Teleport Failed"); return false; } } return true; } } [HarmonyPatch(typeof(PlayerControllerB))] internal class Start_Patch { [HarmonyPostfix] [HarmonyPatch("Start")] public static void StartPatch() { List<PlayerControllerB> list = (from PlayerControllerB e in Resources.FindObjectsOfTypeAll(typeof(PlayerControllerB)) where (Object)(object)e != (Object)null select e).ToList(); foreach (PlayerControllerB item in list) { if ((Object)(object)((Component)item).GetComponent<Lily_PlayerRealmScript>() == (Object)null) { ((Component)item).gameObject.AddComponent<Lily_PlayerRealmScript>(); } } } } } namespace Lily.Config { internal class LilyConfigs { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequestSync; public static HandleNamedMessageDelegate <1>__OnReceiveSync; } private const int byteDim = 4; private const int byteDimConfig = 17; private static int LilySpawnRateLocal = 10; private static float LilyCooldownLocal = 5f; private static float LilyRealmTimeLocal = 3f; private static float LilyBatteryUsageLocal = 0.34f; private static bool LilyRealmLightsLocal = true; public static int LilySpawnRate = 10; public static float LilyCooldown = 5f; public static float LilyRealmTime = 3f; public static float LilyBatteryUsage = 0.34f; public static bool LilyRealmLights = true; private static void SetValues(int SpawnRate, float Cooldown, float RealmTime, float BatteryUsage, bool RealmLights) { LilySpawnRate = SpawnRate; LilyCooldown = Cooldown; LilyRealmTime = RealmTime; LilyBatteryUsage = BatteryUsage; LilyRealmLights = RealmLights; } private static void SetToLocalValues() { SetValues(LilySpawnRateLocal, LilyCooldownLocal, LilyRealmTimeLocal, LilyBatteryUsageLocal, LilyRealmLightsLocal); } public static void LoadConfig(ConfigFile config) { LilySpawnRateLocal = Math.Clamp(config.Bind<int>("General", "LilySpawnRate", 10, "Sets Lily spawn rate, the higher the value, the more common it will be (recommended to keep it between 5 and 40).").Value, 0, 9999); LilyCooldownLocal = Mathf.Clamp(config.Bind<int>("General", "LilyCooldown", 5, "Sets Lily cooldown.").Value, 0, 9999); LilyRealmTimeLocal = Mathf.Clamp(config.Bind<int>("General", "LilyRealmTime", 3, "Sets Lily realm time.").Value, 0, 9999); LilyBatteryUsageLocal = Mathf.Clamp(config.Bind<float>("General", "LilyBatteryUsage", 0.34f, "Sets Lily battery usage (in the case of the default value it removes 34% of the battery with each use).").Value, 0f, 9999f); LilyRealmLightsLocal = config.Bind<bool>("General", "LilyRealmLight", true, "Sets the Realm Lights. If FALSE the realm will be without any form of light sourses (Very Dark).").Value; SetToLocalValues(); } public static byte[] GetSettings() { byte[] array = new byte[17] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Array.Copy(BitConverter.GetBytes(LilySpawnRateLocal), 0, array, 1, 4); Array.Copy(BitConverter.GetBytes(LilyCooldownLocal), 0, array, 5, 4); Array.Copy(BitConverter.GetBytes(LilyRealmTimeLocal), 0, array, 9, 4); Array.Copy(BitConverter.GetBytes(LilyBatteryUsageLocal), 0, array, 13, 4); Array.Copy(BitConverter.GetBytes(LilyRealmLightsLocal), 0, array, 14, 1); return array; } public static void SetSettings(byte[] data) { byte b = data[0]; byte b2 = b; if (b2 == 1) { LilySpawnRate = BitConverter.ToInt32(data, 1); LilyCooldown = BitConverter.ToSingle(data, 5); LilyRealmTime = BitConverter.ToSingle(data, 9); LilyBatteryUsage = BitConverter.ToSingle(data, 13); LilyRealmLights = BitConverter.ToBoolean(data, 14); Debug.Log((object)"LilyLog: Host config set successfully"); return; } throw new Exception("LilyLog: Invalid version byte"); } private static bool IsHost() { return NetworkManager.Singleton.IsHost; } public static void OnRequestSync(ulong clientID, FastBufferReader reader) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!IsHost()) { return; } Debug.Log((object)("LilyLog: Sending config to client " + clientID)); byte[] settings = GetSettings(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(settings.Length, (Allocator)2, settings.Length); try { ((FastBufferWriter)(ref val)).WriteBytes(settings, -1, 0); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Lily_OnReceiveConfigSync", clientID, val, (NetworkDelivery)2); } catch (Exception ex) { Debug.LogError((object)("LilyLog: Failed to send config: " + ex)); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } public static void OnReceiveSync(ulong clientID, FastBufferReader reader) { Debug.Log((object)"LilyLog: Received config from host"); byte[] settings = new byte[17]; try { ((FastBufferReader)(ref reader)).ReadBytes(ref settings, 17, 0); SetSettings(settings); } catch (Exception ex) { Debug.LogError((object)("LilyLog: Failed to receive config: " + ex)); SetToLocalValues(); } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] private static void ServerConnect() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if (IsHost()) { Debug.Log((object)"LilyLog: Started hosting, using local settings"); SetToLocalValues(); CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>O.<0>__OnRequestSync; if (obj == null) { HandleNamedMessageDelegate val = OnRequestSync; <>O.<0>__OnRequestSync = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("Lily_OnRequestConfigSync", (HandleNamedMessageDelegate)obj); return; } Debug.Log((object)"LilyLog: Connected to server, requesting settings"); CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager; object obj2 = <>O.<1>__OnReceiveSync; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnReceiveSync; <>O.<1>__OnReceiveSync = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("Lily_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2); FastBufferWriter val3 = default(FastBufferWriter); ((FastBufferWriter)(ref val3))..ctor(17, (Allocator)2, -1); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Lily_OnRequestConfigSync", 0uL, val3, (NetworkDelivery)2); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")] private static void ServerDisconnect() { Debug.Log((object)"LilyLog: Server disconnect"); SetToLocalValues(); } } }