using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PluginConfig.API; using PluginConfig.API.Fields; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; [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("KawKaw")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+35332e3f7ec0472d371186d5c1bd89eef12f9b9c")] [assembly: AssemblyProduct("Kaw Kaw")] [assembly: AssemblyTitle("KawKaw")] [assembly: AssemblyVersion("1.0.0.0")] [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 KawKaw { [BepInPlugin("com.banana.kawkaw", "Kaw Kaw", "1.0.0")] public class Plugin : BaseUnityPlugin { public enum Character { KawKaw, Flowery, Queen, ShadowMantle, Random } public struct FrameSet { public List idle; public List idleWhite; } public static EnumField character; public static IntField amount; private static List kawkaws = new List(); public static Texture2D kawKaw; public static Texture2D kawKawwhite; public const float SpriteScale = 3.75f; private Harmony Harmony = new Harmony("com.banana.kawkaw"); public static BoolField TrailEnabled; public static FloatField TrailLifetime; public static FloatField HueShiftSpeed; public static BoolField Muted; public static FloatField MinPitch; public static FloatField MaxPitch; public static FloatField Volume; public static BoolField PhysicsBounce; public static FloatField restitution; public static BoolField BounceOnOthers; public static BoolField TriggerOnDamage; public static BoolField TriggerEverySeconds; public static FloatField TriggerInterval; public static BoolField TriggerOnKey; public static KeyCodeField TriggerKey; private float triggerTimer; private PluginConfigurator config; private static GameObject sharedCanvasObj; private static Dictionary frameCache = new Dictionary(); private static Character[] concreteCharacters; private static Dictionary> soundCache = new Dictionary>(); private static Dictionary soundLoadInProgress = new Dictionary(); private static Dictionary>>> pendingCallbacks = new Dictionary>>>(); private static Plugin instance; internal static ManualLogSource Logger { get; private set; } = null; public static Plugin Instance => instance; private void Awake() { //IL_00be: 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) Harmony.PatchAll(); Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin com.banana.kawkaw is loaded!"); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)4; SetupConfigs(); FrameSet orLoadFrames = GetOrLoadFrames(Character.KawKaw); kawKaw = ((orLoadFrames.idle.Count > 0) ? orLoadFrames.idle[0].texture : null); kawKawwhite = ((orLoadFrames.idleWhite.Count > 0) ? orLoadFrames.idleWhite[0].texture : null); config.icon = Sprite.Create(kawKaw, new Rect(0f, 0f, (float)((Texture)kawKaw).width, (float)((Texture)kawKaw).height), new Vector2(0.5f, 0.5f)); } private void SetupConfigs() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Expected O, but got Unknown //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown config = PluginConfigurator.Create("Bouncing Deltarune", "com.banana.kawkaw"); amount = new IntField(config.rootPanel, "Count", "com.kawkaw.count", 0, false); character = new EnumField(config.rootPanel, "Character", "com.kawkaw.character", Character.KawKaw, true); ConfigPanel val = new ConfigPanel(config.rootPanel, "Physics", "com.physics.panel"); PhysicsBounce = new BoolField(val, "Physics Bounce", "com.physics.bounce", false, true); BounceOnOthers = new BoolField(val, "Bounce on Other", "com.others.bounce", true, true); restitution = new FloatField(val, "Restitution", "com.restitution", 1f, true); ConfigPanel val2 = new ConfigPanel(config.rootPanel, "Sound Settings", "com.sound.settings.panel"); Muted = new BoolField(val2, "Muted", "com.sound.muted", false); MinPitch = new FloatField(val2, "Minimum Pitch", "com.sound.minpitch", 0.9f); MaxPitch = new FloatField(val2, "Maximum Pitch", "com.sound.maxpitch", 1.1f); Volume = new FloatField(val2, "Volume", "com.sound.volume", 1f); ConfigPanel val3 = new ConfigPanel(config.rootPanel, "Trail Settings", "com.kawkaw.panel.trail"); TrailEnabled = new BoolField(val3, "Enabled", "com.enabled.trail", true); TrailLifetime = new FloatField(val3, "Lifetime", "com.lifetime.trail", 0.5f); HueShiftSpeed = new FloatField(val3, "Hue Shift Speed", "com.hueshift.trail", 0.5f); ConfigPanel val4 = new ConfigPanel(config.rootPanel, "Triggers", "com.triggers.panel"); TriggerOnDamage = new BoolField(val4, "On Damage", "com.trigger.damage", true); TriggerEverySeconds = new BoolField(val4, "Every Few Seconds", "com.trigger.timer.enabled", false); TriggerInterval = new FloatField(val4, "Interval", "com.trigger.timer.interval", 2f); TriggerOnKey = new BoolField(val4, "On Key Press", "com.trigger.key.enabled", false); TriggerKey = new KeyCodeField(val4, "Key", "com.trigger.key", (KeyCode)107); amount.onValueChange += new IntValueChangeEventDelegate(Amount_onValueChange); character.onValueChange += Character_onValueChange; } private void Amount_onValueChange(IntValueChangeEvent data) { if (kawkaws.Count == data.value) { return; } if (kawkaws.Count < data.value) { int num = data.value - kawkaws.Count; for (int i = 0; i < num; i++) { CreateUI(); } return; } int num2 = kawkaws.Count - data.value; for (int j = 0; j < num2; j++) { GameObject val = kawkaws[0]; kawkaws.Remove(val); Object.Destroy((Object)(object)val); } } private static GameObject GetOrCreateCanvas() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sharedCanvasObj != (Object)null) { return sharedCanvasObj; } sharedCanvasObj = new GameObject("KawKawCanvas"); Canvas val = sharedCanvasObj.AddComponent(); val.overrideSorting = true; val.sortingOrder = 32767; val.renderMode = (RenderMode)0; CanvasScaler val2 = sharedCanvasObj.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.screenMatchMode = (ScreenMatchMode)0; val2.matchWidthOrHeight = 0.5f; sharedCanvasObj.AddComponent(); Object.DontDestroyOnLoad((Object)(object)sharedCanvasObj); return sharedCanvasObj; } private void Character_onValueChange(EnumValueChangeEvent data) { Logger.LogInfo((object)$"Character selection changed to {data.value}."); Nyon.RefreshAllFrames(); } private Texture2D LoadTextureFromResourceName(string resourceName) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourceName); if (stream == null) { Logger.LogWarning((object)("[ItemIcon] Resource not found: " + resourceName)); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; ((Object)val).name = resourceName; return val; } private List LoadFrameSet(string folder, bool whiteSuffix, Character ch) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = ch.ToString(); string str = "KawKaw.Characters." + text + "." + folder + "."; string pattern = (whiteSuffix ? ("^" + Regex.Escape(str) + ".+_idle_(\\d+)_white\\.png$") : ("^" + Regex.Escape(str) + ".+_idle_(\\d+)\\.png$")); Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); SortedDictionary sortedDictionary = new SortedDictionary(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text2 in manifestResourceNames) { Match match = regex.Match(text2); if (match.Success) { int key = int.Parse(match.Groups[1].Value); Texture2D val = LoadTextureFromResourceName(text2); if (!((Object)(object)val == (Object)null)) { Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)val2).name = text2; sortedDictionary[key] = val2; } } } return sortedDictionary.Values.ToList(); } public FrameSet GetOrLoadFrames(Character ch) { if (frameCache.TryGetValue(ch, out var value)) { return value; } FrameSet frameSet = new FrameSet { idle = LoadFrameSet("Normal", whiteSuffix: false, ch), idleWhite = LoadFrameSet("White", whiteSuffix: true, ch) }; if (frameSet.idle.Count == 0) { Logger.LogWarning((object)$"No idle frames found for character '{ch}'."); } if (frameSet.idleWhite.Count == 0) { Logger.LogWarning((object)$"No white idle frames found for character '{ch}'."); } if (frameSet.idle.Count > 0 || frameSet.idleWhite.Count > 0) { Logger.LogInfo((object)$"Loaded {frameSet.idle.Count} idle frames, {frameSet.idleWhite.Count} white idle frames for '{ch}'."); } frameCache[ch] = frameSet; return frameSet; } public static Vector2 SizeForSprite(Sprite sprite) { //IL_001f: 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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sprite == (Object)null) { return new Vector2(150f, 105f); } Rect rect = sprite.rect; float width = ((Rect)(ref rect)).width; rect = sprite.rect; return new Vector2(width, ((Rect)(ref rect)).height) * 3.75f; } private static Character[] ConcreteCharacters() { if (concreteCharacters == null) { concreteCharacters = (from Character c in Enum.GetValues(typeof(Character)) where c != Character.Random select c).ToArray(); } return concreteCharacters; } public static Character RandomConcreteCharacter() { Character[] array = ConcreteCharacters(); return array[Random.Range(0, array.Length)]; } public static Character ResolveCharacter() { return (character.value == Character.Random) ? RandomConcreteCharacter() : character.value; } public static List GetCachedSounds(Character ch) { List value; return soundCache.TryGetValue(ch, out value) ? value : null; } public static IEnumerator LoadSoundsForCharacter(Character ch, Action> onLoaded = null) { if (soundCache.TryGetValue(ch, out List cached)) { onLoaded?.Invoke(cached); yield break; } if (soundLoadInProgress.TryGetValue(ch, out var inProgress) && inProgress) { if (!pendingCallbacks.ContainsKey(ch)) { pendingCallbacks[ch] = new List>>(); } if (onLoaded != null) { pendingCallbacks[ch].Add(onLoaded); } yield break; } soundLoadInProgress[ch] = true; Assembly assembly = Assembly.GetExecutingAssembly(); string prefix = $".Sounds.{ch}."; string[] soundResourceNames = (from name in assembly.GetManifestResourceNames() where name.Contains(prefix) select name).ToArray(); List loaded = new List(); string[] array = soundResourceNames; foreach (string resourceName in array) { AudioType audioType = GetAudioTypeFromName(resourceName); if ((int)audioType == 0) { Logger.LogWarning((object)("Skipping unknown audio type: " + resourceName)); continue; } byte[] buffer; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { if (stream == null) { Logger.LogWarning((object)("Resource not found: " + resourceName)); continue; } buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); } string ext = Path.GetExtension(resourceName); string tempPath = Path.Combine(Application.temporaryCachePath, Path.GetRandomFileName() + ext); File.WriteAllBytes(tempPath, buffer); UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("file://" + tempPath, audioType); try { yield return www.SendWebRequest(); if ((int)www.result != 1) { Logger.LogWarning((object)("Failed to load " + resourceName + ": " + www.error)); } else { AudioClip clip = DownloadHandlerAudioClip.GetContent(www); ((Object)clip).name = Path.GetFileNameWithoutExtension(resourceName); loaded.Add(clip); Logger.LogInfo((object)("Loaded sound: " + ((Object)clip).name)); } } finally { ((IDisposable)www)?.Dispose(); } try { File.Delete(tempPath); } catch { } buffer = null; } if (loaded.Count == 0) { Logger.LogWarning((object)$"No sounds found for character '{ch}'."); } soundCache[ch] = loaded; soundLoadInProgress[ch] = false; onLoaded?.Invoke(loaded); if (pendingCallbacks.TryGetValue(ch, out List>> waiters)) { foreach (Action> cb in waiters) { cb(loaded); } waiters.Clear(); } Logger.LogInfo((object)$"Loaded {loaded.Count} sounds for '{ch}'."); } private static AudioType GetAudioTypeFromName(string resourceName) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) string text = resourceName.ToLowerInvariant(); if (text.EndsWith(".wav")) { return (AudioType)20; } if (text.EndsWith(".ogg")) { return (AudioType)14; } if (text.EndsWith(".mp3")) { return (AudioType)13; } return (AudioType)0; } private void Update() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (TriggerOnKey.value && Input.GetKeyDown(TriggerKey.value)) { IntField obj = amount; int value = obj.value; obj.value = value + 1; CreateUI(); } if (TriggerEverySeconds.value) { triggerTimer += Time.deltaTime; if (triggerTimer >= TriggerInterval.value) { triggerTimer = 0f; IntField obj2 = amount; int value = obj2.value; obj2.value = value + 1; CreateUI(); } } } public static void CreateUI() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) Character character = ResolveCharacter(); FrameSet orLoadFrames = Instance.GetOrLoadFrames(character); GameObject orCreateCanvas = GetOrCreateCanvas(); GameObject val = new GameObject("DVD"); val.SetActive(false); val.transform.SetParent(orCreateCanvas.transform, false); Image val2 = val.AddComponent(); ((Graphic)val2).color = Color.white; ((Graphic)val2).raycastTarget = false; if (orLoadFrames.idle.Count > 0) { val2.sprite = orLoadFrames.idle[0]; } else if ((Object)(object)kawKaw != (Object)null) { val2.sprite = Sprite.Create(kawKaw, new Rect(0f, 0f, (float)((Texture)kawKaw).width, (float)((Texture)kawKaw).height), new Vector2(0.5f, 0.5f)); } else { Logger.LogWarning((object)$"No sprite available for character '{character}'."); } RectTransform rectTransform = ((Graphic)val2).rectTransform; rectTransform.sizeDelta = SizeForSprite(val2.sprite); rectTransform.anchoredPosition = Vector2.zero; Nyon nyon = val.AddComponent(); nyon.Setup(character, orLoadFrames.idle, orLoadFrames.idleWhite); val.SetActive(true); kawkaws.Add(val); } private void OnEnable() { instance = this; } } [HarmonyPatch] public class Patches { [HarmonyPatch(typeof(NewMovement), "GetHurt")] [HarmonyPostfix] public static void Dmg(int damage) { if (Plugin.TriggerOnDamage.value && damage > 1) { IntField amount = Plugin.amount; int value = amount.value; amount.value = value + 1; Plugin.CreateUI(); } } } public class NyonTria : MonoBehaviour { private float t = 1f; private Image img; private void Awake() { img = ((Component)this).GetComponent(); } private void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) t -= Time.deltaTime / Plugin.TrailLifetime.value; if (t <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Color color = ((Graphic)img).color; color.a = t; ((Graphic)img).color = color; } } public class Nyon : MonoBehaviour { public static float gravity = 1500f; public Vector2 velocity = new Vector2(400f, 300f); public float hueSpeed = 0.5f; private RectTransform rect; private Canvas canvas; private float hue; private float trailTimer = 0f; private const float trailInterval = 0.03f; private AudioSource source; private Image img; public Plugin.Character character; private List frames; private List framesWhite; private List sounds; public float frameRate = 10f; private int currentFrame = 0; private float frameTimer = 0f; private static readonly List activeNyons = new List(); public RectTransform Rect => rect; public void Setup(Plugin.Character ch, List idle, List idleWhite) { character = ch; frames = idle; framesWhite = idleWhite; } private void Awake() { //IL_0129: 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) //IL_0132: 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) rect = ((Component)this).GetComponent(); canvas = ((Component)this).GetComponentInParent(); img = ((Component)this).GetComponent(); if (frames == null) { character = Plugin.ResolveCharacter(); Plugin.FrameSet orLoadFrames = Plugin.Instance.GetOrLoadFrames(character); frames = orLoadFrames.idle; framesWhite = orLoadFrames.idleWhite; } if (frames != null && frames.Count > 0) { currentFrame = Random.Range(0, frames.Count); img.sprite = frames[currentFrame]; ApplySizeForCurrentSprite(); } frameTimer = Random.Range(0f, 1f / frameRate); hue = Random.value; source = ((Component)this).gameObject.AddComponent(); float num = Random.Range(300f, 600f); Vector2 val = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); velocity = ((Vector2)(ref val)).normalized * num; activeNyons.Add(this); sounds = Plugin.GetCachedSounds(character); if (sounds == null) { ((MonoBehaviour)this).StartCoroutine(Plugin.LoadSoundsForCharacter(character, delegate(List loaded) { sounds = loaded; })); } } private void OnDestroy() { activeNyons.Remove(this); } private void ApplySizeForCurrentSprite() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rect == (Object)null) && !((Object)(object)img == (Object)null) && !((Object)(object)img.sprite == (Object)null)) { rect.sizeDelta = Plugin.SizeForSprite(img.sprite); } } public static void RefreshAllFrames() { foreach (Nyon n in activeNyons) { if ((Object)(object)n == (Object)null) { continue; } Plugin.Character ch = Plugin.ResolveCharacter(); Plugin.FrameSet orLoadFrames = Plugin.Instance.GetOrLoadFrames(ch); n.character = ch; n.frames = orLoadFrames.idle; n.framesWhite = orLoadFrames.idleWhite; n.sounds = Plugin.GetCachedSounds(ch); if (n.sounds == null) { ((MonoBehaviour)n).StartCoroutine(Plugin.LoadSoundsForCharacter(ch, delegate(List loaded) { if ((Object)(object)n != (Object)null) { n.sounds = loaded; } })); } if (n.frames.Count > 0) { n.currentFrame %= n.frames.Count; n.img.sprite = n.frames[n.currentFrame]; n.ApplySizeForCurrentSprite(); } else { n.currentFrame = 0; } } } private void Bounce() { if (sounds != null && sounds.Count != 0) { AudioClip val = sounds[Random.Range(0, sounds.Count)]; source.volume = Plugin.Volume.value; source.pitch = Random.Range(Plugin.MinPitch.value, Plugin.MaxPitch.value); source.PlayOneShot(val); } } private void AdvanceAnimation() { if (frames != null && frames.Count != 0) { frameTimer += Time.deltaTime; float num = 1f / frameRate; while (frameTimer >= num) { frameTimer -= num; currentFrame = (currentFrame + 1) % frames.Count; img.sprite = frames[currentFrame]; } } } private void SpawnKawKawTrail(Vector3 pos) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (Plugin.TrailEnabled.value) { GameObject val = new GameObject("trail"); val.transform.SetParent(((Component)this).transform.parent, false); val.transform.SetSiblingIndex(((Component)this).transform.GetSiblingIndex()); Image val2 = val.AddComponent(); ((Graphic)val2).color = Color.HSVToRGB(hue, 1f, 1f); Sprite val3 = null; if (framesWhite != null && framesWhite.Count > 0) { int index = Mathf.Min(currentFrame, framesWhite.Count - 1); val3 = framesWhite[index]; } else if ((Object)(object)Plugin.kawKawwhite != (Object)null) { val3 = Sprite.Create(Plugin.kawKawwhite, new Rect(0f, 0f, (float)((Texture)Plugin.kawKawwhite).width, (float)((Texture)Plugin.kawKawwhite).height), new Vector2(0.5f, 0.5f)); } if ((Object)(object)val3 == (Object)null) { Object.Destroy((Object)(object)val); return; } val2.sprite = val3; ((Graphic)val2).raycastTarget = false; RectTransform rectTransform = ((Graphic)val2).rectTransform; rectTransform.sizeDelta = rect.sizeDelta; rectTransform.anchoredPosition = Vector2.op_Implicit(pos); val.AddComponent(); } } private void Update() { //IL_007d: 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_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) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_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_0105: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) hue += Time.deltaTime * Plugin.HueShiftSpeed.value; if (hue > 1f) { hue -= 1f; } AdvanceAnimation(); if (Plugin.PhysicsBounce.value) { velocity.y -= gravity * Time.deltaTime; } RectTransform obj = rect; obj.anchoredPosition += velocity * Time.deltaTime; RectTransform component = ((Component)canvas).GetComponent(); Rect val = component.rect; Vector2 val2 = ((Rect)(ref val)).size * 0.5f; Vector2 val3 = rect.sizeDelta * 0.5f; Vector2 anchoredPosition = rect.anchoredPosition; float num = (Plugin.PhysicsBounce.value ? (0f - Plugin.restitution.value) : (-1f)); if (anchoredPosition.x + val3.x > val2.x) { anchoredPosition.x = val2.x - val3.x; velocity.x *= num; Bounce(); } else if (anchoredPosition.x - val3.x < 0f - val2.x) { anchoredPosition.x = 0f - val2.x + val3.x; velocity.x *= num; Bounce(); } if (anchoredPosition.y + val3.y > val2.y) { anchoredPosition.y = val2.y - val3.y; velocity.y *= num; Bounce(); } else if (anchoredPosition.y - val3.y < 0f - val2.y) { anchoredPosition.y = 0f - val2.y + val3.y; velocity.y *= num; Bounce(); if (Plugin.PhysicsBounce.value && Mathf.Abs(velocity.y) < 40f) { velocity.y = 250f; } } rect.anchoredPosition = anchoredPosition; if (Plugin.BounceOnOthers.value) { HandleNyonCollisions(); } trailTimer += Time.deltaTime; if (trailTimer >= 0.03f) { trailTimer = 0f; SpawnKawKawTrail(Vector2.op_Implicit(anchoredPosition)); } } private void HandleNyonCollisions() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00da: 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_00f1: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < activeNyons.Count; i++) { Nyon nyon = activeNyons[i]; if ((Object)(object)nyon == (Object)(object)this || (Object)(object)nyon == (Object)null || ((Object)nyon).GetInstanceID() < ((Object)this).GetInstanceID()) { continue; } Vector2 val = rect.anchoredPosition - nyon.rect.anchoredPosition; float num = (rect.sizeDelta.x + nyon.rect.sizeDelta.x) * 0.5f; float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < num && magnitude > 0.0001f) { Vector2 val2 = val / magnitude; float num2 = num - magnitude; RectTransform obj = rect; obj.anchoredPosition += val2 * (num2 * 0.5f); RectTransform obj2 = nyon.rect; obj2.anchoredPosition -= val2 * (num2 * 0.5f); Vector2 val3 = velocity - nyon.velocity; float num3 = Vector2.Dot(val3, val2); if (num3 < 0f) { Vector2 val4 = val2 * num3; velocity -= val4; nyon.velocity += val4; Bounce(); nyon.Bounce(); } } } } } internal static class MyPluginInfo { public const string PLUGIN_GUID = "com.banana.kawkaw"; public const string PLUGIN_NAME = "Kaw Kaw"; public const string PLUGIN_VERSION = "1.0.0"; } }