Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepoBots v0.7.2
RepoBots.dll
Decompiled 17 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.AI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [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 RepoBots { internal static class AccessProbe { internal static bool Check(out string error) { error = null; try { Touch(null); return true; } catch (Exception ex) { error = ex.GetType().Name + ": " + ex.Message; return false; } } [MethodImpl(MethodImplOptions.NoInlining)] private static int Touch(PlayerHealth health) { return ((Object)(object)health != (Object)null) ? (health.health + (((Object)(object)health.playerAvatar != (Object)null && health.playerAvatar.playerName != null) ? 1 : 0)) : 0; } } internal static class BotBody { private const float Radius = 0.24f; private const float Height = 1.4f; private const float StepHeight = 0.45f; private const float Skin = 0.04f; private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[24]; private static int _mask; private static int _maskLevel; private static readonly Collider[] Overlaps = (Collider[])(object)new Collider[16]; internal static int Mask() { int num = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (_mask != 0 && num == _maskLevel) { return _mask; } _maskLevel = num; int num2 = -1; if (Object.op_Implicit((Object)(object)PlayerController.instance)) { Collider[] componentsInChildren = ((Component)PlayerController.instance).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (!val.isTrigger) { num2 = ((Component)val).gameObject.layer; break; } } } if (num2 < 0) { num2 = LayerMask.NameToLayer("Player"); } int num3 = 0; for (int j = 0; j < 32; j++) { if ((num2 < 0 || !Physics.GetIgnoreLayerCollision(num2, j)) && !string.IsNullOrEmpty(LayerMask.LayerToName(j))) { num3 |= 1 << j; } } if (num3 == 0) { num3 = -5; } _mask = num3; Plugin.Debug($"Bot collision mask 0x{num3:X8} (player layer {num2})"); return _mask; } internal static Vector3 Collide(BotInfo bot, Vector3 feet, Vector3 move, PhysGrabObject held, float speed, out bool blocked) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_006a: 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_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) blocked = false; move.y = 0f; float magnitude = ((Vector3)(ref move)).magnitude; if (magnitude < 1E-05f) { return Vector3.zero; } Vector3 val = move / magnitude; Vector3 val2 = Vector3.zero; for (int i = 0; i < 3; i++) { if (!(magnitude > 0.0001f)) { break; } if (!Cast(bot, feet + val2, val, magnitude + 0.04f, held, out var best)) { val2 += val * magnitude; break; } blocked = true; bot.LastBlocker = ((RaycastHit)(ref best)).collider; bot.LastBlockTime = Time.time; float num = Mathf.Max(0f, ((RaycastHit)(ref best)).distance - 0.04f); val2 += val * num; Push(best, val, speed); float num2 = magnitude - num; Vector3 normal = ((RaycastHit)(ref best)).normal; normal.y = 0f; if (((Vector3)(ref normal)).sqrMagnitude < 0.0001f) { break; } ((Vector3)(ref normal)).Normalize(); Vector3 val3 = Vector3.ProjectOnPlane(val * num2, normal); val3.y = 0f; magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude < 0.0001f) { break; } val = val3 / magnitude; } return val2; } private static bool Cast(BotInfo bot, Vector3 feet, Vector3 dir, float distance, PhysGrabObject held, out RaycastHit best) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_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_001f: 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_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_0034: 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_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) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_021a: Unknown result type (might be due to invalid IL or missing references) best = default(RaycastHit); Vector3 val = feet + Vector3.up * 0.69f; Vector3 val2 = feet + Vector3.up * 1.16f; int num = Physics.CapsuleCastNonAlloc(val, val2, 0.24f, dir, Hits, distance, Mask(), (QueryTriggerInteraction)1); float num2 = float.MaxValue; Transform val3 = (Object.op_Implicit((Object)(object)bot.Avatar) ? ((Component)bot.Avatar).transform.root : null); Rigidbody val4 = (Object.op_Implicit((Object)(object)held) ? held.rb : null); for (int i = 0; i < num; i++) { RaycastHit val5 = Hits[i]; Collider collider = ((RaycastHit)(ref val5)).collider; if (!Object.op_Implicit((Object)(object)collider) || (((RaycastHit)(ref val5)).distance <= 0f && ((RaycastHit)(ref val5)).point == Vector3.zero) || (Object.op_Implicit((Object)(object)val3) && ((Component)collider).transform.IsChildOf(val3)) || (BotBodyCollider.IsBody(collider) && Object.op_Implicit((Object)(object)bot.Body) && (Object)(object)((Component)collider).gameObject == (Object)(object)((Component)bot.Body).gameObject) || (Object.op_Implicit((Object)(object)val4) && (Object)(object)collider.attachedRigidbody == (Object)(object)val4) || ((RaycastHit)(ref val5)).normal.y > 0.65f || ((RaycastHit)(ref val5)).normal.y < -0.3f) { continue; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if (Object.op_Implicit((Object)(object)attachedRigidbody) && bot.IgnoreBodies.Count > 0 && bot.IgnoreBodies.TryGetValue(attachedRigidbody, out var value)) { if (Time.time < value) { continue; } bot.IgnoreBodies.Remove(attachedRigidbody); } if (((RaycastHit)(ref val5)).distance < num2) { num2 = ((RaycastHit)(ref val5)).distance; best = val5; } } return num2 < float.MaxValue; } private static void Push(RaycastHit hit, Vector3 dir, float speed) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) Rigidbody val = (Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).collider) ? ((RaycastHit)(ref hit)).collider.attachedRigidbody : null); if (Object.op_Implicit((Object)(object)val) && !val.isKinematic && SemiFunc.IsMasterClientOrSingleplayer() && !(Vector3.Dot(val.velocity, dir) > Mathf.Max(0.5f, speed))) { bool flag = Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<ValuableObject>()); float num = Mathf.Clamp(val.mass, 0.5f, 8f); float num2 = (flag ? 6f : 45f); val.AddForceAtPosition(dir * num2 * num, ((RaycastHit)(ref hit)).point, (ForceMode)0); val.WakeUp(); } } internal static bool IsDoor(Collider c) { if (!Object.op_Implicit((Object)(object)c) || !Object.op_Implicit((Object)(object)c.attachedRigidbody)) { return false; } MonoBehaviour[] components = ((Component)c.attachedRigidbody).GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val in components) { if (Object.op_Implicit((Object)(object)val) && ((object)val).GetType().Name == "PhysGrabHinge") { return true; } } return false; } internal static void PullDoor(Collider door, Vector3 botPos) { //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_003e: 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_004b: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Rigidbody val = (Object.op_Implicit((Object)(object)door) ? door.attachedRigidbody : null); if (Object.op_Implicit((Object)(object)val) && !val.isKinematic && SemiFunc.IsMasterClientOrSingleplayer()) { Bounds bounds = door.bounds; Vector3 val2 = botPos - ((Bounds)(ref bounds)).center; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.0001f)) { val.AddForceAtPosition(((Vector3)(ref val2)).normalized * 40f * Mathf.Clamp(val.mass, 0.5f, 8f), door.ClosestPoint(botPos + Vector3.up), (ForceMode)0); val.WakeUp(); } } } internal static void IgnoreFor(BotInfo bot, Collider c, float seconds) { Rigidbody val = (Object.op_Implicit((Object)(object)c) ? c.attachedRigidbody : null); if (Object.op_Implicit((Object)(object)val) && !val.isKinematic && !IsSolidProp(val)) { bot.IgnoreBodies[val] = Time.time + seconds; } } private static bool IsSolidProp(Rigidbody rb) { return rb.mass > 4f || Object.op_Implicit((Object)(object)((Component)rb).GetComponentInParent<PhysGrabCart>()); } internal static Vector3 SolidShove(BotInfo bot, Vector3 feet, PhysGrabObject held) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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) //IL_0016: 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_0018: 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_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_002d: 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_0045: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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) //IL_0154: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) Vector3 val = feet + Vector3.up * 0.69f; Vector3 val2 = feet + Vector3.up * 1.16f; int num = Physics.OverlapCapsuleNonAlloc(val, val2, 0.24f, Overlaps, Mask(), (QueryTriggerInteraction)1); Vector3 val3 = Vector3.zero; Transform val4 = (Object.op_Implicit((Object)(object)bot.Avatar) ? ((Component)bot.Avatar).transform.root : null); Rigidbody val5 = (Object.op_Implicit((Object)(object)held) ? held.rb : null); Vector3 val6 = feet + Vector3.up * 0.8f; for (int i = 0; i < num; i++) { Collider val7 = Overlaps[i]; Rigidbody val8 = (Object.op_Implicit((Object)(object)val7) ? val7.attachedRigidbody : null); if (!Object.op_Implicit((Object)(object)val8) || val8.isKinematic || (Object)(object)val8 == (Object)(object)val5 || !IsSolidProp(val8) || (Object.op_Implicit((Object)(object)val4) && ((Component)val7).transform.IsChildOf(val4))) { continue; } Vector3 val9 = val7.ClosestPoint(val6); Vector3 val10 = val6 - val9; val10.y = 0f; float magnitude = ((Vector3)(ref val10)).magnitude; if (magnitude < 0.001f) { Bounds bounds = val7.bounds; val10 = val6 - ((Bounds)(ref bounds)).center; val10.y = 0f; if (((Vector3)(ref val10)).sqrMagnitude < 0.0001f) { val10 = Vector3.forward; } val3 += ((Vector3)(ref val10)).normalized * 0.29f; } else if (magnitude < 0.26999998f) { val3 += val10 / magnitude * (0.26999998f - magnitude); } } return Vector3.ClampMagnitude(val3, 0.6f); } } internal sealed class BotBodyCollider : MonoBehaviour { private static readonly HashSet<Collider> Bodies = new HashSet<Collider>(); private BotInfo _info; private Rigidbody _rb; private CapsuleCollider _col; private float _nextImpact; internal static bool IsBody(Collider c) { return Object.op_Implicit((Object)(object)c) && Bodies.Contains(c); } internal static BotBodyCollider Create(BotInfo info) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0037: 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_00f9: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("RepoBots.Body"); val.layer = PlayerBodyLayer(info); val.transform.SetParent(((Component)info.Avatar).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; try { val.tag = "Player"; } catch (Exception) { } BotBodyCollider botBodyCollider = val.AddComponent<BotBodyCollider>(); botBodyCollider._info = info; botBodyCollider._rb = val.AddComponent<Rigidbody>(); botBodyCollider._rb.isKinematic = true; botBodyCollider._rb.useGravity = false; botBodyCollider._rb.interpolation = (RigidbodyInterpolation)0; botBodyCollider._rb.collisionDetectionMode = (CollisionDetectionMode)3; botBodyCollider._col = val.AddComponent<CapsuleCollider>(); botBodyCollider._col.radius = 0.28f; botBodyCollider._col.height = 1.6f; botBodyCollider._col.center = new Vector3(0f, 0.85f, 0f); Bodies.Add((Collider)(object)botBodyCollider._col); return botBodyCollider; } private static int PlayerBodyLayer(BotInfo info) { Component o = Refl.Get<Component>(info.Avatar, "playerAvatarCollision"); Collider val = Refl.Get<Collider>(o, "Collider"); if (Object.op_Implicit((Object)(object)val)) { return ((Component)val).gameObject.layer; } if (Object.op_Implicit((Object)(object)info.Avatar)) { Collider[] componentsInChildren = ((Component)info.Avatar).GetComponentsInChildren<Collider>(true); foreach (Collider val2 in componentsInChildren) { if (!val2.isTrigger && !IsBody(val2)) { return ((Component)val2).gameObject.layer; } } } if (Object.op_Implicit((Object)(object)GameDirector.instance)) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!Object.op_Implicit((Object)(object)player) || BotRegistry.IsBot(player) || (Object)(object)player == (Object)(object)PlayerAvatar.instance) { continue; } Collider[] componentsInChildren2 = ((Component)player).GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren2) { if (!val3.isTrigger) { return ((Component)val3).gameObject.layer; } } } } int num = LayerMask.NameToLayer("Player"); return (num >= 0) ? num : 0; } private void FixedUpdate() { //IL_009b: 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_00b6: Unknown result type (might be due to invalid IL or missing references) if (_info == null || !Object.op_Implicit((Object)(object)_info.Avatar)) { BotRegistry.AllowDestroy = true; try { Object.Destroy((Object)(object)((Component)this).gameObject); return; } finally { BotRegistry.AllowDestroy = false; } } PlayerAvatar avatar = _info.Avatar; bool flag = ((Component)avatar).gameObject.activeInHierarchy && !avatar.isDisabled && !avatar.isTumbling; if (((Collider)_col).enabled != flag) { ((Collider)_col).enabled = flag; } if (((Component)this).transform.localPosition != Vector3.zero) { ((Component)this).transform.localPosition = Vector3.zero; } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)_col)) { Bodies.Remove((Collider)(object)_col); } } private void OnCollisionEnter(Collision collision) { Impact(collision); } private void Impact(Collision collision) { //IL_0080: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_info?.Brain == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } Rigidbody rigidbody = collision.rigidbody; if (Object.op_Implicit((Object)(object)rigidbody) && !rigidbody.isKinematic && !(Time.time < _nextImpact) && !_info.Brain.IsOwnObject(rigidbody)) { Vector3 relativeVelocity = collision.relativeVelocity; float magnitude = ((Vector3)(ref relativeVelocity)).magnitude; float num = Mathf.Clamp(rigidbody.mass, 0.2f, 20f); float num2 = magnitude * Mathf.Sqrt(num); if (Object.op_Implicit((Object)(object)((Component)rigidbody).GetComponentInParent<PlayerController>())) { num2 = Mathf.Min(num2, 5f); } if (!(num2 < 4f)) { _nextImpact = Time.time + 0.5f; Vector3 val = -collision.relativeVelocity; val.y = 0f; _info.Brain.OnKnocked(((Vector3)(ref val)).normalized, num2); } } } } internal sealed class BotBrain : MonoBehaviour { private enum TrollKind { Teabag, Stare, Toss, FakeAlarm, Boo, Spin } internal enum Task { Idle, Explore, GetLoot, Carry, DropOff, Flee, GoTruck, AtTruck, UseScreen, GetCart, PushCart, CartWait, Follow, Hold, Tumbling, Hide, Shop, UseUpgrade, Troll, Arena, OpenHinge, Race, NeedHelp, HelpCarry, Heal } private int _expression = -1; private float _expressionUntil; private float _nextIdleFace; private bool _shopDone; private float _offLevelSince = -1f; private bool _arenaGreeted; private bool _shopping; private BotShop.Offer _shopOffer; private int _shopStage; private float _shopPlacedAt; private float _shopStageTime; private BotShop.Offer _upgrade; private float _upgradeStart; private float _upgradeHeldAt; private Vector3 _hideSpot; private bool _hasHideSpot; private Vector3 _hideThreat; private float _hideLastSeen; private float _hideStarted; private float _noHideUntil; private TrollKind _troll; private PlayerAvatar _trollTarget; private float _trollStart; private int _trollStage; private PhysGrabObject _trollProp; private float _nextTrollRoll; private float _trollAllowedAt = 60f; private PhysGrabObject _weapon; private bool _weaponIsGun; private float _nextWeaponLook; private float _nextShot; private float _swingPhase; private bool _swinging; private float _nextArenaLine; private StaticGrabObject _crown; private float _crownGrabbedAt = -1f; private float _crownHuntStart = -1f; private bool _crowned; private Component _hinge; private PhysGrabObject _hingeBody; private float _hingeStart; private float _hingeHeldAt = -1f; private Vector3 _hingePullTo; private float _nextHingeLook; private readonly HashSet<int> _hingesTried = new HashSet<int>(); private float _liftUntil; private float _snagTimer; private PhysGrabObject _snagObject; private int _snagRetries; private Vector3 _driveInput; private float _slowSince = -1f; private float _reverseUntil; private bool _raceGreeted; private float _nextRaceLine; private bool _gaveUp; private bool _stubbornRolled; private bool _stubborn; private float _nextNeedExtractionCallout; private bool _helping; private float _needHelpStart; private float _nextHelpCall; private PlayerAvatar _healTarget; private StaticGrabObject _healGrab; private float _healGrabbedAt; private int _healTargetHealthAtGrab; private bool _manualHeal; private float _nextManualHeal; private float _nextHealLook; private float _energy = -1f; private float _energyMax = 40f; private float _sprintRest; private float _fallSpeed; private float _fallTime; private static readonly RaycastHit[] FloorHits = (RaycastHit[])(object)new RaycastHit[8]; internal BotInfo Info; internal BotMode Mode; internal Task Current = Task.Idle; internal string Note = ""; internal float NextChatTime; internal readonly BotNav Nav = new BotNav(); internal readonly BotMap Map = new BotMap(); private Vector3 _pos; private float _yaw; private float _pitch; private float _speed; private Vector3 _velocity; private bool _crouch; private bool _sprint; private bool _initialised; private Vector3 _knock; private PhysGrabObject _target; private ValuableObject _targetValuable; private PlayerAvatar _targetHeadOwner; private PhysGrabObject _held; private bool _heldIsCart; private PlayerAvatar _heldHeadOwner; private float _heldStrayTimer; private float _grabWindup; private ExtractionPoint _dropPoint; private bool _dropNeedsActivation; private PhysGrabCart _dropCart; private float _dropTimer; private PlayerAvatar _followTarget; private Vector3 _holdPosition; private PhysGrabCart _cart; private bool _cartDelivering; private float _cartWaitUntil; private Vector3 _cartExploreTarget; private bool _hasCartExploreTarget; private ExtractionPoint _cartParkedAt; private float _truckArrived = -1f; private bool _truckWarnedHalf; private bool _truckWarnedFinal; private bool _screenUsed; private float _screenHoldStart = -1f; private bool _screenMessageSent; private StaticGrabObject _screenGrab; private bool _tumbling; private float _tumbleStart; private float _tumbleCalm; private float _nextGetUp; private float _nextTumbleAllowed; private List<Vector3> _route; private int _routeIdx; private Vector3 _routeTarget; private float _nextRoutePlan; private Vector3 _exploreTarget; private LevelPoint _explorePoint; private readonly Dictionary<PhysGrabObject, float> _blacklist = new Dictionary<PhysGrabObject, float>(); private readonly HashSet<ValuableObject> _seen = new HashSet<ValuableObject>(); private readonly HashSet<ExtractionPoint> _knownExtractions = new HashSet<ExtractionPoint>(); private Vector3 _lookPoint; private bool _hasLookPoint; private float _lookUntil; private float _nextIdleGlance; private float _nextWalkGlance; private float _nextThink; private float _nextScan; private float _idleUntil; private float _fleeUntil; private Vector3 _threatPos; private float _nextRepath; private float _stuckTimer; private Vector3 _stuckRef; private int _stuckCount; private float _greetCooldown; private float _greetUntil; private float _hideUntil; private float _nextPick; private float _nextFoundCallout; private float _nextChatter; private float _nextHaulCallout; private float _nextLostCallout; private readonly HashSet<PlayerAvatar> _knownDead = new HashSet<PlayerAvatar>(); private static readonly HashSet<string> Greeted = new HashSet<string>(); private int _errors; private Vector3 _truckSpot; private bool _hasTruckSpot; private static readonly float[] SteerAngles = new float[4] { 35f, -35f, 65f, -65f }; private float _backoffUntil; private Vector3 _backoffDir; private Collider _doorToPull; private float _cartGrabbedAt; internal bool CanChat => Info != null && Info.Alive && Current != Task.Flee && Current != Task.Hide && Current != Task.UseScreen && Current != Task.Tumbling && Current != Task.Arena; internal Vector3 ExploreTarget => (Vector3)((Current == Task.Explore) ? _exploreTarget : new Vector3(9999f, 9999f, 9999f)); internal IEnumerable<ValuableObject> SeenLoot => _seen; internal bool Stubborn { get { if (!_stubbornRolled) { _stubbornRolled = true; _stubborn = Random.value < 0.2f; } return _stubborn; } } internal bool IsHealing => Current == Task.Heal; internal float Energy => (_energy < 0f) ? _energyMax : _energy; private PlayerAvatar Avatar => Info.Avatar; internal void LookAtBriefly(Vector3 point, float seconds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) LookAt(point, seconds); } private void Express(BotMood mood, float seconds) { if (BotConfig.UseExpressions.Value && !((Object)(object)Avatar == (Object)null)) { int num = BotExpression.SlotFor(mood, Avatar); if (num >= 0) { _expression = num; _expressionUntil = Time.time + seconds; } } } private int CurrentExpression() { return (Time.time < _expressionUntil) ? _expression : (-1); } private void IdleFaces() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time < _nextIdleFace)) { _nextIdleFace = Time.time + Random.Range(25f, 60f); if (Object.op_Implicit((Object)(object)BotSenses.NearestHuman(_pos, 8f)) && Random.value < 0.5f) { Express((Random.value < 0.6f) ? BotMood.Happy : BotMood.Silly, Random.Range(1.5f, 3f)); } } } private void OffLevelThink() { if (_offLevelSince < 0f) { _offLevelSince = Time.time; } if (Current == Task.Troll || Current == Task.UseUpgrade || Current == Task.Shop || Current == Task.Arena || Current == Task.Race || Current == Task.GoTruck || Current == Task.AtTruck) { return; } if (GameShim.RunIs("RunIsArena")) { if (BotConfig.PlayMinigames.Value && BotRace.Active) { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } Current = Task.Race; } else if (BotConfig.PlayMinigames.Value) { StartArena(); } else { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } Current = Task.Hold; } return; } if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } float num = Time.time - _offLevelSince; if (BotConfig.BotsShop.Value && !_shopDone && num > 4f && GameShim.RunIs("RunIsShop")) { StartShop(); } else if (GameShim.RunIs("RunIsShop") && num > 4f) { Current = Task.GoTruck; Nav.Clear(); } else if (!(num > 3f) || !TryStartUseUpgrade(30f)) { Current = Task.Hold; IdleFaces(); TryStartTroll(); } } private void StartShop() { _shopping = true; _shopStage = 0; _shopStageTime = Time.time; Current = Task.Shop; } private void ActShop(float dt) { //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) if (!BotShop.InShopNow) { EndShop(); return; } switch (_shopStage) { case 0: _shopOffer = BotShop.PickPurchase(Info, (PhysGrabObject pgo) => Blacklisted(pgo) || OtherBotTargets(pgo)); if (_shopOffer == null || Random.value < 0.15f) { EndShop(); return; } Plugin.Debug($"{Info.Name} wants {BotShop.Spoken(_shopOffer)} ({_shopOffer.Value})"); _target = _shopOffer.Grab; _grabWindup = 0f; _shopStage = 1; _shopStageTime = Time.time; Nav.Clear(); _route = null; Stand(dt); return; case 1: { PhysGrabObject val2 = _shopOffer?.Grab; if (!Object.op_Implicit((Object)(object)val2) || val2.dead || (val2.playerGrabbing.Count > 0 && !BotGrab.IsHolding(Info, val2)) || Time.time - _shopStageTime > 25f) { if (Object.op_Implicit((Object)(object)val2)) { Blacklist(val2, 60f); } _shopStage = 0; return; } Vector3 centerPoint = val2.centerPoint; if (Vector3.Distance(Eye(), centerPoint) < 2.1f) { Stand(dt); LookAt(centerPoint, 0.5f); _grabWindup += dt; if (!(_grabWindup > 0.4f) || !(FacingError(centerPoint) < 25f)) { return; } if (BotGrab.Start(Info, val2)) { _held = val2; _heldIsCart = false; _heldStrayTimer = 0f; _shopStage = 2; _shopStageTime = Time.time; if (Random.value < 0.6f) { BotSpeech.Say(Info, BotLines.Pick(BotLines.Shopping)); } } else { Blacklist(val2, 60f); _shopStage = 0; } } else { WalkTo(centerPoint, BotConfig.WalkSpeed.Value, dt); } return; } case 2: { Vector3? val = BotShop.DropSpot(); if (!Object.op_Implicit((Object)(object)_held) || !val.HasValue || Time.time - _shopStageTime > 30f) { ReleaseHeld(); _shopStage = 0; } else if (FlatDistance(_pos, val.Value) < 1.6f) { Stand(dt); LookAt(val.Value, 0.5f); if (Time.time - _shopStageTime > 0.6f) { OnShopItemPlaced(); } } else if (Vector3.Distance(_held.centerPoint, HoldPoint()) > 1.8f) { Stand(dt); } else { WalkTo(val.Value, BotConfig.CarrySpeed.Value, dt, 0.8f); } return; } } Stand(dt); IdleBehaviour(dt); if (!(Time.time - _shopPlacedAt < 5f)) { if (!BotConfig.BotsPressShopButton.Value || !IsShopButtonBot() || BotShop.TryPressBuy(Info)) { } EndShop(); } } private void OnShopItemPlaced() { PhysGrabObject held = _held; ReleaseHeld(); if (Object.op_Implicit((Object)(object)held)) { Blacklist(held, 120f); } if (_shopOffer != null) { BotShop.AddPending(Info, _shopOffer); BotSpeech.Say(Info, "Put a " + BotShop.Spoken(_shopOffer) + " on the counter."); } Express(BotMood.Happy, 2f); _shopPlacedAt = Time.time; _shopStage = 3; } private void EndShop() { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } _shopping = false; _shopOffer = null; _shopDone = true; Current = Task.Hold; } private bool IsShopButtonBot() { foreach (BotInfo bot in BotRegistry.Bots) { if (!bot.Alive || !Object.op_Implicit((Object)(object)bot.Brain) || (bot.Brain._shopStage != 3 && !bot.Brain._shopDone)) { continue; } return bot == Info; } return false; } private bool TryStartUseUpgrade(float range) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!BotConfig.BotsShop.Value || !BotShop.HasPending(Info)) { return false; } BotShop.Offer offer = BotShop.FindMyUpgrade(Info, _pos, range); if (offer == null || Blacklisted(offer.Grab)) { return false; } _upgrade = offer; _upgradeStart = Time.time; _upgradeHeldAt = -1f; _grabWindup = 0f; Nav.Clear(); _route = null; Current = Task.UseUpgrade; return true; } private void ActUseUpgrade(float dt) { //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_027b: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject val = _upgrade?.Grab; if (!Object.op_Implicit((Object)(object)val) || val.dead || Time.time - _upgradeStart > 30f) { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } if (Object.op_Implicit((Object)(object)val) && !val.dead) { Blacklist(val, 60f); } Current = ((!SemiFunc.RunIsLevel()) ? Task.Hold : Task.Idle); return; } if (_upgradeHeldAt >= 0f) { Stand(dt); LookAt(val.centerPoint, 0.3f); if (!(Time.time - _upgradeHeldAt > 0.8f)) { return; } bool flag = BotShop.Spoken(_upgrade).ToLowerInvariant().Contains("health"); if (BotShop.Use(Info, _upgrade)) { BotSpeech.Say(Info, BotLines.Pick(BotLines.Upgraded)); Express(BotMood.Happy, 3f); if (flag && Object.op_Implicit((Object)(object)BotManager.Instance)) { ((MonoBehaviour)BotManager.Instance).StartCoroutine(RefreshHealthLater()); } } else { Blacklist(val, 120f); } ReleaseHeld(); _upgrade = null; Current = ((!SemiFunc.RunIsLevel()) ? Task.Hold : Task.Idle); return; } Vector3 centerPoint = val.centerPoint; if (Vector3.Distance(Eye(), centerPoint) < 2.1f) { Stand(dt); LookAt(centerPoint, 0.5f); _grabWindup += dt; if (_grabWindup > 0.4f && FacingError(centerPoint) < 25f) { if (val.playerGrabbing.Count == 0 && BotGrab.Start(Info, val)) { _held = val; _heldIsCart = false; _upgradeHeldAt = Time.time; } else { Blacklist(val, 30f); _upgrade = null; Current = ((!SemiFunc.RunIsLevel()) ? Task.Hold : Task.Idle); } } } else { WalkTo(centerPoint, BotConfig.WalkSpeed.Value, dt); } } private IEnumerator RefreshHealthLater() { yield return (object)new WaitForSeconds(1.5f); if (Info != null && Object.op_Implicit((Object)(object)Info.Avatar)) { BotHealth.RefreshMax(Info); } } private void StartHide(Vector3 threatPos, string enemyName, bool shout) { //IL_001f: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time < _noHideUntil) || shout) { _hideThreat = threatPos; _hideLastSeen = Time.time; _hideStarted = Time.time; if (Object.op_Implicit((Object)(object)_held) && !_heldIsCart && (Current == Task.Troll || Current == Task.OpenHinge)) { ReleaseHeld(); } if (_heldIsCart) { ReleaseHeld(); } ReleaseScreen(); ClearTargets(); _route = null; Nav.Clear(); _hasHideSpot = PickHideSpot(threatPos, out _hideSpot); if (_hasHideSpot) { Nav.SetDestination(_pos, _hideSpot); } if (shout) { BotSpeech.Say(Info, BotLines.Pick(BotLines.Hiding), force: true); } Express(BotMood.Scared, 3f); Current = Task.Hide; Note = ((enemyName != null) ? ("hiding from " + enemyName) : "hiding"); } } private bool PickHideSpot(Vector3 threat, out Vector3 spot) { //IL_0003: 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_0013: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) spot = _pos; int num = BotSenses.VisionMask(); Vector3 val = threat + Vector3.up * 0.5f; float num2 = float.MinValue; bool result = false; List<Vector3> list = new List<Vector3>(); foreach (LevelPoint item in BotMap.AllPoints()) { if (Object.op_Implicit((Object)(object)item) && Map.Knows(((Component)item).transform.position)) { list.Add(((Component)item).transform.position); } } for (int i = 0; i < 10; i++) { Vector3 position = _pos + Quaternion.Euler(0f, (float)i * 36f, 0f) * Vector3.forward * Random.Range(2.5f, 7f); if (BotNav.SampleOnMesh(position, 1.5f, out var result2)) { list.Add(result2); } } foreach (Vector3 item2 in list) { float num3 = Vector3.Distance(_pos, item2); if (num3 > 14f) { continue; } float num4 = Vector3.Distance(threat, item2); if (num4 < 4f || num4 < Vector3.Distance(threat, _pos) - 1f) { continue; } Vector3 val2 = item2 + Vector3.up * 0.8f; Vector3 val3 = val2 - val; if (Physics.Raycast(val, ((Vector3)(ref val3)).normalized, ((Vector3)(ref val3)).magnitude, num, (QueryTriggerInteraction)1)) { float num5 = num4 * 0.6f - num3; if (num5 > num2 && BotNav.PathLength(_pos, item2, out var length) && length < 20f) { num2 = num5; spot = item2; result = true; } } } return result; } private bool ActHide(float dt) { //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_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references) if (_hasHideSpot && FlatDistance(_pos, _hideSpot) > 0.6f && Nav.HasPath) { Move(dt, BotConfig.CrouchSpeed.Value + 0.4f); } else { Stand(dt); if (!LookActive()) { LookAt(_hideThreat + Vector3.up, Random.Range(0.8f, 1.6f)); } } return true; } private bool HideDone() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (Time.time - _hideStarted > 40f) { _noHideUntil = Time.time + 20f; return true; } return Time.time - _hideLastSeen > 5f && !BotSenses.AnyEnemyWithin(_pos, 9f); } private bool TryStartTroll() { //IL_008d: 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) if (!BotConfig.Trolling.Value || Object.op_Implicit((Object)(object)_held) || Time.time < _nextTrollRoll || Time.time < _trollAllowedAt) { return false; } _nextTrollRoll = Time.time + 10f; if (Random.value > BotConfig.TrollChance.Value / 6f * (_gaveUp ? 3f : 1f)) { return false; } PlayerAvatar val = BotSenses.NearestHuman(_pos, 12f); if (!Object.op_Implicit((Object)(object)val) || BotSenses.AnyEnemyWithin(_pos, 15f)) { return false; } _trollTarget = val; _trollStart = Time.time; _trollStage = 0; _trollProp = null; List<TrollKind> list = new List<TrollKind> { TrollKind.Teabag, TrollKind.Stare, TrollKind.Spin, TrollKind.Boo, TrollKind.FakeAlarm }; if (SemiFunc.RunIsLevel()) { list.Add(TrollKind.Toss); } else { list.Remove(TrollKind.FakeAlarm); } _troll = list[Random.Range(0, list.Count)]; Current = Task.Troll; Nav.Clear(); _route = null; Note = "trolling " + val.playerName + " (" + _troll.ToString() + ")"; Plugin.Debug($"{Info.Name} trolls {val.playerName}: {_troll}"); return true; } private void EndTroll() { if (Object.op_Implicit((Object)(object)_held) && (Object)(object)_held == (Object)(object)_trollProp) { ReleaseHeld(); } _trollProp = null; _trollAllowedAt = Time.time + Random.Range(150f, 300f); Current = ((!SemiFunc.RunIsLevel()) ? Task.Hold : Task.Idle); _idleUntil = Time.time + 1f; } private bool ActTroll(float dt) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: 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_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0371: 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_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar trollTarget = _trollTarget; float num = Time.time - _trollStart; if (!Object.op_Implicit((Object)(object)trollTarget) || trollTarget.isDisabled || num > 25f) { EndTroll(); return false; } Vector3 position = ((Component)trollTarget).transform.position; Vector3 point = position + Vector3.up * 1.4f; float num2 = FlatDistance(_pos, position); switch (_troll) { case TrollKind.Teabag: if (_trollStage == 0) { if (num2 > 1.4f) { Approach(position, 1.2f, dt); return false; } _trollStage = 1; _trollStart = Time.time; Express(BotMood.Silly, 3f); BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollTeabag), force: true); } Stand(dt); LookAt(point, 0.3f); if (Time.time - _trollStart > 3f) { EndTroll(); return false; } return Mathf.Repeat(Time.time - _trollStart, 0.4f) < 0.2f; case TrollKind.Stare: if (_trollStage == 0) { _trollStage = 1; BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollStare), force: true); } LookAt(point, 0.3f); if (num2 > 1.8f) { Approach(position, 1.6f, dt); } else { Stand(dt); } if (num > 9f) { EndTroll(); } return false; case TrollKind.Spin: if (num2 > 3f && _trollStage == 0) { Approach(position, 2.5f, dt); return false; } if (_trollStage == 0) { _trollStage = 1; _trollStart = Time.time; BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollSpin), force: true); Express(BotMood.Silly, 3f); } Stand(dt); _yaw += 540f * dt; if (Time.time - _trollStart > 3f) { EndTroll(); } return false; case TrollKind.Boo: { Vector3 val = position - ((Component)trollTarget).transform.forward * 1f; if (_trollStage == 0) { if (FlatDistance(_pos, val) > 0.7f) { Approach(val, 0.3f, dt, BotConfig.CrouchSpeed.Value + 0.5f); return true; } _trollStage = 1; _trollStart = Time.time; BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollBoo), force: true); Express(BotMood.Silly, 2f); } Stand(dt); LookAt(point, 0.3f); if (Time.time - _trollStart > 2f) { EndTroll(); } return false; } case TrollKind.FakeAlarm: Stand(dt); LookAt(point, 0.3f); if (_trollStage == 0) { _trollStage = 1; BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollFake), force: true); Express(BotMood.Scared, 2.5f); } else if (_trollStage == 1 && num > 3f) { _trollStage = 2; BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollFakeReveal), force: true); Express(BotMood.Silly, 2.5f); } else if (num > 5.5f) { EndTroll(); } return false; case TrollKind.Toss: return TrollToss(trollTarget, position, num2, dt); default: EndTroll(); return false; } } private bool TrollToss(PlayerAvatar t, Vector3 tp, float dist, float dt) { //IL_01fa: 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_01d6: 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_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) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_027f: 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_02af: 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) if (_trollStage == 0) { _trollProp = FindJunk(8f); if (!Object.op_Implicit((Object)(object)_trollProp)) { _troll = TrollKind.Stare; return false; } _trollStage = 1; _grabWindup = 0f; } if (_trollStage == 1) { if (!Object.op_Implicit((Object)(object)_trollProp) || _trollProp.dead || _trollProp.playerGrabbing.Count > 0) { EndTroll(); return false; } Vector3 centerPoint = _trollProp.centerPoint; if (Vector3.Distance(Eye(), centerPoint) < 2.1f) { Stand(dt); LookAt(centerPoint, 0.4f); _grabWindup += dt; if (_grabWindup > 0.35f && FacingError(centerPoint) < 30f) { if (BotGrab.Start(Info, _trollProp)) { _held = _trollProp; _heldIsCart = false; _trollStage = 2; } else { EndTroll(); } } return false; } WalkTo(centerPoint, BotConfig.WalkSpeed.Value, dt); return false; } if (_trollStage == 2) { if (!Object.op_Implicit((Object)(object)_held)) { EndTroll(); return false; } if (dist > 3.5f) { Approach(tp, 3f, dt); return false; } Stand(dt); LookAt(tp, 0.3f); if (FacingError(tp) > 20f) { return false; } PhysGrabObject held = _held; ReleaseHeld(); if (Object.op_Implicit((Object)(object)held) && Object.op_Implicit((Object)(object)held.rb) && SemiFunc.IsMasterClientOrSingleplayer()) { Vector3 val = tp - held.rb.position; val.y = 0f; held.rb.velocity = ((Vector3)(ref val)).normalized * Mathf.Clamp(((Vector3)(ref val)).magnitude * 1.4f, 2f, 5f) + Vector3.up * 2.5f; } BotSpeech.Say(Info, BotLines.Pick(BotLines.TrollToss), force: true); Express(BotMood.Silly, 2f); _trollStage = 3; _trollStart = Time.time; return false; } Stand(dt); if (Time.time - _trollStart > 1.5f) { EndTroll(); } return false; } private PhysGrabObject FindJunk(float range) { //IL_001d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject result = null; float num = range; Type type = Refl.GameType("ItemAttributes"); Type type2 = Refl.GameType("PhysGrabHinge"); Collider[] array = Physics.OverlapSphere(_pos + Vector3.up, range); foreach (Collider val in array) { PhysGrabObject componentInParent = ((Component)val).GetComponentInParent<PhysGrabObject>(); if (Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.dead && Object.op_Implicit((Object)(object)componentInParent.rb) && !componentInParent.rb.isKinematic && !(componentInParent.rb.mass > 2.5f) && componentInParent.playerGrabbing.Count <= 0 && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent<ValuableObject>()) && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent<PhysGrabCart>()) && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent<PlayerTumble>()) && (!(type != null) || !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent(type))) && (!(type2 != null) || !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent(type2))) && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponentInParent<PlayerDeathHead>())) { float num2 = Vector3.Distance(_pos, ((Component)componentInParent).transform.position); if (num2 < num) { num = num2; result = componentInParent; } } } return result; } private void StartArena() { if (Current != Task.Arena) { Current = Task.Arena; Nav.Clear(); _route = null; if (!_arenaGreeted) { _arenaGreeted = true; BotSpeech.Say(Info, BotLines.Pick(BotLines.ArenaStart), force: true); Express(BotMood.Angry, 3f); } } } private void ActArena(float dt) { //IL_028a: 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_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0334: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0361: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) _swinging = false; if (!GameShim.RunIs("RunIsArena")) { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } Current = Task.Hold; } else { if (AliveOthers() == 0 && TryCrown(dt)) { return; } if (!Object.op_Implicit((Object)(object)_held) || (Object)(object)_held != (Object)(object)_weapon) { if (Object.op_Implicit((Object)(object)_held) && (Object)(object)_held != (Object)(object)_weapon) { ReleaseHeld(); } if (!Object.op_Implicit((Object)(object)_weapon) || _weapon.dead || (_weapon.playerGrabbing.Count > 0 && !BotGrab.IsHolding(Info, _weapon))) { if (Time.time >= _nextWeaponLook) { _nextWeaponLook = Time.time + 1f; _weapon = FindWeapon(out _weaponIsGun); } if (!Object.op_Implicit((Object)(object)_weapon)) { Brawl(dt); return; } } Vector3 centerPoint = _weapon.centerPoint; if (Vector3.Distance(Eye(), centerPoint) < 2.1f) { Stand(dt); LookAt(centerPoint, 0.3f); _grabWindup += dt; if (_grabWindup > 0.25f && FacingError(centerPoint) < 35f) { _grabWindup = 0f; if (BotGrab.Start(Info, _weapon)) { _held = _weapon; _heldIsCart = false; _heldStrayTimer = 0f; } else { _weapon = null; } } } else { _sprint = true; WalkTo(centerPoint, BotConfig.SprintSpeed.Value, dt); } return; } PlayerAvatar val = NearestOpponent(); if (!Object.op_Implicit((Object)(object)val)) { Stand(dt); IdleBehaviour(dt); return; } Vector3 position = ((Component)val).transform.position; Vector3 point = ((Object.op_Implicit((Object)(object)val.PlayerVisionTarget) && Object.op_Implicit((Object)(object)val.PlayerVisionTarget.VisionTransform)) ? val.PlayerVisionTarget.VisionTransform.position : (position + Vector3.up * 1.3f)); float num = FlatDistance(_pos, position); if (_weaponIsGun) { if (num > 9f) { _sprint = true; Approach(position, 7f, dt, BotConfig.SprintSpeed.Value); } else if (num < 3f) { StepAway(position, dt); } else { Stand(dt); } LookAt(point, 0.3f); if (Time.time >= _nextShot && FacingError(position) < 12f) { _nextShot = Time.time + Random.Range(0.8f, 1.4f); BotShopToggle(_weapon); } return; } LookAt(point, 0.3f); if (num > 1.8f) { _sprint = num > 4f; Approach(position, 1.5f, dt, _sprint ? BotConfig.SprintSpeed.Value : BotConfig.WalkSpeed.Value); return; } Stand(dt); _swinging = true; _swingPhase += dt * 9f; if (Time.time >= _nextArenaLine && Random.value < 0.3f) { _nextArenaLine = Time.time + 6f; BotSpeech.Say(Info, BotLines.Pick(BotLines.ArenaHit), force: true); } } } private void Brawl(float dt) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = NearestOpponent(); if (!Object.op_Implicit((Object)(object)val)) { Stand(dt); return; } LookAt(((Component)val).transform.position + Vector3.up * 1.3f, 0.3f); _sprint = true; Approach(((Component)val).transform.position, 0.8f, dt, BotConfig.SprintSpeed.Value); } private bool TryCrown(float dt) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) Component val = Refl.GetStatic<Component>(Refl.GameType("Arena"), "instance"); if (!Object.op_Implicit((Object)(object)_crown)) { _crown = Refl.Get<StaticGrabObject>(val, "crownGrab"); } if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)_crown) || !((Component)_crown).gameObject.activeInHierarchy) { return false; } if (_crowned || Object.op_Implicit((Object)(object)Refl.Get<PlayerAvatar>(val, "winnerPlayer"))) { Stand(dt); return true; } if (_crownHuntStart < 0f) { _crownHuntStart = Time.time; } if (Object.op_Implicit((Object)(object)_held) && (Object)(object)_held == (Object)(object)_weapon) { ReleaseHeld(); } Vector3 position = ((Component)_crown).transform.position; if (Vector3.Distance(Eye(), position) < 2.2f) { Stand(dt); LookAt(position, 0.5f); if (_crownGrabbedAt < 0f && FacingError(position) < 25f && _crown.playerGrabbing.Count == 0 && BotGrab.StartStatic(Info, _crown, position)) { _crownGrabbedAt = Time.time; } if (_crownGrabbedAt >= 0f && Object.op_Implicit((Object)(object)Avatar.physGrabber)) { Refl.Set(Avatar.physGrabber, "initialPressTimer", 0.2f); } } else { WalkTo(position, BotConfig.WalkSpeed.Value, dt, 1f); } bool flag = _crownGrabbedAt >= 0f && Time.time - _crownGrabbedAt > 1.2f; bool flag2 = Time.time - _crownHuntStart > 25f; if (flag || flag2) { PhotonView component = val.GetComponent<PhotonView>(); int num = ((Object.op_Implicit((Object)(object)Avatar.physGrabber) && Object.op_Implicit((Object)(object)Avatar.physGrabber.photonView)) ? Avatar.physGrabber.photonView.ViewID : Info.ViewId); if (Object.op_Implicit((Object)(object)component)) { SafeRpc.Send(component, ((object)val).GetType(), "CrownGrabRPC", (RpcTarget)0, num); } Crowned(); } return true; } private void Crowned() { if (!_crowned) { _crowned = true; Plugin.Log.LogInfo((object)("RepoBots: '" + Info.Name + "' is the KING OF THE LOSERS.")); BotSpeech.Say(Info, BotLines.Pick(BotLines.Crowned), force: true); Express(BotMood.Happy, 6f); } } private PhysGrabObject FindWeapon(out bool gun) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) gun = false; PhysGrabObject result = null; float num = 60f; string[] array = new string[2] { "ItemMelee", "ItemGun" }; foreach (string text in array) { Type type = Refl.GameType(text); if (type == null) { continue; } Object[] array2 = Object.FindObjectsOfType(type); foreach (Object val in array2) { Component val2 = (Component)(object)((val is Component) ? val : null); if (val2 == null || !Object.op_Implicit((Object)(object)val2)) { continue; } PhysGrabObject component = val2.GetComponent<PhysGrabObject>(); if (Object.op_Implicit((Object)(object)component) && !component.dead && component.playerGrabbing.Count <= 0 && !OtherBotTargets(component)) { float num2 = Vector3.Distance(_pos, ((Component)component).transform.position); if (text == "ItemGun") { num2 -= 3f; } if (num2 < num) { num = num2; result = component; gun = text == "ItemGun"; } } } } return result; } private PlayerAvatar NearestOpponent() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; if (!Object.op_Implicit((Object)(object)GameDirector.instance)) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Object.op_Implicit((Object)(object)player) && !((Object)(object)player == (Object)(object)Avatar) && !player.isDisabled && !player.deadSet) { float num2 = Vector3.Distance(_pos, ((Component)player).transform.position); if (num2 < num) { num = num2; result = player; } } } return result; } private int AliveOthers() { int num = 0; if (Object.op_Implicit((Object)(object)GameDirector.instance)) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Object.op_Implicit((Object)(object)player) && (Object)(object)player != (Object)(object)Avatar && !player.isDisabled && !player.deadSet) { num++; } } } return num; } private void BotShopToggle(PhysGrabObject item) { Type type = Refl.GameType("ItemToggle"); Component val = ((type != null && Object.op_Implicit((Object)(object)item)) ? ((Component)item).GetComponent(type) : null); if (Object.op_Implicit((Object)(object)val)) { bool flag = Refl.Get(val, "toggleState", fallback: false); Refl.Call(val, type, "ToggleItem", out var _, !flag, Avatar.photonView.ViewID); } } private bool TryOpenHinge() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (!BotConfig.OpenContainers.Value || Object.op_Implicit((Object)(object)_held) || Time.time < _nextHingeLook) { return false; } _nextHingeLook = Time.time + 1.5f; Vector3 val = Eye(); foreach (Component item in BotHinges.All()) { if (!Object.op_Implicit((Object)(object)item) || _hingesTried.Contains(((Object)item).GetInstanceID()) || Vector3.Distance(val, item.transform.position) > 2.6f) { continue; } _hingesTried.Add(((Object)item).GetInstanceID()); if (BotHinges.Closed(item) && !(Random.value > 0.55f)) { PhysGrabObject component = item.GetComponent<PhysGrabObject>(); if (Object.op_Implicit((Object)(object)component) && !component.dead && component.playerGrabbing.Count <= 0) { _hinge = item; _hingeBody = component; _hingeStart = Time.time; _hingeHeldAt = -1f; _grabWindup = 0f; Current = Task.OpenHinge; Note = "opening " + ((Object)item).name; return true; } } } return false; } private void ActOpenHinge(float dt) { //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_01c0: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_hingeBody) || _hingeBody.dead || Time.time - _hingeStart > 8f) { FinishHinge(); return; } Vector3 centerPoint = _hingeBody.centerPoint; if (_hingeHeldAt < 0f) { if (Vector3.Distance(Eye(), centerPoint) > 2f) { WalkTo(centerPoint, BotConfig.WalkSpeed.Value, dt, 1.2f); return; } Stand(dt); LookAt(centerPoint, 0.4f); _grabWindup += dt; if (!(_grabWindup < 0.3f) && !(FacingError(centerPoint) > 30f)) { if (!BotGrab.Start(Info, _hingeBody, centerPoint)) { FinishHinge(); return; } _held = _hingeBody; _heldIsCart = false; _heldStrayTimer = 0f; _hingeHeldAt = Time.time; Vector3 val = Eye() - centerPoint; val.y = 0f; _hingePullTo = centerPoint + ((Vector3)(ref val)).normalized * 1.1f + Quaternion.Euler(0f, 90f, 0f) * ((Vector3)(ref val)).normalized * 0.4f + Vector3.up * 0.1f; } } else { Stand(dt); LookAt(centerPoint, 0.3f); if (Time.time - _hingeHeldAt > 1.1f) { FinishHinge(); } } } private void FinishHinge() { if (Object.op_Implicit((Object)(object)_held) && (Object)(object)_held == (Object)(object)_hingeBody) { ReleaseHeld(); } _hinge = null; _hingeBody = null; _hingeHeldAt = -1f; _nextScan = 0f; Current = Task.Idle; _idleUntil = Time.time + 0.4f; } private bool HoldOverride(out Vector3 point) { //IL_0002: 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_004b: 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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) point = default(Vector3); if (Current == Task.Arena && _swinging) { float num = Mathf.Sin(_swingPhase) * 75f; point = Eye() + Quaternion.Euler(0f, _yaw + num, 0f) * Vector3.forward * 1.3f - Vector3.up * 0.2f; return true; } if (Current == Task.HelpCarry && Object.op_Implicit((Object)(object)_held)) { BotInfo botInfo = BotHelp.Owner(_held); if (botInfo != null && Object.op_Implicit((Object)(object)botInfo.Brain) && (Object)(object)botInfo.Brain != (Object)(object)this) { point = ((botInfo.Brain.Current == Task.NeedHelp) ? (_held.centerPoint + Vector3.up * 0.4f) : botInfo.Brain.HoldPoint()); return true; } } if (Current == Task.OpenHinge && _hingeHeldAt >= 0f) { point = _hingePullTo; return true; } if (Time.time < _liftUntil) { point = Eye() + Forward() * 0.9f + Vector3.up * 0.35f; return true; } return false; } private void Unsnag(float lag, float dt) { if (Current != Task.Arena && Current != Task.OpenHinge && Current != Task.DropOff) { if ((Object)(object)_held != (Object)(object)_snagObject) { _snagObject = _held; _snagRetries = 0; _snagTimer = 0f; } if (lag > 1f) { _snagTimer += dt; } else { _snagTimer = Mathf.Max(0f, _snagTimer - dt * 2f); } if (_snagTimer > 0.6f && Time.time >= _liftUntil) { _liftUntil = Time.time + 1.2f; _snagTimer = 0f; } } } private bool TryRegrab() { if (_snagRetries >= 2 || !Object.op_Implicit((Object)(object)_held) || _held.dead) { return false; } if (Current != Task.Carry && Current != Task.GetLoot) { return false; } _snagRetries++; PhysGrabObject held = _held; PlayerAvatar heldHeadOwner = _heldHeadOwner; ValuableObject component = ((Component)held).GetComponent<ValuableObject>(); ReleaseHeld(); _snagObject = held; SetTarget(held, component, heldHeadOwner); _heldStrayTimer = 0f; Plugin.Debug($"{Info.Name} re-grabbing snagged {((Object)held).name} ({_snagRetries})"); return true; } private void WalkTo(Vector3 target, float speed, float dt, float stop = 0.3f) { //IL_0021: 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_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) if (!Nav.HasPath || Time.time >= _nextRepath || Vector3.Distance(Nav.Destination, target) > 1f) { _nextRepath = Time.time + 1f; if (!Nav.SetDestination(_pos, target)) { Stand(dt); return; } } Move(dt, speed, stop); } private void Approach(Vector3 target, float stop, float dt, float speed = -1f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) WalkTo(target, (speed > 0f) ? speed : BotConfig.WalkSpeed.Value, dt, stop); } private void StepAway(Vector3 from, float dt) { //IL_0002: 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_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_003a: 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_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_0057: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008a: 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) Vector3 val = _pos - from; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = -Forward(); } Vector3 move = ((Vector3)(ref val)).normalized * BotConfig.WalkSpeed.Value * dt; _pos = BotNav.GroundSnap(_pos + BotBody.Collide(Info, _pos, move, _held, BotConfig.WalkSpeed.Value, out var _)); UpdateLook(dt); } private bool WanderSomewhere() { //IL_0022: 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_0033: 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_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_006e: 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) for (int i = 0; i < 8; i++) { Vector3 val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f) * Vector3.forward; if (BotNav.SampleOnMesh(_pos + val * Random.Range(6f, 20f), 4f, out var result) && Nav.SetDestination(_pos, result)) { return true; } } return false; } private void Drive(Component vehicle, float dt) { //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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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) Current = Task.Race; PlayerTumble tumble = Avatar.tumble; _pos = (Object.op_Implicit((Object)(object)tumble) ? (((Component)tumble).transform.position - Vector3.up * 0.3f) : vehicle.transform.position); _speed = 0f; _crouch = false; _sprint = false; if (!BotConfig.PlayMinigames.Value || !BotRace.IsDriver(vehicle, Avatar)) { _driveInput = Vector3.zero; return; } bool flag = BotRace.State() == "RaceActive" || !BotRace.Active; if (!BotRace.NextTarget(vehicle, _pos, out var target)) { target = _pos + vehicle.transform.forward * 10f; } Vector3 val = target - Eye(); float num = Mathf.Atan2(val.x, val.z) * 57.29578f; _yaw = Mathf.MoveTowardsAngle(_yaw, num, 220f * dt); _pitch = Mathf.MoveTowards(_pitch, 8f, 60f * dt); if (!flag) { _driveInput = Vector3.zero; return; } if ((Object)(object)Refl.Get<PlayerAvatar>(BotRace.Instance(), "winnerPlayer") == (Object)(object)Avatar) { _driveInput = (Vector3)((BotRace.Speed(vehicle) > 1f) ? new Vector3(0f, 0f, -0.4f) : Vector3.zero); if (!_crowned) { Crowned(); } return; } if (!_raceGreeted) { _raceGreeted = true; BotSpeech.Say(Info, BotLines.Pick(BotLines.RaceStart), force: true); Express(BotMood.Happy, 3f); } float num2 = BotRace.Speed(vehicle); if (num2 < 0.8f) { if (_slowSince < 0f) { _slowSince = Time.time; } } else { _slowSince = -1f; } if (_slowSince > 0f && Time.time - _slowSince > 2f) { _reverseUntil = Time.time + 1.1f; _slowSince = -1f; } float num3 = Mathf.DeltaAngle(vehicle.transform.eulerAngles.y, num); if (Time.time < _reverseUntil) { _driveInput = new Vector3(0f, 0f, -1f); } else { float num4 = ((Mathf.Abs(num3) > 70f) ? 0.6f : 1f); float num5 = ((Mathf.Abs(num3) > 45f) ? Mathf.Sign(num3) : 0f); _driveInput = new Vector3(num5, 0f, num4); } if (Time.time >= _nextRaceLine && Random.value < 0.01f) { _nextRaceLine = Time.time + 15f; BotSpeech.Say(Info, BotLines.Pick(BotLines.RaceChatter)); } } internal void OnSplit() { if (Current == Task.Explore || Current == Task.Idle) { Nav.Clear(); _nextPick = 0f; StartExplore(); } } internal void OnGiveUpChanged(bool gaveUp) { if (_gaveUp == gaveUp) { return; } _gaveUp = gaveUp; if (gaveUp) { Express(BotMood.Sad, 4f); if (Object.op_Implicit((Object)(object)_held) && !Object.op_Implicit((Object)(object)_heldHeadOwner)) { ReleaseHeld(); } BotCart.Unclaim(Info); ClearTargets(); Nav.Clear(); _route = null; if (Current != Task.Flee && Current != Task.Hide) { Current = Task.GoTruck; } } else if (Current == Task.GoTruck || Current == Task.AtTruck) { Current = Task.Idle; _idleUntil = Time.time + 1f; } } private bool GiveUpThink() { if (!_gaveUp || Mode != BotMode.Loot) { return false; } if (Object.op_Implicit((Object)(object)_held) && (Object)(object)_heldHeadOwner == (Object)null && Current != Task.Troll) { ReleaseHeld(); } if (Current == Task.Troll || Current == Task.GoTruck || Current == Task.AtTruck) { return true; } if (Object.op_Implicit((Object)(object)_held) && (Object)(object)_heldHeadOwner != (Object)null) { return false; } Current = Task.GoTruck; Nav.Clear(); _route = null; return true; } internal void RunForTruck() { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } BotCart.Unclaim(Info); ClearTargets(); Nav.Clear(); _route = null; Mode = BotMode.Truck; Current = Task.GoTruck; } internal void LearnExtraction(ExtractionPoint e) { if (Object.op_Implicit((Object)(object)e)) { _knownExtractions.Add(e); } } private void CalloutNeedExtraction() { if (!(Time.time < _nextNeedExtractionCallout)) { _nextNeedExtractionCallout = Time.time + 60f; BotSpeech.Say(Info, BotLines.Pick(BotLines.NeedExtraction)); } } private void StartNeedHelp() { Current = Task.NeedHelp; _needHelpStart = Time.time; _nextHelpCall = 0f; BotHelp.Ask(_held, Info); Express(BotMood.Sad, 2f); Note = "needs help with " + (Object.op_Implicit((Object)(object)_held) ? ((Object)_held).name : "something heavy"); } private void ActNeedHelp(float dt) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Stand(dt); if (!Object.op_Implicit((Object)(object)_held) || !BotGrab.IsHolding(Info, _held)) { BotHelp.DoneBy(Info); _held = null; Current = Task.Idle; return; } LookAt(_held.centerPoint + Vector3.up * 0.3f, 0.5f); if (_held.playerGrabbing.Count >= 2) { BotSpeech.Say(Info, BotLines.Pick(BotLines.HelpThanks)); PickDropTarget(); Current = Task.Carry; return; } if (Time.time >= _nextHelpCall) { _nextHelpCall = Time.time + 15f; BotSpeech.Say(Info, BotLines.Pick(BotLines.AskHelp), force: true); } if (Time.time - _needHelpStart > 35f) { PhysGrabObject held = _held; BotHelp.DoneBy(Info); ReleaseHeld(); Blacklist(held, 120f); BotSpeech.Say(Info, BotLines.Pick(BotLines.HelpGiveUp)); Current = Task.Idle; } } private bool TryRespondToHelp() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!BotConfig.AskForHelp.Value || Object.op_Implicit((Object)(object)_held)) { return false; } PhysGrabObject val = BotHelp.Nearby(Info, _pos, 30f); if (!Object.op_Implicit((Object)(object)val) || BotSenses.AnyEnemyWithin(((Component)val).transform.position, 8f)) { return false; } _helping = true; SetTarget(val, ((Component)val).GetComponent<ValuableObject>(), null); BotInfo botInfo = BotHelp.Owner(val); BotSpeech.Say(Info, (botInfo != null) ? string.Format(BotLines.Pick(BotLines.HelpComing), botInfo.Name) : "Coming to help!"); return true; } private void StartHelpCarry() { Current = Task.HelpCarry; Note = "helping carry " + (Object.op_Implicit((Object)(object)_held) ? ((Object)_held).name : ""); } private void ActHelpCarry(float dt) { //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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) BotInfo botInfo = (Object.op_Implicit((Object)(object)_held) ? BotHelp.Owner(_held) : null); if (!Object.op_Implicit((Object)(object)_held) || botInfo == null || !botInfo.Alive || !Object.op_Implicit((Object)(object)botInfo.Brain) || !BotGrab.IsHolding(Info, _held) || ((Object)(object)botInfo.Brain._held != (Object)(object)_held && botInfo.Brain.Current != Task.NeedHelp)) { if (Object.op_Implicit((Object)(object)_held)) { ReleaseHeld(); } _helping = false; Current = Task.Idle; _idleUntil = Time.time + 0.5f; return; } Vector3 centerPoint = _held.centerPoint; Vector3 forward = ((Component)botInfo.Avatar).transform.forward; forward.y = 0f; Vector3 val = Vector3.Cross(Vector3.up, (((Vector3)(ref forward)).sqrMagnitude > 0.01f) ? ((Vector3)(ref forward)).normalized : Forward()); Vector3 val2 = centerPoint + val * 1.3f; if (FlatDistance(_pos, val2) > 0.6f) { WalkTo(val2, BotConfig.CarrySpeed.Value, dt); } else { Stand(dt); } LookAt(centerPoint, 0.3f); } private bool TryStartHeal(PlayerAvatar forced = null) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (!BotConfig.HealTeammates.Value || !Object.op_Implicit((Object)(object)Avatar.playerHealth)) { return false; } if ((Object)(object)forced == (Object)null && Time.time < _nextHealLook) { return false; } _nextHealLook = Time.time + 2f; if (Avatar.playerHealth.health < 45) { return false; } PlayerAvatar val = forced; if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)GameDirector.instance)) { float num = float.MaxValue; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!Object.op_Implicit((Object)(object)player) || (Object)(object)player == (Object)(object)Avatar || !BotHeal.Wounded(player, 30)) { continue; } float num2 = Vector3.Distance(_pos, ((Component)player).transform.position); if (!(num2 > 20f) && !BotSenses.AnyEnemyWithin(((Com