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 ChaosShield v1.0.0
plugins/NH_ChaosShield/NH_ChaosShield.dll
Decompiled 2 weeks agousing System; 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.Text; 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_ChaosShield")] [assembly: AssemblyProduct("NH Chaos Shield")] [assembly: AssemblyDescription("Nostalgia Heroes - Chaos Shield (NH_ChaosShield): round shield with the Chaos skull model, glowing cracks and a Forge recipe")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace NH_ChaosShield; internal static class ChaosAura { public const string Section = "Glow and aura"; public const string SmokeObjectName = "NH_ChaosShield_Smoke"; public const string LightObjectName = "NH_ChaosShield_Glow"; public const string SmokeMaterialName = "NH_ChaosShield_SmokeMat"; private static readonly string[] VanillaSmokeMaterials = new string[3] { "wraith_smoke", "smoke", "ghost_smoke" }; public static readonly Color GlowColor = new Color(0.35f, 0.05f, 0.6f, 1f); private static readonly Color SmokeColorA = new Color(0.6f, 0.45f, 0.7f, 0.45f); private static readonly Color SmokeColorB = new Color(0.4f, 0.3f, 0.5f, 0.3f); public const float BaseRate = 5f; public const int BaseMaxParticles = 24; private static readonly Vector3 FaceNormal = new Vector3(0.2960969f, -0.9548738f, -0.0232936f); private static readonly Vector3 FaceUp = new Vector3(-0.9549924f, -0.2955036f, -0.0258293f); private static readonly Vector3 SmokeOrigin = new Vector3(0.0728f, -0.1455f, 0.0211f); private static readonly Vector3 LightOrigin = new Vector3(0.129f, -0.327f, 0.0166f); private const float SmokeRadius = 0.33f; public static ConfigEntry<bool> GlowEnabled; public static ConfigEntry<float> GlowIntensity; public static ConfigEntry<float> LightIntensity; public static ConfigEntry<float> GlowRange; public static ConfigEntry<bool> SmokeEnabled; public static ConfigEntry<float> SmokeAmount; public static ConfigEntry<float> SmokeSize; public static int SettingsVersion; private static SoftReference<Material> vanillaRef; private static Material smokeMaterial; public static bool GlowOn { get { if (GlowEnabled != null) { return GlowEnabled.Value; } return true; } } public static float Emission { get { if (GlowIntensity == null) { return 1.5f; } return Mathf.Clamp(GlowIntensity.Value, 0f, 4f); } } public static float LightPower { get { if (!GlowOn || LightIntensity == null) { if (!GlowOn) { return 0f; } return 0.6f; } return Mathf.Clamp(LightIntensity.Value, 0f, 4f); } } public static float Range { get { if (GlowRange == null) { return 1.5f; } 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 float Size { get { if (SmokeSize == null) { return 1f; } return Mathf.Clamp(SmokeSize.Value, 0.25f, 2f); } } public static bool SmokeOn { get { if (SmokeEnabled == null || SmokeEnabled.Value) { return Amount > 0.001f; } return false; } } public static void BindConfig(ConfigFile config) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown GlowEnabled = config.Bind<bool>("Glow and aura", "GlowEnabled", true, new ConfigDescription("Glowing dark purple cracks on the Chaos Shield (client-side).", (AcceptableValueBase)null, Array.Empty<object>())); GlowIntensity = config.Bind<float>("Glow and aura", "GlowIntensity", 1.5f, new ConfigDescription("Brightness of the crack glow (emission multiplier on #590D99, client-side). Above ~1.6 the colour turns pinker.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), Array.Empty<object>())); LightIntensity = config.Bind<float>("Glow and aura", "LightIntensity", 0.6f, new ConfigDescription("Small dim purple point light in front of the shield (client-side). 0 = no light.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), Array.Empty<object>())); GlowRange = config.Bind<float>("Glow and aura", "GlowRange", 1.5f, new ConfigDescription("Range of that point light in metres (client-side).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>())); SmokeEnabled = config.Bind<bool>("Glow and aura", "SmokeEnabled", true, new ConfigDescription("Show a little dark purple smoke from the shield face (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 5 puffs per second, max 24 at a time. 0 = no smoke.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); SmokeSize = config.Bind<float>("Glow and aura", "SmokeSize", 1f, new ConfigDescription("Smoke puff size multiplier (client-side).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 2f), Array.Empty<object>())); EventHandler eventHandler = delegate { SettingsVersion++; }; GlowEnabled.SettingChanged += eventHandler; GlowIntensity.SettingChanged += eventHandler; LightIntensity.SettingChanged += eventHandler; GlowRange.SettingChanged += eventHandler; SmokeEnabled.SettingChanged += eventHandler; SmokeAmount.SettingChanged += eventHandler; SmokeSize.SettingChanged += eventHandler; } public static void Install(GameObject visual, ManualLogSource log) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) Light val = CreateLight(visual.transform, visual.layer); log.LogInfo((object)("NHCS: glow light added: color #" + ColorUtility.ToHtmlStringRGB(val.color) + " intensity " + LightPower.ToString("F2") + " range " + Range.ToString("F2") + " (pulse +/-" + 10f.ToString("F0") + "%), crack emission x" + Emission.ToString("F2") + " glowEnabled=" + GlowOn)); ParticleSystem val2 = null; Material val3 = GetSmokeMaterial(log); if (Object.op_Implicit((Object)(object)val3)) { val2 = CreateSmoke(visual.transform, val3, visual.layer); string[] obj = new string[15] { "NHCS: smoke attached (material ", ((Object)val3).name, ", shader ", Object.op_Implicit((Object)(object)val3.shader) ? ((Object)val3.shader).name : "<null>", ", rate ", 5f.ToString(), "/s x", Amount.ToString("F2"), ", max ", null, null, null, null, null, null }; MainModule main = val2.main; obj[9] = ((MainModule)(ref main)).maxParticles.ToString(); obj[10] = ", size x"; obj[11] = Size.ToString("F2"); obj[12] = ", enabled "; obj[13] = SmokeOn.ToString(); obj[14] = ")"; log.LogInfo((object)string.Concat(obj)); } else { log.LogWarning((object)("NHCS: no vanilla smoke material found (" + string.Join(", ", VanillaSmokeMaterials) + "); smoke skipped")); } ShieldAura shieldAura = visual.AddComponent<ShieldAura>(); shieldAura.glow = val; shieldAura.smoke = val2; } private static Light CreateLight(Transform parent, 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_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("NH_ChaosShield_Glow"); val.layer = layer; val.transform.SetParent(parent, false); val.transform.localPosition = LightOrigin; Light val2 = val.AddComponent<Light>(); val2.type = (LightType)2; val2.color = GlowColor; val2.intensity = LightPower; val2.range = Range; val2.shadows = (LightShadows)0; val2.renderMode = (LightRenderMode)0; ((Behaviour)val2).enabled = LightPower > 0.001f; return val2; } 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)("NHCS: 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)("NHCS: 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_ChaosShield_SmokeMat (" + ((Object)val).name + ")"; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", GlowColor); } if (val2.HasProperty("_TintColor")) { val2.SetColor("_TintColor", GlowColor); } if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", Color.black); } smokeMaterial = val2; log.LogInfo((object)("NHCS: 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_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_004f: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00d7: 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_00f9: 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_0103: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_023a: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_027d: 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_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: 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_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: 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) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030e: 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_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("NH_ChaosShield_Smoke"); val.layer = layer; val.transform.SetParent(parent, false); val.transform.localPosition = SmokeOrigin; val.transform.localRotation = Quaternion.LookRotation(FaceNormal, FaceUp); 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.2f, 2f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f, 0.02f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.08f * Size, 0.2f * Size); ((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 = 24; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(5f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10; ((ShapeModule)(ref shape)).radius = 0.33f; ((ShapeModule)(ref shape)).radiusThickness = 1f; ((ShapeModule)(ref shape)).arc = 360f; ((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.015f, 0.015f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.04f, 0.1f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.015f, 0.015f); NoiseModule noise = val2.noise; ((NoiseModule)(ref noise)).enabled = true; ((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.04f); ((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.6f, 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.4f; return val2; } } internal sealed class ShieldAura : MonoBehaviour { public const float PulseAmplitude = 0.1f; private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor"); public Light glow; public ParticleSystem smoke; private MeshRenderer[] renderers; private MaterialPropertyBlock block; private float phase; private int appliedVersion = -1; private void Awake() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown 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); } renderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); block = new MaterialPropertyBlock(); } private void OnEnable() { Apply(); } private void Update() { //IL_005b: 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) if (appliedVersion != ChaosAura.SettingsVersion) { Apply(); } if (ChaosAura.GlowOn) { float num = Time.time + phase; float num2 = 1f + 0.1f * (0.65f * Mathf.Sin(num * 1.3f) + 0.35f * Mathf.Sin(num * 3.1f)); SetEmission(ChaosAura.GlowColor * (ChaosAura.Emission * num2)); if (Object.op_Implicit((Object)(object)glow) && ((Behaviour)glow).enabled) { glow.intensity = ChaosAura.LightPower * num2; } } } private void SetEmission(Color c) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (renderers == null) { return; } MeshRenderer[] array = renderers; foreach (MeshRenderer val in array) { if (Object.op_Implicit((Object)(object)val)) { ((Renderer)val).GetPropertyBlock(block); block.SetColor(EmissionColorId, c); ((Renderer)val).SetPropertyBlock(block); } } } private void Apply() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_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_00cf: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) appliedVersion = ChaosAura.SettingsVersion; SetEmission(ChaosAura.GlowOn ? (ChaosAura.GlowColor * ChaosAura.Emission) : Color.black); if (Object.op_Implicit((Object)(object)glow)) { glow.intensity = ChaosAura.LightPower; glow.range = ChaosAura.Range; ((Behaviour)glow).enabled = ChaosAura.LightPower > 0.001f; } if (!Object.op_Implicit((Object)(object)smoke)) { return; } if (ChaosAura.SmokeOn) { float amount = ChaosAura.Amount; float size = ChaosAura.Size; MainModule main = smoke.main; ((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(24f * Mathf.Max(1f, amount)); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.08f * size, 0.2f * size); EmissionModule emission = smoke.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(5f * 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); } } } [BepInPlugin("com.nostalgiaheroes.chaosshield", "NH Chaos Shield", "1.0.0")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] public sealed class Plugin : BaseUnityPlugin { private struct Req { public string Item; public int Amount; public int PerLevel; } public const string PluginGUID = "com.nostalgiaheroes.chaosshield"; public const string PluginName = "NH Chaos Shield"; public const string PluginVersion = "1.0.0"; private const string BundleFile = "nh_chaosshield"; private const string VisualAssetName = "NH_ChaosShield_Visual"; private const string VisualRuntimeName = "NH_ChaosShield_VisualRuntime"; private const string ModelChildName = "NH_ChaosShield_Model"; private const string IconAssetName = "NH_ChaosShield_Icon"; private const string IconFile = "NH_ChaosShield_Icon.png"; private const string ItemName = "NH_ChaosShield"; private const string BaseItem = "ShieldWood"; private const string VanillaMeshPath = "attach/model"; private static readonly Vector3 ExpectedChildPos = new Vector3(0.0094815f, -0.0206488f, 0.0160509f); private static readonly Quaternion ExpectedChildRot = new Quaternion(-0.0116048f, -0.0010129f, -0.105992f, 0.9942987f); private const float ExpectedChildScale = 1.521159f; private static readonly Vector3 ExpectedModelLocalPos = new Vector3(0.045f, -0.065f, 0.023f); private const float ExpectedModelLocalScale = 0.8f; private const string DefaultStation = "forge"; private const int DefaultMinStationLevel = 1; private const string DefaultRequirements = "Bronze:10:5, Wood:10:5, LeatherScraps:4:2"; private AssetBundle bundle; private GameObject visualPrefab; private Sprite iconSprite; private CustomItem registered; private ConfigEntry<string> cfgStation; private ConfigEntry<int> cfgStationLevel; private ConfigEntry<string> cfgRequirements; private void Awake() { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) try { BindRecipeConfig(); ChaosAura.BindConfig(((BaseUnityPlugin)this).Config); string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); string text = Path.Combine(directoryName, "nh_chaosshield"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHCS: bundle missing: " + text)); return; } bundle = AssetUtils.LoadAssetBundle(text); if (!Object.op_Implicit((Object)(object)bundle)) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHCS: failed to load bundle " + text)); return; } visualPrefab = bundle.LoadAsset<GameObject>("NH_ChaosShield_Visual"); if (!Object.op_Implicit((Object)(object)visualPrefab)) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHCS: bundle has no prefab NH_ChaosShield_Visual; assets: " + string.Join(", ", bundle.GetAllAssetNames()))); return; } ((Object)visualPrefab).name = "NH_ChaosShield_VisualRuntime"; ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: bundle loaded, visual prefab found: NH_ChaosShield_Visual (renamed in memory to " + ((Object)visualPrefab).name + ")")); iconSprite = bundle.LoadAsset<Sprite>("NH_ChaosShield_Icon"); Rect rect; if (Object.op_Implicit((Object)(object)iconSprite)) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[6] { "NHCS: icon sprite found in bundle: ", ((Object)iconSprite).name, " ", null, null, null }; 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 { string text2 = Path.Combine(directoryName, "NH_ChaosShield_Icon.png"); ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: icon sprite NH_ChaosShield_Icon not in bundle (assets: " + string.Join(", ", bundle.GetAllAssetNames()) + "); trying file " + text2)); if (File.Exists(text2)) { iconSprite = AssetUtils.LoadSpriteFromFile(text2); } if (Object.op_Implicit((Object)(object)iconSprite)) { ((Object)iconSprite).name = "NH_ChaosShield_Icon"; ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger; rect = iconSprite.rect; string text3 = ((int)((Rect)(ref rect)).width).ToString(); rect = iconSprite.rect; logger2.LogInfo((object)("NHCS: icon loaded from file " + text3 + "x" + (int)((Rect)(ref rect)).height)); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHCS: no icon file either; will fall back to a RenderManager render"); } } PrefabManager.OnVanillaPrefabsAvailable += RegisterItem; SynchronizationManager.OnConfigurationSynchronized += OnConfigSynced; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHCS: Awake failed: " + ex)); } } private void BindRecipeConfig() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; cfgStation = ((BaseUnityPlugin)this).Config.Bind<string>("Recipe", "CraftingStation", "forge", new ConfigDescription("PLACEHOLDER. Crafting station prefab name (forge, piece_workbench, blackforge, ...).", (AcceptableValueBase)null, new object[1] { val })); cfgStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "MinStationLevel", 1, new ConfigDescription("PLACEHOLDER. Station level needed to craft quality 1 (each upgrade needs one more level).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), new object[1] { val })); cfgRequirements = ((BaseUnityPlugin)this).Config.Bind<string>("Recipe", "Requirements", "Bronze:10:5, Wood:10:5, LeatherScraps:4:2", new ConfigDescription("PLACEHOLDER. Comma separated Item:Amount:AmountPerLevel. Upgrade cost = AmountPerLevel x quality gained.", (AcceptableValueBase)null, new object[1] { val })); EventHandler eventHandler = delegate { ApplyRecipe("config changed"); }; cfgStation.SettingChanged += eventHandler; cfgStationLevel.SettingChanged += eventHandler; cfgRequirements.SettingChanged += eventHandler; } private List<Req> ParseRequirements(string s, out bool ok) { ok = true; List<Req> list = new List<Req>(); string[] array = (s ?? "").Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string[] array2 = text.Trim().Split(new char[1] { ':' }); if (array2.Length != 3 || array2[0].Trim().Length == 0 || !int.TryParse(array2[1].Trim(), out var result) || !int.TryParse(array2[2].Trim(), out var result2) || result < 0 || result2 < 0) { ok = false; continue; } list.Add(new Req { Item = array2[0].Trim(), Amount = result, PerLevel = result2 }); } if (list.Count == 0) { ok = false; } return list; } private List<Req> CurrentRequirements() { bool ok; List<Req> result = ParseRequirements(cfgRequirements.Value, out ok); if (!ok) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: could not fully parse [Recipe] Requirements '" + cfgRequirements.Value + "'; using the default 'Bronze:10:5, Wood:10:5, LeatherScraps:4:2'")); result = ParseRequirements("Bronze:10:5, Wood:10:5, LeatherScraps:4:2", out ok); } return result; } private static string Describe(IEnumerable<Req> reqs, bool perLevel) { return string.Join(", ", reqs.Select((Req r) => r.Item + " " + (perLevel ? r.PerLevel : r.Amount)).ToArray()); } private void RegisterItem() { //IL_00fb: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: 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("ShieldWood"))) { throw new InvalidOperationException("vanilla base prefab missing: ShieldWood"); } GameObject prefab = PrefabManager.Instance.GetPrefab("NH_ChaosShield"); if (Object.op_Implicit((Object)(object)prefab)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: GetPrefab(\"NH_ChaosShield\") 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_ChaosShield"); } if (Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("prefab name already taken: NH_ChaosShield -> " + ((Object)prefab).name); } } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"NHCS: GetPrefab(\"NH_ChaosShield\") returned null; name is free"); } List<Req> list = CurrentRequirements(); ItemConfig val2 = new ItemConfig { Name = "Chaos Shield", Description = "A skull-faced round shield, its cracks glowing with raw chaos.", CraftingStation = (string.IsNullOrEmpty(cfgStation.Value) ? "forge" : cfgStation.Value.Trim()), MinStationLevel = Math.Max(1, cfgStationLevel.Value), Requirements = ((IEnumerable<Req>)list).Select((Func<Req, RequirementConfig>)((Req r) => new RequirementConfig(r.Item, r.Amount, r.PerLevel, true))).ToArray() }; if (Object.op_Implicit((Object)(object)iconSprite)) { val2.Icons = (Sprite[])(object)new Sprite[1] { iconSprite }; } val = new CustomItem("NH_ChaosShield", "ShieldWood", val2); if (!Object.op_Implicit((Object)(object)val.ItemPrefab) || !Object.op_Implicit((Object)(object)val.ItemDrop)) { throw new InvalidOperationException("failed to clone ShieldWood"); } GameObject visual = SwapVisual(val.ItemPrefab); SharedData shared = val.ItemDrop.m_itemData.m_shared; if (shared.m_variants != 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: m_variants " + shared.m_variants + " -> 0 (vanilla wood paint styles do not apply to the custom model)")); shared.m_variants = 0; } if (!Object.op_Implicit((Object)(object)iconSprite)) { Sprite val3 = RenderManager.Instance.Render(val.ItemPrefab, RenderManager.IsometricRotation); if (Object.op_Implicit((Object)(object)val3)) { ((Object)val3).name = "NH_ChaosShield_Icon_Rendered"; iconSprite = val3; ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHCS: using RenderManager fallback icon"); } } if (Object.op_Implicit((Object)(object)iconSprite)) { shared.m_icons = (Sprite[])(object)new Sprite[1] { iconSprite }; } Sprite[] icons = 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] { "NHCS: 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)"NHCS: item has NO icon (m_icons empty)"); } try { ChaosAura.Install(visual, ((BaseUnityPlugin)this).Logger); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHCS: glow/smoke setup failed (shield still registered): " + ex)); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: stats (placeholder, cloned from ShieldWood): type=" + ((object)Unsafe.As<ItemType, ItemType>(ref shared.m_itemType)/*cast due to .constrained prefix*/).ToString() + " blockArmor=" + shared.m_blockPower + " (+" + shared.m_blockPowerPerLevel + "/lvl) blockForce=" + shared.m_deflectionForce + " (+" + shared.m_deflectionForcePerLevel + "/lvl) parryBonus=" + shared.m_timedBlockBonus + " durability=" + shared.m_maxDurability + " (+" + shared.m_durabilityPerLevel + "/lvl) weight=" + shared.m_weight + " maxQuality=" + shared.m_maxQuality + " moveSpeed=" + shared.m_movementModifier + " skill=" + ((object)Unsafe.As<SkillType, SkillType>(ref shared.m_skillType)/*cast due to .constrained prefix*/).ToString())); if (val.Recipe == null || (Object)(object)val.Recipe.Recipe == (Object)null) { throw new InvalidOperationException("Jotunn created no recipe for NH_ChaosShield"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: recipe added (PLACEHOLDER " + val2.CraftingStation + " " + val2.MinStationLevel + ": " + Describe(list, perLevel: false) + "; upgrade amountPerLevel " + Describe(list, perLevel: true) + ") name=" + ((Object)val.Recipe.Recipe).name)); if (!ItemManager.Instance.AddItem(val)) { throw new InvalidOperationException("ItemManager rejected NH_ChaosShield"); } registered = val; ((BaseUnityPlugin)this).Logger.LogInfo((object)"NHCS: NH_ChaosShield registered (clone of ShieldWood); test with: spawn NH_ChaosShield"); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("NHCS: NH_ChaosShield registration failed: " + ex2)); if (val != null && Object.op_Implicit((Object)(object)val.ItemPrefab)) { Object.Destroy((Object)(object)val.ItemPrefab); } } } private void OnConfigSynced(object sender, ConfigurationSynchronizationEventArgs e) { ApplyRecipe("server config sync"); } private void ApplyRecipe(string why) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00f9: Expected O, but got Unknown try { if (registered == null || registered.Recipe == null || !Object.op_Implicit((Object)(object)registered.Recipe.Recipe) || !Object.op_Implicit((Object)(object)ObjectDB.instance)) { return; } Recipe recipe = registered.Recipe.Recipe; List<Req> list = CurrentRequirements(); List<Requirement> list2 = new List<Requirement>(); foreach (Req item in list) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item.Item); ItemDrop val = (Object.op_Implicit((Object)(object)itemPrefab) ? itemPrefab.GetComponent<ItemDrop>() : null); if (!Object.op_Implicit((Object)(object)val)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: recipe item '" + item.Item + "' not found; skipped")); continue; } list2.Add(new Requirement { m_resItem = val, m_amount = item.Amount, m_amountPerLevel = item.PerLevel, m_recover = true }); } if (list2.Count == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHCS: recipe not changed (no valid requirements)"); return; } recipe.m_resources = list2.ToArray(); GameObject prefab = PrefabManager.Instance.GetPrefab(cfgStation.Value.Trim()); CraftingStation val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<CraftingStation>() : null); if (Object.op_Implicit((Object)(object)val2)) { recipe.m_craftingStation = val2; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: crafting station '" + cfgStation.Value + "' not found; station unchanged")); } recipe.m_minStationLevel = Math.Max(1, cfgStationLevel.Value); ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: recipe re-applied (" + why + "): " + (Object.op_Implicit((Object)(object)recipe.m_craftingStation) ? ((Object)recipe.m_craftingStation).name : "<none>") + " " + recipe.m_minStationLevel + ": " + Describe(list, perLevel: false) + "; per level " + Describe(list, perLevel: true))); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: recipe re-apply failed: " + ex.Message)); } } private GameObject SwapVisual(GameObject clone) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_038b: 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_03ad: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_022c: 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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) LogHierarchy(clone.transform, clone.transform); Transform val = clone.transform.Find("attach"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("clone has no 'attach' child"); } if (Object.op_Implicit((Object)(object)clone.transform.Find("attach_back"))) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHCS: clone has an 'attach_back' child; the custom visual is only installed under 'attach'"); } ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[5] { "NHCS: attach localPos=", null, null, null, null }; Vector3 val2 = val.localPosition; obj[1] = ((Vector3)(ref val2)).ToString("F4"); obj[2] = " localRot="; Quaternion localRotation = val.localRotation; obj[3] = ((Quaternion)(ref localRotation)).ToString("F5"); obj[4] = " (game data: pos (0.0000, -0.0500, 0.0500) rot (-0.97399, -0.14556, 0.17174, 0.02567); reset to the hand joint by the game when equipped)"; logger.LogInfo((object)string.Concat(obj)); Transform val3 = clone.transform.Find("attach/model"); MeshRenderer[] array; if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)((Component)val3).GetComponent<MeshRenderer>())) { array = (MeshRenderer[])(object)new MeshRenderer[1] { ((Component)val3).GetComponent<MeshRenderer>() }; if (Vector3.Distance(val3.localPosition, ExpectedModelLocalPos) < 0.001f && Mathf.Abs(val3.localScale.x - 0.8f) < 0.001f) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"NHCS: attach/model transform matches the ShieldWood game data the size/placement was measured from"); } else { ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger; val2 = ExpectedModelLocalPos; logger2.LogWarning((object)("NHCS: attach/model transform differs from the measured game data (expected pos " + ((Vector3)(ref val2)).ToString("F4") + " scale 0.8); check size in game")); } } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHCS: attach/model not found or has no MeshRenderer; hiding every MeshRenderer under attach instead"); array = ((Component)val).GetComponentsInChildren<MeshRenderer>(true); } if (array.Length == 0) { throw new InvalidOperationException("no vanilla MeshRenderer under attach"); } int layer = ((Component)array[0]).gameObject.layer; Bounds val4 = default(Bounds); bool flag = false; MeshRenderer[] array2 = array; foreach (MeshRenderer val5 in array2) { ((Renderer)val5).enabled = false; Transform transform = ((Component)val5).transform; MeshFilter component = ((Component)val5).GetComponent<MeshFilter>(); string text = ""; if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMesh)) { Bounds val6 = ToSpace(component.sharedMesh.bounds, val.worldToLocalMatrix * transform.localToWorldMatrix); if (!flag) { val4 = val6; flag = true; } else { ((Bounds)(ref val4)).Encapsulate(val6); } string[] obj2 = new string[6] { " mesh=", ((Object)component.sharedMesh).name, " boundsInAttach center=", null, null, null }; val2 = ((Bounds)(ref val6)).center; obj2[3] = ((Vector3)(ref val2)).ToString("F4"); obj2[4] = " size="; val2 = ((Bounds)(ref val6)).size; obj2[5] = ((Vector3)(ref val2)).ToString("F4"); text = string.Concat(obj2); } ManualLogSource logger3 = ((BaseUnityPlugin)this).Logger; string[] obj3 = new string[11] { "NHCS: vanilla renderer hidden: ", GetPath(transform, clone.transform), " localPos=", null, null, null, null, null, null, null, null }; val2 = transform.localPosition; obj3[3] = ((Vector3)(ref val2)).ToString("F4"); obj3[4] = " localRot="; localRotation = transform.localRotation; obj3[5] = ((Quaternion)(ref localRotation)).ToString("F5"); obj3[6] = " localScale="; val2 = transform.localScale; obj3[7] = ((Vector3)(ref val2)).ToString("F5"); obj3[8] = " layer="; obj3[9] = ((Component)transform).gameObject.layer.ToString(); obj3[10] = text; logger3.LogInfo((object)string.Concat(obj3)); } GameObject val7 = Object.Instantiate<GameObject>(visualPrefab, val, false); ((Object)val7).name = "NH_ChaosShield_VisualRuntime"; val7.transform.localPosition = Vector3.zero; val7.transform.localRotation = Quaternion.identity; val7.transform.localScale = Vector3.one; int num = 0; Collider[] componentsInChildren = val7.GetComponentsInChildren<Collider>(true); foreach (Collider val8 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val8); num++; } Transform[] componentsInChildren2 = val7.GetComponentsInChildren<Transform>(true); foreach (Transform val9 in componentsInChildren2) { ((Component)val9).gameObject.layer = layer; } Transform val10 = val7.transform.Find("NH_ChaosShield_Model"); if (Object.op_Implicit((Object)(object)val10)) { bool flag2 = Vector3.Distance(val10.localPosition, ExpectedChildPos) < 0.0005f && Quaternion.Angle(val10.localRotation, ExpectedChildRot) < 0.1f && Mathf.Abs(val10.localScale.x - 1.521159f) < 0.0005f; ManualLogSource logger4 = ((BaseUnityPlugin)this).Logger; string[] obj4 = new string[9] { "NHCS: scaled model child ", ((Object)val10).name, " localPos=", null, null, null, null, null, null }; val2 = val10.localPosition; obj4[3] = ((Vector3)(ref val2)).ToString("F4"); obj4[4] = " localRot="; localRotation = val10.localRotation; obj4[5] = ((Quaternion)(ref localRotation)).ToString("F5"); obj4[6] = " localScale="; val2 = val10.localScale; obj4[7] = ((Vector3)(ref val2)).ToString("F4"); obj4[8] = (flag2 ? " (matches the measured placement)" : " (DIFFERS from the measured placement)"); logger4.LogInfo((object)string.Concat(obj4)); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"NHCS: child NH_ChaosShield_Model not found in the bundle visual"); } MeshRenderer[] componentsInChildren3 = val7.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val11 in componentsInChildren3) { MeshFilter component2 = ((Component)val11).GetComponent<MeshFilter>(); Mesh val12 = (Object.op_Implicit((Object)(object)component2) ? component2.sharedMesh : null); Material sharedMaterial = ((Renderer)val11).sharedMaterial; Shader val13 = (Object.op_Implicit((Object)(object)sharedMaterial) ? sharedMaterial.shader : null); string text2 = ""; if (Object.op_Implicit((Object)(object)val12)) { Bounds val14 = ToSpace(val12.bounds, val.worldToLocalMatrix * ((Component)val11).transform.localToWorldMatrix); val2 = ((Bounds)(ref val14)).center; string text3 = ((Vector3)(ref val2)).ToString("F4"); val2 = ((Bounds)(ref val14)).size; text2 = " boundsInAttach center=" + text3 + " size=" + ((Vector3)(ref val2)).ToString("F4"); if (flag) { float num2 = Vector3.Distance(((Bounds)(ref val14)).center, ((Bounds)(ref val4)).center); string[] obj5 = new string[5] { text2, " centerOffsetFromVanillaWood=", num2.ToString("F4"), "m vanillaSize=", null }; val2 = ((Bounds)(ref val4)).size; obj5[4] = ((Vector3)(ref val2)).ToString("F4"); text2 = string.Concat(obj5); if (num2 > 0.15f) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("NHCS: custom visual center is " + num2.ToString("F3") + " m from the vanilla wood shield center; check arm placement")); } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: visual renderer " + ((Object)val11).name + " mesh=" + (Object.op_Implicit((Object)(object)val12) ? (((Object)val12).name + " verts=" + val12.vertexCount) : "<null>") + text2 + " material=" + (Object.op_Implicit((Object)(object)sharedMaterial) ? ((Object)sharedMaterial).name : "<null>") + " shader=" + (Object.op_Implicit((Object)(object)val13) ? ((Object)val13).name : "<null>") + " supported=" + (Object.op_Implicit((Object)(object)val13) && val13.isSupported) + " emission=" + (Object.op_Implicit((Object)(object)sharedMaterial) && sharedMaterial.IsKeywordEnabled("_EMISSION")) + " emissionMap=" + ((Object.op_Implicit((Object)(object)sharedMaterial) && sharedMaterial.HasProperty("_EmissionMap") && Object.op_Implicit((Object)(object)sharedMaterial.GetTexture("_EmissionMap"))) ? ((Object)sharedMaterial.GetTexture("_EmissionMap")).name : "<none>"))); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("NHCS: visual installed under attach at identity; colliders removed from visual=" + num + "; layer=" + layer)); return val7; } private void LogHierarchy(Transform t, Transform root) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown StringBuilder stringBuilder = new StringBuilder(); Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val in components) { if (Object.op_Implicit((Object)(object)val) && !(val is Transform)) { stringBuilder.Append(((object)val).GetType().Name).Append(' '); } } ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[13] { "NHCS: prefab ", ((Object)(object)t == (Object)(object)root) ? ((Object)t).name : GetPath(t, root), " localPos=", null, null, null, null, null, null, null, null, null, null }; Vector3 val2 = t.localPosition; obj[3] = ((Vector3)(ref val2)).ToString("F4"); obj[4] = " localRot="; Quaternion localRotation = t.localRotation; obj[5] = ((Quaternion)(ref localRotation)).ToString("F5"); obj[6] = " localScale="; val2 = t.localScale; obj[7] = ((Vector3)(ref val2)).ToString("F4"); obj[8] = " layer="; obj[9] = ((Component)t).gameObject.layer.ToString(); obj[10] = " components=["; obj[11] = stringBuilder.ToString().Trim(); obj[12] = "]"; logger.LogInfo((object)string.Concat(obj)); foreach (Transform item in t) { Transform t2 = item; LogHierarchy(t2, root); } } private static Bounds ToSpace(Bounds b, Matrix4x4 m) { //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_0014: 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_001c: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0065: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) Vector3 center = ((Bounds)(ref b)).center; Vector3 extents = ((Bounds)(ref b)).extents; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(((Matrix4x4)(ref m)).MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z)), Vector3.zero); for (int i = 1; i < 8; i++) { ((Bounds)(ref result)).Encapsulate(((Matrix4x4)(ref m)).MultiplyPoint3x4(center + new Vector3(((i & 1) != 0) ? extents.x : (0f - extents.x), ((i & 2) != 0) ? extents.y : (0f - extents.y), ((i & 4) != 0) ? extents.z : (0f - extents.z)))); } return result; } private static string GetPath(Transform t, Transform root) { string text = ((Object)t).name; while (Object.op_Implicit((Object)(object)t.parent) && (Object)(object)t.parent != (Object)(object)root) { t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterItem; SynchronizationManager.OnConfigurationSynchronized -= OnConfigSynced; } }