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 FlareArrow v0.2.3
FlareArrow.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace FlareArrow; public static class FlareArrowConfig { public static ConfigEntry<float> DropGravityRate; public static ConfigEntry<float> ForwardSpeedArrestFraction; public static ConfigEntry<float> ProjectileWindInfluence; public static ConfigEntry<float> ProjectileWindResponseRate; public static ConfigEntry<float> MaxAirborneSeconds; public static ConfigEntry<float> FlareBrightness; public static ConfigEntry<float> FlareFalloffDistance; public static ConfigEntry<float> FlareFadeDurationSeconds; public static ConfigEntry<float> FlareGlowSize; public static ConfigEntry<float> SparkWindInfluence; public static ConfigEntry<float> SparkLifetimeMultiplier; public static ConfigEntry<float> SparkSizeMultiplier; public static ConfigEntry<float> SparkGravityMultiplier; public static ConfigEntry<float> SparkEmissionRateMultiplier; public static ConfigEntry<float> SparkStartSpeed; public static ConfigEntry<float> SparkSpeedOverLifetime; public static void Init(ConfigFile config) { AcceptableValueBase val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f); DropGravityRate = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Drop Gravity Rate", 0.01f, "Fraction of normal gravity applied after the arrow reaches the apex of its arc. Lower = slower, more dramatic fall. Range 0.01-1.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f); ForwardSpeedArrestFraction = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Forward Speed Arrest Fraction", 0.4f, "How much of the arrow's forward (horizontal) speed is removed the instant it ignites at the apex. 0 = no change, 1 = fully stops forward motion.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5000f); ProjectileWindInfluence = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Projectile Wind Influence", 15f, "How much Valheim's world wind pushes the falling arrow itself. 0 = unaffected, 1 = natural wind strength. Wind can never push faster than this (scaled) speed, so crank this high to let strong wind fully overpower a fast throw. Applied continuously, so it keeps steering the arrow toward the wind for the whole fall, not just once.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f); ProjectileWindResponseRate = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Projectile Wind Response Rate", 0.25f, "How quickly the falling arrow's velocity catches up to the current wind target (1/seconds -- higher snaps faster, lower drifts more smoothly). Converges over roughly 1/this-value seconds regardless of how big the correction is.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f); MaxAirborneSeconds = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Max Airborne Seconds", 60f, "If the arrow is still flying after this many seconds (e.g. it fell in water or off the map), its light is forced to fade out.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f); FlareBrightness = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Flare Brightness", 2f, "Light intensity of the flare during its fall (no glow on the way up).", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f); FlareFalloffDistance = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Flare Falloff Distance", 500f, "How far the flare's light reaches, in meters.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f); FlareFadeDurationSeconds = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Flare Fade Duration Seconds", 2.5f, "How many seconds the light and glow orb take to fade out after landing or timing out. Spark particle emission also stops at the same moment, so they always match.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f); FlareGlowSize = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Flare Glow Size", 1f, "Scale of the visible glowing sphere on the arrow during the fall (the point light alone has no visible shape of its own).", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5000f); SparkWindInfluence = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Wind Influence", 0.6f, "How much wind pushes the spark trail, independent of how much it pushes the arrow itself.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 200f); SparkLifetimeMultiplier = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Lifetime Multiplier", 30f, "Multiplies how long each spark lives before disappearing. 1 = vanilla flame trail lifetime.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f); SparkSizeMultiplier = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Size Multiplier", 4f, "How big each spark gets once the flare pops at apex. 1 = vanilla flame trail size.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f); SparkGravityMultiplier = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Gravity Multiplier", 1f, "Gravity applied to the spark trail itself, independent of the projectile's own Drop Gravity Rate. 0 = sparks float/hang, 1 = vanilla flame trail gravity.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f); SparkEmissionRateMultiplier = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Emission Rate Multiplier", 15f, "How many sparks per second are emitted during the fall (an absolute rate, not a multiplier on vanilla's own — that could be near 0). Governs both the continuous trail and the randomized 'spit' bursts, so 0 genuinely stops all new sparks.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f); SparkStartSpeed = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Start Speed", 8f, "How fast each spark shoots outward when emitted. Vanilla flame trail particles barely move on their own, so this replaces that value entirely rather than scaling it.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f); SparkSpeedOverLifetime = ConfigFileExtensions.BindConfig<float>(config, "Flare Arrow", "Spark Speed Over Lifetime", 0.5f, "How strongly each spark's speed is damped down as it ages (Limit Velocity Over Lifetime's dampen amount). 0 = no slowdown, 1 = strongest slowdown.", true, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); } } public static class FlareArrowItem { public const string PrefabName = "FlareArrow"; public const string BasePrefabName = "ArrowFire"; public const string ProjectilePrefabName = "FlareArrowProjectile"; public const string BaseProjectilePrefabName = "bow_projectile_fire"; public static CustomItem CustomItem { get; private set; } public static GameObject ProjectilePrefab { get; private set; } public static void Register() { PrefabManager.OnVanillaPrefabsAvailable += AddFlareArrow; } private static void AddFlareArrow() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown ProjectilePrefab = PrefabManager.Instance.CreateClonedPrefab("FlareArrowProjectile", "bow_projectile_fire"); PrefabManager.Instance.AddPrefab(new CustomPrefab(ProjectilePrefab, false)); ProjectilePrefab.AddComponent<FlareArrowProjectile>(); ItemConfig val = new ItemConfig { Name = "$item_flarearrow", Description = "$item_flarearrow_desc", CraftingStation = CraftingStations.Workbench, MinStationLevel = 2, Amount = 20 }; val.AddRequirement("Wood", 8, 0); val.AddRequirement("Resin", 8, 0); val.AddRequirement("Feathers", 2, 0); val.AddRequirement("GreydwarfEye", 5, 0); CustomItem = new CustomItem("FlareArrow", "ArrowFire", val); ItemManager.Instance.AddItem(CustomItem); CustomItem.ItemDrop.m_itemData.m_shared.m_attack.m_attackProjectile = ProjectilePrefab; CustomItem.ItemDrop.m_itemData.m_shared.m_damages.m_pierce = 1f; CustomItem.ItemDrop.m_itemData.m_shared.m_damages.m_fire = 28f; Logger.LogInfo((object)("FlareArrowItem: attackProjectile wired to " + ((Object)ProjectilePrefab).name)); PrefabManager.OnVanillaPrefabsAvailable -= AddFlareArrow; } } public class FlareArrowProjectile : MonoBehaviour { private static readonly FieldInfo VelocityField = typeof(Projectile).GetField("m_vel", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor"); private static readonly Color GlowColor = new Color(1f, 0.55f, 0.15f); private const float FlareGlowBrightness = 1f; private Projectile _projectile; private Light _light; private ParticleSystem _particleSystem; private GameObject _glowOrb; private Renderer _glowOrbRenderer; private bool _glowOrbHasEmission; private float _originalGravity; private bool _hasReachedApex; private bool _isFading; private float _airborneTime; private float _fadeElapsed; private bool _isDedicatedServer; private float _nextSpitTime; private float _nextDiagLogTime; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) _projectile = ((Component)this).GetComponent<Projectile>(); if ((Object)(object)_projectile == (Object)null) { Logger.LogError((object)"FlareArrowProjectile: no Projectile component found on this GameObject — flight/light behavior disabled."); ((Behaviour)this).enabled = false; return; } _originalGravity = _projectile.m_gravity; Projectile projectile = _projectile; projectile.m_onHit = (OnProjectileHit)Delegate.Combine((Delegate?)(object)projectile.m_onHit, (Delegate?)new OnProjectileHit(OnProjectileHit)); Logger.LogInfo((object)"FlareArrowProjectile.Awake — custom projectile prefab spawned"); _projectile.m_ttl = Mathf.Max(_projectile.m_ttl, FlareArrowConfig.MaxAirborneSeconds.Value + FlareArrowConfig.FlareFadeDurationSeconds.Value + 1f); _projectile.m_stayTTL = Mathf.Max(_projectile.m_stayTTL, FlareArrowConfig.FlareFadeDurationSeconds.Value + 0.5f); Logger.LogInfo((object)$"FlareArrowProjectile: ttl={_projectile.m_ttl} stayTTL={_projectile.m_stayTTL} stayAfterHitStatic={_projectile.m_stayAfterHitStatic}"); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) { _isDedicatedServer = true; return; } Light componentInChildren = ((Component)this).GetComponentInChildren<Light>(true); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = false; Behaviour[] components = ((Component)componentInChildren).GetComponents<Behaviour>(); foreach (Behaviour val in components) { if ((Object)(object)val != (Object)(object)componentInChildren) { val.enabled = false; } } GameObject val2 = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, ((Component)componentInChildren).transform.parent); ((Object)val2).name = "FlareGlowLight"; val2.transform.localPosition = ((Component)componentInChildren).transform.localPosition; val2.transform.localRotation = ((Component)componentInChildren).transform.localRotation; val2.transform.localScale = ((Component)componentInChildren).transform.localScale; val2.SetActive(true); _light = val2.GetComponent<Light>(); components = val2.GetComponents<Behaviour>(); foreach (Behaviour val3 in components) { if ((Object)(object)val3 != (Object)(object)_light) { Object.Destroy((Object)(object)val3); } } _light.color = new Color(1f, 0.55f, 0.15f); } else { _light = ((Component)this).gameObject.AddComponent<Light>(); _light.type = (LightType)2; _light.color = new Color(1f, 0.55f, 0.15f); } ((Behaviour)_light).enabled = false; _particleSystem = ((Component)this).GetComponentInChildren<ParticleSystem>(true); _glowOrb = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)_glowOrb).name = "FlareGlowOrb"; _glowOrb.transform.SetParent(((Component)this).transform, false); _glowOrb.transform.localPosition = Vector3.zero; Collider component = _glowOrb.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } _glowOrbRenderer = _glowOrb.GetComponent<Renderer>(); Shader val4 = Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val4 != (Object)null) { Material val5 = new Material(val4); val5.color = GlowColor; _glowOrbHasEmission = val5.HasProperty(EmissionColorId); if (_glowOrbHasEmission) { val5.EnableKeyword("_EMISSION"); val5.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } _glowOrbRenderer.material = val5; } _glowOrb.SetActive(false); } private void Update() { //IL_0023: 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_008c: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03db: 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_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0423: 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_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: 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_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: 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_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_0739: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) _airborneTime += Time.deltaTime; if (!_hasReachedApex && _projectile.GetVelocity().y <= 0f) { _hasReachedApex = true; _projectile.m_gravity = _originalGravity * FlareArrowConfig.DropGravityRate.Value; _projectile.m_drag = 0f; if (VelocityField != null) { Vector3 val = (Vector3)VelocityField.GetValue(_projectile); Vector3 val2 = new Vector3(val.x, 0f, val.z) * (1f - FlareArrowConfig.ForwardSpeedArrestFraction.Value); VelocityField.SetValue(_projectile, val2 + Vector3.up * val.y); } if (!_isDedicatedServer) { ((Behaviour)_light).enabled = true; _light.intensity = FlareArrowConfig.FlareBrightness.Value; _light.range = FlareArrowConfig.FlareFalloffDistance.Value; if ((Object)(object)_glowOrb != (Object)null) { _glowOrb.SetActive(true); _glowOrb.transform.localScale = Vector3.one * FlareArrowConfig.FlareGlowSize.Value; if (_glowOrbHasEmission) { _glowOrbRenderer.material.SetColor(EmissionColorId, GlowColor * 1f); } } if ((Object)(object)_particleSystem != (Object)null) { _particleSystem.Emit(60); MainModule main = _particleSystem.main; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startSizeMultiplier = FlareArrowConfig.SparkSizeMultiplier.Value; ((MainModule)(ref main)).startLifetimeMultiplier = FlareArrowConfig.SparkLifetimeMultiplier.Value; ((MainModule)(ref main)).gravityModifierMultiplier = FlareArrowConfig.SparkGravityMultiplier.Value; ((MainModule)(ref main)).startSpeed = new MinMaxCurve(FlareArrowConfig.SparkStartSpeed.Value); EmissionModule emission = _particleSystem.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(FlareArrowConfig.SparkEmissionRateMultiplier.Value); ShapeModule shape = _particleSystem.shape; ((ShapeModule)(ref shape)).randomDirectionAmount = 1f; ColorOverLifetimeModule colorOverLifetime = _particleSystem.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[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); LimitVelocityOverLifetimeModule limitVelocityOverLifetime = _particleSystem.limitVelocityOverLifetime; ((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true; ((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).separateAxes = true; ((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = FlareArrowConfig.SparkSpeedOverLifetime.Value; ((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limitY = new MinMaxCurve(1000f); InheritVelocityModule inheritVelocity = _particleSystem.inheritVelocity; ((InheritVelocityModule)(ref inheritVelocity)).enabled = false; } _nextSpitTime = _airborneTime + Random.Range(0.1f, 0.4f); } } if (_hasReachedApex && VelocityField != null && (Object)(object)EnvMan.instance != (Object)null) { if (FlareArrowConfig.ProjectileWindInfluence.Value > 0f) { Vector3 windForce = EnvMan.instance.GetWindForce(); if (windForce != Vector3.zero) { Vector3 normalized = ((Vector3)(ref windForce)).normalized; float num = ((Vector3)(ref windForce)).magnitude * FlareArrowConfig.ProjectileWindInfluence.Value; Vector3 val4 = (Vector3)VelocityField.GetValue(_projectile); float num2 = Vector3.Dot(val4, normalized); float num3 = 1f - Mathf.Exp((0f - FlareArrowConfig.ProjectileWindResponseRate.Value) * Time.deltaTime); float num4 = Mathf.Lerp(num2, num, num3); VelocityField.SetValue(_projectile, val4 + normalized * (num4 - num2)); if (_airborneTime >= _nextDiagLogTime) { Vector3 val5 = (Vector3)VelocityField.GetValue(_projectile); Logger.LogInfo((object)$"FlareArrow WIND DIAG t={_airborneTime:F2} windSpeedTarget={num:F2} preAlongWind={num2:F2} postVel={val5} postVelMag={((Vector3)(ref val5)).magnitude:F2} m_gravity={_projectile.m_gravity:F3} m_drag={_projectile.m_drag:F3}"); _nextDiagLogTime = _airborneTime + 0.5f; } } } if ((Object)(object)_particleSystem != (Object)null) { Vector3 val6 = ((FlareArrowConfig.SparkWindInfluence.Value > 0f) ? (EnvMan.instance.GetWindForce() * FlareArrowConfig.SparkWindInfluence.Value) : Vector3.zero); VelocityOverLifetimeModule velocityOverLifetime = _particleSystem.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(val6.x); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(val6.y); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(val6.z); LimitVelocityOverLifetimeModule limitVelocityOverLifetime2 = _particleSystem.limitVelocityOverLifetime; Vector2 val7 = new Vector2(val6.x, val6.z); float magnitude = ((Vector2)(ref val7)).magnitude; float num5 = Mathf.Max(FlareArrowConfig.SparkStartSpeed.Value, magnitude) + 0.5f; ((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime2)).limitX = new MinMaxCurve(num5); ((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime2)).limitZ = new MinMaxCurve(num5); } } if (_hasReachedApex && !_isDedicatedServer && ((Behaviour)_light).enabled && (Object)(object)_particleSystem != (Object)null && FlareArrowConfig.SparkEmissionRateMultiplier.Value > 0f && _airborneTime >= _nextSpitTime) { int num6 = Mathf.CeilToInt(Random.Range(3f, 9f) * Mathf.Clamp01(FlareArrowConfig.SparkEmissionRateMultiplier.Value / 20f)); _particleSystem.Emit(num6); _nextSpitTime = _airborneTime + Random.Range(0.1f, 0.4f); } if (!_isFading && _airborneTime >= FlareArrowConfig.MaxAirborneSeconds.Value) { StartFade(); } if (!_isFading || _isDedicatedServer) { return; } _fadeElapsed += Time.deltaTime; float num7 = Mathf.Clamp01(_fadeElapsed / FlareArrowConfig.FlareFadeDurationSeconds.Value); _light.intensity = Mathf.Lerp(FlareArrowConfig.FlareBrightness.Value, 0f, num7); if ((Object)(object)_glowOrb != (Object)null && _glowOrbHasEmission) { _glowOrbRenderer.material.SetColor(EmissionColorId, GlowColor * 1f * (1f - num7)); } if (num7 >= 1f) { ((Behaviour)_light).enabled = false; if ((Object)(object)_glowOrb != (Object)null) { _glowOrb.SetActive(false); } if ((Object)(object)_particleSystem != (Object)null) { EmissionModule emission2 = _particleSystem.emission; ((EmissionModule)(ref emission2)).enabled = false; } } } private void OnProjectileHit(Collider collider, Vector3 hitPoint, bool water) { if (!_isFading) { StartFade(); } } private void StartFade() { _isFading = true; _fadeElapsed = 0f; } } [BepInPlugin("com.flarearrow.mod", "FlareArrow", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.flarearrow.mod"; public const string PluginName = "FlareArrow"; public const string PluginVersion = "0.1.0"; private void Awake() { Logger.LogInfo((object)"FlareArrow plugin loaded"); CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_flarearrow", "Flare Arrow" }, { "item_flarearrow_desc", "Rises fast, then falls slowly while glowing brightly. Lights up dark areas." } }); FlareArrowConfig.Init(((BaseUnityPlugin)this).Config); FlareArrowItem.Register(); } }