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 SilkPulse v0.1.0
SilkPulse.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SilkPulse")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("SilkPulse")] [assembly: AssemblyTitle("SilkPulse")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/silksongfan/SilkPulse")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace SilkPulse { [BepInPlugin("io.github.silksongfan.silkpulse", "SilkPulse", "0.1.0")] public class SilkPulsePlugin : BaseUnityPlugin { private ConfigEntry<KeyboardShortcut> _useKey = null; private ConfigEntry<float> _cooldown = null; private ConfigEntry<float> _range = null; private ConfigEntry<float> _stunPower = null; private Sprite? _waveSprite; private Texture2D? _waveTexture; private float _nextUseTime; public const string Id = "io.github.silksongfan.silkpulse"; public static string Name => "SilkPulse"; public static string Version => "0.1.0"; private void Awake() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) _useKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("İpek Dalgası", "Kullanım tuşu", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Beyaz ipek dalgasını gönderir."); _cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("İpek Dalgası", "Bekleme süresi", 5f, "Yetenek tekrar kullanılmadan önce beklenecek süre (saniye)."); _range = ((BaseUnityPlugin)this).Config.Bind<float>("İpek Dalgası", "Dalga menzili", 8f, "Dalganın yaklaşık ilerleme mesafesi."); _stunPower = ((BaseUnityPlugin)this).Config.Bind<float>("İpek Dalgası", "Sersemletme gücü", 500f, "Yaratıklara ve sersemletilebilen bosslara uygulanan ipek sersemletme gücü."); if (Mathf.Approximately(_stunPower.Value, 100f)) { _stunPower.Value = 500f; ((BaseUnityPlugin)this).Config.Save(); } _waveSprite = CreateWaveSprite(out _waveTexture); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SilkPulse yüklendi. İpek Dalgası varsayılan olarak G tuşuyla kullanılır."); } private void Update() { //IL_0007: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = _useKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !(Time.time < _nextUseTime)) { HeroController instance = HeroController.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)_waveSprite == (Object)null)) { int num = (instance.cState.facingRight ? 1 : (-1)); Vector3 position = instance.transform.position + Vector3.up * 0.35f + Vector3.right * ((float)num * 0.4f); Renderer componentInChildren = ((Component)instance).GetComponentInChildren<Renderer>(); int sortingLayerId = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.sortingLayerID : 0); int sortingOrder = (((Object)(object)componentInChildren != (Object)null) ? (componentInChildren.sortingOrder + 1) : 100); float num2 = Mathf.Clamp(_cooldown.Value, 0.5f, 60f); float num3 = Mathf.Clamp(_range.Value, 2f, 20f); float stunPower = Mathf.Clamp(_stunPower.Value, 1f, 1000f); float lifetime = num3 / 8f; SilkPulseWave.Spawn(_waveSprite, position, num, 8f, lifetime, stunPower, sortingLayerId, sortingOrder); _nextUseTime = Time.time + num2; } } } private static Sprite CreateWaveSprite(out Texture2D texture) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_01a4: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) texture = new Texture2D(96, 96, (TextureFormat)4, false) { name = "SilkPulseWaveTexture", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[9216]; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(47.5f, 47.5f); float num = 48f; for (int i = 0; i < 96; i++) { for (int j = 0; j < 96; j++) { Vector2 val2 = new Vector2((float)j, (float)i) - val; float num2 = ((Vector2)(ref val2)).magnitude / num; float num3 = Mathf.Atan2(val2.y, val2.x); float num4 = 0.71f + Mathf.Sin(num3 * 8f) * 0.035f; float num5 = 1f - Mathf.Clamp01(Mathf.Abs(num2 - num4) / 0.12f); float num6 = Mathf.Pow(Mathf.Max(0f, Mathf.Cos(num3 * 6f + num2 * 10f)), 18f); float num7 = Mathf.Clamp01(num5 * 0.85f + num6 * Mathf.Clamp01(1f - num2) * 0.35f); if (num2 > 1f) { num7 = 0f; } array[i * 96 + j] = new Color(0.86f, 0.98f, 1f, num7); } } texture.SetPixels(array); texture.Apply(false, false); return Sprite.Create(texture, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 48f); } private void OnDestroy() { if ((Object)(object)_waveSprite != (Object)null) { Object.Destroy((Object)(object)_waveSprite); } if ((Object)(object)_waveTexture != (Object)null) { Object.Destroy((Object)(object)_waveTexture); } } } internal sealed class SilkPulseStunController : MonoBehaviour { private static SilkPulseStunController? _instance; private readonly Dictionary<PlayMakerFSM, float> _restoreAt = new Dictionary<PlayMakerFSM, float>(); internal static void Stun(GameObject target, float duration) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("SilkPulseStunController"); Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent<SilkPulseStunController>(); } PlayMakerFSM[] componentsInChildren = target.GetComponentsInChildren<PlayMakerFSM>(true); PlayMakerFSM[] array = componentsInChildren; foreach (PlayMakerFSM val2 in array) { if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).enabled && !IsProtectedStateMachine(val2.FsmName)) { _instance._restoreAt[val2] = Mathf.Max(_instance._restoreAt.TryGetValue(val2, out var value) ? value : 0f, Time.time + duration); ((Behaviour)val2).enabled = false; } } } private static bool IsProtectedStateMachine(string name) { return name.IndexOf("death", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("health", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("damage", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("hit", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("stun", StringComparison.OrdinalIgnoreCase) >= 0; } private void Update() { List<PlayMakerFSM> list = new List<PlayMakerFSM>(); foreach (KeyValuePair<PlayMakerFSM, float> item in _restoreAt) { if ((Object)(object)item.Key == (Object)null) { list.Add(item.Key); } else if (Time.time >= item.Value) { ((Behaviour)item.Key).enabled = true; list.Add(item.Key); } } foreach (PlayMakerFSM item2 in list) { if (item2 != null) { _restoreAt.Remove(item2); } } } } internal sealed class SilkPulseWave : MonoBehaviour { private readonly HashSet<int> _blastTargets = new HashSet<int>(); private SpriteRenderer _renderer = null; private CircleCollider2D _hitbox = null; private Sprite _sprite = null; private float _direction; private float _speed; private float _lifetime; private float _stunPower; private float _age; private int _sortingLayerId; private int _sortingOrder; private bool _detonated; private const float BlastRadius = 1.25f; private const float DamagePercent = 0.01f; internal static void Spawn(Sprite sprite, Vector3 position, int direction, float speed, float lifetime, float stunPower, int sortingLayerId, int sortingOrder) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: 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) GameObject val = new GameObject("SilkPulseWave"); val.transform.position = position; Rigidbody2D val2 = val.AddComponent<Rigidbody2D>(); val2.bodyType = (RigidbodyType2D)1; val2.gravityScale = 0f; val2.freezeRotation = true; CircleCollider2D val3 = val.AddComponent<CircleCollider2D>(); ((Collider2D)val3).isTrigger = true; val3.radius = 0.2f; SpriteRenderer val4 = val.AddComponent<SpriteRenderer>(); val4.sprite = sprite; ((Renderer)val4).sortingLayerID = sortingLayerId; ((Renderer)val4).sortingOrder = sortingOrder; val4.color = new Color(0.88f, 0.98f, 1f, 0.95f); SilkPulseWave silkPulseWave = val.AddComponent<SilkPulseWave>(); silkPulseWave.Initialize(sprite, val4, val3, direction, speed, lifetime, stunPower, sortingLayerId, sortingOrder); } private void Initialize(Sprite sprite, SpriteRenderer spriteRenderer, CircleCollider2D hitbox, int direction, float speed, float lifetime, float stunPower, int sortingLayerId, int sortingOrder) { //IL_005b: 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) _sprite = sprite; _renderer = spriteRenderer; _hitbox = hitbox; _direction = ((direction >= 0) ? 1f : (-1f)); _speed = speed; _lifetime = lifetime; _stunPower = stunPower; _sortingLayerId = sortingLayerId; _sortingOrder = sortingOrder; ((Component)this).transform.localScale = Vector3.one * 0.3f; } private void Update() { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01cb: 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) if (_detonated) { return; } _age += Time.deltaTime; float num = Mathf.Clamp01(_age / _lifetime); float num2 = Mathf.SmoothStep(0f, 1f, num); Vector3 position = ((Component)this).transform.position; float num3 = _speed * Time.deltaTime; ((Component)this).transform.localScale = Vector3.one * Mathf.Lerp(0.3f, 0.9f, num2); _hitbox.radius = Mathf.Lerp(0.2f, 0.75f, num2); float num4 = Mathf.InverseLerp(0.8f, 1f, num); _renderer.color = new Color(0.88f, 0.98f, 1f, Mathf.Lerp(0.95f, 0f, num4)); float num5 = _hitbox.radius * Mathf.Abs(((Component)this).transform.lossyScale.x); RaycastHit2D[] array = Physics2D.CircleCastAll(Vector2.op_Implicit(position), num5, Vector2.right * _direction, num3); HealthManager val = null; float num6 = float.MaxValue; RaycastHit2D[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit2D val2 = array2[i]; HealthManager val3 = (((Object)(object)((RaycastHit2D)(ref val2)).collider != (Object)null) ? ((Component)((RaycastHit2D)(ref val2)).collider).GetComponentInParent<HealthManager>() : null); if (CanHit(val3) && !(((RaycastHit2D)(ref val2)).distance >= num6)) { val = val3; num6 = ((RaycastHit2D)(ref val2)).distance; } } if ((Object)(object)val != (Object)null) { ((Component)this).transform.position = position + Vector3.right * (_direction * num6); TryDetonate(val); return; } ((Component)this).transform.position = position + Vector3.right * (_direction * num3); CheckNearbyEnemies(num5); if (!_detonated && _age >= _lifetime) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void OnTriggerEnter2D(Collider2D other) { TryDetonate(((Component)other).GetComponentInParent<HealthManager>()); } private void CheckNearbyEnemies(float worldRadius) { //IL_0007: 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) Collider2D[] array = Physics2D.OverlapCircleAll(Vector2.op_Implicit(((Component)this).transform.position), worldRadius); Collider2D[] array2 = array; foreach (Collider2D val in array2) { if (TryDetonate(((Component)val).GetComponentInParent<HealthManager>())) { break; } } } private bool TryDetonate(HealthManager target) { //IL_002d: 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_0053: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00dd: 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) if (_detonated || !CanHit(target)) { return false; } _detonated = true; Vector3 position = ((Component)this).transform.position; SilkPulseBurst.Spawn(_sprite, position, 1.25f, _sortingLayerId, _sortingOrder); ApplyBlastTo(target, position); Collider2D[] array = Physics2D.OverlapCircleAll(Vector2.op_Implicit(position), 1.25f); Collider2D[] array2 = array; foreach (Collider2D val in array2) { ApplyBlastTo(((Component)val).GetComponentInParent<HealthManager>(), position); } foreach (HealthManager item in HealthManager.EnumerateActiveEnemies()) { if (!((Object)(object)item == (Object)null)) { Vector2 val2 = Vector2.op_Implicit(((Component)item).transform.position) - Vector2.op_Implicit(position); if (((Vector2)(ref val2)).sqrMagnitude <= 1.5625f) { ApplyBlastTo(item, position); } } } Object.Destroy((Object)(object)((Component)this).gameObject); return true; } private static bool CanHit(HealthManager? target) { if ((Object)(object)target == (Object)null || target.hp <= 0) { return false; } HeroController instance = HeroController.instance; return (Object)(object)instance == (Object)null || (Object)(object)((Component)target).transform != (Object)(object)instance.transform; } private void ApplyBlastTo(HealthManager target, Vector3 blastPosition) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null || target.hp <= 0 || !_blastTargets.Add(((Object)target).GetInstanceID())) { return; } HeroController instance = HeroController.instance; if (!((Object)(object)instance != (Object)null) || !((Object)(object)((Component)target).transform == (Object)(object)instance.transform)) { int damageDealt = Mathf.Max(1, Mathf.CeilToInt((float)target.hp * 0.01f)); float num = Mathf.Sign(((Component)target).transform.position.x - blastPosition.x); if (Mathf.Approximately(num, 0f)) { num = _direction; } target.Hit(new HitInstance { Source = (((Object)(object)instance != (Object)null) ? ((Component)instance).gameObject : ((Component)this).gameObject), DamageDealt = damageDealt, StunDamage = _stunPower, AttackType = (AttackTypes)11, Direction = num, IgnoreInvulnerable = true, IsManualTrigger = true, IsHeroDamage = true, Multiplier = 1f, MagnitudeMultiplier = 1f }); SilkPulseStunController.Stun(((Component)target).gameObject, 0.7f); } } } internal sealed class SilkPulseBurst : MonoBehaviour { private SpriteRenderer _renderer = null; private float _radius; private float _age; private const float Duration = 0.28f; internal static void Spawn(Sprite sprite, Vector3 position, float radius, int sortingLayerId, int sortingOrder) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SilkPulseBurst"); val.transform.position = position; SpriteRenderer val2 = val.AddComponent<SpriteRenderer>(); val2.sprite = sprite; ((Renderer)val2).sortingLayerID = sortingLayerId; ((Renderer)val2).sortingOrder = sortingOrder + 1; val2.color = new Color(0.9f, 0.99f, 1f, 0.95f); SilkPulseBurst silkPulseBurst = val.AddComponent<SilkPulseBurst>(); silkPulseBurst.Initialize(val2, radius); } private void Initialize(SpriteRenderer spriteRenderer, float radius) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) _renderer = spriteRenderer; _radius = radius; ((Component)this).transform.localScale = Vector3.one * 0.05f; } private void Update() { //IL_003c: 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_0082: Unknown result type (might be due to invalid IL or missing references) _age += Time.deltaTime; float num = Mathf.Clamp01(_age / 0.28f); float num2 = Mathf.SmoothStep(0f, 1f, num); ((Component)this).transform.localScale = Vector3.one * Mathf.Lerp(0.05f, _radius, num2); _renderer.color = new Color(0.9f, 0.99f, 1f, Mathf.Lerp(0.95f, 0f, num)); if (_age >= 0.28f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } }