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.Rendering; 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("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Empress BotFriends")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3+4247eae4b81cc1423970370465980f9d0841d4e8")] [assembly: AssemblyProduct("Empress BotFriends")] [assembly: AssemblyTitle("BotFriends")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.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 EmpressBotAvatarVisual : MonoBehaviour { private const float DefaultSpeed = 4.2f; private const int MaxRandomCosmetics = 4; private static readonly string[] HiddenVisualNameParts = new string[7] { "grab", "grabb", "holder", "suction", "vacuum", "tool", "cart" }; private static readonly string[] PreferredVisibleLayers = new string[2] { "PlayerVisuals", "Default" }; private static readonly CosmeticType[] RandomCosmeticTypes; private static readonly FieldRef PlayerAvatarCosmeticsRef; private static readonly FieldRef VisualsPlayerCosmeticsRef; private static readonly FieldRef PlayerCosmeticsVisualsRef; private static readonly FieldRef> CosmeticParentsRef; private static readonly FieldRef CosmeticParentTypeRef; private static readonly FieldRef CosmeticParentSpringImpulseRef; private static readonly FieldRef CosmeticParentParentRef; private static readonly FieldRef CosmeticParentResetTransformRef; private static readonly FieldRef> BaseMeshParentsRef; private static readonly FieldRef> BaseMeshesRef; private static readonly FieldRef FirstSetupRef; private static readonly FieldRef FirstSetupCoroutineRef; private static readonly FieldRef> CosmeticAssetsRef; private static readonly FieldRef CosmeticAssetTypeRef; private static readonly FieldRef CosmeticAssetPrefabRef; private static readonly MethodInfo InstantiateCosmeticMethod; private NavMeshAgent? _agent; private Animator[] _animators = Array.Empty(); 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(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_0051: 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_0071: 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) 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; } PlayerCosmetics sourceCosmetics = ResolvePlayerCosmetics(player, val); GameObject val2; try { val2 = Object.Instantiate(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, val, sourceCosmetics); TintClone(val2, accent); val2.AddComponent().Init(agent, fallbackSpeed); return CountVisibleRenderers(val2) > 0; } private static GameObject? ResolveAvatarVisualRoot(PlayerAvatar player) { if (!Object.op_Implicit((Object)(object)player)) { return null; } try { if (Object.op_Implicit((Object)(object)player.playerAvatarVisuals)) { return ((Component)player.playerAvatarVisuals).gameObject; } } catch { } 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(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { return ((Component)componentInChildren).gameObject; } } catch { } return null; } private static PlayerCosmetics? ResolvePlayerCosmetics(PlayerAvatar player, GameObject visualRoot) { if (!Object.op_Implicit((Object)(object)player)) { return null; } try { PlayerCosmetics val = PlayerAvatarCosmeticsRef.Invoke(player); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } try { PlayerAvatarVisuals component = visualRoot.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { PlayerCosmetics val2 = VisualsPlayerCosmeticsRef.Invoke(component); if (Object.op_Implicit((Object)(object)val2)) { return val2; } } } catch { } try { PlayerCosmetics componentInChildren = ((Component)player).GetComponentInChildren(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { return componentInChildren; } } catch { } return null; } private static void PrepareClone(GameObject clone, GameObject sourceRoot, PlayerCosmetics? sourceCosmetics) { //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) MonoBehaviour[] componentsInChildren = clone.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (Object.op_Implicit((Object)(object)componentsInChildren[i])) { componentsInChildren[i].StopAllCoroutines(); ((Behaviour)componentsInChildren[i]).enabled = false; } } clone.SetActive(true); int layer = ResolveVisibleLayer(); EnsureCloneCosmetics(clone, sourceRoot, sourceCosmetics); PreventVanillaCosmeticSetup(clone); StripEquippedCosmetics(clone); RestoreBaseAvatarMeshes(clone); RandomizeCloneCosmetics(clone); Transform[] componentsInChildren2 = clone.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if (Object.op_Implicit((Object)(object)componentsInChildren2[j])) { ((Component)componentsInChildren2[j]).gameObject.layer = layer; } } HideNamedVisuals(clone); DisableCloneLights(clone); Renderer[] componentsInChildren3 = clone.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren3) { if (!Object.op_Implicit((Object)(object)val)) { continue; } if (ShouldHide(((Object)((Component)val).gameObject).name)) { val.enabled = false; continue; } val.enabled = true; ((Component)val).gameObject.layer = layer; val.shadowCastingMode = (ShadowCastingMode)1; val.receiveShadows = true; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); if (val2 != null) { val2.updateWhenOffscreen = true; } } Animator[] componentsInChildren4 = clone.GetComponentsInChildren(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(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(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(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(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(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 RandomizeCloneCosmetics(GameObject clone) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00f4: 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) if (!Object.op_Implicit((Object)(object)MetaManager.instance) || InstantiateCosmeticMethod == null) { return; } PlayerCosmetics val = ((IEnumerable)clone.GetComponentsInChildren(true)).FirstOrDefault((Func)((PlayerCosmetics component) => Object.op_Implicit((Object)(object)component))); if (!Object.op_Implicit((Object)(object)val)) { return; } HashSet supportedCosmeticTypes = GetSupportedCosmeticTypes(val); if (supportedCosmeticTypes.Count == 0) { return; } List list = null; try { list = CosmeticAssetsRef.Invoke(MetaManager.instance); } catch { } if (list == null || list.Count == 0) { return; } Dictionary> dictionary = new Dictionary>(); for (int i = 0; i < list.Count; i++) { CosmeticAsset val2 = list[i]; if (!Object.op_Implicit((Object)(object)val2)) { continue; } CosmeticType val3; try { val3 = CosmeticAssetTypeRef.Invoke(val2); } catch { continue; } PrefabRef val4; try { val4 = CosmeticAssetPrefabRef.Invoke(val2); } catch { continue; } if (supportedCosmeticTypes.Contains(val3) && RandomCosmeticTypes.Contains(val3) && val4 != null && val4.IsValid()) { if (!dictionary.TryGetValue(val3, out var value)) { value = (dictionary[val3] = new List()); } value.Add(val2); } } List list3 = dictionary.Keys.OrderBy((CosmeticType _) => Random.value).ToList(); int num = Mathf.Min(4, list3.Count); for (int j = 0; j < num; j++) { List list4 = dictionary[list3[j]]; if (list4.Count == 0) { continue; } CosmeticAsset val5 = list4[Random.Range(0, list4.Count)]; try { object? obj4 = InstantiateCosmeticMethod.Invoke(val, new object[1] { val5 }); GameObject val6 = (GameObject)((obj4 is GameObject) ? obj4 : null); if (Object.op_Implicit((Object)(object)val6)) { val6.SetActive(true); } } catch { } } } private static void EnsureCloneCosmetics(GameObject clone, GameObject sourceRoot, PlayerCosmetics? sourceCosmetics) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)sourceCosmetics)) { return; } PlayerCosmetics val = clone.GetComponentInChildren(true); if (!Object.op_Implicit((Object)(object)val)) { val = clone.AddComponent(); } if (!Object.op_Implicit((Object)(object)val)) { return; } try { ((MonoBehaviour)val).StopAllCoroutines(); } catch { } try { FirstSetupRef.Invoke(val) = false; } catch { } try { FirstSetupCoroutineRef.Invoke(val) = true; } catch { } PlayerAvatarVisuals component = clone.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { try { PlayerCosmeticsVisualsRef.Invoke(val) = component; } catch { } try { VisualsPlayerCosmeticsRef.Invoke(component) = val; } catch { } } List list = null; try { list = CosmeticParentsRef.Invoke(sourceCosmetics); } catch { } if (list == null || list.Count == 0) { return; } List list2 = new List(); for (int i = 0; i < list.Count; i++) { CosmeticParent val2 = list[i]; if (val2 == null) { continue; } Transform val3 = null; List list3 = new List(); List list4 = new List(); try { val3 = MapCloneTransform(CosmeticParentParentRef.Invoke(val2), sourceRoot.transform, clone.transform); } catch { } try { list3 = MapCloneTransforms(BaseMeshParentsRef.Invoke(val2), sourceRoot.transform, clone.transform); } catch { } try { list4 = MapCloneTransforms(BaseMeshesRef.Invoke(val2), sourceRoot.transform, clone.transform); } catch { } if (Object.op_Implicit((Object)(object)val3) && list3.Count != 0) { CosmeticParent val4 = new CosmeticParent(); try { CosmeticParentTypeRef.Invoke(val4) = CosmeticParentTypeRef.Invoke(val2); } catch { continue; } try { CosmeticParentSpringImpulseRef.Invoke(val4) = null; } catch { } try { CosmeticParentParentRef.Invoke(val4) = val3; } catch { } try { CosmeticParentResetTransformRef.Invoke(val4) = CosmeticParentResetTransformRef.Invoke(val2); } catch { } try { BaseMeshParentsRef.Invoke(val4) = list3; } catch { } try { BaseMeshesRef.Invoke(val4) = list4; } catch { } list2.Add(val4); } } if (list2.Count <= 0) { return; } try { CosmeticParentsRef.Invoke(val) = list2; } catch { } } private static HashSet GetSupportedCosmeticTypes(PlayerCosmetics playerCosmetics) { HashSet hashSet = new HashSet(); List list = null; try { list = CosmeticParentsRef.Invoke(playerCosmetics); } catch { } if (list == null) { return hashSet; } for (int i = 0; i < list.Count; i++) { CosmeticParent val = list[i]; if (val == null) { continue; } Transform val2 = null; try { val2 = CosmeticParentParentRef.Invoke(val); } catch { } if (Object.op_Implicit((Object)(object)val2)) { try { hashSet.Add(CosmeticParentTypeRef.Invoke(val)); } catch { } } } return hashSet; } private static List MapCloneTransforms(List? sourceTransforms, Transform sourceRoot, Transform cloneRoot) { List list = new List(); if (sourceTransforms == null) { return list; } for (int i = 0; i < sourceTransforms.Count; i++) { Transform val = MapCloneTransform(sourceTransforms[i], sourceRoot, cloneRoot); if (Object.op_Implicit((Object)(object)val)) { list.Add(val); } } return list; } private static Transform? MapCloneTransform(Transform? source, Transform sourceRoot, Transform cloneRoot) { if (!Object.op_Implicit((Object)(object)source)) { return null; } if ((Object)(object)source == (Object)(object)sourceRoot) { return cloneRoot; } if (!source.IsChildOf(sourceRoot)) { return null; } List list = new List(); Transform val = source; while (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)sourceRoot) { list.Add(val.GetSiblingIndex()); val = val.parent; } Transform val2 = cloneRoot; for (int num = list.Count - 1; num >= 0; num--) { int num2 = list[num]; if (num2 < 0 || num2 >= val2.childCount) { return null; } val2 = val2.GetChild(num2); } return val2; } private static void PreventVanillaCosmeticSetup(GameObject clone) { PlayerCosmetics[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (PlayerCosmetics val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val)) { try { ((MonoBehaviour)val).StopAllCoroutines(); } catch { } try { FirstSetupRef.Invoke(val) = false; } catch { } try { FirstSetupCoroutineRef.Invoke(val) = true; } catch { } } } } private static void StripEquippedCosmetics(GameObject clone) { Cosmetic[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (Cosmetic val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && !((Object)(object)((Component)val).gameObject == (Object)(object)clone)) { ((Component)val).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static void RestoreBaseAvatarMeshes(GameObject clone) { PlayerCosmetics[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (PlayerCosmetics val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } List list = null; try { list = CosmeticParentsRef.Invoke(val); } catch { } if (list == null) { continue; } for (int j = 0; j < list.Count; j++) { CosmeticParent val2 = list[j]; if (val2 != null) { List transforms = null; List transforms2 = null; try { transforms = BaseMeshParentsRef.Invoke(val2); } catch { } try { transforms2 = BaseMeshesRef.Invoke(val2); } catch { } SetBaseMeshesActive(transforms, active: true); SetBaseMeshesActive(transforms2, active: true); } } } } private static void SetBaseMeshesActive(List? transforms, bool active) { if (transforms == null) { return; } for (int i = 0; i < transforms.Count; i++) { Transform val = transforms[i]; if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(active); } } } private static void DisableCloneLights(GameObject clone) { Light[] componentsInChildren = clone.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (Object.op_Implicit((Object)(object)componentsInChildren[i])) { ((Behaviour)componentsInChildren[i]).enabled = false; } } } private static void HideNamedVisuals(GameObject clone) { Transform[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && ShouldHide(((Object)((Component)val).gameObject).name)) { ((Component)val).gameObject.SetActive(false); } } } private static bool ShouldHide(string name) { if (string.IsNullOrWhiteSpace(name)) { return false; } string text = name.ToLowerInvariant(); for (int i = 0; i < HiddenVisualNameParts.Length; i++) { if (text.Contains(HiddenVisualNameParts[i])) { return true; } } return false; } private static void TintClone(GameObject clone, Color accent) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val) || Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent())) { 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.72f)); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", Color.Lerp(val2.GetColor("_BaseColor"), accent, 0.72f)); } if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", accent * 0.5f); } } } } } private static int CountVisibleRenderers(GameObject clone) { int num = 0; Renderer[] componentsInChildren = clone.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { num++; } } return num; } private static int ResolveVisibleLayer() { for (int i = 0; i < PreferredVisibleLayers.Length; i++) { int num = LayerMask.NameToLayer(PreferredVisibleLayers[i]); if (num >= 0) { return num; } } return 0; } static EmpressBotAvatarVisual() { CosmeticType[] array = new CosmeticType[11]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); RandomCosmeticTypes = (CosmeticType[])(object)array; PlayerAvatarCosmeticsRef = AccessTools.FieldRefAccess("playerCosmetics"); VisualsPlayerCosmeticsRef = AccessTools.FieldRefAccess("playerCosmetics"); PlayerCosmeticsVisualsRef = AccessTools.FieldRefAccess("playerAvatarVisuals"); CosmeticParentsRef = AccessTools.FieldRefAccess>("cosmeticParents"); CosmeticParentTypeRef = AccessTools.FieldRefAccess("cosmeticType"); CosmeticParentSpringImpulseRef = AccessTools.FieldRefAccess("springImpulse"); CosmeticParentParentRef = AccessTools.FieldRefAccess("parent"); CosmeticParentResetTransformRef = AccessTools.FieldRefAccess("resetTransform"); BaseMeshParentsRef = AccessTools.FieldRefAccess>("baseMeshParents"); BaseMeshesRef = AccessTools.FieldRefAccess>("baseMeshes"); FirstSetupRef = AccessTools.FieldRefAccess("firstSetup"); FirstSetupCoroutineRef = AccessTools.FieldRefAccess("firstSetupCoroutine"); CosmeticAssetsRef = AccessTools.FieldRefAccess>("cosmeticAssets"); CosmeticAssetTypeRef = AccessTools.FieldRefAccess("type"); CosmeticAssetPrefabRef = AccessTools.FieldRefAccess("prefab"); InstantiateCosmeticMethod = AccessTools.Method(typeof(PlayerCosmetics), "InstantiateCosmetic", new Type[1] { typeof(CosmeticAsset) }, (Type[])null); } } internal class BotChatterAgent : MonoBehaviour { public enum BotState { Idle, Moving, Carrying, Ragdoll } private NavMeshAgent _agent; private Rigidbody _rb; private AudioSource _src; private readonly List _buf = new List(); 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(); _rb = ((Component)this).GetComponent(); _src = ((Component)this).GetComponent(); if (!Object.op_Implicit((Object)(object)_src)) { _src = ((Component)this).gameObject.AddComponent(); } _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(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 (EmpressBotFriendsChatterPlugin.UseDECtalk.Value) { DecTalkSynth.Enqueue(this, text); _lastLocalSpeak = now + EmpressBotFriendsChatterPlugin.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 Claims = new Dictionary(); private static readonly Dictionary IgnoreUntil = new Dictionary(); internal static List 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 list = new List(); try { List 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())) { 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 Claims = new Dictionary(); private static readonly Dictionary EmptyUntil = new Dictionary(); 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 _gunCols = new List(); 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(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() : 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(); _rb = (Object.op_Implicit((Object)(object)_pgo) ? _pgo.rb : null) ?? ((Component)target).GetComponent(); 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() : 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(); 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(); 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(); 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()))) && 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(true, _gunCols); if (_myCols == null || _myCols.Length == 0) { _myCols = ((Component)this).GetComponentsInChildren(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(); 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 _jobs = new ConcurrentQueue(); private static readonly ConcurrentQueue _ready = new ConcurrentQueue(); private static readonly Dictionary _cache = new Dictionary(64); private static readonly LinkedList _lru = new LinkedList(); 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 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 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 _globalTargets = new List(); 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(); 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(); 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 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 _carriedCols = new List(); private readonly HashSet _ignoreIds = new HashSet(); 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(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 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()) && !_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(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(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)) { 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) { DisableJoint(val); } } } } 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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) 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(); foreach (Joint val in components) { if (Object.op_Implicit((Object)(object)val)) { 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))) { DisableJoint(val); } } } } 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 static void DisableJoint(Joint? joint) { if (!Object.op_Implicit((Object)(object)joint)) { return; } try { joint.connectedBody = null; } catch { } try { joint.enableCollision = false; } 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(true, _carriedCols); if (_myCols == null || _myCols.Length == 0) { _myCols = ((Component)this).GetComponentsInChildren(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 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)) { _isJumping = true; ((MonoBehaviour)this).StartCoroutine(JumpCR()); } } } private IEnumerator JumpCR() { _jumpCD = Time.time + 1.25f; if (Object.op_Implicit((Object)(object)_agent)) { NavMeshAgent agent = _agent; agent.baseOffset += 0.4f; } float t = 0f; float dur = 0.25f; while (t < dur) { t += Time.deltaTime; yield return null; } if (Object.op_Implicit((Object)(object)_agent)) { NavMeshAgent agent2 = _agent; agent2.baseOffset -= 0.4f; } _isJumping = false; } } [BepInPlugin("Empress.BotFriends.Chatter", "EmpressBotFriendsChatter", "1.0.0")] public class EmpressBotFriendsChatterPlugin : BaseUnityPlugin { internal static EmpressBotFriendsChatterPlugin Instance; internal static ConfigEntry Enabled; internal static ConfigEntry TalkRadius; internal static ConfigEntry PairCooldown; internal static ConfigEntry SelfCooldown; internal static ConfigEntry MaxConcurrent; internal static ConfigEntry Volume; internal static ConfigEntry UseDECtalk; internal static ConfigEntry ExePath; internal static ConfigEntry Voice; internal static ConfigEntry SampleRate; internal static ConfigEntry DictionaryPath; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; private void Awake() { //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) Instance = this; Enabled = ((BaseUnityPlugin)this).Config.Bind("Chatter", "Enabled", false, "on"); TalkRadius = ((BaseUnityPlugin)this).Config.Bind("Chatter", "TalkRadius", 1f, "m"); PairCooldown = ((BaseUnityPlugin)this).Config.Bind("Chatter", "PairCooldown", 10f, "s"); SelfCooldown = ((BaseUnityPlugin)this).Config.Bind("Chatter", "SelfCooldown", 6f, "s"); MaxConcurrent = ((BaseUnityPlugin)this).Config.Bind("Chatter", "MaxConcurrent", 1, "voices"); Volume = ((BaseUnityPlugin)this).Config.Bind("Chatter", "Volume", 0.6f, "0..1"); UseDECtalk = ((BaseUnityPlugin)this).Config.Bind("DECtalk", "UseDECtalk", true, "on"); ExePath = ((BaseUnityPlugin)this).Config.Bind("DECtalk", "ExePath", "say.exe", "path"); Voice = ((BaseUnityPlugin)this).Config.Bind("DECtalk", "Voice", "Paul", "name"); SampleRate = ((BaseUnityPlugin)this).Config.Bind("DECtalk", "SampleRate", 22050, "Hz"); DictionaryPath = ((BaseUnityPlugin)this).Config.Bind("DECtalk", "DictionaryPath", "dtalk_us.dic", "path or blank"); DecTalkSynth.Configure(ExePath.Value, Voice.Value, SampleRate.Value, DictionaryPath.Value); new GameObject("BotChatterManager") { hideFlags = (HideFlags)61 }.AddComponent(); Logger.LogInfo((object)"Empress chatter ready"); } } internal class BotChatterManager : MonoBehaviour { private static readonly List Agents = new List(); private static readonly Dictionary SelfCD = new Dictionary(); private static readonly Dictionary PairCD = new Dictionary(); private static int _voicesPlaying; private static readonly string[] greetings = new string[41] { "Eyes up.", "Stay sharp.", "You good.", "Keep moving.", "We move.", "Copy.", "On route.", "Heads on a swivel.", "Focus up. No sightseeing.", "Don’t get cute—move.", "Keep it tight.", "We are burning daylight.", "Quit gawking and hustle.", "Stay frosty.", "Watch your damn corners.", "Steady hands, steady feet.", "Less chatter, more ladder.", "Walk like you mean it.", "No hero plays. Not today.", "We’re ghosts—be loud later.", "If it moves, clock it. Twice.", "This place gives me the creeps—keep pace.", "Control your breathing.", "Don’t make me babysit you.", "We’re not lost… we’re exploring aggressively.", "Move smart, not pretty.", "Keep the line clean.", "Comms clear unless it’s critical.", "Don’t trip over your own ego.", "We’re here to work, not decorate the floor.", "If it bites, bite back harder.", "We’re fine. Act like it.", "Heads down, wallets up.", "No panic. Panic is expensive.", "Shut it and strut it.", "Grip it and zip it.", "Keep your soul inside your body.", "Clock’s ticking. Move your ass.", "Don’t test me—I will turn this run around.", "Game faces, criminals.", "Eyes, ears, all of it. On." }; private static readonly string[] movePair = new string[38] { "Form up.", "Stay with me.", "Hold pace.", "On your six.", "Push up.", "Stack up.", "Anchor left.", "Peel right.", "Crossing!", "Bounding—go!", "Don’t lag. I swear.", "Hold the line.", "Break contact if it gets stupid.", "Tight corners—no heroics.", "Don’t step on the loud things.", "Feet light, brain heavier.", "Keep the spacing, geniuses.", "Eyes high, eyes low—cover both.", "Switching lanes—don’t collide.", "Check your flanks, then check mine.", "On your shoulder—don’t stop.", "You lead, I bully.", "Move like rent’s due.", "Silent running—save the drama.", "We glide. We don’t stumble.", "If you clatter, I yell.", "Shuffle faster. Yes, that’s a thing.", "Doors ahead—don’t faceplant.", "I’m pacing you—don’t make me sprint.", "Breach and breathe.", "Keep momentum—friction kills.", "I step, you step. Rhythm, people.", "No zig-zagging like a drunk drone.", "Heel-toe, not heel-whoops.", "Stay latched.", "Trail tight. No wandering.", "Clear lanes. Clear heads.", "Eyes where your feet will be." }; private static readonly string[] carryLead = new string[29] { "Got one.", "Package in hand.", "Taking loot.", "I have it.", "Hauling this thing—don’t make me drop it.", "I’ve got the goods. Nobody sneeze.", "Bag secured—act like professionals.", "Got the prize. Try not to die.", "Courier mode. Cover me, damn it.", "I’m slow and expensive—guard me.", "This is worth more than your life. Move.", "Heavy as sin. Still mine.", "If I trip, I’m blaming you.", "I am the mule now. Respect it.", "Loot in hand, patience in short supply.", "Treasures secured—tempers unsecured.", "Dragging gold and my feet.", "My back hates you and this.", "If I drop this, I drop you.", "I’m the target now. Smile.", "One package. Zero excuses.", "I lift, you shoot.", "I’m the paycheck with legs.", "This better fence for a fortune.", "Got the shiny—eyes open.", "If I hear clattering, I’ll scream.", "Big bag, bigger attitude.", "Toting loot like a legend.", "Carrier pigeon, but angrier." }; private static readonly string[] carryLeadName = new string[26] { "Carrying {0}.", "I have {0}.", "Package is {0}.", "{0} secured.", "Got {0}. Try and keep up.", "If {0} hits the floor, so do you.", "{0} is mine. Back off.", "Walking paycheck: {0}.", "Escorting {0} to freedom.", "This {0} better be worth the back pain.", "Cradling {0} like it’s sacred.", "Babysitting {0}. Cheer for me.", "Hauling {0}. Don’t test me.", "If {0} explodes, that’s on you.", "All roads lead to cash—starring {0}.", "Mother of loot: {0}.", "Dangerous and delicate: {0}.", "My spine signed for {0}.", "Do not poke {0}. Or me.", "If {0} falls, I fall on you.", "Escort detail for {0}, sadly.", "Moving {0}. Pretend we’re smart.", "I got {0}. Pray for my knees.", "This is {0}. Handle me gently.", "I’m marrying {0} if this pays out.", "Slapping a bow on {0} after this." }; private static readonly string[] carrySupport = new string[29] { "I cover.", "Clear the path.", "Move, I got you.", "Go extract.", "Covering your ass—don’t make me regret it.", "You lug it, I plug it.", "Overwatch up. Walk like a boss.", "I’m your shadow. Don’t outrun me.", "Keep that bag high, head low.", "I swat flies; you carry fortune.", "If it looks at you, I’ll make it stop.", "Doors first, problems later—move.", "Eyes on stairwells. Keep rolling.", "You stumble, I scream.", "No sightseeing. I clear, you scurry.", "I’m the umbrella. Don’t step out.", "Take corners wide. I’ve got lanes.", "If you drop it, I drop you. Kidding. Maybe.", "Focus on feet—I’ll handle teeth.", "Breathe and push. I’ll be loud.", "You’re precious cargo now. Try to act it.", "Nothing touches you unless I say so.", "Keep walking. I’m writing threats.", "Move like it’s hot—because it is.", "I’ll stitch the noise. You hug the loot.", "Shield up—go, go, go.", "If it snarls, I bark louder.", "Run lines, not circles.", "I’m the broom; you’re the mess. Sweep time." }; private static readonly string[] carryBothA = new string[27] { "Race you to the gate.", "Two packages.", "Double score.", "Heavy run.", "Two mules, one finish line.", "We’re the economy now.", "Twin jackpots. Try not to choke.", "Don’t brag until we cash in.", "We wobble, we win.", "If we drop both, I’m faking my death.", "Heavy squad, heavier attitude.", "We look ridiculous—keep running.", "Hoarders anonymous, speedrun edition.", "Two bags, zero shame.", "We are walking vaults. Guard us.", "This is greed on legs.", "Call us profit with shoes.", "Double trouble, double payday.", "We’re slow, dumb, and loaded.", "This path better be short.", "If gravity wins, we riot.", "We flex, the world pays.", "Clutch up; both bags live.", "Don’t trip; I will laugh first, help second.", "Two payloads, one exit, no mercy.", "The gate owes us applause.", "We’re bringing the store home." }; private static readonly string[] carryBothB = new string[25] { "Do not trip.", "Do not drop it.", "Keep pace.", "Stay clean.", "One slip and we’re memes.", "Eyes down; ankles up.", "We fumble and I’m screaming.", "No hero turns, just straight lines.", "Left foot, right foot, pay day.", "Balance or embarrassment—pick one.", "Bags high, egos low.", "Close ranks—wobble later.", "No sudden stops, tourists.", "Heels quiet, hearts quieter.", "Grip like your rent depends on it.", "Don’t argue—oxygen is precious.", "We are not sprinting—yet.", "Stop clanking. Sound travels.", "If you sneeze, you carry both.", "Hands steady, brain steady.", "We finish or we suffer.", "Minimal drama. Maximal loot.", "If we make it, I’m napping forever.", "Don’t tail-slap me with that bag.", "Tiptoe like thieves—because we are." }; private static readonly string[] ragdollSelf = new string[29] { "I am fine.", "Minor setback.", "Systems nominal.", "Back up.", "Ow. That sucked.", "I tripped. The floor punched back.", "Body’s fine. Pride’s bleeding.", "I meant to do that. Obviously.", "I slipped on pure stupidity.", "I’m okay—gravity cheated.", "Who moved the ground? Rude.", "That was tactical… falling.", "Don’t clip that. I swear.", "My knees are filing complaints.", "I’m good. I’m great. I’m lying.", "Did the earth jump up or…", "Studying floor patterns. For science.", "I’m vertical-adjacent, not down.", "Ragdoll mode: deactivated. Mostly.", "I’ll bounce. Watch me.", "Floor tasted like disappointment.", "I’ve had worse hugs than that wall.", "No bones broken, just my ego.", "Up. Angry. Motivated.", "Gravity and I are not friends.", "Walk it off. Swear it off.", "Pain is temporary, swearing eternal.", "Okay, that was spicy.", "If you laugh, you carry." }; private static readonly string[] ragdollOther = new string[27] { "Get up.", "Move soldier.", "No downtime.", "Recover now.", "Up you get, floor-lover.", "Stop kissing the concrete.", "On your feet, drama queen.", "Walk it off, champion of gravity.", "The ground isn’t your friend—move.", "No naps mid-run. Up.", "I’ll drag you, but I’ll complain loudly.", "Quit breakdancing. We’re late.", "Try legs. They’re great.", "Pretend you’re tough. Stand.", "You good? Too bad, move.", "We can cry after payday.", "You fall, we stall—rise.", "Come on, my back hurts watching.", "Shake it off. Angrier.", "If you’re dead, say so louder.", "You bend, don’t break. Go.", "If you do that again, I’m charging rent.", "I’ll count to one. Up.", "Dust off and scare the floor back.", "We leave no teammate—get moving.", "Gravity won the round, not the match.", "I didn’t see anything. Move." }; internal static void Register(BotChatterAgent a) { if (!Agents.Contains(a)) { Agents.Add(a); } } internal static void Unregister(BotChatterAgent a) { Agents.Remove(a); SelfCD.Remove(a); } private void Update() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) DrainReady(); if (!EmpressBotFriendsChatterPlugin.Enabled.Value) { return; } for (int num = Agents.Count - 1; num >= 0; num--) { if (!Object.op_Implicit((Object)(object)Agents[num])) { Agents.RemoveAt(num); } } float time = Time.time; for (int i = 0; i < Agents.Count; i++) { BotChatterAgent botChatterAgent = Agents[i]; if (Object.op_Implicit((Object)(object)botChatterAgent) && ((Behaviour)botChatterAgent).isActiveAndEnabled) { if (!SelfCD.TryGetValue(botChatterAgent, out var value)) { value = 0f; } if (botChatterAgent.TickLocal(time, value <= time && RoomForVoice())) { SelfCD[botChatterAgent] = time + EmpressBotFriendsChatterPlugin.SelfCooldown.Value; } } } for (int j = 0; j < Agents.Count; j++) { for (int k = j + 1; k < Agents.Count; k++) { BotChatterAgent botChatterAgent2 = Agents[j]; BotChatterAgent botChatterAgent3 = Agents[k]; if (Object.op_Implicit((Object)(object)botChatterAgent2) && Object.op_Implicit((Object)(object)botChatterAgent3) && !(Vector3.Distance(((Component)botChatterAgent2).transform.position, ((Component)botChatterAgent3).transform.position) > EmpressBotFriendsChatterPlugin.TalkRadius.Value)) { ulong key = PairKey(botChatterAgent2, botChatterAgent3); if (!PairCD.TryGetValue(key, out var value2)) { value2 = 0f; } if (!(value2 > time) && RoomForVoice() && TryDialogue(botChatterAgent2, botChatterAgent3, time)) { PairCD[key] = time + EmpressBotFriendsChatterPlugin.PairCooldown.Value; } } } } _voicesPlaying = Mathf.Max(0, _voicesPlaying - 1); DrainReady(); } private static void DrainReady() { BotChatterAgent who; DecTalkSynth.Clip clip; while (DecTalkSynth.TryDequeueReady(out who, out clip)) { if (Object.op_Implicit((Object)(object)who)) { who.PlayClip(clip, EmpressBotFriendsChatterPlugin.Volume.Value); _voicesPlaying++; } } } private static bool RoomForVoice() { return _voicesPlaying < EmpressBotFriendsChatterPlugin.MaxConcurrent.Value; } private static ulong PairKey(BotChatterAgent a, BotChatterAgent b) { int instanceID = ((Object)a).GetInstanceID(); int instanceID2 = ((Object)b).GetInstanceID(); uint num = (uint)Mathf.Min(instanceID, instanceID2); return ((ulong)(uint)Mathf.Max(instanceID, instanceID2) << 32) | num; } private static string Pick(string[] arr) { return arr[Random.Range(0, arr.Length)]; } private static bool Speak(BotChatterAgent who, string line) { if (!EmpressBotFriendsChatterPlugin.UseDECtalk.Value) { return false; } DecTalkSynth.Enqueue(who, line); return true; } private static bool TryDialogue(BotChatterAgent a, BotChatterAgent b, float now) { BotChatterAgent.BotState state = a.State; BotChatterAgent.BotState state2 = b.State; if (state == BotChatterAgent.BotState.Ragdoll && state2 != BotChatterAgent.BotState.Ragdoll) { string line = Pick(ragdollSelf); string line2 = Pick(ragdollOther); bool num = Speak(a, line); if (num) { Speak(b, line2); } return num; } if (state2 == BotChatterAgent.BotState.Ragdoll && state != BotChatterAgent.BotState.Ragdoll) { string line3 = Pick(ragdollOther); string line4 = Pick(ragdollSelf); bool num2 = Speak(a, line3); if (num2) { Speak(b, line4); } return num2; } if (a.IsCarrying && !b.IsCarrying) { string carriedLabel = a.CarriedLabel; string line5 = (string.IsNullOrEmpty(carriedLabel) ? Pick(carryLead) : string.Format(Pick(carryLeadName), carriedLabel)); string line6 = Pick(carrySupport); bool num3 = Speak(a, line5); if (num3) { Speak(b, line6); } return num3; } if (b.IsCarrying && !a.IsCarrying) { string carriedLabel2 = b.CarriedLabel; string line7 = Pick(carrySupport); string line8 = (string.IsNullOrEmpty(carriedLabel2) ? Pick(carryLead) : string.Format(Pick(carryLeadName), carriedLabel2)); bool num4 = Speak(a, line7); if (num4) { Speak(b, line8); } return num4; } if (a.IsCarrying && b.IsCarrying) { string line9 = Pick(carryBothA); string line10 = Pick(carryBothB); bool num5 = Speak(a, line9); if (num5) { Speak(b, line10); } return num5; } if (state == BotChatterAgent.BotState.Moving && state2 == BotChatterAgent.BotState.Moving) { string line11 = Pick(movePair); return Speak((Random.value < 0.5f) ? a : b, line11); } string line12 = Pick(greetings); return Speak((Random.value < 0.5f) ? a : b, line12); } } [BepInPlugin("Empress.BotFriends", "Empress BotFriends", "1.1.3")] public class StupidBotsPlugin : BaseUnityPlugin { private static readonly string[] NamePool = new string[50] { "1A3", "753", "Ada", "Adalade Kasner", "Atom", "Bishop", "Blok", "Bocon", "Bolt", "Cinder", "Circuit", "Dex", "Doppelclick", "Drift", "Echo", "Ember", "Empress", "Endershade", "Frost", "Friendly", "Goat", "Gremlin", "Hex", "Impboy", "Ivy", "Jettcodey", "Jinx", "Kilo", "Lumen", "Mako", "Nova", "Omniscye", "Onyx", "Origami", "Pixel", "Quark", "Rex", "Rune", "Sable", "Skript", "Sizzlium", "Swaggies", "Talon", "Tangle", "Vanta", "Warden", "Zephyr", "Zehs", "gaymer", "s1ckboy" }; private const int CountMin = 0; private const int CountMax = 5; private const float SpeedMin = 0.5f; private const float SpeedMax = 6f; private const float SearchRadiusMin = 2f; private const float SearchRadiusMax = 40f; private const float ExtractorStopMin = 0.5f; private const float ExtractorStopMax = 4f; private const float HoldOffsetMin = 0.2f; private const float HoldOffsetMax = 2f; private const float FollowOrbitRadius = 12f; public const string PluginGuid = "Empress.BotFriends"; public const string PluginName = "Empress BotFriends"; public const string PluginVersion = "1.1.3"; private ConfigEntry _botCount; private ConfigEntry _botSpeed; private ConfigEntry _botsFollowPlayer; private ConfigEntry _botsFetchValuables; private ConfigEntry _pickupSearchRadius; private ConfigEntry _extractorStopDistance; private ConfigEntry _holdOffsetY; private ConfigEntry _enableRagdoll; private ConfigEntry _ragdollImpactThreshold; private ConfigEntry _ragdollRecoverTime; private readonly List _bots = new List(); private ConfigEntry _enablePersonalities; private ConfigEntry _personalitySeed; private ConfigEntry _enableWeapons; private ConfigEntry _weaponSearchRadius; private bool _spawnedThisLevel; private static Queue _nameBag; internal static StupidBotsPlugin Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? EmpressHarmony { get; set; } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; _botCount = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "ExtraBots", 1, new ConfigDescription("How many stupid bot friends to spawn (0-5).", (AcceptableValueBase)(object)new AcceptableValueRange(0, 5), Array.Empty())); _botSpeed = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "BotSpeed", 4.35f, new ConfigDescription("Move speed for bots.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 6f), Array.Empty())); _botsFollowPlayer = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "FollowPlayer", false, "If true, bots loosely follow you. If false, they roam globally."); _botsFetchValuables = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "FetchValuables", true, "If true, bots will fetch nearby valuables to the active extractor."); _pickupSearchRadius = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "PickupSearchRadius", 25f, new ConfigDescription("Scan radius for valuables.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 40f), Array.Empty())); _extractorStopDistance = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "ExtractorStopDistance", 1.75f, new ConfigDescription("Drop distance from extractor.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 4f), Array.Empty())); _holdOffsetY = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "HoldOffsetY", 1f, new ConfigDescription("Local Y offset for held items.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 2f), Array.Empty())); _enableRagdoll = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "EnablePhysicsRagdoll", true, "Enable temporary physics ragdoll on heavy impact."); _ragdollImpactThreshold = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "RagdollImpactThreshold", 1f, "Minimum impact speed to trigger ragdoll."); _ragdollRecoverTime = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "RagdollRecoverTime", 4f, "Seconds before recovery check."); _enablePersonalities = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "EnablePersonalities", true, "Randomize bot personalities."); _personalitySeed = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "PersonalitySeed", 0, "0=auto random, otherwise deterministic personalities."); _enableWeapons = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "EnableWeapons", true, "Allow bots to pick up and use weapons."); _weaponSearchRadius = ((BaseUnityPlugin)this).Config.Bind("BotFriends", "WeaponSearchRadius", 20f, new ConfigDescription("Scan radius for weapons.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 40f), Array.Empty())); Patch(); SceneManager.activeSceneChanged += OnActiveSceneChanged; ((MonoBehaviour)this).StartCoroutine(LevelWatchdog()); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded."); } internal void Patch() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0025: Expected O, but got Unknown if (EmpressHarmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; EmpressHarmony = val; } EmpressHarmony.PatchAll(); } private void OnActiveSceneChanged(Scene a, Scene b) { _spawnedThisLevel = false; CleanupBots(); } private IEnumerator LevelWatchdog() { WaitForSeconds wait = new WaitForSeconds(0.25f); while (true) { try { Transform player; if (IsMultiplayerSafe()) { if (_bots.Count > 0) { CleanupBots(); } _spawnedThisLevel = false; } else if (TryGetAnyPlayer(out player) && IsLevelGenerated() && !_spawnedThisLevel) { SpawnBots(player); _spawnedThisLevel = true; } } catch (Exception arg) { Logger.LogError((object)$"Watchdog tick failed: {arg}"); } yield return wait; } } private bool TryGetAnyPlayer(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(); if (array != null && array.Length != 0) { player = ((Component)array[0]).transform; return true; } } catch { } return false; } private static bool TryGetAnyPlayerAvatar(out PlayerAvatar? playerAvatar) { playerAvatar = null; try { if (Object.op_Implicit((Object)(object)PlayerAvatar.instance)) { playerAvatar = PlayerAvatar.instance; return true; } } catch { } try { PlayerAvatar[] array = Object.FindObjectsOfType(); if (array != null && array.Length != 0) { playerAvatar = array[0]; return true; } } catch { } return false; } private static bool IsMultiplayerSafe() { try { return GameManager.Multiplayer(); } catch { } try { return SemiFunc.IsMultiplayer(); } catch { } return false; } private static bool IsLevelGenerated() { try { return (Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated; } catch { return false; } } private void SpawnBots(Transform player) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) Transform player2 = player; CleanupBots(); int num = Mathf.Clamp(_botCount.Value, 0, 5); if (num <= 0) { return; } List list = FindOrderedSpawnPoints(player2.position); if (list.Count == 0) { list = Enumerable.Range(0, num).Select((Func)delegate(int i) { //IL_0006: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = player2.position; Vector3 val3 = Random.onUnitSphere.WithY(0f); return new Pose(position + ((Vector3)(ref val3)).normalized * (2f + (float)i * 1.25f), Quaternion.identity); }).ToList(); } int num2 = ((list.Count > 0) ? 1 : 0); int num3 = 0; for (int j = 0; j < list.Count; j++) { if (num3 >= num) { break; } int index = (num2 + j) % list.Count; Pose val = list[index]; GameObject val2 = CreateBot(val.position, val.rotation, num3); if ((Object)(object)val2 != (Object)null) { _bots.Add(val2); num3++; } } Logger.LogInfo((object)$"Spawned {_bots.Count} bot(s)."); } private List FindOrderedSpawnPoints(Vector3 reference) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) List result = new List(); try { result = ((IEnumerable)(from p in Object.FindObjectsOfType() where ((Component)p).gameObject.activeInHierarchy orderby Vector3.SqrMagnitude(((Component)p).transform.position - reference) select p)).Select((Func)((SpawnPoint p) => new Pose(((Component)p).transform.position, ((Component)p).transform.rotation))).ToList(); } catch { } return result; } private static bool TryPlaceOnNavMesh(NavMeshAgent agent, Vector3 desired) { //IL_000a: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)agent)) { return false; } Vector3 val = desired; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(desired, ref val2, 6f, -1)) { val = ((NavMeshHit)(ref val2)).position; } if (agent.Warp(val)) { return agent.isOnNavMesh; } return false; } private GameObject? CreateBot(Vector3 pos, Quaternion rot, int index) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_02d0: Unknown result type (might be due to invalid IL or missing references) try { string text = NextName(); Color val = Color.HSVToRGB(Mathf.Repeat((float)index * 0.381966f + Random.Range(0.02f, 0.14f), 1f), Random.Range(0.8f, 0.98f), 1f); GameObject val2 = new GameObject(text); val2.layer = LayerMask.NameToLayer("Default"); val2.transform.SetPositionAndRotation(pos, rot); CapsuleCollider obj = val2.AddComponent(); obj.height = 1.8f; obj.radius = 0.35f; obj.center = new Vector3(0f, 0.9f, 0f); GameObject val3 = new GameObject("NameTag"); val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = new Vector3(0f, 2.15f, 0f); TextMesh obj2 = val3.AddComponent(); obj2.text = text; obj2.fontSize = 48; obj2.characterSize = 0.06f; obj2.alignment = (TextAlignment)1; obj2.anchor = (TextAnchor)7; NavMeshAgent val4 = val2.AddComponent(); val4.speed = Mathf.Clamp(_botSpeed.Value, 0.5f, 6f); obj2.color = val; val4.angularSpeed = 720f; val4.acceleration = 20f; val4.radius = 0.3f; val4.height = 1.8f; val4.obstacleAvoidanceType = (ObstacleAvoidanceType)4; val4.autoTraverseOffMeshLink = true; TryPlaceOnNavMesh(val4, pos); val4.stoppingDistance = 1.5f; bool flag = false; if (TryGetAnyPlayerAvatar(out PlayerAvatar playerAvatar)) { flag = EmpressBotAvatarVisual.TryAttach(val2, playerAvatar, val, val4, val4.speed); } if (!flag) { GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)1); ((Object)val5).name = "Body"; val5.transform.SetParent(val2.transform, false); val5.transform.localScale = new Vector3(0.7f, 0.9f, 0.7f); val5.transform.localPosition = new Vector3(0f, 0.9f, 0f); Collider component = val5.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.enabled = false; } GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj3).name = "Head"; obj3.transform.SetParent(val2.transform, false); obj3.transform.localScale = Vector3.one * 0.35f; obj3.transform.localPosition = new Vector3(0f, 1.6f, 0f); MeshRenderer component2 = val5.GetComponent(); MeshRenderer component3 = obj3.GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { Material val6 = new Material(((Renderer)component2).sharedMaterial); val6.color = val; ((Renderer)component2).material = val6; } if (Object.op_Implicit((Object)(object)component3)) { Material val7 = new Material(((Renderer)component3).sharedMaterial); val7.color = Color.white; ((Renderer)component3).material = val7; } } StupidBotBrain stupidBotBrain = val2.AddComponent(); BotPersonality botPersonality = null; if (_enablePersonalities.Value) { botPersonality = val2.AddComponent(); int seed = ((_personalitySeed.Value != 0) ? (_personalitySeed.Value + index) : Random.Range(1, int.MaxValue)); botPersonality.InitRandom(seed); float speed = (val4.speed = Mathf.Clamp(_botSpeed.Value * botPersonality.SpeedMultiplier, 0.5f, 6f)); stupidBotBrain.Init(new StupidBotBrain.Config { FollowPlayer = _botsFollowPlayer.Value, WanderRadius = 12f, Speed = speed }); } stupidBotBrain.Init(new StupidBotBrain.Config { FollowPlayer = _botsFollowPlayer.Value, WanderRadius = 12f, Speed = Mathf.Clamp(_botSpeed.Value, 0.5f, 6f) }); val2.AddComponent(); Transform transform = new GameObject("HoldPoint").transform; transform.SetParent(val2.transform, false); transform.localPosition = new Vector3(0f, Mathf.Clamp(_holdOffsetY.Value, 0.2f, 2f), 0.6f); transform.localRotation = Quaternion.identity; StupidBotCarrier stupidBotCarrier = null; if (_botsFetchValuables.Value) { stupidBotCarrier = val2.AddComponent(); stupidBotCarrier.Init(new StupidBotCarrier.Cfg { SearchRadius = Mathf.Clamp(_pickupSearchRadius.Value, 2f, 40f), ExtractorStopDistance = Mathf.Clamp(_extractorStopDistance.Value, 0.5f, 4f), GentleDropTime = 0.25f }, val4, transform, stupidBotBrain); if (Object.op_Implicit((Object)(object)botPersonality) && !botPersonality.AllowValuables) { ((Behaviour)stupidBotCarrier).enabled = false; } } if (_enableWeapons.Value) { val2.AddComponent().Init(new BotWeaponUser.Cfg { SearchRadius = Mathf.Clamp(_weaponSearchRadius.Value, 2f, 40f) }, val4, transform, stupidBotBrain, botPersonality); } Rigidbody val8 = val2.GetComponent() ?? val2.AddComponent(); val8.mass = 60f; val8.useGravity = true; val8.isKinematic = true; val8.collisionDetectionMode = (CollisionDetectionMode)2; val8.interpolation = (RigidbodyInterpolation)1; if (_enableRagdoll.Value) { val2.AddComponent().Init(val4, stupidBotBrain, stupidBotCarrier, val8, _enableRagdoll.Value, _ragdollImpactThreshold.Value, _ragdollRecoverTime.Value); } return val2; } catch (Exception arg) { Logger.LogError((object)$"Failed to create bot: {arg}"); return null; } } private static void EnsureNameBag() { if (_nameBag == null || _nameBag.Count <= 0) { List list = new List(NamePool); for (int i = 0; i < list.Count; i++) { int index = Random.Range(i, list.Count); string value = list[i]; list[i] = list[index]; list[index] = value; } _nameBag = new Queue(list); } } private static string NextName() { EnsureNameBag(); if (_nameBag.Count <= 0) { return $"Unit-{Random.Range(100, 999)}"; } return _nameBag.Dequeue(); } private void CleanupBots() { for (int num = _bots.Count - 1; num >= 0; num--) { GameObject val = _bots[num]; if (Object.op_Implicit((Object)(object)val)) { val.SetActive(false); } } _bots.Clear(); } } }