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 KingLirArmory v0.1.1
KingLirArmory.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using 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 System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KingLirArmory")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1")] [assembly: AssemblyProduct("KingLirArmory")] [assembly: AssemblyTitle("KingLirArmory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 KingLirArmory { internal class AutoFire : MonoBehaviour { private const float HoldDelay = 0.15f; private const float WaitTimeout = 0.3f; private ItemGun gun; private ItemToggle toggle; private PhysGrabObject grab; private float holdTime; private bool waiting; private float waitStart; private void Awake() { gun = ((Component)this).GetComponent<ItemGun>(); toggle = ((Component)this).GetComponent<ItemToggle>(); grab = ((Component)this).GetComponent<PhysGrabObject>(); } private void Update() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gun == (Object)null || (Object)(object)toggle == (Object)null || (Object)(object)grab == (Object)null) { return; } if (!grab.heldByLocalPlayer || toggle.disabled || (Object)(object)PlayerController.instance == (Object)null || PlayerController.instance.InputDisableTimer > 0f || !SemiFunc.InputHold((InputKey)2)) { holdTime = 0f; waiting = false; return; } holdTime += Time.deltaTime; if (holdTime < 0.15f) { return; } if (waiting) { if ((int)gun.stateCurrent == 0 && !(Time.time - waitStart > 0.3f)) { return; } waiting = false; } if ((int)gun.stateCurrent == 0 && !gun.stateStart) { toggle.ToggleItem(!toggle.toggleState, SemiFunc.PhotonViewIDPlayerAvatarLocal()); waiting = true; waitStart = Time.time; } } } internal class BurstFire : MonoBehaviour { public int shots = 3; public float interval = 0.1f; private ItemGun gun; private ItemBattery battery; private PhotonView view; private Coroutine running; private void Awake() { gun = ((Component)this).GetComponent<ItemGun>(); battery = ((Component)this).GetComponent<ItemBattery>(); view = ((Component)this).GetComponent<PhotonView>(); } internal void Begin() { if (running != null) { ((MonoBehaviour)this).StopCoroutine(running); } running = ((MonoBehaviour)this).StartCoroutine(Fire()); } private IEnumerator Fire() { for (int i = 1; i < shots; i++) { yield return (object)new WaitForSeconds(interval); if ((Object)(object)gun == (Object)null || (Object)(object)battery == (Object)null || battery.batteryLife <= 0f) { break; } if (SemiFunc.IsMultiplayer()) { view.RPC("ShootRPC", (RpcTarget)0, Array.Empty<object>()); } else { gun.ShootRPC(default(PhotonMessageInfo)); } } running = null; } } [HarmonyPatch(typeof(ItemGun), "Shoot")] internal static class BurstFirePatch { [HarmonyPostfix] private static void Postfix(ItemGun __instance, bool __result) { if (__result && SemiFunc.IsMasterClientOrSingleplayer()) { BurstFire component = ((Component)__instance).GetComponent<BurstFire>(); if ((Object)(object)component != (Object)null) { component.Begin(); } } } } internal class CaseBehaviour : MonoBehaviour { private const float SplitY = 30f; private const float HingeZ = -24.7f; private const float LidOpenAngle = -105f; private ItemToggle toggle; private PhotonView pv; private ItemAttributes attrs; private PhysGrabObject pgo; private Transform lid; private bool lastToggle; private bool opened; private float openedAt = -1f; private Prize prize; internal static void SplitLid(GameObject go) { //IL_00b7: 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_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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) Transform val = go.transform.Find("KingLir Model"); MeshFilter val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshFilter>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { Plugin.Log.LogWarning((object)"Vapenlåda: modell saknas, locket delas inte."); return; } Mesh src = val2.sharedMesh; Vector3[] v = src.vertices; Vector3[] n = src.normals; Vector2[] uv = src.uv; int[] tri = src.triangles; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, 30f, -24.7f); Mesh val4 = Part(top: false, Vector3.zero); Mesh val5 = Part(top: true, val3); val2.sharedMesh = val4; GameObject val6 = new GameObject("KingLir Lid") { layer = ((Component)val).gameObject.layer }; val6.transform.SetParent(val, false); val6.transform.localPosition = val3; val6.AddComponent<MeshFilter>().sharedMesh = val5; ((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterials; Plugin.Log.LogInfo((object)$"Vapenlåda: lock {val5.vertexCount / 3} trianglar, stomme {val4.vertexCount / 3}."); Mesh Part(bool top, Vector3 shift) { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_00af: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int> list4 = new List<int>(); for (int i = 0; i < tri.Length; i += 3) { if ((v[tri[i]].y + v[tri[i + 1]].y + v[tri[i + 2]].y) / 3f > 30f == top) { for (int j = 0; j < 3; j++) { int num = tri[i + j]; list4.Add(list.Count); list.Add(v[num] - shift); list2.Add((n.Length > num) ? n[num] : Vector3.up); list3.Add((uv.Length > num) ? uv[num] : Vector2.zero); } } } Mesh val7 = new Mesh { name = ((Object)src).name + (top ? " Lid" : " Body") }; if (list.Count > 65000) { val7.indexFormat = (IndexFormat)1; } val7.SetVertices(list); val7.SetNormals(list2); val7.SetUVs(0, list3); val7.SetTriangles(list4, 0); val7.RecalculateBounds(); return val7; } } private void Start() { toggle = ((Component)this).GetComponent<ItemToggle>(); pv = ((Component)this).GetComponent<PhotonView>(); attrs = ((Component)this).GetComponent<ItemAttributes>(); pgo = ((Component)this).GetComponent<PhysGrabObject>(); lid = ((Component)this).transform.Find("KingLir Model/KingLir Lid"); if ((Object)(object)toggle != (Object)null) { lastToggle = toggle.toggleState; } } private void Update() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (!opened && (Object)(object)toggle != (Object)null && toggle.toggleState != lastToggle) { lastToggle = toggle.toggleState; if (SemiFunc.IsMasterClientOrSingleplayer()) { HostOpen(toggle.playerTogglePhotonID); } } if ((Object)(object)lid != (Object)null && openedAt >= 0f) { float num = Mathf.Clamp01((Time.time - openedAt) / 0.7f); float num2 = 1f + 2.2f * Mathf.Pow(num - 1f, 3f) + 1.2f * Mathf.Pow(num - 1f, 2f); lid.localRotation = Quaternion.Euler(-105f * num2, 0f, 0f); } } private void HostOpen(int opener) { if (SemiFunc.RunIsShop() || RunManager.instance.levelIsShop) { return; } Prize prize = StarterRoll.RandomPrize(); if (prize != null) { opened = true; if (SemiFunc.IsMultiplayer()) { pv.RPC("KingLirCaseOpenRPC", (RpcTarget)0, new object[3] { ((Object)prize.Item).name, prize.Tier, opener }); } else { KingLirCaseOpenRPC(((Object)prize.Item).name, prize.Tier, opener); } } } [PunRPC] private void KingLirCaseOpenRPC(string itemName, int tier, int opener) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) Item val = StarterRoll.ItemOf(itemName); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Vapenlåda: okänt föremål " + itemName)); return; } opened = true; openedAt = Time.time; prize = new Prize { Item = val, Tier = tier }; bool num; if (opener <= 0) { if (!((Object)(object)pgo != (Object)null)) { goto IL_0088; } num = pgo.grabbedLocal; } else { num = opener == SemiFunc.PhotonViewIDPlayerAvatarLocal(); } if (num) { CaseOverlay.Show(prize); } goto IL_0088; IL_0088: new GameObject("KingLir Case Roll").AddComponent<CaseWorldRoll>().Init(((Component)this).transform, prize); Plugin.Log.LogInfo((object)$"Vapenlåda öppnad: {val.itemName} (nivå {tier + 1})"); if (SemiFunc.IsMasterClientOrSingleplayer()) { ((MonoBehaviour)this).StartCoroutine(HostFinish()); } } private IEnumerator HostFinish() { yield return (object)new WaitForSeconds(4.6f + (prize.Golden ? 1.1f : 0f) + 0.4f); ItemSpawn val = new ItemSpawn { prefab = prize.Item.prefab, position = ((Component)this).transform.position + Vector3.up * 0.6f, rotation = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f) }; PunManager.instance.ItemSpawnApply(val); StatsManager.instance.ItemPurchase(((Object)prize.Item).name); yield return (object)new WaitForSeconds(2.5f); if ((Object)(object)attrs != (Object)null && !string.IsNullOrEmpty(attrs.instanceName)) { StatsManager.instance.ItemRemove(attrs.instanceName); } PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); if ((Object)(object)component != (Object)null) { component.DestroyObject(true, false); } else if ((Object)(object)pgo != (Object)null) { pgo.DestroyPhysGrabObject(); } } } internal class CaseWorldRoll : MonoBehaviour { private const int Shown = 4; private const float Spacing = 0.42f; private const float IconWidth = 0.38f; private const int Target = 33; private static readonly Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>(); private static Sprite glowSprite; private Transform chest; private Prize prize; private float start; private readonly SpriteRenderer[] icons = (SpriteRenderer[])(object)new SpriteRenderer[4]; private SpriteRenderer glow; private TextMeshPro mark; private Light light; internal void Init(Transform chestTransform, Prize p) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_004b: 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_0099: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown chest = chestTransform; prize = p; start = Time.time; GameObject val = new GameObject("Glow"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = new Vector3(0f, 0f, 0.02f); glow = val.AddComponent<SpriteRenderer>(); glow.sprite = GlowSprite(); ((Renderer)glow).sortingOrder = 0; for (int i = 0; i < 4; i++) { GameObject val2 = new GameObject("Icon " + i); val2.transform.SetParent(((Component)this).transform, false); icons[i] = val2.AddComponent<SpriteRenderer>(); ((Renderer)icons[i]).sortingOrder = 1; } GameObject val3 = new GameObject("Mark"); val3.transform.SetParent(((Component)this).transform, false); mark = val3.AddComponent<TextMeshPro>(); TextMeshPro[] array = Object.FindObjectsByType<TextMeshPro>((FindObjectsSortMode)0); foreach (TextMeshPro val4 in array) { if ((Object)(object)((TMP_Text)val4).font != (Object)null && (Object)(object)val4 != (Object)(object)mark) { ((TMP_Text)mark).font = ((TMP_Text)val4).font; break; } } ((TMP_Text)mark).text = "?"; ((TMP_Text)mark).fontSize = 3f; ((TMP_Text)mark).alignment = (TextAlignmentOptions)514; ((Graphic)mark).color = new Color(1f, 0.95f, 0.75f); ((Behaviour)mark).enabled = false; GameObject val5 = new GameObject("Light"); val5.transform.SetParent(((Component)this).transform, false); light = val5.AddComponent<Light>(); light.type = (LightType)2; light.range = 4f; light.intensity = 0f; light.shadows = (LightShadows)0; } private static Sprite SpriteOf(Item item) { //IL_004d: 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) if ((Object)(object)item == (Object)null) { return null; } if (sprites.TryGetValue(((Object)item).name, out var value)) { return value; } Texture2D val = GunIcons.Get(item); value = (((Object)(object)val != (Object)null) ? Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width / 0.38f) : null); sprites[((Object)item).name] = value; return value; } private static Sprite GlowSprite() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0042: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)glowSprite != (Object)null) { return glowSprite; } Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { Vector2 val = new Vector2((float)j - 32f + 0.5f, (float)i - 32f + 0.5f); float num = ((Vector2)(ref val)).magnitude / 32f; float num2 = Mathf.Clamp01(1f - num); array[i * 64 + j] = Color32.op_Implicit(new Color(1f, 1f, 1f, num2 * num2)); } } Texture2D val2 = new Texture2D(64, 64, (TextureFormat)4, false) { name = "KingLir Glow", wrapMode = (TextureWrapMode)1 }; val2.SetPixels32(array); val2.Apply(false, true); Object.DontDestroyOnLoad((Object)val2); glowSprite = Sprite.Create(val2, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 71.111115f); return glowSprite; } private void LateUpdate() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0076: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0309: 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_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_039c: 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_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: 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_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chest == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject, 1.5f); ((Behaviour)this).enabled = false; return; } ((Component)this).transform.position = chest.position + Vector3.up * 0.55f; Camera main = Camera.main; if ((Object)(object)main != (Object)null) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.position - ((Component)main).transform.position, Vector3.up); } float num = Mathf.Clamp01((Time.time - start) / 4.6f); float num2 = 33f * (1f - Mathf.Pow(1f - num, 4f)); float num3 = (this.prize.Golden ? Mathf.Clamp01((Time.time - start - 4.6f) / 1.1f) : 1f); bool flag = num >= 1f; bool flag2 = !this.prize.Golden || num3 >= 0.45f; int num4 = Mathf.FloorToInt(num2) - 1; Prize prize = null; ((Behaviour)mark).enabled = false; for (int i = 0; i < 4; i++) { int num5 = num4 + i; float num6 = (float)num5 - num2; Prize prize2 = ((num5 == 33) ? this.prize : RollFrame.StripPrize(num5)); SpriteRenderer val = icons[i]; bool flag3 = prize2 != null && prize2.Golden && !(num5 == 33 && flag2); val.sprite = (flag3 ? null : SpriteOf(prize2?.Item)); float num7 = Mathf.Min(1f, Mathf.Abs(num6)); float num8 = ((!flag) ? Mathf.Lerp(1f, 0f, Mathf.Abs(num6) / 1.6f) : ((num5 == 33) ? 1f : 0f)); val.color = new Color(1f, 1f, 1f, num8); ((Component)val).transform.localPosition = new Vector3(num6 * 0.42f, 0f, 0f); float num9 = ((flag && num5 == 33) ? (1.25f + Mathf.Sin(Time.time * 3f) * 0.03f) : 1f); ((Component)val).transform.localScale = Vector3.one * Mathf.Lerp(1f, 0.7f, num7) * num9; if (Mathf.Abs(num6) < 0.5f) { prize = prize2; } if (flag3 && Mathf.Abs(num6) < 0.5f) { ((Behaviour)mark).enabled = true; mark.transform.localPosition = ((Component)val).transform.localPosition - Vector3.forward * 0.01f; } } Color val2 = ((prize != null) ? StarterRoll.TierColors[prize.Tier] : Color.white); float num10 = ((!flag) ? 0.55f : ((this.prize.Golden && !flag2) ? (0.6f + Mathf.Sin(Time.time * 18f) * 0.3f) : 1f)); glow.color = new Color(val2.r, val2.g, val2.b, 0.75f * num10); ((Component)glow).transform.localScale = Vector3.one * (flag ? (1.3f + Mathf.Sin(Time.time * 4f) * 0.08f) : 1f); light.color = val2; light.intensity = 2.5f * num10; } } internal class ScreenOverlay : MonoBehaviour { private static ScreenOverlay inst; private Image image; private float hold; private float fade; private float peak; private float holdEnd; private float target = -1f; private static ScreenOverlay Get() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_00d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inst != (Object)null) { return inst; } GameObject val = new GameObject("KingLir Overlay"); Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32000; GameObject val2 = new GameObject("White"); val2.transform.SetParent(val.transform, false); RectTransform obj2 = val2.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; inst = val.AddComponent<ScreenOverlay>(); inst.image = val2.AddComponent<Image>(); ((Graphic)inst.image).raycastTarget = false; ((Graphic)inst.image).color = new Color(1f, 1f, 1f, 0f); return inst; } internal static void Flash(float strength, float holdSeconds, float fadeSeconds) { ScreenOverlay screenOverlay = Get(); if (!(strength < screenOverlay.CurrentAlpha())) { screenOverlay.target = -1f; screenOverlay.peak = Mathf.Clamp01(strength); screenOverlay.hold = holdSeconds; screenOverlay.fade = Mathf.Max(0.01f, fadeSeconds); screenOverlay.holdEnd = Time.time + holdSeconds; } } internal static void SetLevel(float alpha) { Get().target = Mathf.Clamp01(alpha); } internal static void Clear() { if (!((Object)(object)inst == (Object)null)) { inst.target = -1f; inst.peak = 0f; inst.holdEnd = 0f; } } private float CurrentAlpha() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)image != (Object)null)) { return 0f; } return ((Graphic)image).color.a; } private void Update() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) float num = ((target >= 0f) ? target : ((!(Time.time < holdEnd)) ? Mathf.Max(0f, peak * (1f - (Time.time - holdEnd) / fade)) : peak)); ((Graphic)image).color = new Color(1f, 1f, 1f, num); } } internal static class Flash { private const float Range = 16f; internal static void Blind(Vector3 pos) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_0039: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_008b: 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) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Vector3 val = pos - ((Component)main).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude > 16f)) { Vector3 position = ((Component)main).transform.position; Vector3 val2 = ((Component)main).transform.position - pos; if (!Physics.Linecast(position, pos + ((Vector3)(ref val2)).normalized * 0.3f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1)) { float num = Mathf.Lerp(0.35f, 1f, Mathf.Clamp01(Vector3.Dot(((Component)main).transform.forward, ((Vector3)(ref val)).normalized))); float num2 = Mathf.Clamp01(1.2f - magnitude / 16f) * num; ScreenOverlay.Flash(num2, 1.8f * num2, 2.5f); } } } } internal static class ParticleKit { private static Texture2D soft; private static Shader spriteShader; internal static Material Make(Color tint) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ed: Expected O, but got Unknown //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_0058: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) if ((Object)(object)spriteShader == (Object)null) { GameObject val = new GameObject("tmp"); spriteShader = ((Renderer)val.AddComponent<SpriteRenderer>()).sharedMaterial.shader; Object.Destroy((Object)val); } if ((Object)(object)soft == (Object)null) { soft = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(31.5f, 31.5f)) / 32f; float num2 = Mathf.Clamp01(1f - num); soft.SetPixel(j, i, new Color(1f, 1f, 1f, num2 * num2)); } } soft.Apply(); } return new Material(spriteShader) { mainTexture = (Texture)(object)soft, color = tint }; } internal static ParticleSystem Create(string name, Vector3 pos, Color tint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.position = pos; ParticleSystem val2 = val.AddComponent<ParticleSystem>(); val2.Stop(true, (ParticleSystemStopBehavior)0); ((Renderer)val.GetComponent<ParticleSystemRenderer>()).sharedMaterial = Make(tint); return val2; } } internal class SmokeCloud : MonoBehaviour { private const float Duration = 25f; private const float MaxRadius = 4.5f; internal static readonly List<SmokeCloud> Active = new List<SmokeCloud>(); private float start; internal float Radius { get { float num = Time.time - start; float num2 = Mathf.Clamp01(num / 2f); float num3 = Mathf.Clamp01((25f - num) / 4f); return 4.5f * num2 * num3; } } internal static void Spawn(Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00a2: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00ea: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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) ParticleSystem val = ParticleKit.Create("KingLir Smoke", pos + Vector3.up * 0.5f, new Color(0.78f, 0.78f, 0.8f, 0.85f)); MainModule main = val.main; ((MainModule)(ref main)).duration = 20f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(5f, 8f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 1.4f); ((MainModule)(ref main)).startSize = new MinMaxCurve(2.5f, 4.5f); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, 6.28f); ((MainModule)(ref main)).maxParticles = 220; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.02f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(18f); ShapeModule shape = val.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 1.5f; ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.15f), new GradientAlphaKey(0.8f, 0.7f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2); val.Play(); SmokeCloud smokeCloud = ((Component)val).gameObject.AddComponent<SmokeCloud>(); smokeCloud.start = Time.time; Active.Add(smokeCloud); Object.Destroy((Object)(object)((Component)val).gameObject, 33f); } private void OnDestroy() { Active.Remove(this); } internal static bool Blocks(Vector3 a, Vector3 b) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_006c: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) foreach (SmokeCloud item in Active) { if ((Object)(object)item == (Object)null) { continue; } float radius = item.Radius; if (!(radius < 0.5f)) { Vector3 position = ((Component)item).transform.position; Vector3 val = b - a; float num = Mathf.Clamp01(Vector3.Dot(position - a, val) / Mathf.Max(0.0001f, ((Vector3)(ref val)).sqrMagnitude)); Vector3 val2 = a + val * num - position; if (((Vector3)(ref val2)).sqrMagnitude < radius * radius) { return true; } } } return false; } } [HarmonyPatch(typeof(EnemyVision), "VisionTrigger")] internal static class SmokeVisionPatch { [HarmonyPrefix] private static bool Prefix(EnemyVision __instance, PlayerAvatar player) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0057: 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) if (SmokeCloud.Active.Count == 0 || (Object)(object)player == (Object)null || (Object)(object)__instance.VisionTransform == (Object)null) { return true; } Vector3 b = (((Object)(object)player.PlayerVisionTarget != (Object)null) ? player.PlayerVisionTarget.VisionTransform.position : ((Component)player).transform.position); return !SmokeCloud.Blocks(__instance.VisionTransform.position, b); } } internal class FireZone : MonoBehaviour { private const float Duration = 8f; private const float Radius = 2.2f; private const int EnemyDamage = 10; private const int PlayerDamage = 5; private float start; private float nextTick; private Light[] lights; private PlayerAvatar owner; internal static void Spawn(Vector3 pos, PlayerAvatar owner) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(pos + Vector3.up * 0.3f, Vector3.down, ref val, 4f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1)) { pos = ((RaycastHit)(ref val)).point + Vector3.up * 0.05f; } ParticleSystem val2 = ParticleKit.Create("KingLir Fire", pos, new Color(1f, 0.55f, 0.15f, 1f)); MainModule main = val2.main; ((MainModule)(ref main)).duration = 7f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 1.1f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.8f, 2.2f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.4f, 1f); ((MainModule)(ref main)).maxParticles = 400; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(90f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape)).radius = 2.2f; ((ShapeModule)(ref shape)).rotation = new Vector3(-90f, 0f, 0f); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(new Color(1f, 0.9f, 0.4f), 0f), new GradientColorKey(new Color(1f, 0.35f, 0.05f), 0.5f), new GradientColorKey(new Color(0.3f, 0.3f, 0.3f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(0.9f, 0f), new GradientAlphaKey(0.7f, 0.5f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.2f)); val2.Play(); FireZone fireZone = ((Component)val2).gameObject.AddComponent<FireZone>(); fireZone.start = Time.time; fireZone.owner = owner; fireZone.lights = (Light[])(object)new Light[2]; for (int i = 0; i < 2; i++) { GameObject val4 = new GameObject("Fire Light"); val4.transform.SetParent(((Component)val2).transform, false); val4.transform.localPosition = new Vector3((i == 0) ? 0.6f : (-0.6f), 0.6f, 0f); Light val5 = val4.AddComponent<Light>(); val5.type = (LightType)2; val5.color = new Color(1f, 0.5f, 0.15f); val5.range = 6f; val5.shadows = (LightShadows)0; fireZone.lights[i] = val5; } Object.Destroy((Object)(object)((Component)val2).gameObject, 10f); } private void Update() { //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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_01dc: Unknown result type (might be due to invalid IL or missing references) float num = Time.time - start; float num2 = Mathf.Clamp01((8f - num) / 1.5f); for (int i = 0; i < lights.Length; i++) { if ((Object)(object)lights[i] != (Object)null) { lights[i].intensity = num2 * (2f + 1.2f * Mathf.PerlinNoise(Time.time * 7f, (float)i * 3.1f)); } } if (num > 8f || !SemiFunc.IsMasterClientOrSingleplayer() || Time.time < nextTick) { return; } nextTick = Time.time + 0.5f; HashSet<Enemy> hashSet = new HashSet<Enemy>(); HashSet<PlayerAvatar> hashSet2 = new HashSet<PlayerAvatar>(); Collider[] array = Physics.OverlapSphere(((Component)this).transform.position + Vector3.up * 0.8f, 2.2f, -1, (QueryTriggerInteraction)2); foreach (Collider val in array) { EnemyRigidbody componentInParent = ((Component)val).GetComponentInParent<EnemyRigidbody>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.enemy != (Object)null) { hashSet.Add(componentInParent.enemy); continue; } PlayerAvatar componentInParent2 = ((Component)val).GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent2 != (Object)null) { hashSet2.Add(componentInParent2); } } foreach (Enemy item in hashSet) { if (item.HasHealth && (Object)(object)item.Health != (Object)null) { item.Health.Hurt(10, Vector3.up); } } foreach (PlayerAvatar item2 in hashSet2) { if ((Object)(object)item2.playerHealth != (Object)null && !item2.isDisabled) { item2.playerHealth.HurtOther(5, ((Component)this).transform.position, false, -1, false); } } } } internal class ExplosiveTag : MonoBehaviour { public string key; internal GunDef Def { get { if (!Explosives.DefByKey.TryGetValue(key, out var value)) { return null; } return value; } } } internal static class Explosives { internal static readonly Dictionary<string, GunDef> DefByKey = new Dictionary<string, GunDef>(); internal static void Configure(GameObject go, GunDef def) { DefByKey[def.Key] = def; go.AddComponent<ExplosiveTag>().key = def.Key; if (def.Kind == Special.Case) { ItemGrenadeExplosive component = go.GetComponent<ItemGrenadeExplosive>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } ItemGrenade component2 = go.GetComponent<ItemGrenade>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } go.AddComponent<CaseBehaviour>(); Rigidbody component3 = go.GetComponent<Rigidbody>(); if ((Object)(object)component3 != (Object)null) { component3.mass = Mathf.Max(component3.mass, 1.5f); } return; } ItemGrenade component4 = go.GetComponent<ItemGrenade>(); if ((Object)(object)component4 != (Object)null) { if (def.TickTime > 0f) { component4.tickTime = def.TickTime; } if (def.Kind == Special.Nuke) { component4.tickTime = Mathf.Max(5f, Plugin.NukeCountdown.Value); } go.AddComponent<GrenadeBlink>(); } switch (def.Kind) { case Special.Molotov: go.AddComponent<MolotovImpact>(); break; case Special.PipeBomb: go.AddComponent<PipeBombBeep>(); break; case Special.C4: go.AddComponent<C4Behaviour>(); break; case Special.Nuke: { go.AddComponent<NukeBehaviour>(); Rigidbody component5 = go.GetComponent<Rigidbody>(); if ((Object)(object)component5 != (Object)null) { component5.mass = Mathf.Max(component5.mass, 4f); } break; } case Special.Smoke: case Special.Flash: case Special.AntiTank: break; } } internal static GunDef DefOf(Component c) { ExplosiveTag explosiveTag = (((Object)(object)c != (Object)null) ? c.GetComponent<ExplosiveTag>() : null); if (!((Object)(object)explosiveTag != (Object)null)) { return null; } return explosiveTag.Def; } internal static void Blast(Component source, GunDef def, PlayerAvatar activator) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) ParticleScriptExplosion component = source.GetComponent<ParticleScriptExplosion>(); if (!((Object)(object)component == (Object)null)) { if ((Object)(object)activator != (Object)null) { component.playerCausingHurtOverride = activator; } component.playerHitFullRuckusOverride = true; component.Spawn(source.transform.position, def.ExSize, def.ExPlayerDamage, def.ExEnemyDamage, def.ExForce, false, false, 1f, 0f); } } } [HarmonyPatch(typeof(ItemGrenadeExplosive), "Explosion")] internal static class GrenadeExplosionPatch { [HarmonyPrefix] private static bool Prefix(ItemGrenadeExplosive __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_004b: 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) GunDef gunDef = Explosives.DefOf((Component)(object)__instance); if (gunDef == null) { return true; } ItemGrenade component = ((Component)__instance).GetComponent<ItemGrenade>(); PlayerAvatar val = (((Object)(object)component != (Object)null) ? component.activatorPlayerAvatar : null); Vector3 position = ((Component)__instance).transform.position; switch (gunDef.Kind) { case Special.Smoke: SmokeCloud.Spawn(position); break; case Special.Molotov: { ParticleScriptExplosion component2 = ((Component)__instance).GetComponent<ParticleScriptExplosion>(); if ((Object)(object)component2 != (Object)null) { component2.Spawn(position, 0.5f, 0, 0, 0.5f, true, false, 1f, 0f); } FireZone.Spawn(position, val); break; } case Special.Nuke: NukeBehaviour.Detonate((Component)(object)__instance, position); break; default: Explosives.Blast((Component)(object)__instance, gunDef, val); break; } return false; } } [HarmonyPatch(typeof(ItemGrenadeStun), "Explosion")] internal static class StunExplosionPatch { [HarmonyPostfix] private static void Postfix(ItemGrenadeStun __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) GunDef gunDef = Explosives.DefOf((Component)(object)__instance); if (gunDef != null && gunDef.Kind == Special.Flash) { Flash.Blind(((Component)__instance).transform.position); } } } [HarmonyPatch(typeof(ItemMineExplosive), "OnTriggered")] internal static class MineExplosionPatch { [HarmonyPrefix] private static bool Prefix(ItemMineExplosive __instance) { GunDef gunDef = Explosives.DefOf((Component)(object)__instance); if (gunDef == null) { return true; } ItemMine component = ((Component)__instance).GetComponent<ItemMine>(); Explosives.Blast((Component)(object)__instance, gunDef, ((Object)(object)component != (Object)null) ? component.activatorPlayerAvatar : null); return false; } } [HarmonyPatch(typeof(ItemMineTrigger), "LockOnTarget")] internal static class AntiTankTriggerPatch { [HarmonyPrefix] private static bool Prefix(ItemMineTrigger __instance, TargetType type, PhysGrabObject physObj) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 GunDef gunDef = Explosives.DefOf((Component)(object)__instance.itemMine); if (gunDef == null || gunDef.Kind != Special.AntiTank) { return true; } if ((int)type != 1 || (Object)(object)physObj == (Object)null) { return false; } EnemyParent componentInParent = ((Component)physObj).GetComponentInParent<EnemyParent>(); if ((Object)(object)componentInParent != (Object)null) { return (int)componentInParent.difficulty >= 1; } return false; } } [HarmonyPatch(typeof(ItemGrenade), "Update")] internal static class C4GrenadeUpdatePatch { [HarmonyPrefix] private static bool Prefix(ItemGrenade __instance) { return (Object)(object)((Component)__instance).GetComponent<C4Behaviour>() == (Object)null; } } [HarmonyPatch(typeof(ItemEquippable), "RequestEquip")] internal static class NukeNoEquipPatch { [HarmonyPrefix] private static bool Prefix(ItemEquippable __instance) { if ((Object)(object)((Component)__instance).GetComponent<NukeBehaviour>() == (Object)null) { return (Object)(object)((Component)__instance).GetComponent<CaseBehaviour>() == (Object)null; } return false; } } internal class GrenadeBlink : MonoBehaviour { private ItemGrenade grenade; private Material[] mats; protected float speed = 8f; protected virtual void Start() { grenade = ((Component)this).GetComponent<ItemGrenade>(); Transform val = ((Component)this).transform.Find("KingLir Model"); mats = (Material[])(((Object)(object)val != (Object)null) ? ((Array)(from r in ((Component)val).GetComponentsInChildren<MeshRenderer>(true) select ((Renderer)r).material).ToArray()) : ((Array)new Material[0])); Material[] array = mats; for (int num = 0; num < array.Length; num++) { array[num].EnableKeyword("_EMISSION"); } } protected virtual void Update() { //IL_0029: 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_004e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)grenade == (Object)null) { return; } Color val = (grenade.isActive ? (grenade.blinkColor * Mathf.PingPong(Time.time * BlinkSpeed(), 1f) * 0.6f) : Color.black); Material[] array = mats; foreach (Material val2 in array) { if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", val); } } } protected virtual float BlinkSpeed() { return speed; } } internal class PipeBombBeep : MonoBehaviour { private ItemGrenade grenade; private Light beep; private float nextBeep; private void Start() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) grenade = ((Component)this).GetComponent<ItemGrenade>(); GameObject val = new GameObject("Beep Light"); val.transform.SetParent(((Component)this).transform, false); beep = val.AddComponent<Light>(); beep.type = (LightType)2; beep.color = Color.red; beep.range = 2.5f; beep.intensity = 0f; } private void Update() { if ((Object)(object)grenade == (Object)null || (Object)(object)beep == (Object)null) { return; } if (!grenade.isActive) { beep.intensity = 0f; return; } float num = Mathf.Max(0.05f, grenade.tickTime - grenade.grenadeTimer); if (Time.time >= nextBeep) { nextBeep = Time.time + Mathf.Clamp(num / 6f, 0.07f, 0.6f); beep.intensity = 3f; } beep.intensity = Mathf.MoveTowards(beep.intensity, 0f, Time.deltaTime * 25f); } } internal class MolotovImpact : MonoBehaviour { private ItemGrenade grenade; private PhysGrabObject grab; private bool done; private void Awake() { grenade = ((Component)this).GetComponent<ItemGrenade>(); grab = ((Component)this).GetComponent<PhysGrabObject>(); } private void OnCollisionEnter(Collision c) { //IL_0048: 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) if (!done && !((Object)(object)grenade == (Object)null) && grenade.isActive && SemiFunc.IsMasterClientOrSingleplayer() && (!((Object)(object)grab != (Object)null) || !grab.grabbed)) { Vector3 relativeVelocity = c.relativeVelocity; if (!(((Vector3)(ref relativeVelocity)).magnitude < 2.5f) && !((Object)(object)((Component)c.collider).GetComponentInParent<PlayerAvatar>() != (Object)null)) { done = true; grenade.TickEnd(); } } } private void Update() { if (done && (Object)(object)grenade != (Object)null && !grenade.isActive) { done = false; } } } internal class C4Behaviour : MonoBehaviour { private ItemGrenade grenade; private ItemToggle toggle; private PhysGrabObject grab; private Rigidbody rb; private Light lamp; private bool armed; private bool lastToggle; private bool stuck; private FixedJoint joint; private void Start() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) grenade = ((Component)this).GetComponent<ItemGrenade>(); toggle = ((Component)this).GetComponent<ItemToggle>(); grab = ((Component)this).GetComponent<PhysGrabObject>(); rb = ((Component)this).GetComponent<Rigidbody>(); lastToggle = (Object)(object)toggle != (Object)null && toggle.toggleState; GameObject val = new GameObject("C4 Light"); val.transform.SetParent(((Component)this).transform, false); lamp = val.AddComponent<Light>(); lamp.type = (LightType)2; lamp.color = Color.red; lamp.range = 1.5f; lamp.intensity = 0f; } private void Update() { if ((Object)(object)grenade == (Object)null || (Object)(object)toggle == (Object)null || (Object)(object)grab == (Object)null) { return; } if ((Object)(object)lamp != (Object)null) { lamp.intensity = ((grenade.isActive && Mathf.Repeat(Time.time, 1f) < 0.15f) ? 2.5f : 0f); } if (grenade.isActive && (Object)(object)PlayerAvatar.instance != (Object)null && (Object)(object)grenade.activatorPlayerAvatar == (Object)(object)PlayerAvatar.instance && (Object)(object)PhysGrabber.instance != (Object)null && !PhysGrabber.instance.grabbed && !grab.grabbed && (Object)(object)PlayerController.instance != (Object)null && PlayerController.instance.InputDisableTimer <= 0f && SemiFunc.InputDown((InputKey)2)) { toggle.ToggleItem(!toggle.toggleState, SemiFunc.PhotonViewIDPlayerAvatarLocal()); } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (armed && !grenade.isActive) { armed = false; Unstick(); lastToggle = toggle.toggleState; } bool flag = toggle.toggleState != lastToggle; lastToggle = toggle.toggleState; if (!armed) { if (flag && grab.grabbed) { armed = true; if ((Object)(object)grab.lastPlayerGrabbing != (Object)null) { grenade.SetActivator(grab.lastPlayerGrabbing); } grenade.TickStart(); } } else if (grab.grabbed) { if (stuck) { Unstick(); } } else if (flag) { Unstick(); grenade.TickEnd(); } } private void OnCollisionEnter(Collision c) { if (armed && !stuck && SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)grab == (Object)null) && !grab.grabbed && !((Object)(object)((Component)c.collider).GetComponentInParent<PlayerAvatar>() != (Object)null)) { Rigidbody rigidbody = c.rigidbody; if ((Object)(object)rigidbody != (Object)null && !rigidbody.isKinematic) { joint = ((Component)this).gameObject.AddComponent<FixedJoint>(); ((Joint)joint).connectedBody = rigidbody; } else { rb.isKinematic = true; } stuck = true; } } private void Unstick() { if ((Object)(object)joint != (Object)null) { Object.Destroy((Object)(object)joint); } joint = null; if ((Object)(object)rb != (Object)null && SemiFunc.IsMasterClientOrSingleplayer()) { rb.isKinematic = false; } stuck = false; } } internal class FlareLauncher : MonoBehaviour { } [HarmonyPatch(typeof(ItemGun), "ShootRPC")] internal static class FlareShootPatch { [HarmonyPostfix] private static void Postfix(ItemGun __instance) { //IL_0040: 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) if (!((Object)(object)((Component)__instance).GetComponent<FlareLauncher>() == (Object)null) && !((Object)(object)__instance.gunMuzzle == (Object)null)) { PlayerAvatar shooter = (((Object)(object)__instance.physGrabObject != (Object)null) ? __instance.physGrabObject.lastPlayerGrabbing : null); Flare.Spawn(__instance.gunMuzzle.position, __instance.gunMuzzle.forward, ((Component)__instance).transform, shooter); } } } internal class Flare : MonoBehaviour { private const float Speed = 22f; private const float Gravity = 6f; private const float BurnSeconds = 14f; private const int ImpactDamage = 20; private const int BurnDamage = 6; private const float BurnTick = 0.5f; private const float BurnEnemySeconds = 5f; private const float StunSeconds = 3f; private const float LureRadius = 18f; private static readonly Color FlareColor = new Color(1f, 0.15f, 0.08f); private static Material glowMat; private Vector3 velocity; private Transform ignore; private PlayerAvatar shooter; private bool landed; private float landedTime; private float spawnTime; private Light flareLight; private float baseIntensity = 3.5f; private Enemy burning; private float nextBurn; private float nextLure; private int mask; internal static void Spawn(Vector3 pos, Vector3 dir, Transform ignore, PlayerAvatar shooter) { //IL_0023: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val).name = "KingLir Flare"; Object.Destroy((Object)(object)val.GetComponent<Collider>()); val.transform.position = pos; val.transform.localScale = Vector3.one * 0.07f; ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = GlowMaterial(); Flare flare = val.AddComponent<Flare>(); flare.velocity = ((Vector3)(ref dir)).normalized * 22f; flare.ignore = ignore; flare.shooter = shooter; flare.spawnTime = Time.time; GameObject val2 = new GameObject("Light"); val2.transform.SetParent(val.transform, false); flare.flareLight = val2.AddComponent<Light>(); flare.flareLight.type = (LightType)2; flare.flareLight.color = FlareColor; flare.flareLight.range = 9f; flare.flareLight.intensity = flare.baseIntensity; flare.flareLight.shadows = (LightShadows)0; TrailRenderer obj = val.AddComponent<TrailRenderer>(); obj.time = 0.35f; obj.startWidth = 0.06f; obj.endWidth = 0f; ((Renderer)obj).material = GlowMaterial(); obj.startColor = FlareColor; obj.endColor = new Color(1f, 0.5f, 0.1f, 0f); } private static Material GlowMaterial() { //IL_0039: 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_004e: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)glowMat != (Object)null) { return glowMat; } glowMat = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard")) { name = "KingLir Flare" }; glowMat.color = FlareColor * 2f; if (glowMat.HasProperty("_EmissionColor")) { glowMat.EnableKeyword("_EMISSION"); glowMat.SetColor("_EmissionColor", FlareColor * 4f); } return glowMat; } private void Awake() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) mask = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) | LayerMask.GetMask(new string[1] { "Enemy" }); } private void Update() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if ((Object)(object)flareLight != (Object)null) { float num = (landed ? Mathf.Clamp01((14f - (time - landedTime)) / 2f) : 1f); flareLight.intensity = baseIntensity * num * (0.8f + 0.35f * Mathf.PerlinNoise(time * 9f, 0.3f)); } if (!landed) { Fly(Time.deltaTime); if (time - spawnTime > 6f) { Land(null, ((Component)this).transform.position); } } else if (time - landedTime > 14f) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (time >= nextLure && (Object)(object)EnemyDirector.instance != (Object)null) { EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 18f, false); nextLure = time + 1f; } if ((Object)(object)burning != (Object)null && time - landedTime < 5f && time >= nextBurn) { nextBurn = time + 0.5f; if (burning.HasHealth && (Object)(object)burning.Health != (Object)null) { burning.Health.Hurt(6, Vector3.up); } } } } private void Fly(float dt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_003f: 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) //IL_0064: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) velocity += Vector3.down * 6f * dt; Vector3 position = ((Component)this).transform.position; Vector3 val = velocity * dt; RaycastHit[] array = Physics.RaycastAll(position, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, mask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if ((!((Object)(object)ignore != (Object)null) || !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(ignore)) && (!((Object)(object)shooter != (Object)null) || !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)shooter).transform))) { Land(((RaycastHit)(ref val2)).collider, ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.04f); return; } } ((Component)this).transform.position = position + val; } private void Land(Collider col, Vector3 point) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) landed = true; landedTime = Time.time; ((Component)this).transform.position = point; TrailRenderer component = ((Component)this).GetComponent<TrailRenderer>(); if ((Object)(object)component != (Object)null) { component.emitting = false; } baseIntensity = 5f; if ((Object)(object)flareLight != (Object)null) { flareLight.range = 11f; } if ((Object)(object)col == (Object)null) { return; } ((Component)this).transform.SetParent(((Component)col).transform, true); if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } EnemyRigidbody componentInParent = ((Component)col).GetComponentInParent<EnemyRigidbody>(); Enemy val = (((Object)(object)componentInParent != (Object)null) ? componentInParent.enemy : ((Component)col).GetComponentInParent<Enemy>()); if (!((Object)(object)val == (Object)null)) { burning = val; nextBurn = Time.time + 0.5f; if (val.HasHealth && (Object)(object)val.Health != (Object)null) { val.Health.Hurt(20, ((Vector3)(ref velocity)).normalized); } if (val.HasStateStunned && (Object)(object)val.StateStunned != (Object)null) { val.StateStunned.Set(3f); } } } } internal static class Golden { internal const float DamageMul = 3f; internal static readonly Color Gold = new Color(1f, 0.78f, 0.25f); internal static readonly Dictionary<Item, Item> VariantOf = new Dictionary<Item, Item>(); private static Texture2D goldTex; private static readonly Dictionary<Material, Material> matCache = new Dictionary<Material, Material>(); internal static void BuildAll(GameObject holder, IEnumerable<Item> sources) { foreach (Item source in sources) { try { Item val = Build(holder, source); if ((Object)(object)val != (Object)null) { VariantOf[source] = val; } } catch (Exception arg) { Plugin.Log.LogError((object)$"Gyllene {((Object)source).name} misslyckades: {arg}"); } } Plugin.Log.LogInfo((object)$"{VariantOf.Count} gyllene vapen registrerade."); } private static Item Build(GameObject holder, Item src) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) GameObject value; GameObject val = (GunFactory.PrefabOf.TryGetValue(src, out value) ? value : ((PrefabRef<GameObject>)(object)src.prefab)?.Prefab); if ((Object)(object)val == (Object)null || (Object)(object)val.GetComponent<ItemGun>() == (Object)null) { return null; } GameObject val2 = Object.Instantiate<GameObject>(val, holder.transform); ((Object)val2).name = "Item KingLir Golden " + ((Object)src).name.Replace("Item ", "").Replace("KingLir ", ""); Item val3 = Object.Instantiate<Item>(src); ((Object)val3).name = ((Object)val2).name; val3.itemName = "Golden " + src.itemName; val3.itemNameLocalized = null; val3.description = "Golden version. Infinite ammo, triple damage."; val3.disabled = false; val3.maxAmountInShop = 0; val3.maxAmount = Mathf.Max(val3.maxAmount, 10); val3.itemSecretShopType = (itemSecretShopType)43; ItemAttributes component = val2.GetComponent<ItemAttributes>(); component.item = val3; ItemGun component2 = val2.GetComponent<ItemGun>(); if ((Object)(object)component2.bulletPrefab != (Object)null) { GameObject val4 = Object.Instantiate<GameObject>(component2.bulletPrefab, holder.transform); ((Object)val4).name = ((Object)val2).name + " Bullet"; Triple(val4); component2.bulletPrefab = val4; } Triple(val2); component2.batteryDrainFullBar = false; component2.batteryDrain = 0f; val2.AddComponent<GoldenTag>(); Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val5 in componentsInChildren) { if ((!(val5 is MeshRenderer) && !(val5 is SkinnedMeshRenderer)) || (Object)(object)((Component)val5).GetComponentInParent<ItemVolume>(true) != (Object)null) { continue; } Material[] sharedMaterials = val5.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if ((Object)(object)sharedMaterials[j] != (Object)null) { sharedMaterials[j] = GoldOf(sharedMaterials[j]); } } val5.sharedMaterials = sharedMaterials; } GameObject val6 = new GameObject("Golden Glow"); val6.transform.SetParent(val2.transform, false); Light obj = val6.AddComponent<Light>(); obj.type = (LightType)2; obj.color = Gold; obj.range = 1.2f; obj.intensity = 0.6f; obj.shadows = (LightShadows)0; Items.RegisterItem(component); GunFactory.PrefabOf[val3] = val2; return val3; } private static void Triple(GameObject go) { HurtCollider[] componentsInChildren = go.GetComponentsInChildren<HurtCollider>(true); foreach (HurtCollider obj in componentsInChildren) { obj.enemyDamage = Mathf.RoundToInt((float)obj.enemyDamage * 3f); obj.playerDamage = Mathf.RoundToInt((float)obj.playerDamage * 3f); } } private static Material GoldOf(Material src) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00ae: 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_0141: Unknown result type (might be due to invalid IL or missing references) if (matCache.TryGetValue(src, out var value)) { return value; } value = new Material(src) { name = ((Object)src).name + " (Golden)" }; Texture2D val = GoldTexture(); string[] array = new string[4] { "_MainTex", "_BaseMap", "_BaseColorMap", "_Albedo" }; foreach (string text in array) { if (value.HasProperty(text)) { value.SetTexture(text, (Texture)(object)val); } } array = new string[2] { "_Color", "_BaseColor" }; foreach (string text2 in array) { if (value.HasProperty(text2)) { value.SetColor(text2, Color.white); } } if (value.HasProperty("_Metallic")) { value.SetFloat("_Metallic", 0.9f); } if (value.HasProperty("_Glossiness")) { value.SetFloat("_Glossiness", 0.75f); } if (value.HasProperty("_Smoothness")) { value.SetFloat("_Smoothness", 0.75f); } if (value.HasProperty("_EmissionColor")) { value.EnableKeyword("_EMISSION"); value.SetColor("_EmissionColor", Gold * 0.35f); } matCache[src] = value; return value; } private static Texture2D GoldTexture() { //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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_00bd: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0100: 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_010a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)goldTex != (Object)null) { return goldTex; } Color32[] array = (Color32[])(object)new Color32[16384]; Random random = new Random(79); float[] array2 = new float[128]; for (int i = 0; i < 128; i++) { array2[i] = (float)random.NextDouble(); } for (int j = 0; j < 128; j++) { for (int k = 0; k < 128; k++) { float num = array2[j] * 0.6f + (float)random.NextDouble() * 0.4f; float num2 = 0.5f + 0.5f * Mathf.Sin(((float)k + (float)j * 0.3f) * 0.09f); float num3 = Mathf.Lerp(0.72f, 1.08f, num * 0.6f + num2 * 0.4f); Color val = Gold * num3; array[j * 128 + k] = Color32.op_Implicit(new Color(Mathf.Clamp01(val.r), Mathf.Clamp01(val.g), Mathf.Clamp01(val.b), 1f)); } } goldTex = new Texture2D(128, 128, (TextureFormat)4, true) { name = "KingLir Gold", wrapMode = (TextureWrapMode)0 }; goldTex.SetPixels32(array); goldTex.Apply(true, true); Object.DontDestroyOnLoad((Object)(object)goldTex); return goldTex; } } internal class GoldenTag : MonoBehaviour { private ItemBattery battery; private void Start() { battery = ((Component)this).GetComponent<ItemBattery>(); } private void LateUpdate() { if ((Object)(object)battery != (Object)null && battery.batteryLife < 100f) { battery.batteryLife = 100f; } } } internal enum GunBase { Handgun, Shotgun, GrenadeExplosive, GrenadeStun, MineExplosive } internal enum Special { None, Molotov, Smoke, Flash, C4, PipeBomb, AntiTank, Nuke, Case } internal class GunDef { public int Shelf; public Special Kind; public string[] ExtraParts; public float TickTime = -1f; public float ExSize = 1.2f; public int ExPlayerDamage = 75; public int ExEnemyDamage = 160; public float ExForce = 4f; public string Key; public string Name; public string Description; public GunBase Base; public int PriceK; public float PriceMul; public float Length; public int Ammo; public int Burst = 1; public bool Auto; public bool Flare; public float BurstInterval = 0.09f; public float Cooldown = 0.6f; public float DamageMul = 1f; public float Spread = -1f; public int Pellets = -1; public float Recoil = 1f; public float HitForceMul = 1f; public float StunTime = -1f; public bool IsGun { get { if (Base != GunBase.Handgun) { return Base == GunBase.Shotgun; } return true; } } } internal static class GunDefs { internal static readonly List<GunDef> All = new List<GunDef> { new GunDef { Key = "luger", Name = "Luger", Description = "Old, reliable, loud.", Base = GunBase.Handgun, PriceK = 3, PriceMul = 1f, Length = 0.27f, Ammo = 8, Cooldown = 0.45f }, new GunDef { Key = "makarov", Name = "Makarov", Description = "Fast trigger, small bullets.", Base = GunBase.Handgun, PriceK = 4, PriceMul = 1f, Length = 0.25f, Ammo = 10, Cooldown = 0.3f, DamageMul = 0.8f }, new GunDef { Key = "flaregun", Name = "Flare Gun", Description = "Shoots a burning flare. Lights the room, lures monsters, burns what it hits.", Base = GunBase.Handgun, PriceK = 2, PriceMul = 0.8f, Length = 0.3f, Ammo = 3, Cooldown = 1.2f, Recoil = 2f, Flare = true }, new GunDef { Key = "greasegun", Name = "Grease Gun", Description = "Full auto. Slow and steady.", Base = GunBase.Handgun, PriceK = 7, PriceMul = 1.6f, Length = 0.6f, Ammo = 30, Auto = true, Cooldown = 0.13f, DamageMul = 0.4f, Spread = 5f }, new GunDef { Key = "suomi", Name = "Suomi KP", Description = "Full auto drum gun. Hold on tight.", Base = GunBase.Handgun, PriceK = 8, PriceMul = 1.9f, Length = 0.8f, Ammo = 50, Auto = true, Cooldown = 0.075f, DamageMul = 0.3f, Spread = 6f }, new GunDef { Key = "ak47", Name = "AK-47", Description = "Full auto. Hits hard, kicks harder.", Base = GunBase.Handgun, PriceK = 12, PriceMul = 2.2f, Length = 0.85f, Ammo = 30, Auto = true, Cooldown = 0.1f, DamageMul = 0.5f, Spread = 4f, Recoil = 1.3f }, new GunDef { Key = "m4a1", Name = "M4A1", Description = "Full auto, very accurate.", Base = GunBase.Handgun, PriceK = 13, PriceMul = 2.3f, Length = 0.85f, Ammo = 30, Auto = true, Cooldown = 0.085f, DamageMul = 0.45f, Spread = 2f, Recoil = 1.1f }, new GunDef { Key = "shotgun", Name = "Pump Shotgun", Description = "Close range. Very close range.", Base = GunBase.Shotgun, PriceK = 9, PriceMul = 1.15f, Length = 1f, Ammo = 6, Cooldown = 1f, DamageMul = 1.1f }, new GunDef { Key = "sniper", Name = "Sniper Rifle", Description = "One shot. Make it count.", Base = GunBase.Handgun, PriceK = 15, PriceMul = 2.6f, Length = 1.1f, Ammo = 4, Cooldown = 1.8f, DamageMul = 4f, Spread = 0f, Recoil = 3f, HitForceMul = 2f }, new GunDef { Key = "frag", Name = "Frag Grenade", Description = "Pull, throw, duck.", Base = GunBase.GrenadeExplosive, Shelf = 1, PriceK = 3, PriceMul = 1f, Length = 0.12f, TickTime = 3f }, new GunDef { Key = "m24", Name = "M24 Stick Grenade", Description = "Long fuse, big boom.", Base = GunBase.GrenadeExplosive, Shelf = 1, PriceK = 5, PriceMul = 1.3f, Length = 0.36f, TickTime = 5f, ExSize = 1.6f, ExPlayerDamage = 90, ExEnemyDamage = 230, ExForce = 5f }, new GunDef { Key = "pipebomb", Name = "Pipe Bomb", Description = "Beeps faster and faster. Then it doesn't.", Base = GunBase.GrenadeExplosive, Shelf = 1, PriceK = 6, PriceMul = 1.5f, Length = 0.3f, TickTime = 4f, Kind = Special.PipeBomb, ExSize = 1.8f, ExPlayerDamage = 100, ExEnemyDamage = 260, ExForce = 6f }, new GunDef { Key = "flashbang", Name = "Flashbang", Description = "Stuns monsters. Blinds everyone who looks at it.", Base = GunBase.GrenadeStun, Shelf = 1, PriceK = 3, PriceMul = 1f, Length = 0.14f, TickTime = 2f, Kind = Special.Flash }, new GunDef { Key = "smoke", Name = "Smoke Grenade", Description = "Monsters cannot see through the smoke.", Base = GunBase.GrenadeExplosive, Shelf = 1, PriceK = 2, PriceMul = 0.7f, Length = 0.16f, TickTime = 2f, Kind = Special.Smoke }, new GunDef { Key = "molotov_bottle", Name = "Molotov", Description = "Light it, throw it. Breaks on impact and sets the floor on fire.", Base = GunBase.GrenadeExplosive, Shelf = 1, PriceK = 4, PriceMul = 1.1f, Length = 0.28f, TickTime = 8f, Kind = Special.Molotov, ExtraParts = new string[1] { "molotov_fabric" } }, new GunDef { Key = "c4", Name = "C4", Description = "Arm it, stick it, walk away. Press E with empty hands to detonate.", Base = GunBase.GrenadeExplosive, Shelf = 1, PriceK = 8, PriceMul = 2f, Length = 0.28f, Kind = Special.C4, ExSize = 2f, ExPlayerDamage = 120, ExEnemyDamage = 350, ExForce = 7f }, new GunDef { Key = "claymore", Name = "Claymore", Description = "A mine with a bigger bang.", Base = GunBase.MineExplosive, Shelf = 1, PriceK = 6, PriceMul = 1.2f, Length = 0.25f, ExSize = 1.5f, ExPlayerDamage = 90, ExEnemyDamage = 270, ExForce = 5f }, new GunDef { Key = "atmine", Name = "Anti-Tank Mine", Description = "Ignores players and small monsters. Big monsters, not so much.", Base = GunBase.MineExplosive, Shelf = 1, PriceK = 7, PriceMul = 1.5f, Length = 0.35f, Kind = Special.AntiTank, ExSize = 2.2f, ExPlayerDamage = 150, ExEnemyDamage = 600, ExForce = 8f }, new GunDef { Key = "chest", Name = "KingLir Case", Description = "Open it. Get a weapon. Maybe a golden one.", Base = GunBase.GrenadeExplosive, Shelf = 0, PriceK = 15, Length = 0.45f, Kind = Special.Case }, new GunDef { Key = "nuke", Name = "Nuclear Bomb", Description = "Do not press the button.", Base = GunBase.GrenadeExplosive, Shelf = -1, PriceK = 0, Length = 1.6f, Kind = Special.Nuke } }; } [HarmonyPatch(typeof(RunManager), "Awake")] internal static class GunFactory { internal struct GunPose { public Vector3 Center; public Quaternion Frame; public Vector3 Volume; public float HalfHeight; } internal const itemSecretShopType ShelfType = (itemSecretShopType)42; internal const itemSecretShopType ShelfType2 = (itemSecretShopType)44; internal const itemSecretShopType NeverShopType = (itemSecretShopType)43; internal static readonly List<Item> Items = new List<Item>(); internal static readonly Dictionary<Item, GunDef> DefOf = new Dictionary<Item, GunDef>(); private static bool built; private static GameObject holder; internal static readonly List<Item> VanillaWeapons = new List<Item>(); internal static readonly Dictionary<Item, GameObject> PrefabOf = new Dictionary<Item, GameObject>(); internal static readonly Dictionary<string, GunPose> PoseOf = new Dictionary<string, GunPose>(); private static readonly Dictionary<string, Mesh> meshCache = new Dictionary<string, Mesh>(); internal static itemSecretShopType ShelfTypeOf(int shelf) { if (shelf == 1) { return (itemSecretShopType)44; } return (itemSecretShopType)42; } [HarmonyPostfix] [HarmonyPriority(200)] private static void Postfix() { if (built) { return; } built = true; try { Build(); } catch (Exception ex) { Plugin.Log.LogError((object)("Kunde inte bygga vapnen: " + ex)); } } private static void Build() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Invalid comparison between Unknown and I4 //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Invalid comparison between Unknown and I4 holder = new GameObject("KingLirArmory Prefabs"); holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)holder); Dictionary<GunBase, Item> dictionary = new Dictionary<GunBase, Item>(); Item[] array = Resources.LoadAll<Item>(""); foreach (Item val in array) { if ((Object)(object)val == (Object)null || val.prefab == null || !((PrefabRef<GameObject>)(object)val.prefab).IsValid()) { continue; } GameObject prefab = ((PrefabRef<GameObject>)(object)val.prefab).Prefab; if (!((Object)(object)prefab == (Object)null)) { if (!val.disabled && (Object)(object)prefab.GetComponent<ItemAttributes>() != (Object)null && !VanillaWeapons.Contains(val) && ((int)val.itemType == 9 || (int)val.itemType == 7 || (int)val.itemType == 15)) { VanillaWeapons.Add(val); } GunBase? gunBase = null; ItemGun component = prefab.GetComponent<ItemGun>(); if ((Object)(object)component != (Object)null && !Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGunTranq>()) && !Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGunLaser>()) && !Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGunRevolver>()) && (int)val.itemType == 9) { gunBase = ((component.numberOfBullets > 1) ? GunBase.Shotgun : GunBase.Handgun); } else if (Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGrenadeExplosive>()) && Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGrenade>())) { gunBase = GunBase.GrenadeExplosive; } else if (Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGrenadeStun>()) && Object.op_Implicit((Object)(object)prefab.GetComponent<ItemGrenade>())) { gunBase = GunBase.GrenadeStun; } else if (Object.op_Implicit((Object)(object)prefab.GetComponent<ItemMineExplosive>()) && Object.op_Implicit((Object)(object)prefab.GetComponent<ItemMine>())) { gunBase = GunBase.MineExplosive; } if (gunBase.HasValue && !dictionary.ContainsKey(gunBase.Value)) { dictionary[gunBase.Value] = val; Plugin.Log.LogInfo((object)$"Basitem {gunBase.Value}: {((Object)val).name}"); } } } foreach (KeyValuePair<GunBase, Item> item in dictionary) { try { LogVanilla(item.Key.ToString(), item.Value); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Vanilla-logg: " + ex.Message)); } } if (!dictionary.ContainsKey(GunBase.Handgun)) { Plugin.Log.LogError((object)"Hittade inget basvapen (handgun). Inga KingLir-vapen läggs till."); return; } if (!dictionary.ContainsKey(GunBase.Shotgun)) { dictionary[GunBase.Shotgun] = dictionary[GunBase.Handgun]; } foreach (GunDef item2 in GunDefs.All) { if (!Plugin.NukeEnabled.Value && item2.Kind == Special.Nuke) { continue; } if (!dictionary.TryGetValue(item2.Base, out var value)) { Plugin.Log.LogWarning((object)$"Bas saknas för {item2.Name} ({item2.Base})."); continue; } try { Item val2 = BuildGun(item2, value); if ((Object)(object)val2 != (Object)null) { Items.Add(val2); DefOf[val2] = item2; } } catch (Exception arg) { Plugin.Log.LogError((object)$"Vapnet {item2.Name} misslyckades: {arg}"); } } Plugin.Log.LogInfo((object)$"{Items.Count} KingLir-vapen registrerade."); Plugin.Log.LogInfo((object)string.Format("Spelets vapen ({0}): {1}", VanillaWeapons.Count, string.Join(", ", VanillaWeapons.Select((Item val3) => ((Object)val3).name)))); Golden.BuildAll(holder, Items.Where((Item key) => DefOf[key].IsGun).Concat(VanillaWeapons).ToList()); InjectPool(); } internal static void InjectPool() { RunManager instance = RunManager.instance; if ((Object)(object)instance == (Object)null) { return; } foreach (KeyValuePair<Item, GameObject> item in PrefabOf) { if (item.Key.prefab != null && ((PrefabRef<GameObject>)(object)item.Key.prefab).IsValid() && !((Object)(object)item.Value == (Object)null)) { instance.singleplayerPool[((PrefabRef<GameObject>)(object)item.Key.prefab).ResourcePath] = (Object)(object)item.Value; } } } internal static string PriceText(Item item) { int num = Mathf.CeilToInt(item.value.valueMin * 4f / 1000f); int num2 = Mathf.CeilToInt(item.value.valueMax * 4f / 1000f); if (num != num2) { return num + "-" + num2 + "K"; } return num + "K"; } private static void LogVanilla(string label, Item item) { GameObject prefab = ((PrefabRef<GameObject>)(object)item.prefab).Prefab; ItemGun component = prefab.GetComponent<ItemGun>(); string text = ""; if ((Object)(object)component != (Object)null) { ItemBattery component2 = prefab.GetComponent<ItemBattery>(); float num = (component.batteryDrainFullBar ? ((float)(((Object)(object)component2 != (Object)null) ? component2.batteryBars : 6) / (float)Mathf.Max(1, component.batteryDrainFullBars)) : (100f / Mathf.Max(0.01f, component.batteryDrain))); HurtCollider val = (((Object)(object)component.bulletPrefab != (Object)null) ? component.bulletPrefab.GetComponentInChildren<HurtCollider>(true) : null); text = $", {num:F1} skott/laddning, kulor/skott {component.numberOfBullets}, nedkylning {component.shootCooldown:F2}s, skada fiende {(((Object)(object)val != (Object)null) ? val.enemyDamage : (-1))} spelare {(((Object)(object)val != (Object)null) ? val.playerDamage : (-1))}"; } Plugin.Log.LogInfo((object)string.Format("Vanilla {0}: {1} värde {2:F0}-{3:F0} ({4}){5}", label, ((Object)item).name, item.value?.valueMin, item.value?.valueMax, ((Object)(object)item.value != (Object)null) ? PriceText(item) : "?", text)); } private static Item BuildGun(GunDef def, Item baseItem) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)baseItem.prefab).Prefab, holder.transform); ((Object)val).name = "Item KingLir " + def.Name.Replace("-", ""); Item val2 = Object.Instantiate<Item>(baseItem); ((Object)val2).name = ((Object)val).name; val2.itemName = def.Name; val2.itemNameLocalized = null; val2.description = def.Description; val2.status = (Status)1; val2.disabled = false; Value val3 = ScriptableObject.CreateInstance<Value>(); Value value = baseItem.value; if (def.PriceMul > 0f && (Object)(object)value != (Object)null && value.valueMax > 0f) { val3.valueMin = value.valueMin * def.PriceMul; val3.valueMax = value.valueMax * def.PriceMul; } else { val3.valueMin = (val3.valueMax = (float)def.PriceK * 250f); } val2.value = val3; if (def.IsGun) { val2.maxAmount = Mathf.Max(val2.maxAmount, 10); } val2.maxAmountInShop = (def.IsGun ? 1 : 2); val2.itemSecretShopType = (itemSecretShopType)((def.Shelf < 0) ? 43 : (Plugin.ShelfEnabled.Value ? ((int)ShelfTypeOf(def.Shelf)) : 0)); if (def.Shelf < 0) { val2.maxAmountInShop = 0; } ItemAttributes component = val.GetComponent<ItemAttributes>(); component.item = val2; component.icon = null; if (!def.IsGun) { Explosives.Configure(val, def); ApplyModel(val, null, def); if (def.Kind == Special.Case) { CaseBehaviour.SplitLid(val); } Items.RegisterItem(component); PrefabOf[val2] = val; Plugin.Log.LogInfo((object)("Sprängämne: " + def.Name + " (" + PriceText(val2) + ", bas " + ((Object)baseItem).name + ", prefab " + ((Object)val).name + ")")); return val2; } ItemGun component2 = val.GetComponent<ItemGun>(); component2.shootCooldown = ((def.Burst > 1) ? Mathf.Max(def.Cooldown, (float)def.Burst * def.BurstInterval + 0.1f) : def.Cooldown); component2.gunRecoilForce *= def.Recoil; component2.cameraShakeMultiplier *= Mathf.Lerp(1f, def.Recoil, 0.5f); if (def.Spread >= 0f) { component2.gunRandomSpread = def.Spread; } if (def.Pellets > 0) { component2.numberOfBullets = def.Pellets; } component2.batteryDrainFullBar = false; component2.batteryDrain = 100f / (float)Mathf.Max(1, def.Ammo); component2.bulletPrefab = MakeBullet(component2.bulletPrefab, def, ((Object)val).name); if (!def.Flare) { GunSounds.Apply(component2, def.Key); } if (def.Auto) { val.AddComponent<AutoFire>(); } if (def.Flare) { component2.numberOfBullets = 0; val.AddComponent<FlareLauncher>(); } if (def.Burst > 1) { BurstFire burstFire = val.AddComponent<BurstFire>(); burstFire.shots = def.Burst; burstFire.interval = def.BurstInterval; } ApplyModel(val, component2, def); Items.RegisterItem(component); PrefabOf[val2] = val; Plugin.Log.LogInfo((object)$"Vapen: {def.Name} ({PriceText(val2)}, {def.Ammo} skott, skada x{def.DamageMul}, bas {((Object)baseItem).name}, prefab {((Object)val).name})"); return val2; } private static GameObject MakeBullet(GameObject original, GunDef def, string name) { if ((Object)(object)original == (Object)null) { return null; } if (def.DamageMul == 1f && def.HitForceMul == 1f && def.StunTime < 0f) { return original; } GameObject val = Object.Instantiate<GameObject>(original, holder.transform); ((Object)val).name = name + " Bullet";