using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClassLibrary7")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary7")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4ee0ce42-511a-4b37-8cec-421415119138")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Foddy.BlobCompanionMod;
[BepInPlugin("com.user.goi.blobcompanion", "Terraria Blob Companions Adaptive", "1.4.0")]
[BepInProcess("GettingOverIt.exe")]
public class BlobCompanionMod : BaseUnityPlugin
{
private PlayerControl playerControl;
private HammerCollisions hammerCollisions;
private float hitVelocityThreshold = 6f;
private int maxSpawnLimit = 45;
private Queue<GameObject> spawnedBlobs = new Queue<GameObject>();
private float timeBeforeHammerUnlocks = 14f;
private float timeBeforeBodyUnlocks = 24f;
private float mapStartYPosition = 0f;
private bool hasRecordedStartPosition = false;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Terraria Adaptive Blob Companions Loaded! Advanced AI modules operational.");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
spawnedBlobs.Clear();
playerControl = null;
hammerCollisions = null;
hasRecordedStartPosition = false;
}
private void Update()
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)hammerCollisions == (Object)null || (Object)(object)playerControl == (Object)null)
{
playerControl = Object.FindObjectOfType<PlayerControl>();
if ((Object)(object)playerControl != (Object)null && (Object)(object)playerControl.tip != (Object)null)
{
hammerCollisions = ((Component)playerControl.tip).GetComponent<HammerCollisions>();
if ((Object)(object)hammerCollisions != (Object)null && (Object)(object)((Component)hammerCollisions).gameObject.GetComponent<BlobImpactHook>() == (Object)null)
{
((Component)hammerCollisions).gameObject.AddComponent<BlobImpactHook>().RegisterMod(this);
}
}
}
else if (!hasRecordedStartPosition && playerControl.loadFinished)
{
mapStartYPosition = ((Component)playerControl).transform.position.y;
hasRecordedStartPosition = true;
}
}
public void ForgeBlob(Vector2 impactPoint, Vector2 relativeVelocity)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)playerControl == (Object)null || !playerControl.loadFinished || ((Vector2)(ref relativeVelocity)).magnitude < hitVelocityThreshold)
{
return;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(impactPoint.x, impactPoint.y + 0.5f, ((Component)playerControl).transform.position.z);
while (spawnedBlobs.Count > 0 && (Object)(object)spawnedBlobs.Peek() == (Object)null)
{
spawnedBlobs.Dequeue();
}
if (spawnedBlobs.Count >= maxSpawnLimit)
{
GameObject val2 = spawnedBlobs.Dequeue();
if ((Object)(object)val2 != (Object)null)
{
val2.transform.position = val;
StageEvolutionController component = val2.GetComponent<StageEvolutionController>();
if ((Object)(object)component != (Object)null)
{
component.ResetToStageOne();
}
spawnedBlobs.Enqueue(val2);
return;
}
}
GameObject val3 = Object.Instantiate<GameObject>(((Component)playerControl).gameObject, val, Quaternion.identity);
if ((Object)(object)val3 != (Object)null)
{
((Object)val3).name = "CloneChaser";
SetupChaser(val3);
spawnedBlobs.Enqueue(val3);
}
}
private void SetupChaser(GameObject clone)
{
string[] array = new string[5] { "PlayerControl", "PlayerSounds", "Saviour", "Screener", "RisingTide" };
string[] array2 = array;
foreach (string text in array2)
{
Component component = clone.GetComponent(text);
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
}
Camera[] componentsInChildren = clone.GetComponentsInChildren<Camera>();
foreach (Camera val in componentsInChildren)
{
Object.Destroy((Object)(object)val);
}
Collider2D[] componentsInChildren2 = ((Component)playerControl).GetComponentsInChildren<Collider2D>();
Collider2D[] componentsInChildren3 = clone.GetComponentsInChildren<Collider2D>();
Collider2D[] array3 = componentsInChildren3;
foreach (Collider2D val2 in array3)
{
if (!((Object)(object)val2 != (Object)null))
{
continue;
}
((Behaviour)val2).enabled = true;
val2.isTrigger = false;
Collider2D[] array4 = componentsInChildren2;
foreach (Collider2D val3 in array4)
{
if ((Object)(object)val3 != (Object)null)
{
Physics2D.IgnoreCollision(val2, val3, true);
}
}
}
Rigidbody2D val4 = clone.GetComponent<Rigidbody2D>();
if ((Object)(object)val4 == (Object)null)
{
val4 = clone.AddComponent<Rigidbody2D>();
}
AdaptiveBrain adaptiveBrain = clone.AddComponent<AdaptiveBrain>();
adaptiveBrain.Setup(((Component)playerControl).transform, this);
StageEvolutionController stageEvolutionController = clone.AddComponent<StageEvolutionController>();
stageEvolutionController.InitializeEvolution(((Component)playerControl).transform, adaptiveBrain, val4, timeBeforeHammerUnlocks, timeBeforeBodyUnlocks, mapStartYPosition);
Rigidbody2D[] componentsInChildren4 = clone.GetComponentsInChildren<Rigidbody2D>();
foreach (Rigidbody2D val5 in componentsInChildren4)
{
val5.simulated = true;
val5.sleepMode = (RigidbodySleepMode2D)0;
}
}
}
public class BlobImpactHook : MonoBehaviour
{
private BlobCompanionMod targetMod;
private ContactPoint2D[] collisionData = (ContactPoint2D[])(object)new ContactPoint2D[1];
public void RegisterMod(BlobCompanionMod mod)
{
targetMod = mod;
}
private void OnCollisionEnter2D(Collision2D collision)
{
//IL_0068: 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)
if (!((Object)(object)targetMod == (Object)null) && (collision.gameObject.layer == LayerMask.NameToLayer("Terrain") || collision.gameObject.layer == 0))
{
int contacts = collision.GetContacts(collisionData);
if (contacts > 0)
{
targetMod.ForgeBlob(((ContactPoint2D)(ref collisionData[0])).point, collision.relativeVelocity);
}
}
}
}
public class StageEvolutionController : MonoBehaviour
{
private Transform playerTarget;
private AdaptiveBrain templateAI;
private Rigidbody2D rootRB;
private float hammerDelay;
private float bodyDelay;
private float deletionThresholdY;
private int currentStage = 1;
private float stageTimer = 0f;
private float currentScaleMultiplier = 0.333f;
private float maxScaleMultiplier = 10f;
private float growthRatePerSecond = 0.02f;
private Vector3 internalScaleVector = Vector3.one;
private List<Renderer> stage1Renderers = new List<Renderer>();
private List<Renderer> stage2Renderers = new List<Renderer>();
private List<Renderer> stage3Renderers = new List<Renderer>();
public void InitializeEvolution(Transform target, AdaptiveBrain ai, Rigidbody2D rb, float delay1, float delay2, float initialMapY)
{
playerTarget = target;
templateAI = ai;
rootRB = rb;
hammerDelay = delay1;
bodyDelay = delay2;
deletionThresholdY = initialMapY - 2f;
stage1Renderers.Clear();
stage2Renderers.Clear();
stage3Renderers.Clear();
Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
foreach (Renderer val in componentsInChildren)
{
string name = ((Object)((Component)val).gameObject).name;
string text = name.ToLower();
bool flag = false;
Transform parent = ((Component)val).transform.parent;
while ((Object)(object)parent != (Object)null)
{
if (((Object)parent).name == "handle")
{
flag = true;
break;
}
parent = parent.parent;
}
if (name == "mesh" && flag)
{
stage2Renderers.Add(val);
val.enabled = false;
}
else if (name == "Mesh" && flag)
{
stage2Renderers.Add(val);
val.enabled = false;
}
else if (name == "Mesh" && !text.Contains("pot"))
{
stage1Renderers.Add(val);
}
else if (text.Contains("handle") || text.Contains("hub") || text.Contains("hammer") || text.Contains("tip") || text.Contains("slider"))
{
stage2Renderers.Add(val);
}
else
{
stage3Renderers.Add(val);
}
}
ResetToStageOne();
}
public void ResetToStageOne()
{
//IL_0031: 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_0042: Unknown result type (might be due to invalid IL or missing references)
currentStage = 1;
stageTimer = 0f;
currentScaleMultiplier = 0.333f;
internalScaleVector = new Vector3(currentScaleMultiplier, currentScaleMultiplier, currentScaleMultiplier);
((Component)this).transform.localScale = internalScaleVector;
if ((Object)(object)templateAI != (Object)null)
{
((Behaviour)templateAI).enabled = true;
}
foreach (Renderer stage1Renderer in stage1Renderers)
{
if ((Object)(object)stage1Renderer != (Object)null)
{
stage1Renderer.enabled = true;
}
}
foreach (Renderer stage2Renderer in stage2Renderers)
{
if ((Object)(object)stage2Renderer != (Object)null)
{
stage2Renderer.enabled = false;
}
}
foreach (Renderer stage3Renderer in stage3Renderers)
{
if ((Object)(object)stage3Renderer != (Object)null)
{
stage3Renderer.enabled = false;
}
}
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
if (((Component)this).transform.position.y < deletionThresholdY)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
else
{
if ((Object)(object)playerTarget == (Object)null)
{
return;
}
float num = Vector3.Distance(((Component)this).transform.position, playerTarget.position);
if (currentStage == 1)
{
if ((Object)(object)rootRB != (Object)null && rootRB.velocity.y > 0.05f)
{
float num2 = currentScaleMultiplier + rootRB.velocity.y * 0.05f;
num2 = Mathf.Min(num2, currentScaleMultiplier * 2.2f);
((Component)this).transform.localScale = new Vector3(currentScaleMultiplier, num2, currentScaleMultiplier);
}
else
{
((Component)this).transform.localScale = new Vector3(currentScaleMultiplier, currentScaleMultiplier, currentScaleMultiplier);
}
if (num >= 2f)
{
stageTimer += Time.deltaTime;
if (stageTimer >= hammerDelay)
{
UnlockHammerStage();
}
}
else
{
stageTimer = 0f;
}
}
else if (currentStage == 2)
{
stageTimer += Time.deltaTime;
if (stageTimer >= bodyDelay)
{
UnlockBodyStage();
}
}
else if (currentStage == 3 && currentScaleMultiplier < maxScaleMultiplier)
{
currentScaleMultiplier += growthRatePerSecond * Time.deltaTime;
if (currentScaleMultiplier > maxScaleMultiplier)
{
currentScaleMultiplier = maxScaleMultiplier;
}
internalScaleVector.x = currentScaleMultiplier;
internalScaleVector.y = currentScaleMultiplier;
internalScaleVector.z = currentScaleMultiplier;
((Component)this).transform.localScale = internalScaleVector;
}
}
}
private void UnlockHammerStage()
{
currentStage = 2;
stageTimer = 0f;
foreach (Renderer stage2Renderer in stage2Renderers)
{
if ((Object)(object)stage2Renderer != (Object)null)
{
stage2Renderer.enabled = true;
}
}
}
private void UnlockBodyStage()
{
currentStage = 3;
foreach (Renderer stage3Renderer in stage3Renderers)
{
if ((Object)(object)stage3Renderer != (Object)null)
{
stage3Renderer.enabled = true;
}
}
}
}
public class AdaptiveBrain : MonoBehaviour
{
private class SpatialMove
{
public float angle;
public float extension;
public float terrainSlope;
public float distanceToWall;
}
private Transform player;
private BlobCompanionMod master;
private HingeJoint2D hinge;
private SliderJoint2D slider;
private Rigidbody2D potRB;
private Vector3 lastPos;
private float stuckTimer = 0f;
private bool isExecutingRecovery = false;
private SpatialMove recoveryMove = null;
private List<SpatialMove> moveBrain = new List<SpatialMove>();
private Transform playerHub;
private SliderJoint2D playerSlider;
private Rigidbody2D playerRB;
private float distanceTimer = 0f;
private float styleExtension = 0.5f;
private float aggression = 1000f;
public float movementSlowdownMultiplier = 1f;
private float aggressivePanicTimer = 0f;
public void Setup(Transform p, BlobCompanionMod m)
{
player = p;
master = m;
hinge = ((IEnumerable<HingeJoint2D>)((Component)this).GetComponentsInChildren<HingeJoint2D>()).FirstOrDefault((Func<HingeJoint2D, bool>)((HingeJoint2D t) => ((Object)t).name == "Hub"));
slider = ((Component)this).GetComponentInChildren<SliderJoint2D>();
potRB = ((Component)this).GetComponent<Rigidbody2D>();
if ((Object)(object)player != (Object)null)
{
playerRB = ((Component)player).GetComponent<Rigidbody2D>();
playerSlider = ((Component)player).GetComponentInChildren<SliderJoint2D>();
playerHub = ((IEnumerable<Transform>)((Component)player).GetComponentsInChildren<Transform>()).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "Hub"));
}
}
private void FixedUpdate()
{
//IL_0050: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player == (Object)null || (Object)(object)hinge == (Object)null || (Object)(object)slider == (Object)null || (Object)(object)potRB == (Object)null)
{
return;
}
ObservePlayer();
if (Vector3.Distance(((Component)this).transform.position, lastPos) < 0.5f)
{
stuckTimer += Time.fixedDeltaTime;
}
else
{
stuckTimer = 0f;
isExecutingRecovery = false;
aggressivePanicTimer = 0f;
lastPos = ((Component)this).transform.position;
}
if (Vector3.Distance(((Component)this).transform.position, player.position) > 16f)
{
distanceTimer += Time.fixedDeltaTime;
if (distanceTimer > 3f)
{
TrySafeTeleport();
distanceTimer = 0f;
}
}
else
{
distanceTimer = 0f;
}
ImproviseMovement();
}
private void TrySafeTeleport()
{
//IL_0007: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_0035: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//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_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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)this).transform.position - player.position;
Vector3 val2 = ((Vector3)(ref val)).normalized;
if (val2 == Vector3.zero)
{
val2 = Vector3.left;
}
for (int i = 0; i < 8; i++)
{
float num = (float)i * 45f;
Vector3 val3 = Quaternion.Euler(0f, 0f, num) * val2;
Vector3 val4 = player.position + val3 * 6f;
Collider2D val5 = Physics2D.OverlapCircle(Vector2.op_Implicit(val4), 3f, LayerMask.GetMask(new string[2] { "Terrain", "Default" }));
if ((Object)(object)val5 == (Object)null)
{
ApplyTeleport(val4);
return;
}
}
ApplyTeleport(player.position + Vector3.up * 6f);
}
private void ApplyTeleport(Vector3 targetPos)
{
//IL_0001: 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_000d: 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_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_0035: 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)
Vector3 val = targetPos - ((Component)this).transform.position;
Rigidbody2D[] componentsInChildren = ((Component)this).GetComponentsInChildren<Rigidbody2D>();
Rigidbody2D[] array = componentsInChildren;
foreach (Rigidbody2D val2 in array)
{
val2.position += Vector2.op_Implicit(val);
val2.velocity = Vector2.zero;
val2.angularVelocity = 0f;
}
distanceTimer = 0f;
stuckTimer = 0f;
}
private void ObservePlayer()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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_004f: 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_005f: 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_006b: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)playerRB == (Object)null || (Object)(object)playerHub == (Object)null || (Object)(object)playerSlider == (Object)null)
{
return;
}
Vector2 velocity = playerRB.velocity;
Vector2 normalized = ((Vector2)(ref velocity)).normalized;
RaycastHit2D val = Physics2D.Raycast(Vector2.op_Implicit(player.position), normalized, 3f);
if (playerRB.velocity.y > 1.5f && (Object)(object)((RaycastHit2D)(ref val)).collider != (Object)null)
{
float terrainSlope = Vector2.Angle(((RaycastHit2D)(ref val)).normal, Vector2.up);
moveBrain.Add(new SpatialMove
{
angle = playerHub.localEulerAngles.z,
extension = playerSlider.jointTranslation,
terrainSlope = terrainSlope,
distanceToWall = ((RaycastHit2D)(ref val)).distance
});
if (moveBrain.Count > 500)
{
moveBrain.RemoveAt(0);
}
}
styleExtension = Mathf.Lerp(styleExtension, playerSlider.jointTranslation, 0.05f);
}
private void ImproviseMovement()
{
//IL_0007: 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_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)
//IL_0034: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_0205: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = Vector2.op_Implicit(player.position - ((Component)this).transform.position);
float num = Mathf.Sign(val.x);
Vector2 velocity = potRB.velocity;
float magnitude = ((Vector2)(ref velocity)).magnitude;
hinge.useMotor = true;
slider.useMotor = true;
JointMotor2D hm = hinge.motor;
JointMotor2D sm = slider.motor;
((JointMotor2D)(ref hm)).maxMotorTorque = 22000f;
((JointMotor2D)(ref sm)).maxMotorTorque = 22000f;
if (stuckTimer > 1f)
{
if (moveBrain.Count <= 10 || recoveryMove == null)
{
aggressivePanicTimer += Time.fixedDeltaTime;
((JointMotor2D)(ref hm)).motorSpeed = 1200f * num;
((JointMotor2D)(ref sm)).motorSpeed = ((Mathf.Sin(aggressivePanicTimer * 10f) > 0f) ? 15f : (-15f));
}
else
{
ExecuteRecovery(ref hm, ref sm, num);
}
}
else if (magnitude > 5f)
{
isExecutingRecovery = false;
((JointMotor2D)(ref hm)).motorSpeed = (0f - aggression) * num * 0.45f * movementSlowdownMultiplier;
((JointMotor2D)(ref sm)).motorSpeed = 0f;
}
else
{
isExecutingRecovery = false;
((JointMotor2D)(ref hm)).motorSpeed = (0f - aggression) * num * 0.45f * movementSlowdownMultiplier;
((JointMotor2D)(ref sm)).motorSpeed = (styleExtension - slider.jointTranslation) * 15f;
}
aggression = Mathf.Lerp(aggression, (((Vector2)(ref val)).magnitude > 3f) ? 1400f : 800f, 0.1f);
hinge.motor = hm;
slider.motor = sm;
}
private void ExecuteRecovery(ref JointMotor2D hm, ref JointMotor2D sm, float dir)
{
//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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
if (!isExecutingRecovery)
{
RaycastHit2D val = Physics2D.Raycast(Vector2.op_Implicit(((Component)this).transform.position), Vector2.right * dir, 2.5f);
float currentSlope = (((Object)(object)((RaycastHit2D)(ref val)).collider != (Object)null) ? Vector2.Angle(((RaycastHit2D)(ref val)).normal, Vector2.up) : 0f);
recoveryMove = (from m in moveBrain
where Mathf.Abs(m.terrainSlope - currentSlope) < 30f
orderby Random.value
select m).FirstOrDefault();
isExecutingRecovery = true;
}
if (recoveryMove != null)
{
float num = Mathf.DeltaAngle(((Component)hinge).transform.localEulerAngles.z, recoveryMove.angle);
((JointMotor2D)(ref hm)).motorSpeed = num * 22f;
((JointMotor2D)(ref sm)).motorSpeed = (recoveryMove.extension - slider.jointTranslation) * 20f;
}
}
}