using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI.")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")]
[assembly: AssemblyCompany("PullYourselfTogether")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8b394b54fd87f5d2d5266f344b5d129252978d70")]
[assembly: AssemblyProduct("PullYourselfTogether")]
[assembly: AssemblyTitle("PullYourselfTogether")]
[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 PullYourselfTogether
{
internal static class Crawl
{
public struct Order
{
public Vector2 Move;
public byte Lunges;
public float Time;
}
private sealed class Body
{
public float Phase;
public float NextLunge;
public float AirUntil;
public float RestHeight = 0.25f;
public Vector3 Heading = Vector3.forward;
public Vector3 Velocity;
public byte Lunges;
public bool Steering;
public int Solid;
}
public static readonly Dictionary<ulong, Order> Inputs = new Dictionary<ulong, Order>();
private static readonly Dictionary<DeadPlayerPart, Body> bodies = new Dictionary<DeadPlayerPart, Body>();
public static Quaternion Pose = Quaternion.Euler(Plugin.PoseEuler);
private const float StepUp = 0.5f;
private const float Radius = 0.22f;
private static readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[16];
private static float yaw;
private static float pitch = 15f;
private static bool wasDead;
private static byte lunges;
private static float nextSend;
private static float nextFlop;
private static DeadPlayerPart aimedAt;
private static Vector2 forcedMove;
private static float forcedUntil;
private static bool forcedLunge;
private static bool forcedToLegs;
public static Vector3 Facing { get; private set; } = Vector3.forward;
public static void SetInput(ulong client, Vector2 move, byte lunges)
{
//IL_0010: 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)
Inputs[client] = new Order
{
Move = Vector2.ClampMagnitude(move, 1f),
Lunges = lunges,
Time = Time.time
};
}
public static void HostFixedUpdate()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
float fixedDeltaTime = Time.fixedDeltaTime;
foreach (Player player in GameManager.players)
{
if ((Object)(object)player == (Object)null || player.IsAlive)
{
continue;
}
DeadPlayerPart val = Parts.Torso(player);
if ((Object)(object)val == (Object)null || (Object)(object)((HoldableObject)val).rigidbody == (Object)null)
{
continue;
}
bodies.TryGetValue(val, out var value);
Order value2;
bool num = Inputs.TryGetValue(((NetworkBehaviour)player).OwnerClientId, out value2) && Time.time - value2.Time < 0.5f;
bool flag = !((HoldableObject)val).Active && !((HoldableObject)val).IsHeldByAnyPlayer;
if (!num || !flag || Time.time - val.__spawnTime < 1.5f)
{
if ((value?.Steering ?? false) && flag)
{
Release(val, value, Vector3.zero);
}
else if (value != null)
{
value.Steering = false;
}
continue;
}
if (value == null)
{
Dictionary<DeadPlayerPart, Body> dictionary = bodies;
Body obj = new Body
{
Lunges = value2.Lunges,
Solid = SolidFor(val)
};
value = obj;
dictionary[val] = obj;
}
Move(val, value, value2, fixedDeltaTime);
val.HandleAutoConnect();
}
if (bodies.Count <= 0 || Time.frameCount % 300 != 0)
{
return;
}
List<DeadPlayerPart> list = new List<DeadPlayerPart>();
foreach (DeadPlayerPart key in bodies.Keys)
{
if ((Object)(object)key == (Object)null || !((NetworkBehaviour)key).IsSpawned)
{
list.Add(key);
}
}
foreach (DeadPlayerPart item in list)
{
bodies.Remove(item);
}
}
private static void Move(DeadPlayerPart torso, Body body, Order order, float dt)
{
//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_0011: 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_0046: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00ce: 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_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0347: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
Rigidbody rigidbody = ((HoldableObject)torso).rigidbody;
Vector3 val = Parts.Centre(torso);
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(order.Move.x, 0f, order.Move.y);
float num = Mathf.Clamp01(((Vector3)(ref val2)).magnitude);
if (num > 0.1f)
{
body.Heading = val2 / num;
}
if (order.Lunges != body.Lunges)
{
body.Lunges = order.Lunges;
if (body.Steering && Time.time >= body.NextLunge)
{
body.NextLunge = Time.time + 1.1f;
body.AirUntil = Time.time + 0.35f;
Release(torso, body, body.Heading * Plugin.CrawlSpeed.Value * 1.8f + Vector3.up * 5.5f);
return;
}
}
if (!body.Steering)
{
if (Time.time < body.AirUntil || !Ground(val, 0.6f, body.Solid, out var y) || rigidbody.linearVelocity.y > 0.5f)
{
return;
}
body.Steering = true;
body.RestHeight = Mathf.Clamp(val.y - y, 0.18f, 0.4f);
body.Velocity = new Vector3(rigidbody.linearVelocity.x, 0f, rigidbody.linearVelocity.z);
rigidbody.isKinematic = true;
}
body.Phase += num * (Plugin.CrawlSpeed.Value / 0.9f) * dt;
float num2 = Mathf.Max(0f, Mathf.Sin(body.Phase * MathF.PI * 4f));
Vector3 val3 = body.Heading * (num * Plugin.CrawlSpeed.Value * (0.55f + 0.9f * num2));
body.Velocity = Vector3.Lerp(body.Velocity, val3, 1f - Mathf.Exp((0f - ((num > 0.1f) ? 10f : 6f)) * dt));
Vector3 val4 = body.Velocity * dt;
if (((Vector3)(ref val4)).sqrMagnitude > 1E-08f && Wall(val, val4, body.Solid, out var wall))
{
Vector3 val5 = new Vector3(((RaycastHit)(ref wall)).normal.x, 0f, ((RaycastHit)(ref wall)).normal.z);
Vector3 normalized = ((Vector3)(ref val5)).normalized;
val4 -= normalized * Vector3.Dot(val4, normalized);
body.Velocity -= normalized * Vector3.Dot(body.Velocity, normalized);
}
Vector3 val6 = val + val4;
float y3;
if (Ground(val6, 0.5f + body.RestHeight, body.Solid, out var y2))
{
val6.y = Mathf.MoveTowards(val.y, y2 + body.RestHeight, 4f * dt);
}
else if (!Ground(val6, 0.5f + body.RestHeight + 1.5f, body.Solid, out y3))
{
Release(torso, body, body.Velocity);
return;
}
rigidbody.MovePosition(rigidbody.position + (val6 - val));
rigidbody.MoveRotation(Quaternion.Slerp(rigidbody.rotation, Quaternion.LookRotation(body.Heading) * Pose, 1f - Mathf.Exp(-8f * dt)));
}
private static void Release(DeadPlayerPart torso, Body body, Vector3 velocity)
{
//IL_002a: 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)
body.Steering = false;
if (!((HoldableObject)torso).Active && !((HoldableObject)torso).IsHeldByAnyPlayer)
{
((HoldableObject)torso).rigidbody.isKinematic = false;
((HoldableObject)torso).rigidbody.linearVelocity = velocity;
((HoldableObject)torso).rigidbody.angularVelocity = Vector3.zero;
}
}
private static int SolidFor(DeadPlayerPart torso)
{
int layer = ((Component)torso.sections[torso.initialActiveSection].mainCollider).gameObject.layer;
int num = 0;
for (int i = 0; i < 32; i++)
{
if (!Physics.GetIgnoreLayerCollision(layer, i))
{
num |= 1 << i;
}
}
return num;
}
private static bool Ignored(RaycastHit hit)
{
if (!((RaycastHit)(ref hit)).collider.isTrigger && (!((Object)(object)((RaycastHit)(ref hit)).rigidbody != (Object)null) || ((RaycastHit)(ref hit)).rigidbody.isKinematic) && !((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<Player>() != (Object)null))
{
return (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<HoldableObject>() != (Object)null;
}
return true;
}
private static bool Ground(Vector3 at, float depth, int solid, out float y)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
y = float.NegativeInfinity;
int num = Physics.RaycastNonAlloc(at + Vector3.up * 0.5f, Vector3.down, hits, 0.5f + depth, solid, (QueryTriggerInteraction)1);
bool flag = false;
for (int i = 0; i < num; i++)
{
if (!Ignored(hits[i]) && !(((RaycastHit)(ref hits[i])).normal.y < 0.5f) && (!flag || ((RaycastHit)(ref hits[i])).point.y > y))
{
y = ((RaycastHit)(ref hits[i])).point.y;
flag = true;
}
}
return flag;
}
private static bool Wall(Vector3 centre, Vector3 step, int solid, out RaycastHit wall)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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)
wall = default(RaycastHit);
if (((Vector3)(ref step)).sqrMagnitude < 1E-08f)
{
return false;
}
int num = Physics.SphereCastNonAlloc(centre, 0.22f, ((Vector3)(ref step)).normalized, hits, ((Vector3)(ref step)).magnitude + 0.05f, solid, (QueryTriggerInteraction)1);
float num2 = float.PositiveInfinity;
for (int i = 0; i < num; i++)
{
if (!Ignored(hits[i]) && !(((RaycastHit)(ref hits[i])).normal.y >= 0.6f) && !(((RaycastHit)(ref hits[i])).distance <= 0f) && ((RaycastHit)(ref hits[i])).distance < num2)
{
num2 = ((RaycastHit)(ref hits[i])).distance;
wall = hits[i];
}
}
return num2 < float.PositiveInfinity;
}
public static bool IsMine(DeadPlayerPart torso)
{
if ((Object)(object)torso != (Object)null)
{
return (Object)(object)torso == (Object)(object)aimedAt;
}
return false;
}
public static void Force(Vector2 move, float seconds, bool lungeAfter, bool toLegs = false)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
forcedToLegs = toLegs;
forcedMove = move;
forcedUntil = Time.unscaledTime + seconds;
forcedLunge = lungeAfter;
}
public static DeadPlayerPart Crawling()
{
Player localPlayer = Player.LocalPlayer;
if ((Object)(object)localPlayer == (Object)null || localPlayer.IsAlive || !Plugin.Enabled.Value)
{
return null;
}
DeadPlayerPart currentDeathPart = localPlayer.CurrentDeathPart;
if ((Object)(object)currentDeathPart == (Object)null || !((NetworkBehaviour)currentDeathPart).IsSpawned || currentDeathPart.initialActiveSection != 0 || ((HoldableObject)currentDeathPart).IsHeldByAnyPlayer)
{
return null;
}
Component spectatingPlayer = localPlayer.PlayerLook.SpectatingPlayer;
if ((Object)(object)spectatingPlayer == (Object)null || (Object)(object)spectatingPlayer.GetComponentInParent<DeadPlayerPart>() != (Object)(object)currentDeathPart)
{
return null;
}
return currentDeathPart;
}
public static void ClientUpdate()
{
//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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: 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_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_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: 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)
//IL_00e9: 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_00f4: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.LocalPlayer;
if ((Object)(object)localPlayer != (Object)null && localPlayer.IsAlive == wasDead)
{
wasDead = !localPlayer.IsAlive;
Plugin.Log.LogInfo((object)(wasDead ? "Pull Yourself Together: down" : "Pull Yourself Together: back up"));
}
DeadPlayerPart val = Crawling();
if ((Object)(object)val == (Object)null)
{
aimedAt = null;
forcedUntil = 0f;
forcedLunge = false;
Hud.Restore(null);
return;
}
if ((Object)(object)aimedAt != (Object)(object)val)
{
aimedAt = val;
yaw = ((Component)localPlayer.PlayerLook).transform.eulerAngles.y;
pitch = 15f;
}
Vector2 val2 = Vector2.zero;
Vector2 val3 = Vector2.zero;
bool flag = false;
if (Time.unscaledTime < forcedUntil)
{
val3 = forcedMove;
DeadPlayerPart val4 = (forcedToLegs ? Parts.Legs(localPlayer) : null);
if ((Object)(object)val4 != (Object)null)
{
Vector3 val5 = Parts.Centre(val4) - Parts.Centre(val);
yaw = Mathf.LerpAngle(yaw, Mathf.Atan2(val5.x, val5.z) * 57.29578f, 0.1f);
((Vector2)(ref val3))..ctor(0f, 1f);
}
}
else if (forcedLunge)
{
forcedLunge = false;
flag = true;
}
if (Mouse.current != null)
{
val2 += ((InputControl<Vector2>)(object)((Pointer)Mouse.current).delta).ReadValue() * Plugin.LookSensitivity.Value;
}
if (Keyboard.current != null)
{
Keyboard current = Keyboard.current;
val3 += new Vector2((float)((((ButtonControl)current.dKey).isPressed ? 1 : 0) - (((ButtonControl)current.aKey).isPressed ? 1 : 0)), (float)((((ButtonControl)current.wKey).isPressed ? 1 : 0) - (((ButtonControl)current.sKey).isPressed ? 1 : 0)));
flag |= ((ButtonControl)current.spaceKey).wasPressedThisFrame;
}
if (Gamepad.current != null)
{
Gamepad current2 = Gamepad.current;
val3 += ((InputControl<Vector2>)(object)current2.leftStick).ReadValue();
val2 += ((InputControl<Vector2>)(object)current2.rightStick).ReadValue() * (180f * Time.unscaledDeltaTime);
flag |= current2.buttonSouth.wasPressedThisFrame;
}
yaw += val2.x;
pitch = Mathf.Clamp(pitch - val2.y, -5f, 65f);
val3 = Vector2.ClampMagnitude(val3, 1f);
Quaternion val6 = Quaternion.Euler(0f, yaw, 0f);
Facing = val6 * Vector3.forward;
Vector3 val7 = val6 * new Vector3(val3.x, 0f, val3.y);
if (flag)
{
lunges++;
}
if (Net.HostHasMod)
{
if (flag || Time.unscaledTime >= nextSend)
{
nextSend = Time.unscaledTime + 0.05f;
Net.SendInput(new Vector2(val7.x, val7.z), lunges);
}
}
else if ((((Vector2)(ref val3)).sqrMagnitude > 0.04f || flag) && Time.unscaledTime >= nextFlop)
{
nextFlop = Time.unscaledTime + (flag ? 1.2f : 0.75f);
Vector3 velocity_ServerRpc = ((Vector3)(ref val7)).normalized * Plugin.CrawlSpeed.Value * (flag ? 2f : 1.2f) + Vector3.up * (flag ? 5.5f : 3f);
((HoldableObject)val).SetVelocity_ServerRpc(velocity_ServerRpc);
}
}
public static void PlaceCamera(PlayerLook look)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_00dc: 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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_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)
DeadPlayerPart val = Crawling();
if ((Object)(object)val == (Object)null)
{
Hud.Show(look, null);
return;
}
Vector3 val2 = Parts.Centre(val) + Vector3.up * 0.55f;
Quaternion val3 = Quaternion.Euler(pitch, yaw, 0f);
float num = 2.8f;
int num2 = Physics.SphereCastNonAlloc(val2, 0.25f, val3 * Vector3.back, hits, num, SolidFor(val), (QueryTriggerInteraction)1);
for (int i = 0; i < num2; i++)
{
if (!Ignored(hits[i]) && ((RaycastHit)(ref hits[i])).distance > 0f)
{
num = Mathf.Min(num, Mathf.Max(0.4f, ((RaycastHit)(ref hits[i])).distance - 0.15f));
}
}
((Component)look).transform.SetPositionAndRotation(val2 + val3 * Vector3.back * num, val3);
Hud.Show(look, val);
}
}
[HarmonyPatch(typeof(PlayerLook), "HandleSpectatingCamera")]
internal static class CrawlCamera
{
private static void Postfix(PlayerLook __instance)
{
try
{
Crawl.PlaceCamera(__instance);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Pull Yourself Together: camera: " + ex.Message));
}
}
}
internal static class Debug
{
public static void DumpRig()
{
Player localPlayer = Player.LocalPlayer;
if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Animator == (Object)null)
{
return;
}
ThirdPersonRig[] array = (ThirdPersonRig[])(object)new ThirdPersonRig[2]
{
localPlayer.Animator.ThirdPersonRig,
localPlayer.Animator.LocalThirdPersonRig
};
foreach (ThirdPersonRig val in array)
{
if (!((Object)(object)val == (Object)null))
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("rig ").Append(((Object)val).name).Append(" active ")
.Append(((Component)val).gameObject.activeInHierarchy)
.Append('\n');
Dump(((Component)val).transform, 0, stringBuilder);
SkinnedMeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (SkinnedMeshRenderer val2 in componentsInChildren)
{
stringBuilder.Append("skinned ").Append(((Object)val2).name).Append(": ")
.Append(val2.bones.Length)
.Append(" bones, root ")
.Append(((Object)(object)val2.rootBone != (Object)null) ? ((Object)val2.rootBone).name : "-")
.Append(", mesh ")
.Append(((Object)(object)val2.sharedMesh != (Object)null) ? ((Object)val2.sharedMesh).name : "-")
.Append('\n');
}
Plugin.Log.LogInfo((object)stringBuilder.ToString());
}
}
}
private static void Dump(Transform t, int depth, StringBuilder sb)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
StringBuilder stringBuilder = sb.Append(' ', depth * 2).Append(((Object)t).name).Append(' ');
Vector3 val = t.localPosition;
StringBuilder stringBuilder2 = stringBuilder.Append(((Vector3)(ref val)).ToString("F2")).Append(' ');
val = t.localEulerAngles;
stringBuilder2.Append(((Vector3)(ref val)).ToString("F0"));
Component[] components = ((Component)t).GetComponents<Component>();
foreach (Component val2 in components)
{
if (!(val2 is Transform))
{
sb.Append(" [").Append(((object)val2).GetType().Name).Append(']');
}
}
sb.Append('\n');
foreach (Transform item in t)
{
Dump(item, depth + 1, sb);
}
}
}
internal static class Hud
{
private static Canvas canvas;
private static RectTransform marker;
private static RectTransform arrow;
private static Image icon;
private static TextMeshProUGUI label;
private static TextMeshProUGUI hint;
private static bool hidDeathScreen;
private static bool hidMission;
private static readonly List<Ping> hiddenPings = new List<Ping>();
private static Sprite triangle;
public static void Show(PlayerLook look, DeadPlayerPart torso)
{
//IL_00fa: 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_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: 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_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: 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_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)torso == (Object)null)
{
Restore(look);
return;
}
Player localPlayer = Player.LocalPlayer;
if ((Object)(object)look.deathSpectateScreen != (Object)null && look.deathSpectateScreen.activeSelf)
{
look.deathSpectateScreen.SetActive(false);
hidDeathScreen = true;
}
if (!look.DisableMissionHUD)
{
look.DisableMissionHUD = true;
hidMission = true;
}
foreach (Ping ping in Highlighter.pings)
{
if ((Object)(object)ping?.graphic != (Object)null && ((Behaviour)ping.graphic).enabled)
{
((Behaviour)ping.graphic).enabled = false;
hiddenPings.Add(ping);
}
}
if ((Object)(object)canvas == (Object)null)
{
Build(look);
}
((Component)canvas).gameObject.SetActive(true);
bool flag = (Object)(object)LevelData.Instance != (Object)null && UpgradeFlagsExtensions.IsEnabled(LevelData.Instance.LevelFlags, (LevelFlags)2048);
((TMP_Text)hint).SetText(flag ? "WASD crawl SPACE lunge CLICK watch your team HOLD X respawn" : "WASD crawl SPACE lunge CLICK watch your team");
DeadPlayerPart val = Parts.Legs(localPlayer);
Camera localCamera = PlayerLook.LocalCamera;
if ((Object)(object)val == (Object)null || (Object)(object)localCamera == (Object)null)
{
((Component)marker).gameObject.SetActive(false);
return;
}
((Component)marker).gameObject.SetActive(true);
Vector3 val2 = Parts.Centre(val) + Vector3.up * 0.4f;
float num = Vector3.Distance(Parts.Centre(torso), Parts.Centre(val));
((TMP_Text)label).SetText((num < 10f) ? "YOUR LEGS\n{0:1} m" : "YOUR LEGS\n{0:0} m", num);
((Graphic)icon).color = localPlayer.Color;
float num2 = 1f + 0.08f * Mathf.Sin(Time.unscaledTime * 5f);
((Transform)marker).localScale = new Vector3(num2, num2, 1f);
Rect rect = ((RectTransform)((Component)canvas).transform).rect;
Vector2 size = ((Rect)(ref rect)).size;
Vector2 val3 = size * 0.5f;
Vector2 val4 = default(Vector2);
((Vector2)(ref val4))..ctor(110f, 120f);
Vector3 val5 = localCamera.WorldToViewportPoint(val2);
bool num3 = val5.z < 0f;
Vector2 val6 = default(Vector2);
((Vector2)(ref val6))..ctor((val5.x - 0.5f) * size.x, (val5.y - 0.5f) * size.y);
if (num3)
{
val6 = -val6;
}
bool flag2 = !num3 && Mathf.Abs(val6.x) < val3.x - val4.x && Mathf.Abs(val6.y) < val3.y - val4.y;
if (!flag2)
{
if (((Vector2)(ref val6)).sqrMagnitude < 1f)
{
((Vector2)(ref val6))..ctor(0f, -1f);
}
float num4 = Mathf.Min((val3.x - val4.x) / Mathf.Max(Mathf.Abs(val6.x), 0.001f), (val3.y - val4.y) / Mathf.Max(Mathf.Abs(val6.y), 0.001f));
val6 *= num4;
}
marker.anchoredPosition = val6;
((Component)arrow).gameObject.SetActive(!flag2);
if (!flag2)
{
Vector2 normalized = ((Vector2)(ref val6)).normalized;
arrow.anchoredPosition = normalized * 70f;
((Transform)arrow).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(normalized.y, normalized.x) * 57.29578f - 90f);
}
}
public static void Restore(PlayerLook look)
{
if ((Object)(object)canvas != (Object)null && ((Component)canvas).gameObject.activeSelf)
{
((Component)canvas).gameObject.SetActive(false);
}
if ((Object)(object)look == (Object)null)
{
look = PlayerLook.Instance;
}
Player localPlayer = Player.LocalPlayer;
if (hidDeathScreen)
{
hidDeathScreen = false;
if ((Object)(object)look != (Object)null && (Object)(object)look.deathSpectateScreen != (Object)null && (Object)(object)localPlayer != (Object)null && !localPlayer.IsAlive)
{
look.deathSpectateScreen.SetActive(true);
}
}
if (hidMission)
{
hidMission = false;
if ((Object)(object)look != (Object)null)
{
look.DisableMissionHUD = false;
}
}
if (hiddenPings.Count <= 0)
{
return;
}
foreach (Ping hiddenPing in hiddenPings)
{
if ((Object)(object)hiddenPing?.graphic != (Object)null && Highlighter.pings.Contains(hiddenPing))
{
((Behaviour)hiddenPing.graphic).enabled = true;
}
}
hiddenPings.Clear();
}
public static void Destroy()
{
Restore(null);
if ((Object)(object)canvas != (Object)null)
{
Object.Destroy((Object)(object)((Component)canvas).gameObject);
}
canvas = null;
}
private static void Build(PlayerLook look)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: 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_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
canvas = new GameObject("PullYourselfTogether HUD", new Type[1] { typeof(RectTransform) }).AddComponent<Canvas>();
Object.DontDestroyOnLoad((Object)(object)((Component)canvas).gameObject);
canvas.renderMode = (RenderMode)0;
canvas.sortingOrder = 500;
CanvasScaler obj = ((Component)canvas).gameObject.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.matchWidthOrHeight = 0.5f;
TMP_Text killedByText = (TMP_Text)(object)look.killedByText;
marker = Rect("Legs", ((Component)canvas).transform, new Vector2(160f, 160f));
icon = new GameObject("Icon", new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
((Component)icon).transform.SetParent((Transform)(object)marker, false);
icon.sprite = Global.Instance.PlayerDeathIcons[1];
icon.preserveAspect = true;
((Graphic)icon).raycastTarget = false;
((RectTransform)((Component)icon).transform).sizeDelta = new Vector2(72f, 72f);
((RectTransform)((Component)icon).transform).anchoredPosition = new Vector2(0f, 18f);
label = Text("Label", (Transform)(object)marker, killedByText, 26f);
((RectTransform)((TMP_Text)label).transform).anchoredPosition = new Vector2(0f, -48f);
arrow = Rect("Arrow", (Transform)(object)marker, new Vector2(34f, 30f));
Image obj2 = ((Component)arrow).gameObject.AddComponent<Image>();
obj2.sprite = Triangle();
((Graphic)obj2).raycastTarget = false;
hint = Text("Hint", ((Component)canvas).transform, killedByText, 24f);
RectTransform val = (RectTransform)((TMP_Text)hint).transform;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0f);
val.anchorMax = val2;
val.anchorMin = val2;
val.sizeDelta = new Vector2(1600f, 40f);
val.anchoredPosition = new Vector2(0f, 70f);
((Graphic)hint).color = new Color(1f, 1f, 1f, 0.85f);
}
private static RectTransform Rect(string name, Transform parent, Vector2 size)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject(name, new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
component.sizeDelta = size;
return component;
}
private static TextMeshProUGUI Text(string name, Transform parent, TMP_Text style, float size)
{
//IL_0014: 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_0084: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = new GameObject(name, new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>();
((TMP_Text)val).transform.SetParent(parent, false);
if ((Object)(object)style != (Object)null)
{
((TMP_Text)val).font = style.font;
((TMP_Text)val).fontSharedMaterial = style.fontSharedMaterial;
}
((TMP_Text)val).fontSize = size;
((TMP_Text)val).alignment = (TextAlignmentOptions)514;
((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
((Graphic)val).raycastTarget = false;
((RectTransform)((TMP_Text)val).transform).sizeDelta = new Vector2(400f, size * 2.6f);
return val;
}
private static Sprite Triangle()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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)
//IL_002d: Expected O, but got Unknown
//IL_00da: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)triangle != (Object)null)
{
return triangle;
}
Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
{
filterMode = (FilterMode)1,
wrapMode = (TextureWrapMode)1
};
Color32[] array = (Color32[])(object)new Color32[4096];
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
byte b = (byte)(Mathf.Clamp01((1f - ((float)i + 0.5f) / 64f) * 64f * 0.5f - Mathf.Abs((float)j + 0.5f - 32f)) * 255f);
array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
}
}
val.SetPixels32(array);
val.Apply(false, true);
triangle = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
return triangle;
}
}
internal static class Mixup
{
private sealed class Pair
{
public ulong Torso;
public ulong Legs;
public float Started;
public float Ends;
public bool Locked;
public bool CollidersOff;
public bool Announced;
public bool SplitSent;
public float Held;
public readonly List<Renderer> Hidden = new List<Renderer>();
}
private static readonly List<Pair> pairs = new List<Pair>();
private static Pair Find(ulong client)
{
foreach (Pair pair in pairs)
{
if (pair.Torso == client || pair.Legs == client)
{
return pair;
}
}
return null;
}
public static bool IsLocalLegs(Player player)
{
if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner)
{
return false;
}
foreach (Pair pair in pairs)
{
if (pair.Legs == ((NetworkBehaviour)player).OwnerClientId && player.IsAlive)
{
return true;
}
}
return false;
}
public static bool TorsoOn(Player legs, out Player torso)
{
torso = null;
if ((Object)(object)legs == (Object)null)
{
return false;
}
foreach (Pair pair in pairs)
{
if (pair.Legs == ((NetworkBehaviour)legs).OwnerClientId)
{
torso = GameManager.GetPlayer(pair.Torso);
return (Object)(object)torso != (Object)null && torso.IsAlive && legs.IsAlive;
}
}
return false;
}
public static void HostFixedUpdate()
{
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
for (int num = pairs.Count - 1; num >= 0; num--)
{
Pair pair = pairs[num];
Player player = GameManager.GetPlayer(pair.Torso);
Player player2 = GameManager.GetPlayer(pair.Legs);
if (Time.time >= pair.Ends || (Object)(object)player == (Object)null || (Object)(object)player2 == (Object)null || (Time.time - pair.Started > 2f && (!player.IsAlive || !player2.IsAlive)))
{
Net.SendUnmix(pair.Torso);
}
}
if (!Plugin.Mixups.Value)
{
return;
}
foreach (Player player3 in GameManager.players)
{
if ((Object)(object)player3 == (Object)null || player3.IsAlive || Find(((NetworkBehaviour)player3).OwnerClientId) != null || !Net.Modded.Contains(((NetworkBehaviour)player3).OwnerClientId))
{
continue;
}
DeadPlayerPart val = Parts.Torso(player3);
if ((Object)(object)val == (Object)null || Time.time - val.__spawnTime < 3f || ((!Crawl.Inputs.TryGetValue(((NetworkBehaviour)player3).OwnerClientId, out var value) || !(Time.time - value.Time < 0.4f)) && !((HoldableObject)val).IsHeldByAnyPlayer && (!val.hasBeenThrown || !((Object)(object)((HoldableObject)val).rigidbody != (Object)null) || ((HoldableObject)val).rigidbody.IsSleeping())))
{
continue;
}
foreach (Player player4 in GameManager.players)
{
if (!((Object)(object)player4 == (Object)null) && !((Object)(object)player4 == (Object)(object)player3) && !player4.IsAlive && Find(((NetworkBehaviour)player4).OwnerClientId) == null && Net.Modded.Contains(((NetworkBehaviour)player4).OwnerClientId))
{
DeadPlayerPart val2 = Parts.Legs(player4);
if (!((Object)(object)val2 == (Object)null) && Parts.Touching(val, val2))
{
Vector3 val3 = Parts.Centre(val2);
Plugin.Log.LogInfo((object)("Pull Yourself Together: " + player3.Name + "'s torso on " + player4.Name + "'s legs"));
player4.Resurrect_ServerRpc(val3, default(Quaternion));
player3.Resurrect_ServerRpc(val3, default(Quaternion));
Net.SendMix(((NetworkBehaviour)player3).OwnerClientId, ((NetworkBehaviour)player4).OwnerClientId, Plugin.MixSeconds.Value);
return;
}
}
}
}
}
public static void SplitRequested(ulong client)
{
Pair pair = Find(client);
if (pair != null)
{
Net.SendUnmix(pair.Torso);
}
}
public static void Begin(ulong torso, ulong legs, float seconds)
{
if (Find(torso) == null && Find(legs) == null)
{
pairs.Add(new Pair
{
Torso = torso,
Legs = legs,
Started = Time.time,
Ends = Time.time + seconds
});
}
}
public static void End(ulong torso)
{
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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_0104: 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)
Pair pair = pairs.Find((Pair x) => x.Torso == torso);
if (pair == null)
{
return;
}
pairs.Remove(pair);
Player player = GameManager.GetPlayer(pair.Torso);
Player player2 = GameManager.GetPlayer(pair.Legs);
Player localPlayer = Player.LocalPlayer;
foreach (Renderer item in pair.Hidden)
{
if ((Object)(object)item != (Object)null)
{
item.enabled = true;
}
}
if ((Object)(object)player != (Object)null && (Object)(object)player == (Object)(object)localPlayer)
{
if (pair.Locked)
{
int movementLocks = player.MovementLocks;
player.MovementLocks = movementLocks - 1;
}
if (player.IsAlive && (Object)(object)player2 != (Object)null)
{
player.MovePosition(((Component)player2).transform.position + ((Component)player2).transform.right * 1.3f + Vector3.up * 0.3f, true);
}
}
else if ((Object)(object)player != (Object)null && pair.CollidersOff && player.IsAlive)
{
player.EnableColliders(true);
}
if ((Object)(object)player2 != (Object)null && (Object)(object)player2 == (Object)(object)localPlayer && player2.IsAlive)
{
player2.EquipGear(player2.LastSelectedGearSlot);
}
if (pair.Announced && ((Object)(object)player == (Object)(object)localPlayer || (Object)(object)player2 == (Object)(object)localPlayer))
{
Chat("<color=#ffb347>Pulled apart.</color> You're your own robot again.");
}
}
public static void LateUpdate()
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.LocalPlayer;
foreach (Pair pair in pairs)
{
Player player = GameManager.GetPlayer(pair.Torso);
Player player2 = GameManager.GetPlayer(pair.Legs);
if ((Object)(object)player == (Object)null || (Object)(object)player2 == (Object)null || !player.IsAlive || !player2.IsAlive)
{
continue;
}
if (!pair.Announced)
{
pair.Announced = true;
int num = Mathf.RoundToInt(pair.Ends - Time.time);
string text = $"Hold {Plugin.SplitKey.Value} to pull apart (or wait {num} s).";
if ((Object)(object)player == (Object)(object)localPlayer)
{
Chat("<color=#ffb347>Put back together wrong!</color> You're the torso on " + player2.Name + "'s legs: they walk, you shoot. " + text);
}
else if ((Object)(object)player2 == (Object)(object)localPlayer)
{
Chat("<color=#ffb347>Put back together wrong!</color> You're the legs under " + player.Name + "'s torso: you walk, they shoot. " + text);
}
else
{
Chat("<color=#ffb347>" + player.Name + "'s torso is on " + player2.Name + "'s legs.</color>");
}
}
if ((Object)(object)player == (Object)(object)localPlayer)
{
if (!pair.Locked)
{
int movementLocks = player.MovementLocks;
player.MovementLocks = movementLocks + 1;
pair.Locked = true;
}
player.MovePositionSoft(((Component)player2).transform.position);
Hide(pair, player2);
}
else
{
if (!pair.CollidersOff)
{
player.EnableColliders(false);
pair.CollidersOff = true;
}
Hide(pair, player);
}
if ((Object)(object)player2 == (Object)(object)localPlayer && player2.SelectedGear != null)
{
player2.UnequipNow();
}
if (((Object)(object)player == (Object)(object)localPlayer || (Object)(object)player2 == (Object)(object)localPlayer) && !pair.SplitSent && Keyboard.current != null)
{
pair.Held = (((ButtonControl)Keyboard.current[Plugin.SplitKey.Value]).isPressed ? (pair.Held + Time.deltaTime) : 0f);
if (pair.Held >= 1.2f)
{
pair.SplitSent = true;
Net.SendSplit();
}
}
}
}
private static void Hide(Pair p, Player player)
{
ThirdPersonRig val = (((Object)(object)player.Animator != (Object)null) ? player.Animator.ThirdPersonRig : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>();
foreach (Renderer val2 in componentsInChildren)
{
if (val2.enabled)
{
val2.enabled = false;
if (!p.Hidden.Contains(val2))
{
p.Hidden.Add(val2);
}
}
}
}
public static void Clear()
{
Pair[] array = pairs.ToArray();
for (int i = 0; i < array.Length; i++)
{
End(array[i].Torso);
}
pairs.Clear();
}
private static void Chat(string text)
{
if ((Object)(object)PlayerLook.Instance != (Object)null)
{
PlayerLook.Instance.AddTextChatMessage(text, (Player)null);
}
}
}
[HarmonyPatch(typeof(Player), "SwapToSlot")]
internal static class LegsHaveNoArms
{
private static void Prefix(Player __instance, ref int slot, ref IGear gearToHold)
{
if (Mixup.IsLocalLegs(__instance))
{
slot = 0;
gearToHold = null;
}
}
}
[HarmonyPatch(typeof(PlayerAnimation), "LateUpdate")]
internal static class TwistedWaist
{
private static void Postfix(PlayerAnimation __instance)
{
//IL_0029: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance.thirdPersonWaist == (Object)null) && Mixup.TorsoOn(__instance.playerMovement, out var torso))
{
float num = Mathf.DeltaAngle(((Component)__instance.playerMovement).transform.eulerAngles.y, ((Component)torso).transform.eulerAngles.y);
__instance.thirdPersonWaist.rotation = Quaternion.AngleAxis(num, Vector3.up) * __instance.thirdPersonWaist.rotation;
}
}
}
internal static class Net
{
private delegate void Writer(FastBufferWriter w);
[CompilerGenerated]
private static class <>O
{
public static HandleNamedMessageDelegate <0>__OnHello;
public static HandleNamedMessageDelegate <1>__OnInput;
public static HandleNamedMessageDelegate <2>__OnMix;
public static HandleNamedMessageDelegate <3>__OnUnmix;
public static HandleNamedMessageDelegate <4>__OnSplit;
}
private const string Hello = "QuadsPYT.hello";
private const string Input = "QuadsPYT.input";
private const string Mix = "QuadsPYT.mix";
private const string Unmix = "QuadsPYT.unmix";
private const string Split = "QuadsPYT.split";
public static readonly HashSet<ulong> Modded = new HashSet<ulong>();
private static CustomMessagingManager registered;
private static bool helloSent;
public static bool HostHasMod { get; private set; }
public static bool IsHost
{
get
{
if ((Object)(object)NetworkManager.Singleton != (Object)null)
{
return NetworkManager.Singleton.IsServer;
}
return false;
}
}
public static ulong Me
{
get
{
if (!((Object)(object)NetworkManager.Singleton != (Object)null))
{
return 0uL;
}
return NetworkManager.Singleton.LocalClientId;
}
}
public static void Tick()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//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)
//IL_0084: Expected O, but got Unknown
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
NetworkManager singleton = NetworkManager.Singleton;
CustomMessagingManager val = (((Object)(object)singleton != (Object)null && singleton.IsListening) ? singleton.CustomMessagingManager : null);
if (val != registered)
{
Unregister();
if (val != null)
{
registered = val;
object obj = <>O.<0>__OnHello;
if (obj == null)
{
HandleNamedMessageDelegate val2 = OnHello;
<>O.<0>__OnHello = val2;
obj = (object)val2;
}
val.RegisterNamedMessageHandler("QuadsPYT.hello", (HandleNamedMessageDelegate)obj);
object obj2 = <>O.<1>__OnInput;
if (obj2 == null)
{
HandleNamedMessageDelegate val3 = OnInput;
<>O.<1>__OnInput = val3;
obj2 = (object)val3;
}
val.RegisterNamedMessageHandler("QuadsPYT.input", (HandleNamedMessageDelegate)obj2);
object obj3 = <>O.<2>__OnMix;
if (obj3 == null)
{
HandleNamedMessageDelegate val4 = OnMix;
<>O.<2>__OnMix = val4;
obj3 = (object)val4;
}
val.RegisterNamedMessageHandler("QuadsPYT.mix", (HandleNamedMessageDelegate)obj3);
object obj4 = <>O.<3>__OnUnmix;
if (obj4 == null)
{
HandleNamedMessageDelegate val5 = OnUnmix;
<>O.<3>__OnUnmix = val5;
obj4 = (object)val5;
}
val.RegisterNamedMessageHandler("QuadsPYT.unmix", (HandleNamedMessageDelegate)obj4);
object obj5 = <>O.<4>__OnSplit;
if (obj5 == null)
{
HandleNamedMessageDelegate val6 = OnSplit;
<>O.<4>__OnSplit = val6;
obj5 = (object)val6;
}
val.RegisterNamedMessageHandler("QuadsPYT.split", (HandleNamedMessageDelegate)obj5);
}
}
if (registered == null)
{
return;
}
if (singleton.IsServer)
{
HostHasMod = true;
Modded.Add(singleton.LocalClientId);
}
else if (!helloSent && singleton.IsConnectedClient)
{
helloSent = true;
Send("QuadsPYT.hello", 0uL, delegate(FastBufferWriter w)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
int num = 1;
((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num, default(ForPrimitives));
}, (NetworkDelivery)2);
}
}
public static void Unregister()
{
if (registered != null)
{
try
{
string[] array = new string[5] { "QuadsPYT.hello", "QuadsPYT.input", "QuadsPYT.mix", "QuadsPYT.unmix", "QuadsPYT.split" };
foreach (string text in array)
{
registered.UnregisterNamedMessageHandler(text);
}
}
catch (Exception)
{
}
}
registered = null;
helloSent = false;
HostHasMod = false;
Modded.Clear();
Crawl.Inputs.Clear();
}
private static void Send(string name, ulong to, Writer write, NetworkDelivery delivery = (NetworkDelivery)2)
{
//IL_0014: 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_0022: Unknown result type (might be due to invalid IL or missing references)
if (registered == null)
{
return;
}
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1);
try
{
write(val);
registered.SendNamedMessage(name, to, val, delivery);
}
finally
{
((FastBufferWriter)(ref val)).Dispose();
}
}
private static void SendToAll(string name, Writer write)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (registered == null)
{
return;
}
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1);
try
{
write(val);
registered.SendNamedMessageToAll(name, val, (NetworkDelivery)2);
}
finally
{
((FastBufferWriter)(ref val)).Dispose();
}
}
public static void SendInput(Vector2 move, byte lunges)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
if (IsHost)
{
Crawl.SetInput(Me, move, lunges);
return;
}
Send("QuadsPYT.input", 0uL, delegate(FastBufferWriter w)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
((FastBufferWriter)(ref w)).WriteValueSafe(ref move);
((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref lunges, default(ForPrimitives));
}, (NetworkDelivery)1);
}
private static void OnInput(ulong sender, FastBufferReader r)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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)
if (IsHost)
{
Vector2 move = default(Vector2);
((FastBufferReader)(ref r)).ReadValueSafe(ref move);
byte lunges = default(byte);
((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref lunges, default(ForPrimitives));
Crawl.SetInput(sender, move, lunges);
}
}
private static void OnHello(ulong sender, FastBufferReader r)
{
//IL_0006: 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)
int num = default(int);
((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num, default(ForPrimitives));
if (IsHost)
{
if (num == 1)
{
Modded.Add(sender);
}
Plugin.Log.LogInfo((object)string.Format("Pull Yourself Together: player {0} has it too{1}", sender, (num == 1) ? "" : " (another version: no mix-ups with them)"));
Send("QuadsPYT.hello", sender, delegate(FastBufferWriter w)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
int num2 = 1;
((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num2, default(ForPrimitives));
}, (NetworkDelivery)2);
}
else
{
HostHasMod = num == 1;
Plugin.Log.LogInfo((object)("Pull Yourself Together: the host has it" + (HostHasMod ? "" : " (another version: flopping only)")));
}
}
public static void SendMix(ulong torso, ulong legs, float seconds)
{
SendToAll("QuadsPYT.mix", delegate(FastBufferWriter w)
{
//IL_000a: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_003c: Unknown result type (might be due to invalid IL or missing references)
((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref torso, default(ForPrimitives));
((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref legs, default(ForPrimitives));
((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref seconds, default(ForPrimitives));
});
Mixup.Begin(torso, legs, seconds);
}
public static void SendUnmix(ulong torso)
{
SendToAll("QuadsPYT.unmix", delegate(FastBufferWriter w)
{
//IL_000a: 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)
((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref torso, default(ForPrimitives));
});
Mixup.End(torso);
}
public static void SendSplit()
{
if (IsHost)
{
Mixup.SplitRequested(Me);
return;
}
Send("QuadsPYT.split", 0uL, delegate(FastBufferWriter w)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
byte b = 1;
((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
}, (NetworkDelivery)2);
}
private static void OnMix(ulong sender, FastBufferReader r)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references)
if (!IsHost)
{
ulong torso = default(ulong);
((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref torso, default(ForPrimitives));
ulong legs = default(ulong);
((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref legs, default(ForPrimitives));
float seconds = default(float);
((FastBufferReader)(ref r)).ReadValueSafe<float>(ref seconds, default(ForPrimitives));
Mixup.Begin(torso, legs, seconds);
}
}
private static void OnUnmix(ulong sender, FastBufferReader r)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (!IsHost)
{
ulong torso = default(ulong);
((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref torso, default(ForPrimitives));
Mixup.End(torso);
}
}
private static void OnSplit(ulong sender, FastBufferReader r)
{
if (IsHost)
{
Mixup.SplitRequested(sender);
}
}
}
internal static class Parts
{
public static DeadPlayerPart Torso(Player player)
{
return Find(player, 0);
}
public static DeadPlayerPart Legs(Player player)
{
return Find(player, 1);
}
private static DeadPlayerPart Find(Player player, int section)
{
if ((Object)(object)player == (Object)null || !DeadPlayerPart.allParts.TryGetValue(player, out var value))
{
return null;
}
foreach (DeadPlayerPart item in value)
{
if ((Object)(object)item != (Object)null && ((NetworkBehaviour)item).IsSpawned && item.initialActiveSection == section && !item.AreAllSectionsActive)
{
return item;
}
}
return null;
}
public static Vector3 Centre(DeadPlayerPart part)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
BoxCollider mainCollider = part.sections[part.initialActiveSection].mainCollider;
return ((Component)mainCollider).transform.TransformPoint(mainCollider.center);
}
public static bool Touching(DeadPlayerPart a, DeadPlayerPart b)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = Centre(a) - Centre(b);
return ((Vector3)(ref val)).sqrMagnitude < 4f;
}
}
[BepInPlugin("quadslab.mycopunk.pullyourselftogether", "Quad's Pull Yourself Together", "0.1.0")]
[BepInProcess("Mycopunk.exe")]
public class Plugin : BaseUnityPlugin
{
public const string Guid = "quadslab.mycopunk.pullyourselftogether";
public const string Title = "Quad's Pull Yourself Together";
public const string Version = "0.1.0";
public const int Protocol = 1;
internal static ManualLogSource Log;
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<bool> Mixups;
internal static ConfigEntry<float> CrawlSpeed;
internal static ConfigEntry<float> LookSensitivity;
internal static ConfigEntry<float> MixSeconds;
internal static ConfigEntry<Key> SplitKey;
internal static Vector3 PoseEuler = new Vector3(90f, 0f, 0f);
private Harmony harmony;
private GameObject runner;
private void Awake()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Crawling", "Enabled", true, "Crawl your torso back to your legs when you die (WASD, Space to lunge).");
CrawlSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Crawling", "CrawlSpeed", 2.4f, new ConfigDescription("How fast a torso crawls, in metres a second (on the host).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
LookSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Crawling", "LookSensitivity", 0.1f, new ConfigDescription("How fast the mouse turns the crawling camera.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>()));
Mixups = ((BaseUnityPlugin)this).Config.Bind<bool>("Mix-ups", "Enabled", true, "Two downed players can be put back together wrong: one's torso on the other's legs (on the host).");
MixSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Mix-ups", "Seconds", 60f, new ConfigDescription("How long a mixed-up body holds together before it comes apart by itself (on the host).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>()));
SplitKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Mix-ups", "SplitKey", (Key)22, "Hold it to pull a mixed-up body apart early.");
runner = new GameObject("PullYourselfTogether");
Object.DontDestroyOnLoad((Object)(object)runner);
((Object)runner).hideFlags = (HideFlags)61;
runner.AddComponent<Runner>();
harmony = new Harmony("quadslab.mycopunk.pullyourselftogether");
harmony.PatchAll(typeof(Plugin).Assembly);
Log.LogInfo((object)"Quad's Pull Yourself Together 0.1.0 loaded");
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
Mixup.Clear();
Puppet.Clear();
Hud.Destroy();
Net.Unregister();
if ((Object)(object)runner != (Object)null)
{
Object.Destroy((Object)(object)runner);
}
}
}
internal sealed class Runner : MonoBehaviour
{
private float nextFileCheck;
private void Update()
{
try
{
Net.Tick();
Crawl.ClientUpdate();
Puppet.Tick();
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Pull Yourself Together: " + ex));
}
if (Time.unscaledTime >= nextFileCheck)
{
nextFileCheck = Time.unscaledTime + 0.5f;
TestFiles();
}
}
private void FixedUpdate()
{
if (!Net.IsHost)
{
return;
}
try
{
Crawl.HostFixedUpdate();
Mixup.HostFixedUpdate();
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Pull Yourself Together (host): " + ex));
}
}
private void LateUpdate()
{
try
{
Mixup.LateUpdate();
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Pull Yourself Together: " + ex));
}
}
private static void TestFiles()
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_010f: 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_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
if (!LevelData.IsHub)
{
return;
}
if (Read("die") != null && (Object)(object)Player.LocalPlayer != (Object)null && Player.LocalPlayer.IsAlive)
{
Plugin.Log.LogInfo((object)"Pull Yourself Together test: dying");
Player.LocalPlayer.RespawnPoint = null;
Player.LocalPlayer.Kill((IDamageSource)null, default(DamageData));
}
string text = Read("crawl");
if (text != null)
{
float[] array = Numbers(text.Replace("legs", ""));
if (text.Contains("legs"))
{
Crawl.Force(Vector2.zero, (array.Length != 0) ? array[0] : 10f, lungeAfter: false, toLegs: true);
}
else if (array.Length >= 3)
{
Crawl.Force(new Vector2(array[0], array[1]), array[2], array.Length >= 4 && array[3] > 0.5f);
}
}
if (Read("bones") != null)
{
Debug.DumpRig();
}
string text2 = Read("pose");
if (text2 != null)
{
float[] array2 = Numbers(text2);
if (array2.Length >= 3)
{
Crawl.Pose = Quaternion.Euler(array2[0], array2[1], array2[2]);
Plugin.Log.LogInfo((object)("Pull Yourself Together test: pose " + ((object)((Quaternion)(ref Crawl.Pose)).eulerAngles/*cast due to .constrained prefix*/).ToString()));
}
}
static float[] Numbers(string text3)
{
string[] array3 = text3.Split(new char[5] { ' ', ',', '\n', '\r', '\t' }, StringSplitOptions.RemoveEmptyEntries);
float[] array4 = new float[array3.Length];
for (int i = 0; i < array3.Length; i++)
{
float.TryParse(array3[i], NumberStyles.Float, CultureInfo.InvariantCulture, out array4[i]);
}
return array4;
}
static string Read(string name)
{
string path = Path.Combine(Paths.BepInExRootPath, "pullyourselftogether-" + name + ".txt");
if (!File.Exists(path))
{
return null;
}
try
{
string result = File.ReadAllText(path);
File.Delete(path);
return result;
}
catch (Exception)
{
return null;
}
}
}
}
internal sealed class Puppet : MonoBehaviour
{
private static readonly Dictionary<DeadPlayerPart, Puppet> all = new Dictionary<DeadPlayerPart, Puppet>();
private DeadPlayerPart torso;
private Transform root;
private Transform chest;
private Transform neck;
private Transform shoulderL;
private Transform shoulderR;
private Transform elbowL;
private Transform elbowR;
private readonly List<Renderer> pieces = new List<Renderer>();
private Vector3 lastCentre;
private Vector3 heading = Vector3.forward;
private float phase;
private float speed;
private bool showing;
public static void Tick()
{
if (!Plugin.Enabled.Value)
{
Clear();
return;
}
foreach (Player player in GameManager.players)
{
if (!((Object)(object)player == (Object)null) && !player.IsAlive)
{
DeadPlayerPart val = Parts.Torso(player);
if ((Object)(object)val != (Object)null && !all.ContainsKey(val))
{
Make(player, val);
}
}
}
if (all.Count == 0)
{
return;
}
List<DeadPlayerPart> list = null;
foreach (KeyValuePair<DeadPlayerPart, Puppet> item in all)
{
if ((Object)(object)item.Key == (Object)null || !((NetworkBehaviour)item.Key).IsSpawned || (Object)(object)item.Key.ParentPlayer == (Object)null || item.Key.ParentPlayer.IsAlive)
{
(list ?? (list = new List<DeadPlayerPart>())).Add(item.Key);
}
}
if (list == null)
{
return;
}
foreach (DeadPlayerPart item2 in list)
{
if (all.TryGetValue(item2, out var value) && (Object)(object)value != (Object)null)
{
Object.Destroy((Object)(object)((Component)value).gameObject);
}
all.Remove(item2);
}
}
public static void Clear()
{
foreach (Puppet value in all.Values)
{
if ((Object)(object)value != (Object)null)
{
Object.Destroy((Object)(object)((Component)value).gameObject);
}
}
all.Clear();
}
private static void Make(Player player, DeadPlayerPart torso)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: 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)
ThirdPersonRig val = (((Object)(object)player.Animator != (Object)null) ? (player.Animator.ThirdPersonRig ?? player.Animator.LocalThirdPersonRig) : null);
if ((Object)(object)val == (Object)null)
{
return;
}
GameObject val2 = new GameObject("PullYourselfTogether puppet");
val2.SetActive(false);
GameObject copy = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform);
Component[] componentsInChildren = copy.GetComponentsInChildren<Component>(true);
foreach (Component val3 in componentsInChildren)
{
if (!(val3 is Transform) && !(val3 is SkinnedMeshRenderer) && !(val3 is MeshFilter) && !(val3 is MeshRenderer))
{
Object.DestroyImmediate((Object)(object)val3);
}
}
Transform[] componentsInChildren2 = copy.GetComponentsInChildren<Transform>(true);
for (int i = 0; i < componentsInChildren2.Length; i++)
{
((Component)componentsInChildren2[i]).gameObject.layer = 0;
}
SkinnedMeshRenderer[] componentsInChildren3 = copy.GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (SkinnedMeshRenderer obj in componentsInChildren3)
{
((Renderer)obj).enabled = true;
obj.updateWhenOffscreen = true;
}
copy.SetActive(true);
Puppet puppet = val2.AddComponent<Puppet>();
puppet.torso = torso;
puppet.root = copy.transform;
componentsInChildren2 = copy.GetComponentsInChildren<Transform>(true);
foreach (Transform val4 in componentsInChildren2)
{
if (((Object)val4).name.StartsWith("joint_") || ((Object)val4).name.Contains("Rotator"))
{
val4.localRotation = Quaternion.identity;
}
}
puppet.chest = Bone("joint_Spine03");
puppet.neck = Bone("joint_Neck");
puppet.shoulderL = Bone("joint_Shoulder_L");
puppet.shoulderR = Bone("joint_Shoulder_R");
puppet.elbowL = Bone("joint_Elbow_L");
puppet.elbowR = Bone("joint_Elbow_R");
string[] array = new string[2] { "joint_Thigh_L", "joint_Thigh_R" };
for (int i = 0; i < array.Length; i++)
{
Transform val5 = Bone(array[i]);
if ((Object)(object)val5 != (Object)null)
{
val5.localScale = Vector3.zero;
}
}
PartSectionData[] sections = torso.sections;
for (int i = 0; i < sections.Length; i++)
{
TargetMesh[] meshes = sections[i].meshes;
foreach (TargetMesh val6 in meshes)
{
if ((Object)(object)val6 != (Object)null && (Object)(object)val6.Renderer != (Object)null)
{
puppet.pieces.Add(val6.Renderer);
}
}
}
puppet.lastCentre = Parts.Centre(torso);
val2.SetActive(true);
all[torso] = puppet;
if ((Object)(object)puppet.chest == (Object)null || (Object)(object)puppet.shoulderL == (Object)null || (Object)(object)puppet.shoulderR == (Object)null)
{
Plugin.Log.LogWarning((object)"Pull Yourself Together: this robot's rig isn't the usual one: no crawling puppet");
Object.Destroy((Object)(object)val2);
all[torso] = null;
}
Transform Bone(string name)
{
Transform[] componentsInChildren4 = copy.GetComponentsInChildren<Transform>(true);
foreach (Transform val7 in componentsInChildren4)
{
if (((Object)val7).name == name)
{
return val7;
}
}
return null;
}
}
private void LateUpdate()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0037: 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_003a: 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_00f5: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_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_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_01f1: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: 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_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)torso == (Object)null)
{
return;
}
Vector3 val = Parts.Centre(torso);
float num = Mathf.Max(Time.deltaTime, 0.0001f);
Vector3 val2 = val - lastCentre;
lastCentre = val;
val2.y = 0f;
float num2 = ((Vector3)(ref val2)).magnitude / num;
speed = Mathf.Lerp(speed, (num2 > 20f) ? 0f : num2, 1f - Mathf.Exp(-10f * num));
if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f && num2 > 0.15f)
{
heading = Vector3.Slerp(heading, ((Vector3)(ref val2)).normalized, 1f - Mathf.Exp(-8f * num));
}
else if (Crawl.IsMine(torso))
{
heading = Vector3.Slerp(heading, Crawl.Facing, 1f - Mathf.Exp(-4f * num));
}
bool flag = !((HoldableObject)torso).IsHeldByAnyPlayer && !((HoldableObject)torso).Active;
if (flag != showing)
{
showing = flag;
((Component)root).gameObject.SetActive(flag);
}
foreach (Renderer piece in pieces)
{
if ((Object)(object)piece != (Object)null)
{
piece.enabled = !flag;
}
}
if (flag)
{
phase += speed / 0.9f * num;
float num3 = Mathf.Sin(phase * MathF.PI * 2f) * 7f * Mathf.Clamp01(speed);
Quaternion rotation = Quaternion.LookRotation(Vector3.down, heading) * Quaternion.AngleAxis(num3, Vector3.up);
root.rotation = rotation;
Arm(shoulderL, elbowL, phase, -1f);
Arm(shoulderR, elbowR, phase + 0.5f, 1f);
if ((Object)(object)neck != (Object)null)
{
neck.localRotation = Quaternion.AngleAxis(-55f, Vector3.right);
}
Transform obj = root;
obj.position += val + Vector3.up * 0.05f - chest.position;
}
}
private static void Arm(Transform shoulder, Transform elbow, float t, float side)
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_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)
t -= Mathf.Floor(t);
float num2;
float num3;
float num4;
if (t < 0.55f)
{
float num = Ease(t / 0.55f);
num2 = Mathf.Lerp(-155f, -40f, num);
num3 = Mathf.Lerp(28f, 12f, num);
num4 = Mathf.Lerp(30f, 10f, num);
}
else
{
float num5 = (t - 0.55f) / 0.45f;
float num6 = Mathf.Sin(num5 * MathF.PI);
num2 = Mathf.Lerp(-40f, -155f, Ease(num5));
num3 = Mathf.Lerp(12f, 28f, num5) + 35f * num6;
num4 = Mathf.Lerp(10f, 30f, num5) + 70f * num6;
}
shoulder.localRotation = Quaternion.AngleAxis(num2, Vector3.right) * Quaternion.AngleAxis(num3 * side, Vector3.forward);
if ((Object)(object)elbow != (Object)null)
{
elbow.localRotation = Quaternion.AngleAxis(0f - num4, Vector3.right);
}
}
private static float Ease(float x)
{
return x * x * (3f - 2f * x);
}
private void OnDestroy()
{
foreach (Renderer piece in pieces)
{
if ((Object)(object)piece != (Object)null)
{
piece.enabled = true;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}