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 BotFriends v2.0.1
BotFriends.dll
Decompiled 5 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.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+4247eae4b81cc1423970370465980f9d0841d4e8")] [assembly: AssemblyProduct("BotFriends")] [assembly: AssemblyTitle("BotFriends")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 Empress.StupidBots { internal sealed class BotAvatarVisual : MonoBehaviour { private const float DefaultSpeed = 4.2f; private NavMeshAgent? _agent; private Animator[] _animators = Array.Empty<Animator>(); private Vector3 _lastPosition; private float _fallbackSpeed = 4.2f; internal void Init(NavMeshAgent? agent, float fallbackSpeed) { //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) _agent = agent; _fallbackSpeed = Mathf.Max(0.1f, fallbackSpeed); _animators = ((Component)this).GetComponentsInChildren<Animator>(true); _lastPosition = ((Component)this).transform.position; for (int i = 0; i < _animators.Length; i++) { Animator val = _animators[i]; if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = true; val.applyRootMotion = false; val.speed = 1f; val.cullingMode = (AnimatorCullingMode)0; } } } private void LateUpdate() { //IL_002b: 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_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_001e: 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_004d: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_010a: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) //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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Invalid comparison between Unknown and I4 //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Invalid comparison between Unknown and I4 //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) if (_animators == null || _animators.Length == 0) { return; } Vector3 val = ((Time.deltaTime > 0.0001f) ? ((((Component)this).transform.position - _lastPosition) / Time.deltaTime) : Vector3.zero); _lastPosition = ((Component)this).transform.position; if (Object.op_Implicit((Object)(object)_agent) && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > ((Vector3)(ref val)).sqrMagnitude) { val = _agent.velocity; } } Vector3 val2 = val; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; bool flag = magnitude > 0.08f; float num = (Object.op_Implicit((Object)(object)_agent) ? Mathf.Max(1.5f, _agent.speed) : Mathf.Max(1.5f, _fallbackSpeed)); float num2 = Mathf.Clamp01(magnitude / num); Vector3 val3 = ((Component)this).transform.InverseTransformDirection(val2); for (int i = 0; i < _animators.Length; i++) { Animator val4 = _animators[i]; if (!Object.op_Implicit((Object)(object)val4)) { continue; } AnimatorControllerParameter[] parameters = val4.parameters; foreach (AnimatorControllerParameter val5 in parameters) { string text = val5.name.ToLowerInvariant(); AnimatorControllerParameterType type = val5.type; if ((int)type != 1) { if ((int)type == 4) { if (text.Contains("moving") || text.Contains("move") || text.Contains("walk") || text.Contains("run")) { val4.SetBool(val5.nameHash, flag); } else if (text.Contains("ground")) { val4.SetBool(val5.nameHash, true); } } } else if (text.Contains("horizontal") || text.Contains("strafe")) { val4.SetFloat(val5.nameHash, val3.x); } else if (text.Contains("vertical") || text.Contains("forward")) { val4.SetFloat(val5.nameHash, val3.z); } else if (text.Contains("speed") || text.Contains("move") || text.Contains("velocity")) { val4.SetFloat(val5.nameHash, num2); } } } } internal static bool TryAttach(GameObject root, PlayerAvatar? player, Color accent, NavMeshAgent? agent, float fallbackSpeed) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) if (!Object.op_Implicit((Object)(object)root) || !Object.op_Implicit((Object)(object)player)) { return false; } GameObject val = ResolveAvatarVisualRoot(player); if (!Object.op_Implicit((Object)(object)val)) { return false; } GameObject val2; try { val2 = Object.Instantiate<GameObject>(val, root.transform, false); } catch { return false; } ((Object)val2).name = "AvatarBody"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; PrepareClone(val2); TintClone(val2, accent); val2.AddComponent<BotAvatarVisual>().Init(agent, fallbackSpeed); return CountVisibleRenderers(val2) > 0; } private static GameObject? ResolveAvatarVisualRoot(PlayerAvatar player) { if (!Object.op_Implicit((Object)(object)player)) { return null; } try { FieldInfo fieldInfo = AccessTools.Field(((object)player).GetType(), "playerAvatarVisuals"); if (fieldInfo != null) { object? value = fieldInfo.GetValue(player); Component val = (Component)((value is Component) ? value : null); if (Object.op_Implicit((Object)(object)val)) { return val.gameObject; } } } catch { } try { PropertyInfo propertyInfo = AccessTools.Property(((object)player).GetType(), "playerAvatarVisuals"); if (propertyInfo != null) { object? value2 = propertyInfo.GetValue(player, null); Component val2 = (Component)((value2 is Component) ? value2 : null); if (Object.op_Implicit((Object)(object)val2)) { return val2.gameObject; } } } catch { } try { PlayerAvatarVisuals componentInChildren = ((Component)player).GetComponentInChildren<PlayerAvatarVisuals>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { return ((Component)componentInChildren).gameObject; } } catch { } return null; } private static void PrepareClone(GameObject clone) { //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) MonoBehaviour[] componentsInChildren = clone.GetComponentsInChildren<MonoBehaviour>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (Object.op_Implicit((Object)(object)componentsInChildren[i])) { ((Behaviour)componentsInChildren[i]).enabled = false; } } clone.SetActive(true); Transform[] componentsInChildren2 = clone.GetComponentsInChildren<Transform>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if (Object.op_Implicit((Object)(object)componentsInChildren2[j])) { ((Component)componentsInChildren2[j]).gameObject.SetActive(true); } } Renderer[] componentsInChildren3 = clone.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren3) { if (Object.op_Implicit((Object)(object)val)) { val.enabled = true; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); if (val2 != null) { val2.updateWhenOffscreen = true; } } } Animator[] componentsInChildren4 = clone.GetComponentsInChildren<Animator>(true); foreach (Animator val3 in componentsInChildren4) { if (Object.op_Implicit((Object)(object)val3)) { ((Behaviour)val3).enabled = true; val3.applyRootMotion = false; val3.speed = 1f; val3.cullingMode = (AnimatorCullingMode)0; } } Collider[] componentsInChildren5 = clone.GetComponentsInChildren<Collider>(true); for (int m = 0; m < componentsInChildren5.Length; m++) { if (Object.op_Implicit((Object)(object)componentsInChildren5[m])) { componentsInChildren5[m].enabled = false; } } Rigidbody[] componentsInChildren6 = clone.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val4 in componentsInChildren6) { if (Object.op_Implicit((Object)(object)val4)) { val4.isKinematic = true; val4.detectCollisions = false; val4.useGravity = false; } } AudioSource[] componentsInChildren7 = clone.GetComponentsInChildren<AudioSource>(true); for (int num = 0; num < componentsInChildren7.Length; num++) { if (Object.op_Implicit((Object)(object)componentsInChildren7[num])) { ((Behaviour)componentsInChildren7[num]).enabled = false; } } ParticleSystem[] componentsInChildren8 = clone.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val5 in componentsInChildren8) { if (Object.op_Implicit((Object)(object)val5)) { EmissionModule emission = val5.emission; ((EmissionModule)(ref emission)).enabled = false; val5.Stop(true, (ParticleSystemStopBehavior)0); } } TextMesh[] componentsInChildren9 = clone.GetComponentsInChildren<TextMesh>(true); for (int num3 = 0; num3 < componentsInChildren9.Length; num3++) { if (Object.op_Implicit((Object)(object)componentsInChildren9[num3])) { ((Component)componentsInChildren9[num3]).gameObject.SetActive(false); } } } private static void TintClone(GameObject clone, Color accent) { //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_006f: 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_009a: 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_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) Renderer[] componentsInChildren = clone.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Material[] materials; try { materials = val.materials; } catch { continue; } foreach (Material val2 in materials) { if (Object.op_Implicit((Object)(object)val2)) { if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.Lerp(val2.GetColor("_Color"), accent, 0.32f)); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", Color.Lerp(val2.GetColor("_BaseColor"), accent, 0.32f)); } if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", accent * 0.18f); } } } } } private static int CountVisibleRenderers(GameObject clone) { int num = 0; Renderer[] componentsInChildren = clone.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { num++; } } return num; } } internal class BotChatterAgent : MonoBehaviour { public enum BotState { Idle, Moving, Carrying, Ragdoll } private NavMeshAgent _agent; private Rigidbody _rb; private AudioSource _src; private readonly List<PhysGrabObject> _buf = new List<PhysGrabObject>(); private float _lastLocalSpeak; private bool _lastCarrying; private string _lastCarriedName; public BotState State { get; private set; } public bool IsCarrying { get; private set; } public string CarriedLabel { get; private set; } private void Awake() { _agent = ((Component)this).GetComponent<NavMeshAgent>(); _rb = ((Component)this).GetComponent<Rigidbody>(); _src = ((Component)this).GetComponent<AudioSource>(); if (!Object.op_Implicit((Object)(object)_src)) { _src = ((Component)this).gameObject.AddComponent<AudioSource>(); } _src.spatialBlend = 1f; _src.rolloffMode = (AudioRolloffMode)0; _src.minDistance = 2f; _src.maxDistance = 18f; } private void OnEnable() { BotChatterManager.Register(this); } private void OnDisable() { BotChatterManager.Unregister(this); } private void Update() { UpdateState(); } private void UpdateState() { //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) bool flag = false; if (Object.op_Implicit((Object)(object)_agent) && ((Behaviour)_agent).enabled) { Vector3 velocity = _agent.velocity; flag = ((Vector3)(ref velocity)).sqrMagnitude > 0.04f; } bool flag2 = false; if (Object.op_Implicit((Object)(object)_rb)) { flag2 = !_rb.isKinematic && !((Behaviour)_agent).enabled; } DetectCarry(out bool carrying, out string label); IsCarrying = carrying; CarriedLabel = label; if (flag2) { State = BotState.Ragdoll; } else if (carrying) { State = BotState.Carrying; } else if (flag) { State = BotState.Moving; } else { State = BotState.Idle; } } private void DetectCarry(out bool carrying, out string label) { //IL_005c: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) carrying = false; label = ""; _buf.Clear(); ((Component)this).GetComponentsInChildren<PhysGrabObject>(true, _buf); PhysGrabObject val = null; float num = float.PositiveInfinity; for (int i = 0; i < _buf.Count; i++) { PhysGrabObject val2 = _buf[i]; if (!Object.op_Implicit((Object)(object)val2)) { continue; } Transform transform = ((Component)val2).transform; if (!((Object)(object)transform == (Object)(object)((Component)this).transform)) { Vector3 val3 = transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val2; } } } if (Object.op_Implicit((Object)(object)val)) { carrying = true; label = ((Object)((Component)val).gameObject).name; } } internal void PlayClip(DecTalkSynth.Clip clip, float volume) { if (Object.op_Implicit((Object)(object)_src)) { AudioClip val = AudioClip.Create("BotChat", clip.Samples.Length / clip.Channels, clip.Channels, clip.SampleRate, false); val.SetData(clip.Samples, 0); _src.Stop(); _src.clip = val; _src.loop = false; _src.volume = Mathf.Clamp01(volume); _src.Play(); } } internal bool TickLocal(float now, bool canSpeak) { if (!canSpeak) { return false; } if (now < _lastLocalSpeak) { return false; } bool flag = false; if (IsCarrying && !_lastCarrying) { flag = true; } _lastCarrying = IsCarrying; if (!flag) { return false; } string text = (IsCarrying ? "Moving with package." : "Moving."); if (BotFriendsChatterPlugin.UseDECtalk.Value) { DecTalkSynth.Enqueue(this, text); _lastLocalSpeak = now + BotFriendsChatterPlugin.SelfCooldown.Value; return true; } return false; } } internal enum BotPersonalityType { Clumsy, Fast, Slow, Aggressive, Coward, Curious, Guardian, Jittery, Pacifist, Trickster } internal class BotPersonality : MonoBehaviour { public BotPersonalityType Type { get; private set; } public float SpeedMultiplier { get; private set; } = 1f; public bool AllowValuables { get; private set; } = true; public bool AllowWeapons { get; private set; } = true; public float AimConeDegrees { get; private set; } = 6f; public Vector2 FireInterval { get; private set; } = new Vector2(0.9f, 1.6f); public float ToyingChance { get; private set; } public float DropChanceOnShoot { get; private set; } public void InitRandom(int seed) { Random random = new Random(seed); BotPersonalityType[] array = (BotPersonalityType[])Enum.GetValues(typeof(BotPersonalityType)); Type = array[random.Next(array.Length)]; ApplyDefaults(Type); } public void ApplyDefaults(BotPersonalityType t) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) Type = t; SpeedMultiplier = 1f; AllowValuables = true; AllowWeapons = true; AimConeDegrees = 6f; FireInterval = new Vector2(0.9f, 1.6f); ToyingChance = 0f; DropChanceOnShoot = 0f; switch (t) { case BotPersonalityType.Clumsy: SpeedMultiplier = 0.95f; AimConeDegrees = 10f; DropChanceOnShoot = 0.12f; break; case BotPersonalityType.Fast: SpeedMultiplier = 1.25f; AimConeDegrees = 7f; FireInterval = new Vector2(0.6f, 1f); break; case BotPersonalityType.Slow: SpeedMultiplier = 0.7f; AimConeDegrees = 8f; FireInterval = new Vector2(1.2f, 2f); break; case BotPersonalityType.Aggressive: SpeedMultiplier = 1.1f; AimConeDegrees = 5f; FireInterval = new Vector2(0.35f, 0.75f); break; case BotPersonalityType.Coward: SpeedMultiplier = 1f; AimConeDegrees = 12f; FireInterval = new Vector2(1.5f, 2.2f); AllowValuables = false; break; case BotPersonalityType.Curious: SpeedMultiplier = 1f; AimConeDegrees = 9f; FireInterval = new Vector2(0.8f, 1.6f); ToyingChance = 0.25f; break; case BotPersonalityType.Guardian: SpeedMultiplier = 0.95f; AimConeDegrees = 4f; FireInterval = new Vector2(0.55f, 1.1f); break; case BotPersonalityType.Jittery: SpeedMultiplier = 1.1f; AimConeDegrees = 14f; FireInterval = new Vector2(0.25f, 0.6f); break; case BotPersonalityType.Pacifist: SpeedMultiplier = 1f; AllowWeapons = false; break; case BotPersonalityType.Trickster: SpeedMultiplier = 1f; AimConeDegrees = 18f; FireInterval = new Vector2(0.4f, 1.2f); ToyingChance = 0.5f; break; } } } internal class BotRagdoll : MonoBehaviour { private bool _feature; private float _thresholdSqr; private float _recover; private Rigidbody _rb; private NavMeshAgent _agent; private StupidBotBrain _brain; private StupidBotCarrier _carrier; private bool _active; private bool _carrierPrevEnabled; private float _timer; internal void Init(NavMeshAgent agent, StupidBotBrain brain, StupidBotCarrier carrier, Rigidbody rb, bool enabled, float threshold, float recover) { _agent = agent; _brain = brain; _carrier = carrier; _rb = rb; _feature = enabled; _thresholdSqr = Mathf.Max(0.01f, threshold * threshold); _recover = Mathf.Max(0.5f, recover); } private void OnCollisionEnter(Collision c) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (_feature && !_active) { Vector3 relativeVelocity = c.relativeVelocity; if (((Vector3)(ref relativeVelocity)).sqrMagnitude >= _thresholdSqr) { Activate(); } } } private void Activate() { _active = true; _timer = 0f; if (Object.op_Implicit((Object)(object)_carrier)) { _carrierPrevEnabled = ((Behaviour)_carrier).enabled; ((Behaviour)_carrier).enabled = false; } if (Object.op_Implicit((Object)(object)_agent)) { ((Behaviour)_agent).enabled = false; } if (Object.op_Implicit((Object)(object)_brain)) { _brain.SetExternalControl(on: true); } if (Object.op_Implicit((Object)(object)_rb)) { _rb.isKinematic = false; } } private void Deactivate() { //IL_001a: 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) _active = false; if (Object.op_Implicit((Object)(object)_rb)) { _rb.velocity = Vector3.zero; _rb.angularVelocity = Vector3.zero; _rb.isKinematic = true; } if (Object.op_Implicit((Object)(object)_agent)) { ((MonoBehaviour)this).StartCoroutine(EnableAgent()); return; } if (Object.op_Implicit((Object)(object)_brain)) { _brain.SetExternalControl(on: false); } if (Object.op_Implicit((Object)(object)_carrier) && _carrierPrevEnabled) { ((Behaviour)_carrier).enabled = true; } } private IEnumerator EnableAgent() { yield return null; if (Object.op_Implicit((Object)(object)_agent)) { _agent.Warp(((Component)this).transform.position); } if (Object.op_Implicit((Object)(object)_agent)) { ((Behaviour)_agent).enabled = true; } if (Object.op_Implicit((Object)(object)_brain)) { _brain.SetExternalControl(on: false); } if (Object.op_Implicit((Object)(object)_carrier) && _carrierPrevEnabled) { ((Behaviour)_carrier).enabled = true; } } private void Update() { //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) if (!_feature || !_active) { return; } _timer += Time.deltaTime; if (!(_timer < _recover) && Object.op_Implicit((Object)(object)_rb)) { Vector3 velocity = _rb.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 0.16f) { Deactivate(); } } } internal void SetEnabled(bool on) { _feature = on; } internal void Reconfigure(float threshold, float recover) { _thresholdSqr = Mathf.Max(0.01f, threshold * threshold); _recover = Mathf.Max(0.5f, recover); } } internal static class BotUtils { private static readonly Dictionary<int, StupidBotCarrier> Claims = new Dictionary<int, StupidBotCarrier>(); private static readonly Dictionary<int, float> IgnoreUntil = new Dictionary<int, float>(); internal static List<PhysGrabObject> FindNearbyValuables(Vector3 position, float range) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) List<PhysGrabObject> list = new List<PhysGrabObject>(); try { List<PhysGrabObject> list2 = SemiFunc.PhysGrabObjectGetAllWithinRange(range, position, true, default(LayerMask), (PhysGrabObject)null); for (int i = 0; i < list2.Count; i++) { PhysGrabObject val = list2[i]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<ValuableObject>())) { list.Add(val); } } } catch { } return list; } internal static bool TryClaim(PhysGrabObject pgo, StupidBotCarrier owner) { if (!Object.op_Implicit((Object)(object)pgo)) { return false; } int instanceID = ((Object)pgo).GetInstanceID(); if (IsIgnored(pgo)) { return false; } if (Claims.TryGetValue(instanceID, out StupidBotCarrier value) && Object.op_Implicit((Object)(object)value) && (Object)(object)value != (Object)(object)owner) { return false; } Claims[instanceID] = owner; return true; } internal static void ReleaseClaim(PhysGrabObject pgo, StupidBotCarrier owner) { if (Object.op_Implicit((Object)(object)pgo)) { int instanceID = ((Object)pgo).GetInstanceID(); if (Claims.TryGetValue(instanceID, out StupidBotCarrier value) && (Object)(object)value == (Object)(object)owner) { Claims.Remove(instanceID); } } } internal static bool IsClaimedByOther(PhysGrabObject pgo, StupidBotCarrier owner) { if (!Object.op_Implicit((Object)(object)pgo)) { return false; } int instanceID = ((Object)pgo).GetInstanceID(); if (!Claims.TryGetValue(instanceID, out StupidBotCarrier value)) { return false; } if (Object.op_Implicit((Object)(object)value)) { return (Object)(object)value != (Object)(object)owner; } return false; } internal static void IgnoreFor(PhysGrabObject pgo, float seconds) { if (Object.op_Implicit((Object)(object)pgo)) { int instanceID = ((Object)pgo).GetInstanceID(); IgnoreUntil[instanceID] = Time.time + Mathf.Max(0f, seconds); Claims.Remove(instanceID); } } internal static bool IsIgnored(PhysGrabObject pgo) { if (!Object.op_Implicit((Object)(object)pgo)) { return false; } int instanceID = ((Object)pgo).GetInstanceID(); if (!IgnoreUntil.TryGetValue(instanceID, out var value)) { return false; } return value > Time.time; } internal static Vector3 WithY(this Vector3 v, float y) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) v.y = y; return v; } } internal class BotWeaponUser : MonoBehaviour { internal struct Cfg { public float SearchRadius; } private static readonly Dictionary<int, BotWeaponUser> Claims = new Dictionary<int, BotWeaponUser>(); private static readonly Dictionary<int, float> EmptyUntil = new Dictionary<int, float>(); private Cfg _cfg; private NavMeshAgent _agent; private Transform _hold; private StupidBotBrain _brain; private BotPersonality _persona; private ItemGun _gun; private PhysGrabObject _pgo; private Rigidbody _rb; private Collider[] _myCols; private readonly List<Collider> _gunCols = new List<Collider>(); private float _retargetTimer; private float _fireTimer; private float _toyTimer; private bool _busy; private bool _subscribed; internal void Init(Cfg cfg, NavMeshAgent agent, Transform hold, StupidBotBrain brain, BotPersonality persona) { _cfg = cfg; _agent = agent; _hold = hold; _brain = brain; _persona = persona; _myCols = ((Component)this).GetComponentsInChildren<Collider>(true); _retargetTimer = Random.Range(0.2f, 0.8f); _fireTimer = Random.Range(0.4f, 1f); _toyTimer = Random.Range(1.5f, 3.5f); } private void OnDisable() { Drop(immediate: true); } private void Update() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00de: Unknown result type (might be due to invalid IL or missing references) if ((Object.op_Implicit((Object)(object)_persona) && !_persona.AllowWeapons) || _busy) { return; } if (Object.op_Implicit((Object)(object)_gun)) { EnsureHeldTransform(); _brain.SetExternalControl(on: true); AimAndShoot(); return; } _retargetTimer -= Time.deltaTime; if (_retargetTimer > 0f) { return; } _retargetTimer = Random.Range(0.9f, 1.6f); ItemGun val = FindNearestGun(); if (!Object.op_Implicit((Object)(object)val) || !TryClaim(val)) { return; } _busy = true; Vector3 position = ((Component)val).transform.position; if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val2, 2.5f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val2)).position); } else { _agent.SetDestination(position); } _agent.stoppingDistance = 0.35f; } ((MonoBehaviour)this).StartCoroutine(ApproachAndPick(val)); } private IEnumerator ApproachAndPick(ItemGun target) { float giveUp = 8f; _pgo = (Object.op_Implicit((Object)(object)target) ? ((Component)target).GetComponent<PhysGrabObject>() : null); while (giveUp > 0f && Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { giveUp -= Time.deltaTime; if (!IsValidTarget(target) || Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position) <= 1.8f) { break; } yield return null; } if (!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)_agent) || !_agent.isOnNavMesh || !IsValidTarget(target)) { if (Object.op_Implicit((Object)(object)target)) { Release(target); } _busy = false; _brain.SetExternalControl(on: false); yield break; } _gun = target; _pgo = ((Component)target).GetComponent<PhysGrabObject>(); _rb = (Object.op_Implicit((Object)(object)_pgo) ? _pgo.rb : null) ?? ((Component)target).GetComponent<Rigidbody>(); try { Transform transform = ((Component)target).transform; transform.SetParent(_hold, false); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; if (Object.op_Implicit((Object)(object)_rb)) { _rb.velocity = Vector3.zero; _rb.angularVelocity = Vector3.zero; _rb.isKinematic = true; } } catch { } SetCarryCollisionIgnore(ignore: true); HookGunEvents(_gun, on: true); _brain.SetExternalControl(on: true); _busy = false; } private void AimAndShoot() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: 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_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) //IL_007c: 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_0166: Unknown result type (might be due to invalid IL or missing references) _toyTimer -= Time.deltaTime; _fireTimer -= Time.deltaTime; Vector3 aimPos; Transform val = FindEnemyConstrained(out aimPos); Vector3 val2 = aimPos - _hold.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude > 0.0001f) { _hold.rotation = Quaternion.Slerp(_hold.rotation, Quaternion.LookRotation(normalized, Vector3.up), Time.deltaTime * 10f); } if (Object.op_Implicit((Object)(object)_persona) && _persona.ToyingChance > 0f && _toyTimer <= 0f) { _toyTimer = Random.Range(1.5f, 3.5f); if (Random.value < _persona.ToyingChance && Object.op_Implicit((Object)(object)_pgo)) { ItemToggle val3 = (Object.op_Implicit((Object)(object)_gun) ? ((Component)_gun).GetComponent<ItemToggle>() : null); if (Object.op_Implicit((Object)(object)val3)) { val3.ToggleItem(!val3.toggleState, -1); } } } if (_fireTimer <= 0f) { _fireTimer = (Object.op_Implicit((Object)(object)_persona) ? Random.Range(_persona.FireInterval.x, _persona.FireInterval.y) : Random.Range(0.8f, 1.6f)); if (Object.op_Implicit((Object)(object)val)) { _gun.Shoot(); } if (Object.op_Implicit((Object)(object)_persona) && _persona.DropChanceOnShoot > 0f && Random.value < _persona.DropChanceOnShoot) { Drop(immediate: false); } } } private void EnsureHeldTransform() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_gun)) { Transform transform = ((Component)_gun).transform; if ((Object)(object)transform.parent != (Object)(object)_hold) { transform.SetParent(_hold, false); } if (transform.localPosition != Vector3.zero) { transform.localPosition = Vector3.zero; } if (transform.localRotation != Quaternion.identity) { transform.localRotation = Quaternion.identity; } if (Object.op_Implicit((Object)(object)_rb) && !_rb.isKinematic) { _rb.velocity = Vector3.zero; _rb.angularVelocity = Vector3.zero; _rb.isKinematic = true; } } } private void Drop(bool immediate) { //IL_0054: 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) if (!Object.op_Implicit((Object)(object)_gun)) { return; } try { HookGunEvents(_gun, on: false); SetCarryCollisionIgnore(ignore: false); ((Component)_gun).transform.SetParent((Transform)null, true); if (Object.op_Implicit((Object)(object)_rb)) { _rb.isKinematic = false; _rb.velocity = Vector3.zero; _rb.angularVelocity = Vector3.zero; } } catch { } Release(_gun); _gun = null; _pgo = null; _rb = null; _brain.SetExternalControl(on: false); } private bool IsValidTarget(ItemGun g) { if (!Object.op_Implicit((Object)(object)g)) { return false; } int instanceID = ((Object)g).GetInstanceID(); if (EmptyUntil.TryGetValue(instanceID, out var value) && value > Time.time) { return false; } PhysGrabObject component = ((Component)g).GetComponent<PhysGrabObject>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } if (SemiFunc.PhysGrabObjectIsGrabbed(component)) { return false; } return true; } private ItemGun FindNearestGun() { //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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) ItemGun result = null; float num = float.PositiveInfinity; ItemGun[] array = Object.FindObjectsOfType<ItemGun>(); Vector3 position = ((Component)this).transform.position; float num2 = _cfg.SearchRadius * _cfg.SearchRadius; foreach (ItemGun val in array) { if (Object.op_Implicit((Object)(object)val) && IsValidTarget(val) && !IsLikelyInsideExtractor(((Component)val).transform) && (!Claims.TryGetValue(((Object)val).GetInstanceID(), out BotWeaponUser value) || !Object.op_Implicit((Object)(object)value) || !((Object)(object)value != (Object)(object)this))) { Vector3 val2 = ((Component)val).transform.position - position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude > num2) && sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } private Transform FindEnemyConstrained(out Vector3 aimPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_011d: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) aimPos = ((Component)this).transform.position + ((Component)this).transform.forward * 6f; Enemy[] array = Object.FindObjectsOfType<Enemy>(); Transform result = null; float num = float.PositiveInfinity; Vector3 val = (Object.op_Implicit((Object)(object)_hold) ? _hold.position : (((Component)this).transform.position + Vector3.up * 1.5f)); float num2 = Mathf.Cos((Object.op_Implicit((Object)(object)_persona) ? Mathf.Max(1f, _persona.AimConeDegrees) : 8f) * (MathF.PI / 180f)); RaycastHit val5 = default(RaycastHit); foreach (Enemy val2 in array) { if (!Object.op_Implicit((Object)(object)val2) || !((Component)val2).gameObject.activeInHierarchy) { continue; } Transform transform = ((Component)val2).transform; Vector3 val3 = transform.position + Vector3.up * 0.6f; Vector3 val4 = val3 - val; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (!(sqrMagnitude > 900f)) { Vector3 normalized = ((Vector3)(ref val4)).normalized; if (!(Vector3.Dot(((Component)this).transform.forward, normalized) < num2) && (!Physics.Raycast(val, normalized, ref val5, Mathf.Sqrt(sqrMagnitude), -1, (QueryTriggerInteraction)1) || (Object.op_Implicit((Object)(object)((RaycastHit)(ref val5)).collider) && Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<Enemy>()))) && sqrMagnitude < num) { num = sqrMagnitude; result = transform; aimPos = val3; } } } return result; } private bool IsLikelyInsideExtractor(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) ExtractionPoint val = SemiFunc.ExtractionPointGetNearest(t.position); if (!Object.op_Implicit((Object)(object)val)) { return false; } return Vector3.Distance(t.position, ((Component)val).transform.position) <= 1.25f; } private void SetCarryCollisionIgnore(bool ignore) { if (!Object.op_Implicit((Object)(object)_gun)) { return; } _gunCols.Clear(); ((Component)_gun).GetComponentsInChildren<Collider>(true, _gunCols); if (_myCols == null || _myCols.Length == 0) { _myCols = ((Component)this).GetComponentsInChildren<Collider>(true); } for (int i = 0; i < _myCols.Length; i++) { Collider val = _myCols[i]; if (!Object.op_Implicit((Object)(object)val)) { continue; } for (int j = 0; j < _gunCols.Count; j++) { Collider val2 = _gunCols[j]; if (Object.op_Implicit((Object)(object)val2)) { Physics.IgnoreCollision(val, val2, ignore); } } } } private void HookGunEvents(ItemGun g, bool on) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)g) && _subscribed != on) { _subscribed = on; if (on) { g.onStateOutOfAmmoStart.AddListener(new UnityAction(OnGunOutOfAmmoStart)); } else { g.onStateOutOfAmmoStart.RemoveListener(new UnityAction(OnGunOutOfAmmoStart)); } } } private void OnGunOutOfAmmoStart() { if (Object.op_Implicit((Object)(object)_gun)) { int instanceID = ((Object)_gun).GetInstanceID(); EmptyUntil[instanceID] = Time.time + 25f; } Drop(immediate: false); } private bool TryClaim(ItemGun g) { if (!Object.op_Implicit((Object)(object)g)) { return false; } int instanceID = ((Object)g).GetInstanceID(); if (Claims.TryGetValue(instanceID, out BotWeaponUser value) && Object.op_Implicit((Object)(object)value) && (Object)(object)value != (Object)(object)this) { return false; } Claims[instanceID] = this; return true; } private void Release(ItemGun g) { if (Object.op_Implicit((Object)(object)g)) { int instanceID = ((Object)g).GetInstanceID(); if (Claims.TryGetValue(instanceID, out BotWeaponUser value) && (Object)(object)value == (Object)(object)this) { Claims.Remove(instanceID); } } } } internal static class DecTalkSynth { internal struct Clip { public float[] Samples; public int Channels; public int SampleRate; } private struct Job { public BotChatterAgent Agent; public string Text; } private struct Ready { public BotChatterAgent Agent; public Clip Clip; } private static class Wav { internal static bool TryLoad(string path, out float[] data, out int channels, out int sampleRate) { data = Array.Empty<float>(); channels = 0; sampleRate = 0; using FileStream input = File.OpenRead(path); using BinaryReader binaryReader = new BinaryReader(input); if (new string(binaryReader.ReadChars(4)) != "RIFF") { return false; } binaryReader.ReadInt32(); if (new string(binaryReader.ReadChars(4)) != "WAVE") { return false; } short num = 1; short num2 = 16; bool flag = false; while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length) { string text = new string(binaryReader.ReadChars(4)); int num3 = binaryReader.ReadInt32(); if (text == "fmt ") { flag = true; num = binaryReader.ReadInt16(); channels = binaryReader.ReadInt16(); sampleRate = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt16(); num2 = binaryReader.ReadInt16(); int num4 = num3 - 16; if (num4 > 0) { binaryReader.ReadBytes(num4); } continue; } if (text == "data") { if (!flag) { return false; } byte[] array = binaryReader.ReadBytes(num3); if (num != 1) { return false; } switch (num2) { case 16: { int num6 = array.Length / 2; float[] array3 = new float[num6]; int num7 = 0; int num8 = 0; while (num7 < num6) { short num9 = (short)(array[num8] | (array[num8 + 1] << 8)); array3[num7] = (float)num9 / 32768f; num7++; num8 += 2; } data = array3; return true; } case 8: { int num5 = array.Length; float[] array2 = new float[num5]; for (int i = 0; i < num5; i++) { array2[i] = (float)(array[i] - 128) / 128f; } data = array2; return true; } default: return false; } } binaryReader.ReadBytes(num3); } return false; } internal static float[] ResampleLinear(float[] interleaved, int channels, int srcRate, int dstRate) { if (srcRate == dstRate) { return interleaved; } int num = interleaved.Length / channels; double num2 = (double)dstRate / (double)srcRate; int num3 = Mathf.Max(1, (int)Math.Round((double)num * num2)); float[] array = new float[num3 * channels]; for (int i = 0; i < channels; i++) { for (int j = 0; j < num3; j++) { double num4 = (double)j / num2; int num5 = (int)Math.Floor(num4); int num6 = Math.Min(num - 1, num5 + 1); double num7 = num4 - (double)num5; float num8 = interleaved[num5 * channels + i]; float num9 = interleaved[num6 * channels + i]; array[j * channels + i] = (float)((double)num8 + (double)(num9 - num8) * num7); } } return array; } } private static string _exe; private static string _voice; private static int _rate; private static string _dict; private static readonly ConcurrentQueue<Job> _jobs = new ConcurrentQueue<Job>(); private static readonly ConcurrentQueue<Ready> _ready = new ConcurrentQueue<Ready>(); private static readonly Dictionary<string, Clip> _cache = new Dictionary<string, Clip>(64); private static readonly LinkedList<string> _lru = new LinkedList<string>(); private static Thread _worker; private static volatile bool _run; internal static void Configure(string exe, string voice, int sampleRate, string dictionaryPath) { _exe = ResolvePath(exe); _voice = (string.IsNullOrWhiteSpace(voice) ? "Paul" : voice.Trim()); _rate = Mathf.Clamp(sampleRate, 8000, 48000); _dict = (string.IsNullOrWhiteSpace(dictionaryPath) ? "" : ResolvePath(dictionaryPath.Trim())); StartWorker(); } internal static void Enqueue(BotChatterAgent who, string text) { if (!((Object)(object)who == (Object)null) && !string.IsNullOrWhiteSpace(text)) { _jobs.Enqueue(new Job { Agent = who, Text = text }); StartWorker(); } } internal static bool TryDequeueReady(out BotChatterAgent who, out Clip clip) { who = null; clip = default(Clip); if (_ready.TryDequeue(out var result)) { who = result.Agent; clip = result.Clip; return true; } return false; } internal static bool TrySynthesize(string text, out Clip clip) { clip = default(Clip); if (!TrySynthesizeInternal(text, out clip)) { return false; } return true; } private static void StartWorker() { if (_worker == null || !_worker.IsAlive) { _run = true; _worker = new Thread(WorkerLoop) { IsBackground = true, Name = "DecTalkSynthWorker" }; _worker.Start(); } } private static void WorkerLoop() { while (_run) { Clip clip; if (!_jobs.TryDequeue(out var result)) { Thread.Sleep(1); } else if (!((Object)(object)result.Agent == (Object)null) && TrySynthesizeInternal(result.Text, out clip)) { _ready.Enqueue(new Ready { Agent = result.Agent, Clip = clip }); } } } private static bool TrySynthesizeInternal(string text, out Clip clip) { clip = default(Clip); if (string.IsNullOrEmpty(_exe) || !File.Exists(_exe)) { return false; } if (TryGetCache(text, out clip)) { return true; } try { string text2 = "[:name " + _voice + "] " + text; string text3 = Path.GetDirectoryName(_exe) ?? Directory.GetCurrentDirectory(); string text4 = Path.Combine(text3, "out"); Directory.CreateDirectory(text4); string text5 = DateTime.UtcNow.Ticks.ToString("x"); string text6 = Path.Combine(text4, "dt_" + text5 + ".wav"); string text7 = ""; if (!string.IsNullOrEmpty(_dict) && File.Exists(_dict)) { text7 = "-d \"" + _dict + "\" "; } ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = _exe; processStartInfo.Arguments = "-w \"" + text6 + "\" " + text7 + "\"" + text2 + "\""; processStartInfo.WorkingDirectory = text3; processStartInfo.CreateNoWindow = true; processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardOutput = true; processStartInfo.RedirectStandardError = true; using (Process process = Process.Start(processStartInfo)) { process?.WaitForExit(15000); } if (!File.Exists(text6)) { return false; } if (!Wav.TryLoad(text6, out float[] data, out int channels, out int sampleRate)) { return false; } if (sampleRate != _rate) { data = Wav.ResampleLinear(data, channels, sampleRate, _rate); sampleRate = _rate; } clip = new Clip { Samples = data, Channels = channels, SampleRate = sampleRate }; try { File.Delete(text6); } catch { } PutCache(text, clip); return true; } catch { return false; } } private static bool TryGetCache(string text, out Clip clip) { if (_cache.TryGetValue(text, out clip)) { LinkedListNode<string> linkedListNode = _lru.Find(text); if (linkedListNode != null) { _lru.Remove(linkedListNode); _lru.AddFirst(linkedListNode); } return true; } return false; } private static void PutCache(string text, Clip clip) { if (_cache.ContainsKey(text)) { return; } _cache[text] = clip; _lru.AddFirst(text); if (_lru.Count > 64) { LinkedListNode<string> last = _lru.Last; if (last != null) { _cache.Remove(last.Value); _lru.RemoveLast(); } } } private static string ResolvePath(string p) { if (Path.IsPathRooted(p)) { return p; } string location = Assembly.GetExecutingAssembly().Location; return Path.GetFullPath(Path.Combine(string.IsNullOrEmpty(location) ? Directory.GetCurrentDirectory() : (Path.GetDirectoryName(location) ?? Directory.GetCurrentDirectory()), p)); } } internal class StupidBotBrain : MonoBehaviour { internal struct Config { public bool FollowPlayer; public float WanderRadius; public float Speed; } private const float FollowOrbitRadius = 12f; private Config _cfg; private NavMeshAgent? _agent; private Transform? _player; private Vector3 _homePos; private float _retargetTimer; private float _emoteTimer; private Vector3 _lastPos; private float _stuckTimer; private bool _hopping; private readonly List<Vector3> _globalTargets = new List<Vector3>(); private bool _haveGlobal; internal bool ExternalControl { get; private set; } internal void SetExternalControl(bool on) { ExternalControl = on; } internal void Init(Config cfg) { _cfg = cfg; } private void Start() { //IL_0068: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) _agent = ((Component)this).GetComponent<NavMeshAgent>(); if (Object.op_Implicit((Object)(object)_agent)) { if (!_agent.isOnNavMesh) { TryPlaceOnNavMesh(_agent, ((Component)this).transform.position); } _agent.isStopped = false; _agent.updateRotation = true; _agent.autoBraking = true; } _homePos = ((Component)this).transform.position; TryGetPlayer(out _player); _retargetTimer = Random.Range(0.25f, 1.25f); _emoteTimer = Random.Range(2.5f, 7.5f); _lastPos = ((Component)this).transform.position; BuildGlobalTargets(); } private void Update() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_agent) && ((Behaviour)_agent).enabled) { _agent.speed = _cfg.Speed; } if ((Object)(object)_player == (Object)null) { TryGetPlayer(out _player); } if (ExternalControl) { return; } _retargetTimer -= Time.deltaTime; bool flag = false; if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { bool num = !_agent.hasPath || (int)_agent.pathStatus > 0; bool flag2 = _agent.hasPath && !_agent.pathPending && _agent.remainingDistance <= _agent.stoppingDistance + 0.1f; if (num || flag2 || _retargetTimer <= 0f) { flag = true; } } else if (_retargetTimer <= 0f) { flag = true; } if (flag) { _retargetTimer = Random.Range(1.6f, 3.2f); PickNextDestination(); } _emoteTimer -= Time.deltaTime; if (_emoteTimer <= 0f) { _emoteTimer = Random.Range(4f, 10f); TryHop(); } Vector3 val; if (Object.op_Implicit((Object)(object)_agent) && _agent.hasPath) { val = _agent.velocity; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { val = _agent.velocity; Vector3 normalized = ((Vector3)(ref val)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude > 0.001f) { Quaternion val2 = Quaternion.LookRotation(normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * 5f); } } } val = ((Component)this).transform.position - _lastPos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; _stuckTimer = ((sqrMagnitude < 0.0009f) ? (_stuckTimer + Time.deltaTime) : 0f); _lastPos = ((Component)this).transform.position; if (_stuckTimer > 1.5f && Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { _stuckTimer = 0f; _agent.ResetPath(); _agent.Warp(((Component)this).transform.position); } } private void PickNextDestination() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_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_004d: 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_0068: 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_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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0120: 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_016a: 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_00dd: 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_00f5: Unknown result type (might be due to invalid IL or missing references) Vector3 homePos = _homePos; if (_cfg.FollowPlayer && Object.op_Implicit((Object)(object)_player)) { Vector3 val = Random.insideUnitSphere; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } homePos = _player.position + ((Vector3)(ref val)).normalized * Random.Range(2.5f, 12f); } else if (_haveGlobal) { int index = Random.Range(0, _globalTargets.Count); homePos = _globalTargets[index]; } else { homePos = _homePos + Random.insideUnitSphere.WithY(0f) * 25f; } if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(homePos, ref val2, 3f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val2)).position); } else { _agent.SetDestination(homePos); } return; } Vector3 val3 = homePos - ((Component)this).transform.position; val3.y = 0f; float num = Mathf.Min(_cfg.Speed * 0.5f * Time.deltaTime, ((Vector3)(ref val3)).magnitude); if (num > 0f) { Transform transform = ((Component)this).transform; transform.position += ((Vector3)(ref val3)).normalized * num; } } private void TryHop() { if (!((Object)(object)_agent == (Object)null) && !_hopping) { ((MonoBehaviour)this).StartCoroutine(HopCR()); } } private IEnumerator HopCR() { _hopping = true; float start = _agent.baseOffset; float peak = start + 0.6f; float t2 = 0f; float up = 0.15f; while (t2 < up) { t2 += Time.deltaTime; _agent.baseOffset = Mathf.Lerp(start, peak, t2 / up); yield return null; } t2 = 0f; float down = 0.2f; while (t2 < down) { t2 += Time.deltaTime; _agent.baseOffset = Mathf.Lerp(peak, start, t2 / down); yield return null; } _agent.baseOffset = start; _hopping = false; } private static bool TryGetPlayer(out Transform? player) { player = null; try { if (Object.op_Implicit((Object)(object)PlayerController.instance)) { player = ((Component)PlayerController.instance).transform; return true; } } catch { } try { PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>(); if (array != null && array.Length != 0) { player = ((Component)array[0]).transform; return true; } } catch { } return false; } private static bool TryPlaceOnNavMesh(NavMeshAgent agent, Vector3 desired) { //IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(desired, ref val, 6f, -1)) { return agent.Warp(((NavMeshHit)(ref val)).position); } return agent.Warp(desired); } private void BuildGlobalTargets() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0064: Unknown result type (might be due to invalid IL or missing references) _globalTargets.Clear(); try { if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.LevelPathPoints != null) { List<LevelPoint> levelPathPoints = LevelGenerator.Instance.LevelPathPoints; NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < levelPathPoints.Count; i++) { LevelPoint val = levelPathPoints[i]; if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position, ref val2, 3f, -1)) { _globalTargets.Add(((NavMeshHit)(ref val2)).position); } } } } catch { } if (_globalTargets.Count == 0) { try { Vector3[] vertices = NavMesh.CalculateTriangulation().vertices; int num = Mathf.Max(1, vertices.Length / 64); NavMeshHit val3 = default(NavMeshHit); for (int j = 0; j < vertices.Length; j += num) { if (NavMesh.SamplePosition(vertices[j], ref val3, 3f, -1)) { _globalTargets.Add(((NavMeshHit)(ref val3)).position); } } } catch { } } _haveGlobal = _globalTargets.Count > 0; } } internal class StupidBotCarrier : MonoBehaviour { internal struct Cfg { public float SearchRadius; public float ExtractorStopDistance; public float GentleDropTime; } private Cfg _cfg; private NavMeshAgent _agent; private Transform _hold; private StupidBotBrain _brain; private int _lastActivateId; private float _lastActivateTime; private Vector3 _truckDestination; private bool _truckCached; private PhysGrabObject _carried; private Rigidbody _carriedRB; private bool _busy; private bool _dropping; private float _retargetTimer; private float _savedStopDist; private Collider[] _myCols; private readonly List<Collider> _carriedCols = new List<Collider>(); private readonly HashSet<int> _ignoreIds = new HashSet<int>(); private float _activationGraceUntil; private float _carryTimer; private bool _isJumping; private float _jumpCD; private readonly Collider[] _overlap = (Collider[])(object)new Collider[32]; private void OnDisable() { if (Object.op_Implicit((Object)(object)_carried)) { ForceDrop(immediate: true); } } internal void Init(Cfg cfg, NavMeshAgent agent, Transform holdPoint, StupidBotBrain brain) { _myCols = ((Component)this).GetComponentsInChildren<Collider>(true); _cfg = cfg; _agent = agent; _hold = holdPoint; _brain = brain; _retargetTimer = Random.Range(0.25f, 0.75f); _activationGraceUntil = 0f; _carryTimer = 0f; _isJumping = false; _jumpCD = 0f; } private void Update() { //IL_01e9: 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_00c6: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: 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_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_carried)) { _brain.SetExternalControl(on: true); _carryTimer += Time.deltaTime; ExtractionPoint targetEP = null; if (TryResolveDeliveryTarget(out Vector3 goal, out targetEP)) { if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { if (!_agent.hasPath || Vector3.SqrMagnitude(_agent.destination - goal) > 0.25f) { _agent.SetDestination(goal); } _agent.stoppingDistance = Mathf.Clamp(_cfg.ExtractorStopDistance * 0.5f, 0.2f, 1f); } float num = Vector3.Distance(((Component)this).transform.position, goal); if (!_dropping && num <= Mathf.Max(0.5f, _cfg.ExtractorStopDistance + 0.25f)) { if (IsDeliveryDropAllowed(targetEP) || Time.time < _activationGraceUntil || _carryTimer > 12f) { _dropping = true; ((MonoBehaviour)this).StartCoroutine(DropGently()); } else if (Object.op_Implicit((Object)(object)targetEP)) { TryActivateExtraction(targetEP); } } } if (Object.op_Implicit((Object)(object)_carried) && !_dropping) { Transform transform = ((Component)_carried).transform; if ((Object)(object)transform.parent != (Object)(object)_hold) { transform.SetParent(_hold, false); } transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; } return; } _carryTimer = 0f; if (_busy) { return; } _retargetTimer -= Time.deltaTime; if (_retargetTimer > 0f) { return; } _retargetTimer = Random.Range(0.9f, 1.4f); List<PhysGrabObject> list = BotUtils.FindNearbyValuables(((Component)this).transform.position, _cfg.SearchRadius); PhysGrabObject val = null; float num2 = float.PositiveInfinity; foreach (PhysGrabObject item in list) { if (Object.op_Implicit((Object)(object)item) && !SemiFunc.PhysGrabObjectIsGrabbed(item) && Object.op_Implicit((Object)(object)((Component)item).GetComponent<ValuableObject>()) && !_ignoreIds.Contains(((Object)item).GetInstanceID()) && !BotUtils.IsIgnored(item) && !BotUtils.IsClaimedByOther(item, this) && !IsLikelyInsideExtractor(((Component)item).transform)) { float num3 = Vector3.SqrMagnitude(((Component)item).transform.position - ((Component)this).transform.position); if (num3 < num2) { num2 = num3; val = item; } } } if (!Object.op_Implicit((Object)(object)val) || !BotUtils.TryClaim(val, this)) { return; } _brain.SetExternalControl(on: true); _busy = true; if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { Vector3 position = ((Component)val).transform.position; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val2, 2.5f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val2)).position); } else { _agent.SetDestination(position); } } ((MonoBehaviour)this).StartCoroutine(ApproachAndPick(val)); } private IEnumerator ApproachAndPick(PhysGrabObject target) { float stoppingDistance = 0.15f; float prevStop = (Object.op_Implicit((Object)(object)_agent) ? _agent.stoppingDistance : 0f); if (Object.op_Implicit((Object)(object)_agent)) { _agent.stoppingDistance = stoppingDistance; } float giveUp = 10f; while (giveUp > 0f && Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { giveUp -= Time.deltaTime; if (BotUtils.IsClaimedByOther(target, this)) { BotUtils.ReleaseClaim(target, this); break; } if (CanReachByHold(target) || CanTouchTarget(target)) { break; } TryJumpAssist(target); yield return null; } if (Object.op_Implicit((Object)(object)_agent)) { _agent.stoppingDistance = prevStop; } if (!Object.op_Implicit((Object)(object)target)) { _busy = false; _brain.SetExternalControl(on: false); yield break; } if (!Object.op_Implicit((Object)(object)_agent) || !_agent.isOnNavMesh) { BotUtils.ReleaseClaim(target, this); _busy = false; _brain.SetExternalControl(on: false); yield break; } if (SemiFunc.PhysGrabObjectIsGrabbed(target)) { BotUtils.ReleaseClaim(target, this); _busy = false; _brain.SetExternalControl(on: false); yield break; } if (!CanReachByHold(target) && !CanTouchTarget(target)) { BotUtils.ReleaseClaim(target, this); _busy = false; _brain.SetExternalControl(on: false); yield break; } bool flag = false; Vector3 val = (Object.op_Implicit((Object)(object)_hold) ? _hold.position : (((Component)this).transform.position + Vector3.up * 1.5f)); Vector3 val2 = ((Component)target).transform.position + Vector3.up * 0.1f; RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val, val2, ref val3, -1, (QueryTriggerInteraction)1)) { Transform transform = ((RaycastHit)(ref val3)).transform; if (Object.op_Implicit((Object)(object)transform) && (Object)(object)transform != (Object)(object)((Component)target).transform && !transform.IsChildOf(((Component)target).transform)) { flag = true; } } if (flag && (CanReachByHold(target) || CanTouchTarget(target))) { flag = false; } if (flag) { BotUtils.ReleaseClaim(target, this); _busy = false; _brain.SetExternalControl(on: false); yield break; } if (Object.op_Implicit((Object)(object)target.rb) && !target.rb.isKinematic && (CanReachByHold(target) || CanTouchTarget(target))) { Vector3 val4 = (((Component)target).transform.position - ((Component)this).transform.position).WithY(0f); Vector3 val5 = ((Vector3)(ref val4)).normalized; if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = ((Component)this).transform.forward; } try { target.rb.AddForce(val5 * 1.25f + Vector3.down * 2f, (ForceMode)1); } catch { } yield return (object)new WaitForSeconds(0.05f); } DetachExternalLinks(target); _carried = target; _carriedRB = target.rb; try { ((Component)_carried).transform.SetParent((Transform)null, true); if (Object.op_Implicit((Object)(object)_carriedRB)) { _carriedRB.velocity = Vector3.zero; _carriedRB.angularVelocity = Vector3.zero; _carriedRB.isKinematic = true; } target.OverrideKnockOutOfGrabDisable(2f); } catch { } SetCarryCollisionIgnore(ignore: true); if (Object.op_Implicit((Object)(object)_agent)) { _savedStopDist = _agent.stoppingDistance; } _carryTimer = 0f; } private bool CanReachByHold(PhysGrabObject target) { //IL_0034: 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_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_0039: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Object.op_Implicit((Object)(object)_hold) ? _hold.position : (((Component)this).transform.position + Vector3.up * 1.5f)); float num = float.PositiveInfinity; float num2 = float.PositiveInfinity; _carriedCols.Clear(); ((Component)target).GetComponentsInChildren<Collider>(true, _carriedCols); for (int i = 0; i < _carriedCols.Count; i++) { Collider val2 = _carriedCols[i]; if (Object.op_Implicit((Object)(object)val2)) { Vector3 val3 = val2.ClosestPoint(val); float num3 = Vector3.Distance(val, val3); if (num3 < num) { num = num3; } float num4 = Mathf.Abs(val3.y - val.y); if (num4 < num2) { num2 = num4; } } } if (float.IsInfinity(num)) { num = Vector3.Distance(val, ((Component)target).transform.position); num2 = Mathf.Abs(((Component)target).transform.position.y - val.y); } Vector3 position = ((Component)this).transform.position; position.y = 0f; Vector3 position2 = ((Component)target).transform.position; position2.y = 0f; float num5 = Vector3.Distance(position, position2); if (num <= 1.5f && num5 <= 2.2f) { return true; } if (num5 <= 2.5f && num2 <= 2.2f) { return true; } return false; } private bool CanTouchTarget(PhysGrabObject target) { //IL_0034: 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_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) int num = Physics.OverlapSphereNonAlloc(Object.op_Implicit((Object)(object)_hold) ? _hold.position : (((Component)this).transform.position + Vector3.up * 1.5f), 0.5f, _overlap, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { Collider obj = _overlap[i]; Transform val = ((obj != null) ? ((Component)obj).transform : null); if (Object.op_Implicit((Object)(object)val) && ((Object)(object)val == (Object)(object)((Component)target).transform || val.IsChildOf(((Component)target).transform))) { return true; } } return false; } private void DetachExternalLinks(PhysGrabObject target) { try { Joint[] componentsInChildren = ((Component)target).GetComponentsInChildren<Joint>(true); foreach (Joint val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Rigidbody connectedBody = val.connectedBody; if (!Object.op_Implicit((Object)(object)connectedBody)) { continue; } Transform transform = ((Component)connectedBody).transform; if (Object.op_Implicit((Object)(object)transform) && !transform.IsChildOf(((Component)target).transform) && (Object)(object)transform != (Object)(object)((Component)target).transform) { try { Object.Destroy((Object)(object)val); } catch { } } } } catch { } try { ((Component)target).transform.SetParent((Transform)null, true); } catch { } } private IEnumerator DropGently() { if (!Object.op_Implicit((Object)(object)_carried)) { _dropping = false; yield break; } Transform tform = ((Component)_carried).transform; try { tform.SetParent((Transform)null, true); } catch { } Vector3 start = tform.position; ExtractionPoint val = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position); Vector3 val2; Vector3 val3; if (!Object.op_Implicit((Object)(object)val)) { val2 = ((Component)this).transform.forward; } else { val3 = (((Component)val).transform.position - ((Component)this).transform.position).WithY(0f); val2 = ((Vector3)(ref val3)).normalized; } Vector3 val4 = val2; if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = ((Component)this).transform.forward; } Vector3 end = start + val4 * 0.6f + Vector3.down * 0.3f; float t = 0f; float dur = Mathf.Max(0.05f, _cfg.GentleDropTime); while (t < dur && Object.op_Implicit((Object)(object)_carried)) { t += Time.deltaTime; float num = Mathf.Clamp01(t / dur); tform.position = Vector3.Lerp(start, end, num); tform.rotation = Quaternion.Slerp(tform.rotation, Quaternion.identity, num * 0.5f); yield return null; } ForceDropInternal(reenableCollision: false); if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { Vector3 position = ((Component)this).transform.position; val3 = Random.insideUnitSphere.WithY(0f); NavMeshHit val5 = default(NavMeshHit); if (NavMesh.SamplePosition(position + ((Vector3)(ref val3)).normalized * 1.2f, ref val5, 2f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val5)).position); } } yield return (object)new WaitForFixedUpdate(); HardReleaseAndSeparate(((Component)this).transform.position); FinalizeDropCommon(); _dropping = false; } private void HardReleaseAndSeparate(Vector3 awayFrom, float minSeparation = 0.9f) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0145: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_017f: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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) if ((Object)(object)_carried == (Object)null) { return; } try { ((Component)_carried).transform.SetParent((Transform)null, true); } catch { } try { SetCarryCollisionIgnore(ignore: false); } catch { } if (Object.op_Implicit((Object)(object)_carriedRB)) { try { _carriedRB.isKinematic = false; _carriedRB.detectCollisions = true; if ((int)_carriedRB.collisionDetectionMode == 0) { _carriedRB.collisionDetectionMode = (CollisionDetectionMode)2; } _carriedRB.velocity = Vector3.zero; _carriedRB.angularVelocity = Vector3.zero; } catch { } } try { Joint[] components = ((Component)((Component)_carried).transform).GetComponents<Joint>(); foreach (Joint val in components) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Rigidbody connectedBody = val.connectedBody; if (Object.op_Implicit((Object)(object)connectedBody) && !((Object)(object)((Component)connectedBody).transform == (Object)null) && ((Object)(object)((Component)connectedBody).transform == (Object)(object)((Component)this).transform || ((Component)connectedBody).transform.IsChildOf(((Component)this).transform))) { try { Object.Destroy((Object)(object)val); } catch { } } } } catch { } Vector3 val2 = (((Component)_carried).transform.position - awayFrom).WithY(0f); if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = ((Component)this).transform.forward; } val2 = ((Vector3)(ref val2)).normalized; Vector3 position = ((Component)_carried).transform.position + val2 * minSeparation; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(((Component)_carried).transform.position + Vector3.up * 0.1f, val2, ref val3, minSeparation, -1, (QueryTriggerInteraction)1)) { position = ((RaycastHit)(ref val3)).point - val2 * 0.05f; } ((Component)_carried).transform.position = position; Physics.SyncTransforms(); try { if (Object.op_Implicit((Object)(object)_carriedRB)) { _carriedRB.AddForce(val2 * 1.25f, (ForceMode)1); } } catch { } } private void ForceDrop(bool immediate) { //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_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_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_006c: Unknown result type (might be due to invalid IL or missing references) ForceDropInternal(reenableCollision: true); if (!immediate && Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { Vector3 position = ((Component)this).transform.position; Vector3 val = Random.insideUnitSphere.WithY(0f); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(position + ((Vector3)(ref val)).normalized * 1.2f, ref val2, 2f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val2)).position); } } } private void ForceDropInternal(bool reenableCollision) { //IL_006b: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_carried)) { return; } PhysGrabObject carried = _carried; try { ((Component)carried).transform.SetParent((Transform)null, true); if (Object.op_Implicit((Object)(object)_carriedRB) && reenableCollision) { _carriedRB.isKinematic = false; _carriedRB.velocity = Vector3.zero; _carriedRB.angularVelocity = Vector3.zero; } } catch { } ExtractionPoint val = null; try { val = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position); } catch { val = null; } if (Object.op_Implicit((Object)(object)val) && Vector3.Distance(((Component)carried).transform.position, ((Component)val).transform.position) <= Mathf.Max(0.75f, _cfg.ExtractorStopDistance + 0.25f)) { _ignoreIds.Add(((Object)carried).GetInstanceID()); BotUtils.IgnoreFor(carried, 3.5f); } if (!reenableCollision) { return; } try { SetCarryCollisionIgnore(ignore: false); } catch { } try { if (Object.op_Implicit((Object)(object)_carriedRB)) { _carriedRB.isKinematic = false; } } catch { } FinalizeDropCommon(); } private void FinalizeDropCommon() { BotUtils.ReleaseClaim(_carried, this); _carried = null; _carriedRB = null; _busy = false; _brain.SetExternalControl(on: false); _activationGraceUntil = 0f; _carryTimer = 0f; if (Object.op_Implicit((Object)(object)_agent)) { _agent.stoppingDistance = _savedStopDist; } } private bool IsLikelyInsideExtractor(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) ExtractionPoint val = SemiFunc.ExtractionPointGetNearest(t.position); if (!Object.op_Implicit((Object)(object)val)) { return false; } return Vector3.Distance(t.position, ((Component)val).transform.position) <= Mathf.Max(1f, _cfg.ExtractorStopDistance + 0.25f); } private void SetCarryCollisionIgnore(bool ignore) { if ((Object)(object)_carried == (Object)null) { return; } _carriedCols.Clear(); ((Component)_carried).GetComponentsInChildren<Collider>(true, _carriedCols); if (_myCols == null || _myCols.Length == 0) { _myCols = ((Component)this).GetComponentsInChildren<Collider>(true); } for (int i = 0; i < _myCols.Length; i++) { Collider val = _myCols[i]; if (!Object.op_Implicit((Object)(object)val)) { continue; } for (int j = 0; j < _carriedCols.Count; j++) { Collider val2 = _carriedCols[j]; if (Object.op_Implicit((Object)(object)val2)) { try { Physics.IgnoreCollision(val, val2, ignore); } catch { } } } } } private bool TryResolveDeliveryTarget(out Vector3 goal, out ExtractionPoint targetEP) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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) goal = ((Component)this).transform.position; targetEP = null; try { if (Object.op_Implicit((Object)(object)RoundDirector.instance)) { if (RoundDirector.instance.allExtractionPointsCompleted) { goal = GetTruckDestination(); return true; } if (RoundDirector.instance.extractionPointActive && Object.op_Implicit((Object)(object)RoundDirector.instance.extractionPointCurrent)) { targetEP = RoundDirector.instance.extractionPointCurrent; goal = ((Component)targetEP).transform.position; return true; } ExtractionPoint val = SemiFunc.ExtractionPointGetNearestNotActivated(((Component)this).transform.position); if (Object.op_Implicit((Object)(object)val)) { targetEP = val; goal = ((Component)val).transform.position; return true; } } } catch { } ExtractionPoint val2 = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position); if (Object.op_Implicit((Object)(object)val2)) { targetEP = val2; goal = ((Component)val2).transform.position; return true; } return false; } private bool IsDeliveryDropAllowed(ExtractionPoint targetEP) { try { if (Object.op_Implicit((Object)(object)RoundDirector.instance)) { if (RoundDirector.instance.allExtractionPointsCompleted) { return true; } if ((Object)(object)targetEP == (Object)null) { return false; } return RoundDirector.instance.extractionPointActive && (Object)(object)RoundDirector.instance.extractionPointCurrent == (Object)(object)targetEP; } } catch { } return true; } private void TryActivateExtraction(ExtractionPoint ep) { if (!Object.op_Implicit((Object)(object)ep)) { return; } int instanceID = ((Object)ep).GetInstanceID(); if (_lastActivateId == instanceID && Time.time - _lastActivateTime < 0.75f) { return; } _lastActivateId = instanceID; _lastActivateTime = Time.time; _activationGraceUntil = Time.time + 2f; try { ep.ButtonPress(); } catch { } } private Vector3 GetTruckDestination() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (_truckCached) { return _truckDestination; } _truckDestination = ((Component)this).transform.position; try { if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.LevelPathPoints != null) { List<LevelPoint> levelPathPoints = LevelGenerator.Instance.LevelPathPoints; for (int i = 0; i < levelPathPoints.Count; i++) { LevelPoint val = levelPathPoints[i]; if (Object.op_Implicit((Object)(object)val)) { RoomVolume room = val.Room; if (Object.op_Implicit((Object)(object)room) && room.Truck) { _truckDestination = ((Component)val).transform.position; _truckCached = true; break; } } } } } catch { } return _truckDestination; } private void TryJumpAssist(PhysGrabObject target) { //IL_004b: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //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_0089: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!_isJumping && !(_jumpCD > Time.time)) { Vector3 val = (Object.op_Implicit((Object)(object)_hold) ? _hold.position : (((Component)this).transform.position + Vector3.up * 1.5f)); Vector3 val2 = ((Component)target).transform.position - val; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; RaycastHit val3 = default(RaycastHit); if (!(magnitude <= 2.5f) && !(magnitude > 5.5f) && Physics.Raycast(val + Vector3.up * 0.2f, ((Vector3)(ref val2)).normalized, ref val3, magnitude, -1, (QueryTriggerInteraction)1)) {