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 NH JesterSword02 v1.1.2
plugins/NH_JesterSword02/NH_JesterSword02.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using SoftReferenceableAssets; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("NH_JesterSword02")] [assembly: AssemblyProduct("NH Chaos Blade")] [assembly: AssemblyDescription("Nostalgia Heroes - Chaos Blade (NH_JesterSword02, formerly Jester Sword II): custom sword with glow, icon, Forge recipe, the Jester Cry camp location and a smoke aura")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.1.2.0")] namespace NH_JesterSword02; internal static class GlowAura { public const string Section = "Glow and aura"; public const string SmokeObjectName = "NH_JesterSword02_Smoke"; public const string SmokeMaterialName = "NH_JesterSword02_SmokeMat"; private static readonly string[] VanillaSmokeMaterials = new string[3] { "wraith_smoke", "smoke", "ghost_smoke" }; public const float BaseRate = 14f; public const int BaseMaxParticles = 60; private static readonly Color MaterialTint = new Color(0.35f, 0.05f, 0.6f, 1f); private static readonly Color SmokeColorA = new Color(0.6f, 0.45f, 0.7f, 0.5f); private static readonly Color SmokeColorB = new Color(0.4f, 0.3f, 0.5f, 0.35f); private static readonly Vector3 BladeMidpoint = new Vector3(0f, 0.271028f, 0.01f); private static readonly Vector3 BladeBox = new Vector3(0.06f, 0.72f, 0.025f); public static ConfigEntry<float> GlowIntensity; public static ConfigEntry<float> GlowRange; public static ConfigEntry<bool> SmokeEnabled; public static ConfigEntry<float> SmokeAmount; public static int SettingsVersion; private static SoftReference<Material> vanillaRef; private static Material smokeMaterial; public static float Intensity { get { if (GlowIntensity == null) { return 3f; } return Mathf.Max(0f, GlowIntensity.Value); } } public static float Range { get { if (GlowRange == null) { return 3f; } return Mathf.Max(0.1f, GlowRange.Value); } } public static float Amount { get { if (SmokeAmount == null) { return 1f; } return Mathf.Clamp(SmokeAmount.Value, 0f, 2f); } } public static bool SmokeOn { get { if (SmokeEnabled == null || SmokeEnabled.Value) { return Amount > 0.001f; } return false; } } public static void BindConfig(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown GlowIntensity = config.Bind<float>("Glow and aura", "GlowIntensity", 3f, new ConfigDescription("Brightness of the sword's dark purple point light (client-side). 1.1.0 used 1.75.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f), Array.Empty<object>())); GlowRange = config.Bind<float>("Glow and aura", "GlowRange", 3f, new ConfigDescription("Range of the purple point light in metres (client-side). 1.1.0 used 1.75.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 8f), Array.Empty<object>())); SmokeEnabled = config.Bind<bool>("Glow and aura", "SmokeEnabled", true, new ConfigDescription("Show the dark purple smoke aura around the blade (client-side).", (AcceptableValueBase)null, Array.Empty<object>())); SmokeAmount = config.Bind<float>("Glow and aura", "SmokeAmount", 1f, new ConfigDescription("Smoke amount multiplier (client-side). 1 = about 14 puffs per second, max 60 at a time. 0 = no smoke.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); EventHandler eventHandler = delegate { SettingsVersion++; }; GlowIntensity.SettingChanged += eventHandler; GlowRange.SettingChanged += eventHandler; SmokeEnabled.SettingChanged += eventHandler; SmokeAmount.SettingChanged += eventHandler; } public static void Install(GameObject visual, Light glow, ManualLogSource log) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)glow)) { glow.intensity = Intensity; glow.range = Range; log.LogInfo((object)("NHJS2: glow set intensity " + glow.intensity.ToString("F2") + " range " + glow.range.ToString("F2") + " color #" + ColorUtility.ToHtmlStringRGB(glow.color) + " (pulse +/-" + 8f.ToString("F0") + "%)")); } ParticleSystem val = null; Material val2 = GetSmokeMaterial(log); if (Object.op_Implicit((Object)(object)val2)) { val = CreateSmoke(visual.transform, val2, visual.layer); string[] obj = new string[13] { "NHJS2: smoke aura attached (material ", ((Object)val2).name, ", shader ", Object.op_Implicit((Object)(object)val2.shader) ? ((Object)val2.shader).name : "<null>", ", rate ", 14f.ToString(), "/s x", Amount.ToString("F2"), ", max ", null, null, null, null }; MainModule main = val.main; obj[9] = ((MainModule)(ref main)).maxParticles.ToString(); obj[10] = ", enabled "; obj[11] = SmokeOn.ToString(); obj[12] = ")"; log.LogInfo((object)string.Concat(obj)); } else { log.LogWarning((object)("NHJS2: no vanilla smoke material found (" + string.Join(", ", VanillaSmokeMaterials) + "); smoke aura skipped")); } JesterAura jesterAura = visual.AddComponent<JesterAura>(); jesterAura.glow = glow; jesterAura.smoke = val; } private static Material GetSmokeMaterial(ManualLogSource log) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_003d: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0065: 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) if (Object.op_Implicit((Object)(object)smokeMaterial)) { return smokeMaterial; } Material val = null; string text = null; string[] vanillaSmokeMaterials = VanillaSmokeMaterials; foreach (string text2 in vanillaSmokeMaterials) { try { if (AssetManager.Instance.IsReady()) { SoftReference<Material> softReference = AssetManager.Instance.GetSoftReference<Material>(text2); if (softReference.IsValid) { softReference.Load(); if (Object.op_Implicit((Object)(object)softReference.Asset)) { vanillaRef = softReference; val = softReference.Asset; text = "SoftRef " + text2; } } } } catch (Exception ex) { log.LogWarning((object)("NHJS2: soft reference lookup for " + text2 + " failed: " + ex.Message)); } if (!Object.op_Implicit((Object)(object)val)) { Material prefab = Cache.GetPrefab<Material>(text2); if (Object.op_Implicit((Object)(object)prefab)) { val = prefab; text = "PrefabManager.Cache " + text2; } } if (Object.op_Implicit((Object)(object)val)) { break; } log.LogWarning((object)("NHJS2: vanilla material " + text2 + " not found, trying the next one")); } if (!Object.op_Implicit((Object)(object)val)) { return null; } Material val2 = new Material(val); ((Object)val2).name = "NH_JesterSword02_SmokeMat (" + ((Object)val).name + ")"; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", MaterialTint); } if (val2.HasProperty("_TintColor")) { val2.SetColor("_TintColor", MaterialTint); } if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", Color.black); } smokeMaterial = val2; log.LogInfo((object)("NHJS2: smoke material " + ((Object)val2).name + " cloned from " + text + " shader=" + (Object.op_Implicit((Object)(object)val2.shader) ? ((Object)val2.shader).name : "<null>") + " supported=" + (Object.op_Implicit((Object)(object)val2.shader) && val2.shader.isSupported) + " texture=" + (Object.op_Implicit((Object)(object)val2.mainTexture) ? ((Object)val2.mainTexture).name : "<none>"))); return val2; } private static ParticleSystem CreateSmoke(Transform parent, Material mat, int layer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0025: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: 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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("NH_JesterSword02_Smoke"); val.layer = layer; val.transform.SetParent(parent, false); val.transform.localPosition = BladeMidpoint; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; ParticleSystem val2 = val.AddComponent<ParticleSystem>(); val2.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val2.main; ((MainModule)(ref main)).duration = 2f; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).prewarm = false; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 2.5f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f, 0.03f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.3f); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); ((MainModule)(ref main)).startColor = new MinMaxGradient(SmokeColorA, SmokeColorB); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; ((MainModule)(ref main)).maxParticles = 60; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(14f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = BladeBox; ((ShapeModule)(ref shape)).position = Vector3.zero; ((ShapeModule)(ref shape)).rotation = Vector3.zero; VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.02f, 0.02f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.06f, 0.16f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.02f, 0.02f); NoiseModule noise = val2.noise; ((NoiseModule)(ref noise)).enabled = true; ((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.06f); ((NoiseModule)(ref noise)).frequency = 0.8f; ((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.15f); ((NoiseModule)(ref noise)).octaveCount = 1; ((NoiseModule)(ref noise)).quality = (ParticleSystemNoiseQuality)0; ((NoiseModule)(ref noise)).damping = true; ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.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.25f), new GradientAlphaKey(0.7f, 0.65f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3); SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.6f, 1f, 1.3f)); RotationOverLifetimeModule rotationOverLifetime = val2.rotationOverLifetime; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true; ((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-0.34906584f, 0.34906584f); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).sharedMaterial = mat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; component.alignment = (ParticleSystemRenderSpace)0; component.sortMode = (ParticleSystemSortMode)0; component.maxParticleSize = 0.5f; return val2; } } internal sealed class JesterAura : MonoBehaviour { public const float PulseAmplitude = 0.08f; public Light glow; public ParticleSystem smoke; private float phase; private float baseIntensity; private int appliedVersion = -1; private void Awake() { phase = Random.value * 100f; if (!Object.op_Implicit((Object)(object)glow)) { glow = ((Component)this).GetComponentInChildren<Light>(true); } if (!Object.op_Implicit((Object)(object)smoke)) { smoke = ((Component)this).GetComponentInChildren<ParticleSystem>(true); } } private void OnEnable() { Apply(); } private void Update() { if (appliedVersion != GlowAura.SettingsVersion) { Apply(); } if (Object.op_Implicit((Object)(object)glow)) { float num = Time.time + phase; float num2 = 0.65f * Mathf.Sin(num * 1.3f) + 0.35f * Mathf.Sin(num * 3.1f); glow.intensity = baseIntensity * (1f + 0.08f * num2); } } private void Apply() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) appliedVersion = GlowAura.SettingsVersion; baseIntensity = GlowAura.Intensity; if (Object.op_Implicit((Object)(object)glow)) { glow.intensity = baseIntensity; glow.range = GlowAura.Range; } if (!Object.op_Implicit((Object)(object)smoke)) { return; } if (GlowAura.SmokeOn) { float amount = GlowAura.Amount; MainModule main = smoke.main; ((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(60f * Mathf.Max(1f, amount)); EmissionModule emission = smoke.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(14f * amount); if (!((Component)smoke).gameObject.activeSelf) { ((Component)smoke).gameObject.SetActive(true); } if (!smoke.isPlaying) { smoke.Play(true); } } else if (((Component)smoke).gameObject.activeSelf) { smoke.Stop(true, (ParticleSystemStopBehavior)0); ((Component)smoke).gameObject.SetActive(false); } } } internal sealed class JesterCryCamp { public const string LocationName = "NH_JesterCryCamp"; public const string ChestName = "NH_JesterCry_Chest"; private const string ChestBase = "TreasureChest_blackforest"; private const string RuneStoneAsset = "RuneStone_BlackForest"; private const string RuneStoneObjectName = "NH_JesterCry_RuneStone"; private const string GuardSpawner = "Spawner_Greydwarf"; public const string LoreTopic = "Jester Cry"; public const string DefaultLore = "Bells rang in these pines, and laughter where no one should laugh.\\nJester Cry made camp here, and left before the fire was cold.\\nSomething bright was left behind for whoever came next."; private readonly ManualLogSource log; private readonly ConfigEntry<int> quantity; private readonly ConfigEntry<bool> guard; private readonly ConfigEntry<string> lore; private GameObject container; private CustomLocation customLocation; private RuneStone runeStone; private SoftReference<GameObject> runeStoneRef; private bool runeStoneTried; public JesterCryCamp(ConfigFile config, ManualLogSource log) { //IL_000d: 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_001a: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown this.log = log; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; quantity = config.Bind<int>("Jester Cry camp", "Quantity", 3, new ConfigDescription("How many Jester Cry camps are placed in the Black Forest of a world. 0 = none. Only affects worlds or areas generated after the change; existing camps are not added or removed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), new object[1] { val })); guard = config.Bind<bool>("Jester Cry camp", "Guard", true, new ConfigDescription("Add one vanilla Greydwarf spawner at camps generated from now on. Read at game start.", (AcceptableValueBase)null, new object[1] { val })); lore = config.Bind<string>("Jester Cry camp", "LoreText", "Bells rang in these pines, and laughter where no one should laugh.\\nJester Cry made camp here, and left before the fire was cold.\\nSomething bright was left behind for whoever came next.", new ConfigDescription("Runestone text at the camp (PLACEHOLDER lore). Use \\n for a new line.", (AcceptableValueBase)null, new object[1] { val })); lore.SettingChanged += delegate { ApplyLore(); }; } public static string LoreFromConfigValue(string value) { return (value ?? string.Empty).Replace("\\n", "\n"); } public void Build(GameObject swordPrefab) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0097: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0343: 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_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Expected O, but got Unknown //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) try { List<string> list = new List<string>(); GameObject val = CreateChestPrefab(swordPrefab, list); container = ZoneManager.Instance.CreateLocationContainer("NH_JesterCryCamp"); GameObject val2 = new GameObject("NH_JesterCry_Ground"); val2.transform.SetParent(container.transform, false); TerrainModifier val3 = val2.AddComponent<TerrainModifier>(); val3.m_level = true; val3.m_levelRadius = 6f; val3.m_levelOffset = 0f; val3.m_square = false; val3.m_smooth = true; val3.m_smoothRadius = 9f; val3.m_smoothPower = 3f; val3.m_paintCleared = true; val3.m_paintType = (PaintType)0; val3.m_paintRadius = 5f; val3.m_paintStrength = 1f; GameObject val4 = Place(container, "fire_pit", new Vector3(0f, 0f, 0f), 0f, Vector3.zero, 0.02f, list); if (Object.op_Implicit((Object)(object)val4)) { Fireplace component = val4.GetComponent<Fireplace>(); if (Object.op_Implicit((Object)(object)component)) { component.m_startFuel = 0f; } } if (Object.op_Implicit((Object)(object)val)) { PlaceFacingCentre(container, val, new Vector3(0.4f, 0f, -3.3f), 0.02f); } Place(container, "jute_carpet", new Vector3(-2.8f, 0f, -1.2f), 25f, Vector3.zero, 0.05f, list); Place(container, "wood_pole2", new Vector3(-3f, 0f, -0.4f), 70f, new Vector3(0f, 0f, 90f), 0.05f, list); Place(container, "rug_straw", new Vector3(-3.3f, 0f, 1.6f), -35f, Vector3.zero, 0.05f, list); BannerOnPole(container, "wood_pole_log_4_worn", "piece_banner09", new Vector3(-4.3f, 0f, -3.6f), 35f, new Vector3(3f, 0f, -4f), list); BannerOnPole(container, "wood_pole_log_4_worn", "piece_banner04", new Vector3(4.6f, 0f, 1.9f), -110f, new Vector3(-5f, 0f, 2f), list); FallenBanner(container, "piece_banner08", new Vector3(1.8f, 0f, 3.4f), 60f, list); Place(container, "bone_stack", new Vector3(3.2f, 0f, 3f), 15f, Vector3.zero, 0.02f, list); Place(container, "Skull1", new Vector3(1.3f, 0f, -1.1f), 140f, new Vector3(0f, 0f, 12f), 0.03f, list); Place(container, "Skull2", new Vector3(-1.6f, 0f, 2.6f), -60f, Vector3.zero, 0.03f, list); if (guard.Value) { GameObject val5 = Place(container, "Spawner_Greydwarf", new Vector3(0f, 0f, 6.5f), 0f, Vector3.zero, 0f, list); if (Object.op_Implicit((Object)(object)val5)) { ((Object)val5).name = "Spawner_Greydwarf"; } } LocationConfig val6 = new LocationConfig { Biome = (Biome)8, BiomeArea = (BiomeArea)3, Quantity = Mathf.Clamp(quantity.Value, 0, 50), Priotized = false, ExteriorRadius = 8f, ClearArea = true, MinDistance = 500f, MaxDistance = 0f, MinAltitude = 3f, MaxTerrainDelta = 2f, RandomRotation = true, Group = "NH_JesterCryCamp", MinDistanceFromSimilar = 500f }; customLocation = new CustomLocation(container, false, val6); customLocation.Location.m_noBuild = false; if (!ZoneManager.Instance.AddCustomLocation(customLocation)) { throw new InvalidOperationException("ZoneManager rejected NH_JesterCryCamp"); } ZoneManager.OnVanillaLocationsAvailable += OnVanillaLocationsAvailable; ZoneManager.OnLocationsRegistered += OnLocationsRegistered; if (list.Count > 0) { log.LogWarning((object)("NHJS2: camp props missing (skipped): " + string.Join(", ", list.ToArray()))); } else { log.LogInfo((object)"NHJS2: camp props: all vanilla prefabs found"); } log.LogInfo((object)("NHJS2: Jester Cry camp registered (quantity " + val6.Quantity + ", Black Forest, min " + val6.MinDistance + " m from centre, radius " + val6.ExteriorRadius + " m, guard " + (guard.Value ? "on" : "off") + "); runestone added on world load")); } catch (Exception ex) { log.LogError((object)("NHJS2: Jester Cry camp registration failed: " + ex)); } } private GameObject CreateChestPrefab(GameObject swordPrefab, List<string> missing) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("Coins"); GameObject prefab2 = PrefabManager.Instance.GetPrefab("Amber"); if (!Object.op_Implicit((Object)(object)prefab)) { missing.Add("Coins"); } if (!Object.op_Implicit((Object)(object)prefab2)) { missing.Add("Amber"); } if (!Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("TreasureChest_blackforest"))) { missing.Add("TreasureChest_blackforest"); return null; } if (!Object.op_Implicit((Object)(object)swordPrefab)) { log.LogError((object)"NHJS2: no sword prefab; chest not created"); return null; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("NH_JesterCry_Chest", "TreasureChest_blackforest"); if (!Object.op_Implicit((Object)(object)val)) { log.LogError((object)"NHJS2: could not clone TreasureChest_blackforest"); return null; } Container component = val.GetComponent<Container>(); if (!Object.op_Implicit((Object)(object)component)) { log.LogError((object)"NHJS2: TreasureChest_blackforest has no Container"); return null; } List<DropData> list = new List<DropData> { new DropData { m_item = swordPrefab, m_stackMin = 1, m_stackMax = 1, m_weight = 1f, m_dontScale = true } }; if (Object.op_Implicit((Object)(object)prefab)) { list.Add(new DropData { m_item = prefab, m_stackMin = 15, m_stackMax = 35, m_weight = 1f, m_dontScale = true }); } if (Object.op_Implicit((Object)(object)prefab2)) { list.Add(new DropData { m_item = prefab2, m_stackMin = 1, m_stackMax = 3, m_weight = 1f, m_dontScale = true }); } component.m_defaultItems = new DropTable { m_drops = list, m_dropMin = list.Count, m_dropMax = list.Count, m_dropChance = 1f, m_oneOfEach = true }; PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false)); log.LogInfo((object)("NHJS2: chest prefab NH_JesterCry_Chest (clone of TreasureChest_blackforest) drops: NH_JesterSword02 x1" + (Object.op_Implicit((Object)(object)prefab) ? ", Coins 15-35" : "") + (Object.op_Implicit((Object)(object)prefab2) ? ", Amber 1-3" : ""))); return val; } private void OnVanillaLocationsAvailable() { try { if (customLocation != null && customLocation.ZoneLocation != null) { customLocation.ZoneLocation.m_quantity = Mathf.Clamp(quantity.Value, 0, 50); } if (!runeStoneTried) { runeStoneTried = true; AddRuneStone(); } ApplyLore(); } catch (Exception ex) { log.LogError((object)("NHJS2: Jester Cry camp world-load setup failed: " + ex)); } } private void OnLocationsRegistered() { ZoneLocation zoneLocation = ZoneManager.Instance.GetZoneLocation("NH_JesterCryCamp"); if (zoneLocation != null) { log.LogInfo((object)("NHJS2: Jester Cry camp in ZoneSystem (quantity " + zoneLocation.m_quantity + ", biome " + ((object)Unsafe.As<Biome, Biome>(ref zoneLocation.m_biome)/*cast due to .constrained prefix*/).ToString() + ")")); } else { log.LogWarning((object)"NHJS2: Jester Cry camp NOT found in ZoneSystem after registration"); } } private void AddRuneStone() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_00a6: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ed: 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_0102: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)container)) { return; } runeStoneRef = AssetManager.Instance.GetSoftReference<GameObject>("RuneStone_BlackForest"); if (!runeStoneRef.IsValid) { log.LogWarning((object)"NHJS2: runestone asset RuneStone_BlackForest not found; camp has no runestone"); return; } runeStoneRef.Load(); GameObject asset = runeStoneRef.Asset; if (!Object.op_Implicit((Object)(object)asset)) { log.LogWarning((object)"NHJS2: runestone asset RuneStone_BlackForest failed to load"); return; } GameObject val = Object.Instantiate<GameObject>(asset, container.transform, false); ((Object)val).name = "NH_JesterCry_RuneStone"; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(3.6f, 0f, -2.4f); Vector3 val3 = new Vector3(0f - val2.x, 0f, 0f - val2.z); Quaternion val4 = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up); val.transform.localRotation = val4; float num = MinY(asset, val4); val.transform.localPosition = new Vector3(val2.x, 0f - num - 0.15f, val2.z); if (val.GetComponentsInChildren<ZNetView>(true).Length != 0) { log.LogWarning((object)"NHJS2: runestone copy has a ZNetView; it will be saved as a networked object"); } runeStone = val.GetComponentInChildren<RuneStone>(true); if (!Object.op_Implicit((Object)(object)runeStone)) { log.LogWarning((object)"NHJS2: RuneStone_BlackForest has no RuneStone component"); return; } runeStone.m_randomTexts = new List<RandomRuneText>(); runeStone.m_locationName = ""; runeStone.m_showMap = false; runeStone.m_dreamCinematic = ""; runeStone.m_label = ""; runeStone.m_topic = "Jester Cry"; log.LogInfo((object)"NHJS2: Jester Cry runestone added (copy of RuneStone_BlackForest)"); } private void ApplyLore() { if (Object.op_Implicit((Object)(object)runeStone)) { runeStone.m_text = LoreFromConfigValue(lore.Value); log.LogInfo((object)("NHJS2: Jester Cry runestone text set (" + runeStone.m_text.Split(new char[1] { '\n' }).Length + " lines)")); } } private GameObject Place(GameObject parent, string prefabName, Vector3 pos, float yaw, Vector3 tilt, float sink, List<string> missing) { //IL_0020: 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_002a: 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) GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); if (!Object.op_Implicit((Object)(object)prefab)) { missing.Add(prefabName); return null; } return PlacePrefab(parent, prefab, pos, Quaternion.Euler(tilt.x, yaw, tilt.z), sink); } private GameObject PlaceFacingCentre(GameObject parent, GameObject prefab, Vector3 pos, float sink) { //IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) Vector3 val = new Vector3(0f - pos.x, 0f, 0f - pos.z); Quaternion rot = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); return PlacePrefab(parent, prefab, pos, rot, sink); } private static GameObject PlacePrefab(GameObject parent, GameObject prefab, Vector3 pos, Quaternion rot, float sink) { //IL_0020: 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_0032: 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_0043: 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) GameObject val = Object.Instantiate<GameObject>(prefab, parent.transform, false); ((Object)val).name = ((Object)prefab).name; val.transform.localRotation = rot; val.transform.localPosition = new Vector3(pos.x, pos.y - MinY(prefab, rot) - sink, pos.z); return val; } private void BannerOnPole(GameObject parent, string poleName, string bannerName, Vector3 pos, float yaw, Vector3 tilt, List<string> missing) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0061: 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_0070: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0137: 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) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab(poleName); GameObject prefab2 = PrefabManager.Instance.GetPrefab(bannerName); if (!Object.op_Implicit((Object)(object)prefab)) { missing.Add(poleName); } if (!Object.op_Implicit((Object)(object)prefab2)) { missing.Add(bannerName); } if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab2)) { Quaternion val = Quaternion.Euler(tilt.x, yaw, tilt.z); GameObject val2 = PlacePrefab(parent, prefab, pos, val, 0.8f); Bounds val3 = LocalBounds(prefab, Quaternion.identity); Bounds val4 = LocalBounds(prefab2, Quaternion.identity); Vector3 val5 = default(Vector3); if (((Bounds)(ref val4)).size.x < ((Bounds)(ref val4)).size.z) { ((Vector3)(ref val5))..ctor(((Bounds)(ref val3)).max.x - ((Bounds)(ref val4)).min.x - 0.03f, 0f, ((Bounds)(ref val3)).center.z - ((Bounds)(ref val4)).center.z); } else { ((Vector3)(ref val5))..ctor(((Bounds)(ref val3)).center.x - ((Bounds)(ref val4)).center.x, 0f, ((Bounds)(ref val3)).max.z - ((Bounds)(ref val4)).min.z - 0.03f); } val5.y = ((Bounds)(ref val3)).max.y - 0.15f - ((Bounds)(ref val4)).max.y; GameObject val6 = Object.Instantiate<GameObject>(prefab2, parent.transform, false); ((Object)val6).name = ((Object)prefab2).name; val6.transform.localRotation = val; val6.transform.localPosition = val2.transform.localPosition + val * val5; } } private void FallenBanner(GameObject parent, string bannerName, Vector3 pos, float yaw, List<string> missing) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0066: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab(bannerName); if (!Object.op_Implicit((Object)(object)prefab)) { missing.Add(bannerName); return; } Bounds val = LocalBounds(prefab, Quaternion.identity); Quaternion rot = ((((Bounds)(ref val)).size.x < ((Bounds)(ref val)).size.z) ? Quaternion.Euler(0f, yaw, 90f) : Quaternion.Euler(90f, yaw, 0f)); PlacePrefab(parent, prefab, pos, rot, 0.05f); } private static float MinY(GameObject prefab, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Bounds val = LocalBounds(prefab, rot); if (!(((Bounds)(ref val)).size == Vector3.zero)) { return ((Bounds)(ref val)).min.y; } return 0f; } private static Bounds LocalBounds(GameObject prefab, Quaternion rot) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) bool flag = false; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(Vector3.zero, Vector3.zero); Matrix4x4 worldToLocalMatrix = prefab.transform.worldToLocalMatrix; MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val.sharedMesh)) { continue; } Matrix4x4 val2 = worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; Bounds bounds = val.sharedMesh.bounds; for (int j = 0; j < 8; j++) { Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); Vector3 val4 = rot * ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3); if (!flag) { ((Bounds)(ref result))..ctor(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref result)).Encapsulate(val4); } } } return result; } public void Unhook() { ZoneManager.OnVanillaLocationsAvailable -= OnVanillaLocationsAvailable; ZoneManager.OnLocationsRegistered -= OnLocationsRegistered; } } [BepInPlugin("com.nostalgiaheroes.jestersword02test", "NH Chaos Blade", "1.1.2")] [BepInDependency("com.jotunn.jotunn", "2.30.1")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.nostalgiaheroes.jestersword02test"; public const string PluginName = "NH Chaos Blade"; public const string PluginVersion = "1.1.2"; private const string BundleFile = "nh_jestersword02"; private const string VisualAssetName = "NH_JesterSword02"; private const string VisualRuntimeName = "NH_JesterSword02_Visual"; private const string ItemName = "NH_JesterSword02"; private const string BaseItem = "SwordBronze"; private const string VanillaMeshPath = "attach/Viking_Sword (1)"; private const string GlowName = "NH_JesterSword02_Glow"; private const string IconAssetName = "NH_JesterSword02_Icon"; private static readonly Vector3 VisualLocalPosition = new Vector3(0f, -0.01f, 0.3f); private static readonly Quaternion VisualLocalRotation = new Quaternion(0f, 0.7071068f, 0.7071068f, 0f); private static readonly Vector3 VisualLocalScale = Vector3.one; private AssetBundle bundle; private GameObject visualPrefab; private Sprite iconSprite; private JesterCryCamp camp; private GameObject installedVisual; private Light installedGlow; private void Awake() { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) try { string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); string text = Path.Combine(directoryName, "nh_jestersword02"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHJS2: bundle missing: " + text)); return; } bundle = AssetUtils.LoadAssetBundle(text); if (!Object.op_Implicit((Object)(object)bundle)) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHJS2: failed to load bundle " + text)); return; } visualPrefab = bundle.LoadAsset<GameObject>("NH_JesterSword02"); if (!Object.op_Implicit((Object)(object)visualPrefab)) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHJS2: bundle has no prefab NH_JesterSword02; assets: " + string.Join(", ", bundle.GetAllAssetNames()))); return; } ((Object)visualPrefab).name = "NH_JesterSword02_Visual"; ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHJS2: bundle loaded, visual prefab found: NH_JesterSword02 (renamed in memory to " + ((Object)visualPrefab).name + ")")); iconSprite = bundle.LoadAsset<Sprite>("NH_JesterSword02_Icon"); if (Object.op_Implicit((Object)(object)iconSprite)) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[6] { "NHJS2: icon sprite found in bundle: ", ((Object)iconSprite).name, " ", null, null, null }; Rect rect = iconSprite.rect; obj[3] = ((int)((Rect)(ref rect)).width).ToString(); obj[4] = "x"; rect = iconSprite.rect; obj[5] = ((int)((Rect)(ref rect)).height).ToString(); logger.LogInfo((object)string.Concat(obj)); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHJS2: icon sprite NH_JesterSword02_Icon not in bundle; will fall back to a RenderManager render. Assets: " + string.Join(", ", bundle.GetAllAssetNames()))); } camp = new JesterCryCamp(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); GlowAura.BindConfig(((BaseUnityPlugin)this).Config); PrefabManager.OnVanillaPrefabsAvailable += RegisterItem; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHJS2: Awake failed: " + ex)); } } private void RegisterItem() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= RegisterItem; CustomItem val = null; try { if (!Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("SwordBronze"))) { throw new InvalidOperationException("vanilla base prefab missing: SwordBronze"); } GameObject prefab = PrefabManager.Instance.GetPrefab("NH_JesterSword02"); if (Object.op_Implicit((Object)(object)prefab)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHJS2: GetPrefab(\"NH_JesterSword02\") returned '" + ((Object)prefab).name + "' (" + (((Object)(object)prefab == (Object)(object)visualPrefab) ? "our bundle visual via a stale cache entry" : "another object") + ")")); if ((Object)(object)prefab == (Object)(object)visualPrefab) { Cache.Clear<GameObject>(); prefab = PrefabManager.Instance.GetPrefab("NH_JesterSword02"); } if (Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("prefab name already taken: NH_JesterSword02 -> " + ((Object)prefab).name); } } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"NHJS2: GetPrefab(\"NH_JesterSword02\") returned null; name is free"); } ItemConfig val2 = new ItemConfig(); val2.Name = "Chaos Blade"; val2.Description = "A blade of pure chaos, touched by VLCE."; val2.CraftingStation = CraftingStations.Forge; val2.MinStationLevel = 1; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Bronze", 8, 4, true), new RequirementConfig("Wood", 2, 1, true), new RequirementConfig("LeatherScraps", 4, 2, true) }; ItemConfig val3 = val2; if (Object.op_Implicit((Object)(object)iconSprite)) { val3.Icons = (Sprite[])(object)new Sprite[1] { iconSprite }; } val = new CustomItem("NH_JesterSword02", "SwordBronze", val3); if (!Object.op_Implicit((Object)(object)val.ItemPrefab) || !Object.op_Implicit((Object)(object)val.ItemDrop)) { throw new InvalidOperationException("failed to clone SwordBronze"); } SwapVisual(val.ItemPrefab); if (!Object.op_Implicit((Object)(object)iconSprite)) { Sprite val4 = RenderManager.Instance.Render(val.ItemPrefab, RenderManager.IsometricRotation); if (Object.op_Implicit((Object)(object)val4)) { ((Object)val4).name = "NH_JesterSword02_Icon_Rendered"; iconSprite = val4; ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHJS2: using RenderManager fallback icon"); } } if (Object.op_Implicit((Object)(object)iconSprite)) { val.ItemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { iconSprite }; } try { GlowAura.Install(installedVisual, installedGlow, ((BaseUnityPlugin)this).Logger); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHJS2: glow/smoke aura setup failed (sword still registered): " + ex)); } Sprite[] icons = val.ItemDrop.m_itemData.m_shared.m_icons; if (icons != null && icons.Length != 0 && Object.op_Implicit((Object)(object)icons[0])) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[6] { "NHJS2: icon set ", ((Object)icons[0]).name, " ", null, null, null }; Rect rect = icons[0].rect; obj[3] = ((int)((Rect)(ref rect)).width).ToString(); obj[4] = "x"; rect = icons[0].rect; obj[5] = ((int)((Rect)(ref rect)).height).ToString(); logger.LogInfo((object)string.Concat(obj)); } else { ((BaseUnityPlugin)this).Logger.LogError((object)"NHJS2: item has NO icon (m_icons empty)"); } if (val.Recipe == null || (Object)(object)val.Recipe.Recipe == (Object)null) { throw new InvalidOperationException("Jotunn created no recipe for NH_JesterSword02"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHJS2: recipe added (forge 1: Bronze 8, Wood 2, LeatherScraps 4) name=" + ((Object)val.Recipe.Recipe).name + " perLevel(Bronze 4, Wood 1, LeatherScraps 2)")); if (!ItemManager.Instance.AddItem(val)) { throw new InvalidOperationException("ItemManager rejected NH_JesterSword02"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"NH_JesterSword02 registered"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"NHJS2: clone of SwordBronze; test with: spawn NH_JesterSword02"); if (camp != null) { camp.Build(val.ItemPrefab); } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHJS2: NH_JesterSword02 registration failed: " + ex2)); if (val != null && Object.op_Implicit((Object)(object)val.ItemPrefab)) { Object.Destroy((Object)(object)val.ItemPrefab); } } } private void SwapVisual(GameObject clone) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) Transform val = clone.transform.Find("attach"); Transform val2 = clone.transform.Find("attach/Viking_Sword (1)"); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { throw new InvalidOperationException("clone lacks attach/Viking_Sword (1)"); } MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>(); if (!Object.op_Implicit((Object)(object)component)) { throw new InvalidOperationException("attach/Viking_Sword (1) has no MeshRenderer"); } ((Renderer)component).enabled = false; GameObject val3 = Object.Instantiate<GameObject>(visualPrefab, val, false); ((Object)val3).name = "NH_JesterSword02_Visual"; val3.transform.localPosition = VisualLocalPosition; val3.transform.localRotation = VisualLocalRotation; val3.transform.localScale = VisualLocalScale; int num = 0; Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>(true); foreach (Collider val4 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val4); num++; } int layer = ((Component)val2).gameObject.layer; Transform[] componentsInChildren2 = val3.GetComponentsInChildren<Transform>(true); foreach (Transform val5 in componentsInChildren2) { ((Component)val5).gameObject.layer = layer; } MeshRenderer[] componentsInChildren3 = val3.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val6 in componentsInChildren3) { Material sharedMaterial = ((Renderer)val6).sharedMaterial; Shader val7 = (Object.op_Implicit((Object)(object)sharedMaterial) ? sharedMaterial.shader : null); ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHJS2: visual renderer " + ((Object)val6).name + " materials=" + ((Renderer)val6).sharedMaterials.Length + " material=" + (Object.op_Implicit((Object)(object)sharedMaterial) ? ((Object)sharedMaterial).name : "<null>") + " shader=" + (Object.op_Implicit((Object)(object)val7) ? ((Object)val7).name : "<null>") + " supported=" + (Object.op_Implicit((Object)(object)val7) && val7.isSupported))); } Light val8 = null; Light[] componentsInChildren4 = val3.GetComponentsInChildren<Light>(true); foreach (Light val9 in componentsInChildren4) { if (((Object)val9).name == "NH_JesterSword02_Glow") { val8 = val9; break; } } Vector3 val10; if (Object.op_Implicit((Object)(object)val8)) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[18] { "NHJS2: glow light ", ((Object)val8).name, " type=", ((object)val8.type/*cast due to .constrained prefix*/).ToString(), " color=", null, null, null, null, null, null, null, null, null, null, null, null, null }; Color color = val8.color; obj[5] = ((Color)(ref color)).ToString("F3"); obj[6] = " intensity="; obj[7] = val8.intensity.ToString("F2"); obj[8] = " range="; obj[9] = val8.range.ToString("F2"); obj[10] = " shadows="; obj[11] = ((object)val8.shadows/*cast due to .constrained prefix*/).ToString(); obj[12] = " renderMode="; obj[13] = ((object)val8.renderMode/*cast due to .constrained prefix*/).ToString(); obj[14] = " localPos="; val10 = ((Component)val8).transform.localPosition; obj[15] = ((Vector3)(ref val10)).ToString("F4"); obj[16] = " enabled="; obj[17] = ((Behaviour)val8).enabled.ToString(); logger.LogInfo((object)string.Concat(obj)); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHJS2: glow light NH_JesterSword02_Glow not found on visual"); } installedVisual = val3; installedGlow = val8; ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger; string[] obj2 = new string[10] { "NHJS2: visual installed under attach at pos ", null, null, null, null, null, null, null, null, null }; val10 = VisualLocalPosition; obj2[1] = ((Vector3)(ref val10)).ToString("F4"); obj2[2] = " rot "; Quaternion visualLocalRotation = VisualLocalRotation; obj2[3] = ((Quaternion)(ref visualLocalRotation)).ToString("F7"); obj2[4] = " scale "; val10 = VisualLocalScale; obj2[5] = ((Vector3)(ref val10)).ToString("F3"); obj2[6] = "; vanilla renderer disabled; colliders removed from visual="; obj2[7] = num.ToString(); obj2[8] = "; layer="; obj2[9] = layer.ToString(); logger2.LogInfo((object)string.Concat(obj2)); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterItem; if (camp != null) { camp.Unhook(); } } }