using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using SideLoader;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("brokenruune.wisplantern", "Wisp Lantern", "1.0.1")]
public sealed class WispLantern : BaseUnityPlugin
{
internal sealed class Part
{
internal Mesh Mesh;
internal int Material;
internal int Group;
}
internal const int BlueId = -847511;
internal const int WhiteId = -847512;
internal const int PrismId = -847513;
private const int Price = 1500;
private static readonly int[] ItemIds = new int[3] { -847511, -847512, -847513 };
private static ConfigEntry<string> seeded;
private static HashSet<string> seededShops;
private Harmony harmony;
internal static Texture2D HaloTexture;
internal static Mesh HaloMesh;
private static readonly Dictionary<int, Sprite> Icons = new Dictionary<int, Sprite>();
internal static readonly List<Part> Parts = new List<Part>();
private static bool IsWisp(int id)
{
return Array.IndexOf(ItemIds, id) >= 0;
}
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Expected O, but got Unknown
//IL_0414: Unknown result type (might be due to invalid IL or missing references)
//IL_041e: Expected O, but got Unknown
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
LoadModel();
Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
((Object)val).name = "Wisp glow";
((Texture)val).wrapMode = (TextureWrapMode)1;
HaloTexture = val;
Color32[] array = (Color32[])(object)new Color32[4096];
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
float num = ((float)j + 0.5f) * 2f / 64f - 1f;
float num2 = ((float)i + 0.5f) * 2f / 64f - 1f;
float num3 = Mathf.Clamp01(1f - num * num - num2 * num2);
ref Color32 reference = ref array[i * 64 + j];
reference = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(255f * num3 * num3 * num3));
}
}
HaloTexture.SetPixels32(array);
HaloTexture.Apply(false, true);
Mesh val2 = new Mesh();
((Object)val2).name = "Wisp glow quad";
HaloMesh = val2;
HaloMesh.vertices = (Vector3[])(object)new Vector3[4]
{
new Vector3(-0.5f, -0.5f, 0f),
new Vector3(0.5f, -0.5f, 0f),
new Vector3(0.5f, 0.5f, 0f),
new Vector3(-0.5f, 0.5f, 0f)
};
HaloMesh.uv = (Vector2[])(object)new Vector2[4]
{
Vector2.zero,
Vector2.right,
Vector2.one,
Vector2.up
};
HaloMesh.colors32 = (Color32[])(object)new Color32[4]
{
new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue),
new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue),
new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue),
new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)
};
HaloMesh.triangles = new int[6] { 0, 2, 1, 0, 3, 2 };
int[] itemIds = ItemIds;
foreach (int num4 in itemIds)
{
Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, false);
using (Stream stream = typeof(WispLantern).Assembly.GetManifestResourceStream("WispIcon" + num4))
{
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
if (!ImageConversion.LoadImage(val3, memoryStream.ToArray(), true))
{
throw new InvalidDataException("Wisp icon " + num4);
}
}
Icons.Add(num4, Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0));
}
seeded = ((BaseUnityPlugin)this).Config.Bind<string>("Merchants", "SeededStock", "", "Saves and shops that received the initial stock.");
seededShops = new HashSet<string>(seeded.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
harmony = new Harmony("brokenruune.wisplantern");
harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("SideLoader.CustomItemVisuals"), "CloneAndSetVisuals", (Type[])null, (Type[])null), (HarmonyMethod)null, Hook("AfterClone"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemLanternVisual), "SetLinkedItem", new Type[1] { typeof(Item) }, (Type[])null), (HarmonyMethod)null, Hook("AfterLink"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemLanternVisual), "Update", Type.EmptyTypes, (Type[])null), (HarmonyMethod)null, Hook("RefreshBinding"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemLanternVisual), "Light", new Type[2]
{
typeof(bool),
typeof(bool)
}, (Type[])null), (HarmonyMethod)null, Hook("AfterLight"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(ResourcesPrefabManager), "GetItemIcon", new Type[1] { typeof(Item) }, (Type[])null), Hook("UseIcon", 800), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(Item), "GetBuyValue", new Type[3]
{
typeof(Character),
typeof(Merchant),
typeof(bool)
}, (Type[])null), (HarmonyMethod)null, Hook("SetPrice"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(MerchantPouch), "RefreshInventory", new Type[1] { typeof(Dropable) }, (Type[])null), Hook("BeforeRestock"), Hook("AfterRestock"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(Merchant), "OnReceiveConfirmStartShopping", new Type[2]
{
typeof(bool),
typeof(Character)
}, (Type[])null), Hook("SeedShop"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Wisp Lantern variants registered: " + string.Join(", ", ItemIds) + "."));
}
private static HarmonyMethod Hook(string name, int priority = 0)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
HarmonyMethod val = new HarmonyMethod(typeof(WispLantern), name, (Type[])null);
val.priority = priority;
return val;
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private static void LoadModel()
{
//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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
using Stream stream = typeof(WispLantern).Assembly.GetManifestResourceStream("WispMesh");
using BinaryReader binaryReader = new BinaryReader(stream);
int num = binaryReader.ReadInt32();
for (int i = 0; i < num; i++)
{
int num2 = binaryReader.ReadInt32();
int num3 = binaryReader.ReadInt32();
Vector3[] array = (Vector3[])(object)new Vector3[binaryReader.ReadInt32()];
int[] array2 = new int[binaryReader.ReadInt32()];
Vector3[] array3 = (Vector3[])(object)new Vector3[array.Length];
for (int j = 0; j < array.Length; j++)
{
ref Vector3 reference = ref array[j];
reference = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
ref Vector3 reference2 = ref array3[j];
reference2 = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
}
for (int k = 0; k < array2.Length; k++)
{
array2[k] = binaryReader.ReadInt32();
}
Mesh val = new Mesh();
((Object)val).name = "Wisp " + i;
val.vertices = array;
val.normals = array3;
Mesh val2 = val;
val2.uv = (Vector2[])(object)new Vector2[array.Length];
Color32[] array4 = (Color32[])(object)new Color32[array.Length];
float num4 = 0f;
if (num2 == 1)
{
Vector3[] array5 = array;
for (int l = 0; l < array5.Length; l++)
{
Vector3 val3 = array5[l];
num4 = Mathf.Max(num4, 0f - val3.z);
}
}
for (int m = 0; m < array.Length; m++)
{
float num5 = ((num2 == 0) ? 1f : (1f - Mathf.Clamp01((0f - array[m].z) / num4)));
ref Color32 reference3 = ref array4[m];
reference3 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(255f * num5));
}
val2.colors32 = array4;
val2.SetTriangles(array2, 0, true);
Parts.Add(new Part
{
Mesh = val2,
Material = num2,
Group = num3
});
}
if (stream.Position != stream.Length)
{
throw new InvalidDataException("Unexpected Wisp mesh data.");
}
}
private static void AfterClone(Item __0, GameObject __1, GameObject __result)
{
if (Object.op_Implicit((Object)(object)__0) && IsWisp(__0.ItemID) && Object.op_Implicit((Object)(object)__result) && !((Object)(object)__result == (Object)(object)__1))
{
((Object)__result).name = __0.ItemID + "_WispLantern_v";
}
}
private static void AfterLink(ItemLanternVisual __instance, Item __0)
{
WispFloat wispFloat = ((Component)__instance).GetComponent<WispFloat>();
if (!Object.op_Implicit((Object)(object)__0) || !IsWisp(__0.ItemID))
{
if (Object.op_Implicit((Object)(object)wispFloat))
{
wispFloat.Unbind();
}
return;
}
if (!Object.op_Implicit((Object)(object)wispFloat))
{
wispFloat = ((Component)__instance).gameObject.AddComponent<WispFloat>();
}
wispFloat.Bind(__instance, __0);
}
private static void RefreshBinding(ItemLanternVisual __instance, Item ___m_item)
{
WispFloat component = ((Component)__instance).GetComponent<WispFloat>();
if (!Object.op_Implicit((Object)(object)___m_item) || !IsWisp(___m_item.ItemID))
{
if (Object.op_Implicit((Object)(object)component) && component.HasBinding)
{
component.Unbind();
}
}
else if (!Object.op_Implicit((Object)(object)component) || !component.IsBoundTo(__instance, ___m_item))
{
AfterLink(__instance, ___m_item);
}
}
private static void AfterLight(ItemLanternVisual __instance, bool __0)
{
WispFloat component = ((Component)__instance).GetComponent<WispFloat>();
if (Object.op_Implicit((Object)(object)component))
{
component.SetLit(__0);
}
}
private static bool UseIcon(Item __0, ref Sprite __result)
{
if (!Object.op_Implicit((Object)(object)__0) || !IsWisp(__0.ItemID))
{
return true;
}
__result = Icons[__0.ItemID];
return false;
}
private static bool IsGeneralStore(Merchant merchant)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)merchant))
{
return false;
}
string text = UID.op_Implicit(merchant.HolderUID);
Scene scene = ((Component)merchant).gameObject.scene;
switch (((Scene)(ref scene)).name)
{
case "CierzoNewTerrain":
return text == "jFw7BReLDkW6NT5msHloig";
case "Berg":
case "Monsoon":
return text == "FU5328pcz025ME9tVRYP7g";
case "Levant":
if (!(text == "FU5328pcz025ME9tVRYP7g"))
{
return text == "6fSS8CIi70WgslppPjI54w";
}
return true;
case "Harmattan":
if (!(text == "i55dlUkx-Eqz9tpYmtRiyQ") && !(text == "PMWNwz0r30SMRb-kx3WavA"))
{
return text == "L6BrQy5mF0uaMWE0FEpiVg";
}
return true;
case "NewSirocco":
{
if (text == "9AIXwwQGCkuX3T0ZOCSbfQ")
{
return true;
}
Transform val = ((Component)merchant).transform;
while (Object.op_Implicit((Object)(object)val))
{
if (((Object)val).name == "GeneralMerchant_Dialogue")
{
return true;
}
val = val.parent;
}
return false;
}
default:
return false;
}
}
private static void SetPrice(Item __instance, Character __0, Merchant __1, bool __2, ref int __result)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (IsWisp(__instance.ItemID) && IsGeneralStore(__1) && (__2 || !Object.op_Implicit((Object)(object)__0) || !(EnvironmentConditions.GameTime < __instance.RebuyLimitTime) || !(__instance.PreviousOwnerUID == UID.op_Implicit(__0.UID))))
{
__result = 1500;
}
}
private static void BeforeRestock(MerchantPouch __instance, double ___m_nextRefreshTime, out bool __state)
{
__state = !PhotonNetwork.isNonMasterClientInRoom && EnvironmentConditions.GameTime >= ___m_nextRefreshTime && IsGeneralStore(__instance.Merchant);
}
private static void AfterRestock(MerchantPouch __instance, bool __state)
{
if (__state)
{
int[] itemIds = ItemIds;
foreach (int id in itemIds)
{
EnsureStock(__instance, id);
}
}
}
private static bool EnsureStock(MerchantPouch pouch, int id)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if (HasStock(pouch, id))
{
return true;
}
if (!Object.op_Implicit((Object)(object)ResourcesPrefabManager.Instance.GetItemPrefab(id)))
{
return false;
}
SL_ItemDrop val = new SL_ItemDrop();
val.DroppedItemID = id;
val.MinQty = 1;
val.MaxQty = 1;
val.GenerateDrop(((Component)pouch).transform);
return HasStock(pouch, id);
}
private static bool HasStock(MerchantPouch pouch, int id)
{
return ((ItemContainer)pouch).GetItemsFromID(id).Exists((Item item) => Object.op_Implicit((Object)(object)item) && !item.IsPendingDestroy);
}
private static void SeedShop(Merchant __instance, bool __0, Character __1)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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)
if (!__0 || !Object.op_Implicit((Object)(object)__1) || PhotonNetwork.isNonMasterClientInRoom || !IsGeneralStore(__instance))
{
return;
}
ItemContainer merchantPouch = __instance.MerchantPouch;
MerchantPouch val = (MerchantPouch)(object)((merchantPouch is MerchantPouch) ? merchantPouch : null);
Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)worldHostCharacter))
{
return;
}
string[] array = new string[5]
{
UID.op_Implicit(worldHostCharacter.UID),
":",
null,
null,
null
};
Scene scene = ((Component)__instance).gameObject.scene;
array[2] = ((Scene)(ref scene)).name;
array[3] = ":";
array[4] = UID.op_Implicit(__instance.HolderUID);
string text = string.Concat(array);
bool flag = false;
int[] itemIds = ItemIds;
foreach (int num in itemIds)
{
string item = text + ":" + num;
if (!seededShops.Contains(item) && EnsureStock(val, num))
{
flag |= seededShops.Add(item);
}
}
if (flag)
{
seeded.Value = string.Join(",", seededShops);
}
}
}
[DefaultExecutionOrder(2000)]
public sealed class WispFloat : MonoBehaviour
{
private sealed class TailFilament
{
internal readonly Mesh Mesh;
private readonly Vector3[] rest;
private readonly Vector3[] animated;
private readonly float[] distance;
private readonly float offset;
internal TailFilament(Mesh source, int strand)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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)
//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_00bc: 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)
Mesh = Object.Instantiate<Mesh>(source);
Mesh.MarkDynamic();
rest = source.vertices;
animated = (Vector3[])(object)new Vector3[rest.Length];
distance = new float[rest.Length];
Bounds bounds = source.bounds;
float num = 0f - ((Bounds)(ref bounds)).min.z;
for (int i = 0; i < rest.Length; i++)
{
distance[i] = Mathf.Clamp01((0f - rest[i].z - 0.012f) / (num - 0.012f));
}
Bounds bounds2 = source.bounds;
((Bounds)(ref bounds2)).Expand(new Vector3(0.14f, 0.1f, 0f));
Mesh.bounds = bounds2;
offset = (float)strand * 0.55f;
}
internal void Curl(float time)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_007e: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < rest.Length; i++)
{
float num = distance[i];
float num2 = time - num * 7.2f + offset;
float num3 = num * num;
Vector3 val = rest[i];
val.x += num3 * 0.062f * Mathf.Sin(num2);
val.y += num3 * 0.042f * Mathf.Cos(num2);
animated[i] = val;
}
Mesh.SetVertices(animated, 0, animated.Length, (MeshUpdateFlags)8);
}
}
private Item item;
private Light lanternLight;
private Vector3 stockLightPosition;
private Color stockLightColor;
private Renderer[] stockRenderers;
private bool[] stockVisibility;
private GameObject wisp;
private readonly List<TailFilament> tail = new List<TailFilament>();
private Material core;
private Material vapor;
private Material haloMaterial;
private Transform orb;
private Transform halo;
private float time;
internal bool HasBinding => !object.ReferenceEquals(item, null);
internal bool IsBoundTo(ItemLanternVisual visual, Item linked)
{
if ((Object)(object)item == (Object)(object)linked)
{
return (Object)(object)lanternLight == (Object)(object)visual.LanternLight;
}
return false;
}
internal void Bind(ItemLanternVisual visual, Item linked)
{
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Invalid comparison between Unknown and I4
//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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
if (!IsBoundTo(visual, linked))
{
Unbind();
item = linked;
lanternLight = visual.LanternLight;
stockRenderers = ((Component)visual).GetComponentsInChildren<Renderer>(true);
stockVisibility = new bool[stockRenderers.Length];
for (int i = 0; i < stockRenderers.Length; i++)
{
stockVisibility[i] = stockRenderers[i].forceRenderingOff;
stockRenderers[i].forceRenderingOff = true;
}
if (Object.op_Implicit((Object)(object)lanternLight))
{
stockLightPosition = ((Component)lanternLight).transform.localPosition;
stockLightColor = lanternLight.color;
}
}
SetLit((int)linked.LitStatus == 1);
}
internal void SetLit(bool active)
{
if (HasBinding && !active)
{
OnDisable();
}
}
private void LateUpdate()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: 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_01af: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: 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_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)item) || (int)item.LitStatus != 1 || !Object.op_Implicit((Object)(object)lanternLight))
{
OnDisable();
return;
}
if (!Object.op_Implicit((Object)(object)wisp))
{
BuildWisp();
}
Character val = null;
if (item.DisplayedOnBag && Object.op_Implicit((Object)(object)item.ParentContainer))
{
Bag refBag = item.ParentContainer.RefBag;
if (Object.op_Implicit((Object)(object)refBag) && ((Item)refBag).IsEquipped)
{
val = ((EffectSynchronizer)refBag).OwnerCharacter;
}
}
else if (item.IsEquipped)
{
val = ((EffectSynchronizer)item).OwnerCharacter;
}
time += Time.deltaTime;
float num = time * (float)Math.PI * 2f;
float num2 = 0.012f * Mathf.Sin(num / 2.6f);
Vector3 val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).transform.forward : ((Component)this).transform.forward);
val2.y = 0f;
if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
{
val2 = Vector3.forward;
}
((Vector3)(ref val2)).Normalize();
Vector3 val3 = (Object.op_Implicit((Object)(object)val) ? (((Component)val).transform.position + Vector3.up * (2.04f + num2) + val2 * 0.18f + Vector3.Cross(Vector3.up, val2) * 0.4f) : (((Component)this).transform.position + Vector3.up * (0.18f + num2)));
wisp.transform.SetPositionAndRotation(val3, Quaternion.LookRotation(val2, Vector3.up));
foreach (TailFilament item in tail)
{
item.Curl(num / 1.65f);
}
Color val4 = Color.white;
Color color = Color.white;
if (this.item.ItemID == -847511)
{
((Color)(ref val4))..ctor(0.045f, 0.32f, 0.9f);
color = Color.Lerp(val4, Color.white, 0.65f);
}
else if (this.item.ItemID == -847513)
{
float num3 = Mathf.Repeat(time, 72f) / 72f;
float num4 = 0.94f + 0.06f * Mathf.Cos(num / 6f);
val4 = (color = Color.HSVToRGB(num3, 0.67f, 1f) * num4);
}
float num5 = 0.5f + 0.5f * Mathf.Sin(num / 3.2f);
orb.localScale = Vector3.one * (0.92f + 0.16f * num5);
float num6 = 0.55f + 0.45f * num5;
core.color = new Color(val4.r * num6, val4.g * num6, val4.b * num6, 1f);
Camera main = Camera.main;
if (Object.op_Implicit((Object)(object)main))
{
halo.rotation = ((Component)main).transform.rotation;
}
halo.localScale = Vector3.one * (0.084f + 0.048f * num5);
haloMaterial.color = new Color(val4.r, val4.g, val4.b, 0.28f + 0.56f * num5);
vapor.color = new Color(val4.r, val4.g, val4.b, 0.53f);
((Component)lanternLight).transform.position = val3;
lanternLight.color = color;
((Behaviour)lanternLight).enabled = true;
if (!wisp.activeSelf)
{
wisp.SetActive(true);
}
}
private void BuildWisp()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
wisp = new GameObject("Wisp Lantern");
wisp.SetActive(false);
Material val = new Material(Shader.Find("Sprites/Default"));
((Object)val).name = "Wisp core";
core = val;
Material val2 = new Material(Shader.Find("Sprites/Default"));
((Object)val2).name = "Wisp tail";
vapor = val2;
GameObject val3 = new GameObject("Soft orb glow");
val3.AddComponent<MeshFilter>().sharedMesh = WispLantern.HaloMesh;
halo = val3.transform;
halo.SetParent(wisp.transform, false);
Material val4 = new Material(Shader.Find("Sprites/Default"));
((Object)val4).name = "Wisp halo";
haloMaterial = val4;
haloMaterial.mainTexture = (Texture)(object)WispLantern.HaloTexture;
MeshRenderer val5 = val3.AddComponent<MeshRenderer>();
((Renderer)val5).sharedMaterial = haloMaterial;
((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val5).receiveShadows = false;
foreach (WispLantern.Part part in WispLantern.Parts)
{
GameObject val6 = new GameObject((part.Group == 0) ? "Orb" : "Tail filament");
val6.transform.SetParent(wisp.transform, false);
MeshFilter val7 = val6.AddComponent<MeshFilter>();
if (part.Group > 0)
{
TailFilament tailFilament = new TailFilament(part.Mesh, part.Group - 1);
tail.Add(tailFilament);
val7.sharedMesh = tailFilament.Mesh;
}
else
{
orb = val6.transform;
val7.sharedMesh = part.Mesh;
}
MeshRenderer val8 = val6.AddComponent<MeshRenderer>();
((Renderer)val8).sharedMaterial = ((part.Material == 0) ? core : vapor);
((Renderer)val8).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val8).receiveShadows = false;
}
}
private void OnDisable()
{
if (Object.op_Implicit((Object)(object)wisp))
{
wisp.SetActive(false);
}
}
internal void Unbind()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
OnDisable();
if (Object.op_Implicit((Object)(object)lanternLight))
{
((Component)lanternLight).transform.localPosition = stockLightPosition;
lanternLight.color = stockLightColor;
}
if (stockRenderers != null)
{
for (int i = 0; i < stockRenderers.Length; i++)
{
if (Object.op_Implicit((Object)(object)stockRenderers[i]))
{
stockRenderers[i].forceRenderingOff = stockVisibility[i];
}
}
}
stockRenderers = null;
stockVisibility = null;
item = null;
lanternLight = null;
}
private void OnDestroy()
{
Unbind();
if (Object.op_Implicit((Object)(object)wisp))
{
Object.Destroy((Object)(object)wisp);
}
if (Object.op_Implicit((Object)(object)core))
{
Object.Destroy((Object)(object)core);
}
if (Object.op_Implicit((Object)(object)vapor))
{
Object.Destroy((Object)(object)vapor);
}
foreach (TailFilament item in tail)
{
Object.Destroy((Object)(object)item.Mesh);
}
if (Object.op_Implicit((Object)(object)haloMaterial))
{
Object.Destroy((Object)(object)haloMaterial);
}
}
}