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 ChickenKick v1.0.0
plugins/ChickenKick.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("PetyusPolisz")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 ChesTeRcs")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChickenKick")] [assembly: AssemblyTitle("ChickenKick")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ChickenKick { public class Flight : MonoBehaviour { private const float Skin = 0.02f; private const float Drag = 0.003f; private const float Friction = 0.35f; private const float BounceSpeed = 3.5f; private const float RestSpeed = 2f; private const float MaxSeconds = 15f; private const int MaxBounces = 25; private static readonly HashSet<Character> flying = new HashSet<Character>(); private static readonly Dictionary<int, float> whiteness = new Dictionary<int, float>(); private static int mask; private const float Darkest = 0.18f; private const float Whitest = 0.59f; private const float WhiteSlip = 0.25f; private const float WhiteRest = 0.1f; private Character chicken; private Rigidbody body; private bool wasKinematic; private bool wasDetecting; private bool landed; private bool done; private bool grounded; private Vector3 velocity; private Vector3 spin; private Vector3 center; private Vector3 middle; private Quaternion rotation; private float seconds; private float friction; private float rest; private int bounces; internal static IEnumerable<Character> All => flying.Where((Character c) => Object.op_Implicit((Object)(object)c)); private static int Mask { get { if (mask == 0) { return mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); } return mask; } } internal static bool InAir(Character c) { return flying.Contains(c); } internal static void Launch(Character chicken, Vector3 velocity) { //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) //IL_016e: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f3: 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_0108: Unknown result type (might be due to invalid IL or missing references) flying.RemoveWhere((Character c) => !Object.op_Implicit((Object)(object)c)); Flight flight = ((Component)chicken).GetComponent<Flight>(); if (Object.op_Implicit((Object)(object)flight) && flight.done) { Object.DestroyImmediate((Object)(object)flight); flight = null; } if ((Object)(object)flight == (Object)null) { flight = ((Component)chicken).gameObject.AddComponent<Flight>(); flight.chicken = chicken; flight.body = chicken.m_body; flight.wasKinematic = flight.body.isKinematic; flight.wasDetecting = flight.body.detectCollisions; flight.body.isKinematic = true; flight.body.detectCollisions = false; Flight flight2 = flight; CapsuleCollider collider = chicken.m_collider; flight2.middle = ((collider != null) ? collider.center : (Vector3.up * 0.3f)); flight.rotation = flight.body.rotation; flight.center = flight.body.position + flight.rotation * flight.middle; float num = Whiteness(chicken); flight.friction = 0.35f * (1f - 0.25f * num); flight.rest = 2f * (1f - 0.1f * num); flying.Add(chicken); } flight.velocity = velocity; flight.seconds = 0f; flight.bounces = 0; Vector3 val = velocity; val.y = 0f; Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? Vector3.Cross(Vector3.up, ((Vector3)(ref val)).normalized) : Vector3.right); flight.spin = val2 * Random.Range(300f, 420f) + Vector3.up * Random.Range(-60f, 60f); } private static float Whiteness(Character chicken) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00a1: 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_00c8: 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) try { Renderer componentInChildren = (Renderer)(object)((Component)chicken).GetComponentInChildren<SkinnedMeshRenderer>(); Material val = (Object.op_Implicit((Object)(object)componentInChildren) ? componentInChildren.sharedMaterial : null); Texture val2 = (Object.op_Implicit((Object)(object)val) ? val.mainTexture : null); if (!Object.op_Implicit((Object)(object)val2)) { return 0f; } if (!whiteness.TryGetValue(((Object)val2).GetInstanceID(), out var value)) { RenderTexture temporary = RenderTexture.GetTemporary(16, 16, 0, (RenderTextureFormat)0); RenderTexture active = RenderTexture.active; Graphics.Blit(val2, temporary); RenderTexture.active = temporary; Texture2D val3 = new Texture2D(16, 16, (TextureFormat)4, false); val3.ReadPixels(new Rect(0f, 0f, 16f, 16f), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color tint = (val.HasProperty("_Color") ? val.color : Color.white); value = val3.GetPixels().Average((Color p) => 0.2126f * p.r * tint.r + 0.7152f * p.g * tint.g + 0.0722f * p.b * tint.b); Object.Destroy((Object)(object)val3); whiteness[((Object)val2).GetInstanceID()] = value; } return Mathf.Clamp01((value - 0.18f) / 0.40999997f); } catch (Exception ex) { Plugin.Log.LogDebug((object)("whiteness: " + ex.Message)); return 0f; } } internal static void LandAll() { Flight flight = default(Flight); foreach (Character item in flying.ToList()) { try { if (Object.op_Implicit((Object)(object)item) && ((Component)item).TryGetComponent<Flight>(ref flight)) { flight.Land(cluck: false); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("unload: " + ex.Message)); } } flying.Clear(); } private void FixedUpdate() { //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_007e: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c1: 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_01fb: 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_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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_023c: 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) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_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_0106: 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_0111: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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) if (done) { return; } if (!Object.op_Implicit((Object)(object)chicken) || !chicken.m_nview.IsValid() || !chicken.m_nview.IsOwner() || chicken.IsDead()) { Land(cluck: true); return; } body.isKinematic = true; float fixedDeltaTime = Time.fixedDeltaTime; float num = fixedDeltaTime; seconds += fixedDeltaTime; velocity += Physics.gravity * fixedDeltaTime; velocity -= velocity * Mathf.Min(1f, 0.003f * ((Vector3)(ref velocity)).magnitude * fixedDeltaTime); grounded = false; float num2 = Radius(); RaycastHit val3 = default(RaycastHit); for (int i = 0; i < 3; i++) { if (landed) { break; } if (!(num > 0f)) { break; } if (!(((Vector3)(ref velocity)).sqrMagnitude > 1E-08f)) { break; } Vector3 val = velocity * num; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = val / magnitude; if (!Physics.SphereCast(center - val2 * num2, num2, val2, ref val3, magnitude + num2 + 0.02f, Mask, (QueryTriggerInteraction)1)) { center += val; break; } float num3 = Mathf.Max(0f, ((RaycastHit)(ref val3)).distance - num2 - 0.02f); center += val2 * num3; num *= 1f - num3 / magnitude; Hit(((RaycastHit)(ref val3)).normal); } if (Object.op_Implicit((Object)(object)ZoneSystem.instance)) { float num4 = ZoneSystem.instance.GetGroundHeight(center) + num2; if (center.y < num4) { center.y = num4; Hit(Vector3.up); } } if (grounded && ((Vector3)(ref velocity)).magnitude < rest) { landed = true; } if (!landed) { rotation = Quaternion.Euler(spin * fixedDeltaTime) * rotation; } body.MoveRotation(rotation); body.MovePosition(center - rotation * middle); if (landed || seconds > 15f || (chicken.InWater() && velocity.y < 0f && seconds > 0.1f)) { Land(cluck: true); } } private void Hit(Vector3 normal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0088: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0097: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Dot(velocity, normal); if (num >= 0f) { return; } bool num2 = 0f - num > 3.5f; float num3 = (num2 ? Plugin.Bounce.Value : 0f); Vector3 val = normal * num; Vector3 val2 = velocity - val; float num4 = (0f - num) * (1f + num3); float magnitude = ((Vector3)(ref val2)).magnitude; val2 = ((magnitude > 0.0001f) ? (val2 * (Mathf.Max(0f, magnitude - friction * num4) / magnitude)) : Vector3.zero); velocity = val2 - val * num3; if (normal.y > 0.6f) { grounded = true; } if (num2) { bounces++; Vector3 val3 = Vector3.Cross(normal, val2) * (57.29578f / Radius()); spin = Vector3.Lerp(spin, val3, 0.6f); if (grounded && bounces >= 25) { landed = true; } } } private float Radius() { CapsuleCollider collider = chicken.m_collider; if (collider == null) { return 0.25f; } return (collider.radius + collider.height * 0.5f) * 0.5f; } private void Land(bool cluck) { //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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a5: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (done) { return; } done = true; ((Behaviour)this).enabled = false; if (Object.op_Implicit((Object)(object)chicken)) { if (cluck && Object.op_Implicit((Object)(object)chicken.m_baseAI)) { Kick.Squawk(chicken.m_baseAI.m_idleSound, ((Component)chicken).transform); } Vector3 val = velocity; val.y = 0f; float y; if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f)) { y = ((Quaternion)(ref rotation)).eulerAngles.y; } else { Quaternion val2 = Quaternion.LookRotation(val); y = ((Quaternion)(ref val2)).eulerAngles.y; } float num = y; Vector3 val3 = center - Vector3.up * middle.y; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(center, Vector3.down, ref val4, middle.y + 1f, Mask, (QueryTriggerInteraction)1)) { val3.y = ((RaycastHit)(ref val4)).point.y; } body.rotation = Quaternion.Euler(0f, num, 0f); body.position = val3; ((Component)this).transform.SetPositionAndRotation(val3, body.rotation); Restore(); chicken.m_currentVel = Vector3.zero; chicken.m_maxAirAltitude = body.position.y; flying.Remove(chicken); } Object.Destroy((Object)(object)this); } private void Restore() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) body.detectCollisions = wasDetecting; body.isKinematic = wasKinematic; if (!body.isKinematic) { body.linearVelocity = Vector3.zero; } } private void OnDestroy() { flying.Remove(chicken); if (!done && Object.op_Implicit((Object)(object)chicken) && Object.op_Implicit((Object)(object)body)) { Restore(); } } } internal static class Kick { private const float BigTimes = 2.5f; private const float BigLift = 5f; private const float MinAngle = 3f; private const float ChargeSeconds = 4f; private const float FullTimes = 3.325f; private const float CatchReach = 4f; private const float CatchAngle = 25f; private const float Cooldown = 0.3f; private const float KeepReach = 5f; private static float lastKick = -1f; private static float chargeStart = -1f; private static Character charged; private static readonly string[] KickFx = new string[2] { "vfx_clubhit", "sfx_unarmed_hit" }; private static readonly string[] MediumFx = new string[2] { "vfx_RockHit", "sfx_club_hit" }; private static readonly string[] BigFx = new string[2] { "vfx_sledge_hit", "sfx_sledge_hit" }; internal static float Charge { get { if (!(chargeStart < 0f)) { return Mathf.Clamp01((Time.time - chargeStart) / 4f); } return -1f; } } internal static bool IsChicken(Component c) { string prefabName = Utils.GetPrefabName(c.gameObject); if (!(prefabName == "Hen")) { return prefabName == "Chicken"; } return true; } internal static Character Hovered() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0072: 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_0088: 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) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return null; } GameObject hovering = localPlayer.m_hovering; Character val = (Object.op_Implicit((Object)(object)hovering) ? hovering.GetComponentInParent<Character>() : null); if (Object.op_Implicit((Object)(object)val) && IsChicken((Component)(object)val)) { return val; } Vector3 eyePoint = ((Character)localPlayer).GetEyePoint(); Vector3 lookDir = ((Character)localPlayer).GetLookDir(); Character result = null; float num = 25f; foreach (Character item in Flight.All) { Vector3 val2 = item.GetCenterPoint() - eyePoint; if (!(((Vector3)(ref val2)).magnitude > 4f)) { float num2 = Vector3.Angle(lookDir, val2); if (num2 < num) { num = num2; result = item; } } } return result; } internal static IEnumerable<Character> InReach(Player p, float reach, float arc) { Vector3 look = ((Character)p).GetLookDir(); look.y = 0f; ((Vector3)(ref look)).Normalize(); foreach (Character item in Flight.All) { Vector3 val = item.GetCenterPoint() - (((Component)p).transform.position + Vector3.up); if (!(((Vector3)(ref val)).magnitude > reach)) { Vector3 val2 = val; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.25f || Vector3.Angle(look, val2) <= arc) { yield return item; } } } } internal static bool Pressed(KeyboardShortcut key) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref key)).MainKey == 0 || !Input.GetKeyDown(((KeyboardShortcut)(ref key)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref key)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } internal static void Tick() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; KeyboardShortcut value = Plugin.Key.Value; bool flag = Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).TakeInput() && !Hud.InRadial() && Application.isFocused; if (chargeStart >= 0f) { if (!flag) { Drop(); } else if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey)) { float charge = Charge; Character val = Hovered(); if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)charged) && Vector3.Distance(((Component)charged).transform.position, ((Component)localPlayer).transform.position) < 5f) { val = charged; } Drop(); if (Object.op_Implicit((Object)(object)val)) { lastKick = Time.time; Launch(val, (Humanoid)(object)localPlayer, charge); } } } else if (flag && !(Time.time - lastKick < 0.3f) && Pressed(value)) { charged = Hovered(); if (Object.op_Implicit((Object)(object)charged)) { chargeStart = Time.time; } } } internal static void Drop() { chargeStart = -1f; charged = null; } internal static void Launch(Character chicken, Humanoid kicker, float charge) { Launch(chicken, kicker, Mathf.Lerp(1f, 3.325f, charge), Mathf.Lerp(Plugin.Lift.Value, 5f, charge), (charge >= 0.95f) ? BigFx : ((charge >= 0.5f) ? MediumFx : KickFx)); } internal static void Launch(Character chicken, Humanoid kicker, bool big) { Launch(chicken, kicker, big ? 2.5f : 1f, big ? 5f : Plugin.Lift.Value, big ? MediumFx : KickFx); } private static void Launch(Character chicken, Humanoid kicker, float times, float lift, string[] effects) { //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_0030: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)chicken) && !chicken.IsDead() && chicken.m_nview.IsValid()) { chicken.m_nview.ClaimOwnership(); Vector3 val2; Vector3 val = (val2 = ((Character)kicker).GetLookDir()); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = ((Component)kicker).transform.forward; } ((Vector3)(ref val2)).Normalize(); float num = Mathf.Clamp(Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f + lift, 3f, 80f) * ((float)Math.PI / 180f); float num2 = Plugin.Speed.Value * times; Flight.Launch(chicken, val2 * (Mathf.Cos(num) * num2) + Vector3.up * (Mathf.Sin(num) * num2)); Squawk(chicken.m_hitEffects, ((Component)chicken).transform); Vector3 at = ((Component)chicken).transform.position + Vector3.up * 0.3f; for (int i = 0; i < effects.Length; i++) { Spawn(effects[i], at); } } } private static void Spawn(string prefab, Vector3 at) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) GameObject val = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab(prefab) : null); if (Object.op_Implicit((Object)(object)val)) { Object.Instantiate<GameObject>(val, at, Quaternion.identity); } else { Plugin.Log.LogWarning((object)("no effect " + prefab + " in this game version")); } } internal static void Squawk(EffectList effects, Transform at) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) EffectData[] effectPrefabs = effects.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if (val.m_enabled && Object.op_Implicit((Object)(object)val.m_prefab) && ((Object)val.m_prefab).name.StartsWith("sfx_")) { Object.Instantiate<GameObject>(val.m_prefab, at.position, at.rotation); } } } internal static string KeyName(KeyboardShortcut key) { //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_0079: 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) string text = ""; foreach (KeyCode modifier in ((KeyboardShortcut)(ref key)).Modifiers) { text = text + ((object)modifier/*cast due to .constrained prefix*/).ToString().Replace("Left", "").Replace("Right", "") .Replace("Control", "Ctrl") + " + "; } return text + ((object)((KeyboardShortcut)(ref key)).MainKey/*cast due to .constrained prefix*/).ToString(); } internal static string Word() { return Localization.instance.GetSelectedLanguage() switch { "Hungarian" => "Rúgás (tartsd: erősebb)", "German" => "Treten (halten: stärker)", "Russian" => "Пнуть (удерживать: сильнее)", "Chinese" => "踢(按住:更用力)", _ => "Kick (hold: harder)", }; } } [HarmonyPatch(typeof(Character), "GetHoverText")] internal static class KickHoverText { private static void Postfix(Character __instance, ref string __result) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (Kick.IsChicken((Component)(object)__instance)) { if (string.IsNullOrEmpty(__result)) { __result = Localization.instance.Localize(__instance.m_name); } __result = __result + "\n[<color=yellow><b>" + Kick.KeyName(Plugin.Key.Value) + "</b></color>] " + Kick.Word(); } } } [HarmonyPatch(typeof(Hud), "UpdateAdrenaline")] internal static class ChargeBar { private const float NoTrinketMax = 100f; private static bool Prefix(Hud __instance) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) float charge = Kick.Charge; if (charge < 0f) { return true; } __instance.m_adrenalineAnimator.SetBool("Visible", true); __instance.m_adrenalineText.text = Mathf.FloorToInt(charge * 100f) + "%"; if (__instance.m_lastMaxAdrenaline <= 0f) { __instance.SetAdrenalineBarSize(256f); } ((RectTransform)((Component)__instance.m_adrenalineBarRoot).transform).anchoredPosition = new Vector2(0f, (__instance.m_buildHud.activeSelf || __instance.m_shipHudRoot.activeSelf) ? 320f : 130f); __instance.m_adrenalineBarSlow.SetValue(charge); __instance.m_adrenalineBarFast.SetValue(charge); return false; } } [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] internal static class FistsKick { private static readonly Collider[] found = (Collider[])(object)new Collider[128]; private static int mask; private static void Prefix(Attack __instance) { //IL_008e: 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_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_0140: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Plugin.Fists.Value || !Object.op_Implicit((Object)(object)localPlayer) || (Object)(object)__instance.m_character != (Object)(object)localPlayer || __instance.m_weapon == null || !Object.op_Implicit((Object)(object)((Humanoid)localPlayer).m_unarmedWeapon) || __instance.m_weapon != ((Humanoid)localPlayer).m_unarmedWeapon.m_itemData) { return; } if (mask == 0) { mask = LayerMask.GetMask(new string[4] { "character", "character_net", "character_ghost", "character_noenv" }); } Vector3 val = ((Component)localPlayer).transform.position + Vector3.up; Vector3 lookDir = ((Character)localPlayer).GetLookDir(); lookDir.y = 0f; ((Vector3)(ref lookDir)).Normalize(); float num = __instance.m_attackRange + 0.8f; float num2 = Mathf.Max(__instance.m_attackAngle * 0.5f, 45f) + 15f; int num3 = Physics.OverlapSphereNonAlloc(val, num, found, mask, (QueryTriggerInteraction)1); HashSet<Character> hashSet = new HashSet<Character>(); for (int i = 0; i < num3; i++) { Character componentInParent = ((Component)found[i]).GetComponentInParent<Character>(); if (Object.op_Implicit((Object)(object)componentInParent) && !((Object)(object)componentInParent == (Object)(object)localPlayer) && Kick.IsChicken((Component)(object)componentInParent) && hashSet.Add(componentInParent)) { Vector3 val2 = ((Component)componentInParent).transform.position - ((Component)localPlayer).transform.position; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f) || !(Vector3.Angle(lookDir, val2) > num2)) { Kick.Launch(componentInParent, (Humanoid)(object)localPlayer, ((Humanoid)localPlayer).m_currentAttackIsSecondary); } } } foreach (Character item in Kick.InReach(localPlayer, num + 0.7f, num2).ToList()) { if (hashSet.Add(item)) { Kick.Launch(item, (Humanoid)(object)localPlayer, ((Humanoid)localPlayer).m_currentAttackIsSecondary); } } } } [HarmonyPatch(typeof(Character), "Damage")] internal static class FistsNoHarm { private static bool Prefix(Character __instance, HitData hit) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if (Plugin.Fists.Value && (int)hit.m_skill == 11 && Kick.IsChicken((Component)(object)__instance) && Flight.InAir(__instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return !((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer); } return true; } } [HarmonyPatch(typeof(Character), "UpdateMotion")] internal static class NoWalkingInTheAir { private static bool Prefix(Character __instance, float dt) { if (!Flight.InAir(__instance)) { return true; } __instance.m_lastGroundTouch += dt; return false; } } [BepInPlugin("PetyusPolisz.ChickenKick", "ChickenKick", "1.0.0")] [BepInProcess("valheim.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "PetyusPolisz.ChickenKick"; public const string Name = "ChickenKick"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<KeyboardShortcut> Key; internal static ConfigEntry<float> Speed; internal static ConfigEntry<float> Lift; internal static ConfigEntry<float> Bounce; internal static ConfigEntry<bool> Fists; private Harmony harmony; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Kick", "Key", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), "The key that kicks the chicken under the crosshair (B: free in the game). Hold it to charge the kick: a tap is a plain kick, 4 seconds a full one; the trinkets' bar shows the charge."); Speed = ((BaseUnityPlugin)this).Config.Bind<float>("Kick", "Speed", 18f, new ConfigDescription("How hard the kick is (metres a second).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 40f), Array.Empty<object>())); Lift = ((BaseUnityPlugin)this).Config.Bind<float>("Kick", "Lift", 10f, new ConfigDescription("How much higher than the crosshair the chicken flies off (degrees; the harder the kick, the nearer 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 45f), Array.Empty<object>())); Bounce = ((BaseUnityPlugin)this).Config.Bind<float>("Kick", "Bounce", 0.8f, new ConfigDescription("How much speed a bounce off a wall or the ground keeps (0: none, 0.95: a rubber chicken).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.95f), Array.Empty<object>())); Fists = ((BaseUnityPlugin)this).Config.Bind<bool>("Kick", "Fists", true, "Bare hands on a chicken: a punch kicks it, the fists' own kick (the secondary attack) is the big kick. No damage."); harmony = new Harmony("PetyusPolisz.ChickenKick"); harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"ChickenKick 1.0.0 loaded"); } private void Update() { Kick.Tick(); } private void OnDestroy() { Kick.Drop(); try { Flight.LandAll(); } catch (Exception ex) { Log.LogDebug((object)("unload: " + ex.Message)); } Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }