using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using SelfMovingCart.Patches;
using Strobotnik.Klattersynth;
using TMPro;
using TalkingCart.Patches;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TalkingCart")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TalkingCart")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4357e01f-9e17-426f-a193-4a1b4792318a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SelfMovingCart.Patches
{
public static class ReflectionHelper
{
public static object InvokePrivateMethod(object instance, string methodName, params object[] parameters)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
Type type = instance.GetType();
MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
if (methodInfo == null)
{
throw new MissingMethodException("Method '" + methodName + "' not found on type '" + type.FullName + "'");
}
return methodInfo.Invoke(instance, parameters);
}
public static object InvokePrivateStaticMethod(Type type, string methodName, params object[] parameters)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
if (methodInfo == null)
{
throw new MissingMethodException("Static method '" + methodName + "' not found on type '" + type.FullName + "'");
}
return methodInfo.Invoke(null, parameters);
}
public static T GetPrivateField<T>(object instance, string fieldName)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
Type type = instance.GetType();
FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
if (fieldInfo == null)
{
throw new MissingFieldException("Field '" + fieldName + "' not found on type '" + type.FullName + "'");
}
return (T)fieldInfo.GetValue(instance);
}
public static T GetPrivateStaticField<T>(Type type, string fieldName)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
if (fieldInfo == null)
{
throw new MissingFieldException("Static field '" + fieldName + "' not found on type '" + type.FullName + "'");
}
return (T)fieldInfo.GetValue(null);
}
public static void SetPrivateField(object instance, string fieldName, object value)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
Type type = instance.GetType();
FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
if (fieldInfo == null)
{
throw new MissingFieldException("Field '" + fieldName + "' not found on type '" + type.FullName + "'");
}
fieldInfo.SetValue(instance, value);
}
public static void SetPrivateStaticField(Type type, string fieldName, object value)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
if (fieldInfo == null)
{
throw new MissingFieldException("Static field '" + fieldName + "' not found on type '" + type.FullName + "'");
}
fieldInfo.SetValue(null, value);
}
public static T GetPrivateProperty<T>(object instance, string propertyName)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
Type type = instance.GetType();
PropertyInfo propertyInfo = AccessTools.Property(type, propertyName);
if (propertyInfo == null)
{
throw new MissingMemberException("Property '" + propertyName + "' not found on type '" + type.FullName + "'");
}
return (T)propertyInfo.GetValue(instance);
}
public static object GetPrivateEnumValue(Type containingType, string enumTypeName, string enumValueName)
{
Type type = AccessTools.Inner(containingType, enumTypeName);
if (type == null)
{
throw new MissingMemberException("Enum type '" + enumTypeName + "' not found in '" + containingType.FullName + "'");
}
return Enum.Parse(type, enumValueName);
}
}
}
namespace TalkingCart
{
[BepInPlugin("Syntaxe.TalkingCart", "Talking Cart", "1.0.0")]
public class TalkingCartBase : BaseUnityPlugin
{
private const string modGUID = "Syntaxe.TalkingCart";
private const string modName = "Talking Cart";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Syntaxe.TalkingCart");
private static TalkingCartBase Instance;
public static ManualLogSource mls;
public static List<AudioClip> SoundFX;
public static List<AudioClip> RoastsFX;
public static List<string> RoastsText;
internal static AssetBundle Bundle1;
internal static AssetBundle Bundle2;
public static int AllEnemiesNearbyVLInd = 0;
public static int ItemsNearbyVLInd = 1;
public static int LevelEnemiesVLInd = 2;
public static int EnemyDespawnedInd = 3;
public static int EnemyDiedInd = 22;
public static int EnemyLeftInd = 41;
public static int EnemyNamesPluralInd = 60;
public static int EnemyNamesSingularInd = 79;
public static int EnemyNearbyInd = 98;
public static int EnemyRespawnedInd = 117;
public static int NumbersInd = 136;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Syntaxe.TalkingCart");
ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
mls.LogInfo((object)"Syntaxe.TalkingCart is now awake!");
harmony.PatchAll(typeof(TalkingCartBase));
harmony.PatchAll(typeof(ValuableObjectsRecords));
harmony.PatchAll(typeof(RoundDirectorPatch));
harmony.PatchAll(typeof(EnemyPatch));
harmony.PatchAll(typeof(EnemyHealthPatch));
harmony.PatchAll(typeof(EnemyParentPatch));
harmony.PatchAll(typeof(PlayerControllerPatch));
harmony.PatchAll(typeof(CartVocalPatch));
harmony.PatchAll(typeof(ChatManagerPatch));
harmony.PatchAll(typeof(PlayerAvatarPatch));
harmony.PatchAll(typeof(PhysGrabObjectPatch));
SoundFX = new List<AudioClip>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("TalkingCart.dll".ToCharArray());
Bundle1 = AssetBundle.LoadFromFile(location + "talkingcartassetbundle");
if ((Object)(object)Bundle1 != (Object)null)
{
SoundFX = Bundle1.LoadAllAssets<AudioClip>().ToList();
mls.LogInfo((object)$"Audio Array Size: {SoundFX.Count}");
}
else
{
mls.LogError((object)"Failed to load asset bundle1 !!");
}
RoastsFX = new List<AudioClip>();
Bundle2 = AssetBundle.LoadFromFile(location + "roasts");
if ((Object)(object)Bundle2 != (Object)null)
{
RoastsFX = Bundle2.LoadAllAssets<AudioClip>().ToList();
mls.LogInfo((object)$"Audio Array Size: {RoastsFX.Count}");
}
else
{
mls.LogError((object)"Failed to load asset bundle2 !!");
}
RoastsText = new List<string>
{
"Nice one", "Who needs money anyways", "Keep at it and we'll have to sell you to pay rent", "Were you born like this?", "Yikes", "Who needs enemies when we have you", "The dumbass strikes again", "Wisdom chases you but you are faster", "A brain dead hippo would play better than this", "Are you kidding me right now?",
"You're the type of guy who would eat all the supplies in a zombie movie and then die first", "I would rather burn my eyes looking at the sun than watch you play one more level", "Seriously can we kick this guy?", "Have you considered uninstalling the game?", "I bet your family doesn't invite you over for christmas", "I wish I had legs so I could kick your ass", "Single digit IQ", "This has to be some form of disability", "Good job", "Nice",
"Dumbass", "Can't wait until they add the kick button", "Is your spirit animal a rock?", "You're so ugly even a TSA agent wouldn't touch you", "I'm considering retirement", "I should've taken the walmart job", "We should've left bro in the ship", "Great now go find the robe and give him a hug", "I would drop kick you if I had legs", "Bro is destroying items so much you'd think that he's 3 gnomes in a trenchcoat.",
"This is why you're always picked last", "It takes a special person to screw up this badly", "This is why no one wants to join you", "This is why you're playing alone", "Oh nevermind it's just the idiot who keeps breaking shit"
};
mls.LogInfo((object)$"Texts Array Size: {RoastsText.Count}");
}
}
}
namespace TalkingCart.Patches
{
internal class CartRoastSync : MonoBehaviourPun
{
public CartTalkingManager cart;
public void AttemptRoast()
{
if (cart.cartVoiceQueue.Count > 0)
{
return;
}
float value = Random.value;
if (!(value >= ConfigManager.cartChanceToReactToDamagingItems.Value))
{
int num = Random.Range(0, TalkingCartBase.RoastsFX.Count);
int num2 = Object.FindObjectsOfType<PlayerAvatar>().Length;
while ((num == 32 || num == 33) && num2 > 1)
{
num = Random.Range(0, TalkingCartBase.RoastsFX.Count);
}
List<int> list = new List<int>();
List<float> list2 = new List<float>();
if (num == 34)
{
int num3 = TalkingCartBase.EnemyNearbyInd + 4;
list.Add(-1);
list2.Add(2f);
}
list.Add(num);
list2.Add(0f);
if (SemiFunc.IsMultiplayer())
{
((MonoBehaviourPun)this).photonView.RPC("AttemptRoastRPC", (RpcTarget)0, new object[2]
{
list.ToArray(),
list2.ToArray()
});
}
else
{
AttemptRoastRPC(list.ToArray(), list2.ToArray());
}
}
}
[PunRPC]
private void AttemptRoastRPC(int[] inds, float[] delays)
{
for (int i = 0; i < inds.Length; i++)
{
int num = inds[i];
if (num == -1)
{
if (ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text = "Clown nearby";
List<AudioClip> list = cart.TTSGenerateAudioClip(text);
foreach (AudioClip item in list)
{
cart.EnqueueValues(item, delays[i], text);
}
}
else
{
int index = TalkingCartBase.EnemyNearbyInd + 4;
cart.EnqueueValues(TalkingCartBase.SoundFX[index], delays[i], "Clown nearby");
}
}
else if (ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text2 = TalkingCartBase.RoastsText[num];
List<AudioClip> list2 = cart.TTSGenerateAudioClip(text2);
foreach (AudioClip item2 in list2)
{
cart.EnqueueValues(item2, delays[i], text2);
}
}
else
{
cart.EnqueueValues(TalkingCartBase.RoastsFX[num], delays[i], TalkingCartBase.RoastsText[num]);
}
}
}
}
internal class CartTalkingManager : MonoBehaviour
{
private bool isCommEnabled = true;
private PhysGrabCart physGrabCart;
public bool isCartBeingPulled = false;
public CartRoastSync cartRoastSync;
private Sound cartSound = new Sound();
private Speech cartSpeech;
public Queue<AudioClip> cartVoiceQueue = new Queue<AudioClip>();
private Queue<float> cartVoiceDelayQueue = new Queue<float>();
private Queue<string> cartTextQueue = new Queue<string>();
public List<RoundDirectorPatch.EnemyCommState> lastCommunicatedStatus = new List<RoundDirectorPatch.EnemyCommState>();
public List<bool> isEnemyNearby = new List<bool>();
public List<int> despawnRespawnTimer = new List<int>();
private float cartVoiceTimer = 0f;
private float checkTimer = 1f;
private GameObject cartTalkText;
private RectTransform cartTalkTextTransform;
private TextMeshProUGUI cartTalkTextTMP;
private float textAlpha = 1f;
private float textAlphaTarget = 1f;
private float alphaCheckTimer = 0f;
private Color textColor = Color.white;
private static TextMeshProUGUI enableInstructionTMP;
private static TextMeshProUGUI itemsInstructionTMP;
private void InitializeVariables()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
physGrabCart = ((Component)this).GetComponent<PhysGrabCart>();
isCartBeingPulled = false;
cartSound = new Sound();
cartVoiceQueue = new Queue<AudioClip>();
cartVoiceDelayQueue = new Queue<float>();
cartTextQueue = new Queue<string>();
lastCommunicatedStatus = new List<RoundDirectorPatch.EnemyCommState>();
isEnemyNearby = new List<bool>();
despawnRespawnTimer = new List<int>();
cartVoiceTimer = 0f;
checkTimer = 1f;
}
private void SetupTTS()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>();
GameObject val2 = new GameObject("CartSpeech");
val2.transform.parent = ((Component)this).transform;
cartSpeech = val2.AddComponent<Speech>();
cartSpeech.useStreamingMode = true;
cartSpeech.maxAutoCachedClips = 10;
cartSpeech.voiceBaseFrequency = 220;
cartSpeech.voicingSource = (VoicingSource)0;
cartSpeech.msPerSpeechFrame = 10;
cartSpeech.flutter = 10;
cartSpeech.flutterSpeed = 1f;
}
private void Start()
{
InitializeVariables();
Sound.CopySound(physGrabCart.soundHaulIncrease, cartSound);
cartSound.Volume = 1f;
cartSound.Pitch = 1f;
cartSound.PitchRandom = 0f;
SetupTTS();
InitializeCartText();
}
private void Update()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_006e: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager.warnAboutEnemies.Value && !RoundDirectorPatch.initialEnemiesCommunicated && SemiFunc.RunIsLevel())
{
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(PlayerControllerPatch.playerPosition.x, 0f, PlayerControllerPatch.playerPosition.z);
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(((Component)this).transform.position.x, 0f, ((Component)this).transform.position.z);
float num = Vector3.Distance(val2, val);
if (num < 8f)
{
RoundDirectorPatch.initialEnemiesCommunicated = true;
HandleStarterEnemies();
}
}
CartVoiceQueueRoller();
if (ConfigManager.warnAboutEnemies.Value)
{
checkTimer -= Time.deltaTime;
if (checkTimer <= 0f)
{
HandleNearbyEnemies();
HandleDespawnedEnemies();
HandleRespawnedEnemies();
checkTimer = 1f;
}
}
HandleCartText();
HandleCartUI();
}
private void InitializeCartText()
{
//IL_0016: 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_0085: Unknown result type (might be due to invalid IL or missing references)
cartTalkText = Object.Instantiate<GameObject>(WorldSpaceUIParent.instance.TTSPrefab, ((Component)WorldSpaceUIParent.instance).transform.position, ((Component)WorldSpaceUIParent.instance).transform.rotation, ((Component)WorldSpaceUIParent.instance).transform);
WorldSpaceUITTS component = cartTalkText.GetComponent<WorldSpaceUITTS>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
cartTalkTextTransform = cartTalkText.GetComponent<RectTransform>();
cartTalkTextTMP = cartTalkText.GetComponent<TextMeshProUGUI>();
((Graphic)cartTalkTextTMP).color = textColor;
((TMP_Text)cartTalkTextTMP).text = "";
}
private void HandleCartText()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0100: 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)
Vector3 val = SemiFunc.UIWorldToCanvasPosition(((Component)this).transform.position);
cartTalkTextTransform.anchoredPosition = Vector2.op_Implicit(val);
alphaCheckTimer -= Time.deltaTime;
if (alphaCheckTimer <= 0f)
{
alphaCheckTimer = 0.1f;
textAlphaTarget = 1f;
float num = 5f;
float num2 = 25f;
float num3 = Vector3.Distance(((Component)this).transform.position, PlayerControllerPatch.playerPosition);
if (num3 > num)
{
num3 = Mathf.Clamp(num3, num, num2);
textAlphaTarget = 1f - (num3 - num) / (num2 - num);
}
}
textAlpha = Mathf.Lerp(textAlpha, textAlphaTarget, 30f * Time.deltaTime);
((Graphic)cartTalkTextTMP).color = new Color(textColor.r, textColor.g, textColor.b, textAlpha);
}
private void HandleStarterEnemies()
{
if (ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text = "Level enemies:";
List<AudioClip> list = TTSGenerateAudioClip(text);
foreach (AudioClip item in list)
{
EnqueueValues(item, 0f, text);
}
}
else
{
EnqueueValues(TalkingCartBase.SoundFX[TalkingCartBase.LevelEnemiesVLInd], 0.2f, "Level enemies:");
}
int[] array = new int[RoundDirectorPatch.roundEnemyNamesList.Count];
foreach (EnemyParent enemyParent in RoundDirectorPatch.enemyParentList)
{
int num = RoundDirectorPatch.roundEnemyNamesList.IndexOf(enemyParent.enemyName);
array[num]++;
}
for (int i = 0; i < array.Length; i++)
{
int num2 = array[i];
string text2 = RoundDirectorPatch.roundEnemyNamesList[i];
if (num2 == 0)
{
continue;
}
int num3 = Array.IndexOf(RoundDirectorPatch.enemyNames, text2);
if (num3 == -1 || ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text3 = text2;
if (num2 > 1)
{
text3 = num2 + " " + text2;
}
List<AudioClip> list2 = TTSGenerateAudioClip(text3);
foreach (AudioClip item2 in list2)
{
EnqueueValues(item2, 0f, text3);
}
}
else if (num2 == 1)
{
int index = TalkingCartBase.EnemyNamesSingularInd + num3;
EnqueueValues(TalkingCartBase.SoundFX[index], 0.2f, RoundDirectorPatch.enemyNamesTextSingular[num3]);
}
else
{
string text4 = num2 + " " + RoundDirectorPatch.enemyNamesTextPlural[num3];
int index2 = TalkingCartBase.NumbersInd + num2;
EnqueueValues(TalkingCartBase.SoundFX[index2], -0.2f, text4);
int index3 = TalkingCartBase.EnemyNamesPluralInd + num3;
EnqueueValues(TalkingCartBase.SoundFX[index3], 0.2f, text4);
}
}
}
private void HandleNearbyEnemies()
{
//IL_0009: 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_00ac: 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_00d0: 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)
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(((Component)this).transform.position.x, 0f, ((Component)this).transform.position.z);
Vector3 val4 = default(Vector3);
for (int i = 0; i < RoundDirectorPatch.enemyList.Count; i++)
{
try
{
EnemyParent val2 = RoundDirectorPatch.enemyParentList[i];
Enemy val3 = RoundDirectorPatch.enemyList[i];
RoundDirectorPatch.EnemyStatus enemyStatus = RoundDirectorPatch.currentEnemyStatus[i];
int num = Array.IndexOf(RoundDirectorPatch.enemyNames, val2.enemyName);
if (num == 1 || num == 6)
{
continue;
}
if (enemyStatus == RoundDirectorPatch.EnemyStatus.Absent)
{
isEnemyNearby[i] = false;
continue;
}
((Vector3)(ref val4))..ctor(((Component)val3).transform.position.x, 0f, ((Component)val3).transform.position.z);
float num2 = Vector3.Distance(val, val4);
if (num2 < 20f && !isEnemyNearby[i])
{
TalkingCartBase.mls.LogInfo((object)("Enemy Nearby: " + val2.enemyName));
if (num == -1 || ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text = val2.enemyName + " nearby";
List<AudioClip> list = TTSGenerateAudioClip(text);
foreach (AudioClip item in list)
{
EnqueueValues(item, 0f, text);
}
}
else
{
int index = TalkingCartBase.EnemyNearbyInd + num;
EnqueueValues(TalkingCartBase.SoundFX[index], 0.2f, RoundDirectorPatch.enemyNamesTextSingular[num] + " nearby");
}
isEnemyNearby[i] = true;
lastCommunicatedStatus[i] = RoundDirectorPatch.EnemyCommState.Nearby;
}
else
{
if (!(num2 > 23f) || !isEnemyNearby[i])
{
continue;
}
TalkingCartBase.mls.LogInfo((object)("Enemy Left Area: " + val2.enemyName));
if (num == -1 || ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text2 = val2.enemyName + " left";
List<AudioClip> list2 = TTSGenerateAudioClip(text2);
foreach (AudioClip item2 in list2)
{
EnqueueValues(item2, 0f, text2);
}
}
else
{
int index2 = TalkingCartBase.EnemyLeftInd + num;
EnqueueValues(TalkingCartBase.SoundFX[index2], 0.2f, RoundDirectorPatch.enemyNamesTextSingular[num] + " left");
}
isEnemyNearby[i] = false;
lastCommunicatedStatus[i] = RoundDirectorPatch.EnemyCommState.Nearby;
continue;
}
}
catch (ArgumentOutOfRangeException ex)
{
TalkingCartBase.mls.LogError((object)$"Index {i} is out of range for one of the enemy lists.");
TalkingCartBase.mls.LogError((object)$"List lengths: {RoundDirectorPatch.enemyParentList.Count}, {RoundDirectorPatch.enemyList.Count}, {RoundDirectorPatch.currentEnemyStatus.Count}, {isEnemyNearby.Count}, {lastCommunicatedStatus.Count}");
TalkingCartBase.mls.LogError((object)("Error: " + ex.Message));
}
catch (IndexOutOfRangeException ex2)
{
TalkingCartBase.mls.LogError((object)$"Index {i} is out of range for one of the enemy arrays.");
TalkingCartBase.mls.LogError((object)$"List lengths: {RoundDirectorPatch.enemyParentList.Count}, {RoundDirectorPatch.enemyList.Count}, {RoundDirectorPatch.currentEnemyStatus.Count}, {isEnemyNearby.Count}, {lastCommunicatedStatus.Count}");
TalkingCartBase.mls.LogError((object)("Error: " + ex2.Message));
}
}
}
private void HandleDespawnedEnemies()
{
for (int i = 0; i < RoundDirectorPatch.enemyList.Count; i++)
{
if (RoundDirectorPatch.currentEnemyStatus[i] != RoundDirectorPatch.EnemyStatus.Absent || lastCommunicatedStatus[i] == RoundDirectorPatch.EnemyCommState.Despawned || lastCommunicatedStatus[i] == RoundDirectorPatch.EnemyCommState.Dead)
{
continue;
}
if (despawnRespawnTimer[i] < 0)
{
despawnRespawnTimer[i] = 0;
}
despawnRespawnTimer[i]++;
if (despawnRespawnTimer[i] < 3)
{
continue;
}
EnemyParent val = RoundDirectorPatch.enemyParentList[i];
TalkingCartBase.mls.LogInfo((object)("Enemy Despawned End: " + val.enemyName));
int num = Array.IndexOf(RoundDirectorPatch.enemyNames, val.enemyName);
if (num == -1 || ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text = val.enemyName + " despawned";
List<AudioClip> list = TTSGenerateAudioClip(text);
foreach (AudioClip item in list)
{
EnqueueValues(item, 0f, text);
}
}
else
{
int index = TalkingCartBase.EnemyDespawnedInd + num;
EnqueueValues(TalkingCartBase.SoundFX[index], 0.2f, RoundDirectorPatch.enemyNamesTextSingular[num] + " despawned");
}
lastCommunicatedStatus[i] = RoundDirectorPatch.EnemyCommState.Despawned;
despawnRespawnTimer[i] = 0;
}
}
private void HandleRespawnedEnemies()
{
for (int i = 0; i < RoundDirectorPatch.enemyList.Count; i++)
{
if (RoundDirectorPatch.currentEnemyStatus[i] != 0 || (lastCommunicatedStatus[i] != RoundDirectorPatch.EnemyCommState.Despawned && lastCommunicatedStatus[i] != RoundDirectorPatch.EnemyCommState.Dead))
{
continue;
}
if (despawnRespawnTimer[i] > 0)
{
despawnRespawnTimer[i] = 0;
}
despawnRespawnTimer[i]--;
if (despawnRespawnTimer[i] > -3)
{
continue;
}
EnemyParent val = RoundDirectorPatch.enemyParentList[i];
TalkingCartBase.mls.LogInfo((object)("Enemy Respawned End: " + val.enemyName));
int num = Array.IndexOf(RoundDirectorPatch.enemyNames, val.enemyName);
if (num == -1 || ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text = val.enemyName + " respawned";
List<AudioClip> list = TTSGenerateAudioClip(text);
foreach (AudioClip item in list)
{
EnqueueValues(item, 0f, text);
}
}
else
{
int index = TalkingCartBase.EnemyRespawnedInd + num;
EnqueueValues(TalkingCartBase.SoundFX[index], 0.2f, RoundDirectorPatch.enemyNamesTextSingular[num] + " respawned");
}
lastCommunicatedStatus[i] = RoundDirectorPatch.EnemyCommState.Respawned;
despawnRespawnTimer[i] = 0;
}
}
public void HandleDeadEnemy(int enemyInd)
{
if (lastCommunicatedStatus[enemyInd] == RoundDirectorPatch.EnemyCommState.Despawned || lastCommunicatedStatus[enemyInd] == RoundDirectorPatch.EnemyCommState.Dead)
{
TalkingCartBase.mls.LogError((object)"Enemy death ignored!");
return;
}
EnemyParent val = RoundDirectorPatch.enemyParentList[enemyInd];
TalkingCartBase.mls.LogInfo((object)("Enemy Died End: " + val.enemyName));
int num = Array.IndexOf(RoundDirectorPatch.enemyNames, val.enemyName);
if (num == 1 || num == 6)
{
return;
}
if (num == -1 || ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
string text = val.enemyName + " died";
List<AudioClip> list = TTSGenerateAudioClip(text);
foreach (AudioClip item in list)
{
EnqueueValues(item, 0f, text);
}
}
else
{
int index = TalkingCartBase.EnemyDiedInd + num;
EnqueueValues(TalkingCartBase.SoundFX[index], 0.2f, RoundDirectorPatch.enemyNamesTextSingular[num] + " died");
}
lastCommunicatedStatus[enemyInd] = RoundDirectorPatch.EnemyCommState.Dead;
}
public void CommunicateNearbyItems()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//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)
int num = 0;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(((Component)this).transform.position.x, 0f, ((Component)this).transform.position.z);
Vector3 val2 = default(Vector3);
foreach (ValuableObject levelValuable in ValuableObjectsRecords.levelValuables)
{
if (!((Object)(object)levelValuable == (Object)null))
{
((Vector3)(ref val2))..ctor(((Component)levelValuable).transform.position.x, 0f, ((Component)levelValuable).transform.position.z);
float num2 = Vector3.Distance(val, val2);
if (num2 > 1.1f && num2 < 20f)
{
num++;
}
}
}
TalkingCartBase.mls.LogInfo((object)$"Valuables Nearby: {num}");
string text = num + " items nearby";
if (ConfigManager.alwaysUseGameTTSToVoiceCart.Value)
{
List<AudioClip> list = TTSGenerateAudioClip(text);
{
foreach (AudioClip item in list)
{
EnqueueValues(item, 0f, text);
}
return;
}
}
int index = TalkingCartBase.NumbersInd + num;
EnqueueValues(TalkingCartBase.SoundFX[index], -0.2f, text);
int itemsNearbyVLInd = TalkingCartBase.ItemsNearbyVLInd;
EnqueueValues(TalkingCartBase.SoundFX[itemsNearbyVLInd], 0.2f, text);
}
public List<AudioClip> TTSGenerateAudioClip(string text)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
List<AudioClip> list = new List<AudioClip>();
List<string> list2 = new List<string>(text.Split(new char[1] { ' ' }));
foreach (string item in list2)
{
StringBuilder stringBuilder = new StringBuilder(text.Length * 3 / 2);
stringBuilder.Length = 0;
stringBuilder.Append(item);
SpeechClip val = (SpeechClip)ReflectionHelper.InvokePrivateMethod(cartSpeech, "findFromCache", stringBuilder, 220, (object)(VoicingSource)0, false);
if (val == null)
{
cartSpeech.pregenerate(ref val, 220, (VoicingSource)0, stringBuilder, false, true);
}
if (val != null)
{
list.Add(val.pregenAudio);
}
}
return list;
}
public void EnqueueValues(AudioClip audioClip, float delay, string text)
{
if (isCommEnabled)
{
cartVoiceQueue.Enqueue(audioClip);
cartVoiceDelayQueue.Enqueue(delay);
cartTextQueue.Enqueue(text);
}
}
private void CartVoiceQueueRoller()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
cartVoiceTimer -= Time.deltaTime;
if (cartVoiceQueue.Count == 0 && cartVoiceTimer <= 0f && ((TMP_Text)cartTalkTextTMP).text != "")
{
((TMP_Text)cartTalkTextTMP).text = "";
}
if (cartVoiceQueue.Count != 0 && !(cartVoiceTimer > 0f) && isCommEnabled)
{
AudioClip val = cartVoiceQueue.Dequeue();
float num = cartVoiceDelayQueue.Dequeue();
cartSound.Sounds = (AudioClip[])(object)new AudioClip[1] { val };
cartVoiceTimer = val.length + num;
cartSound.Play(physGrabCart.displayText.transform.position, 1f, ConfigManager.cartVoiceFalloffMultiplier.Value, 1f, 1f);
string text = cartTextQueue.Dequeue();
((TMP_Text)cartTalkTextTMP).text = text;
}
}
public void ToggleComms()
{
isCommEnabled = !isCommEnabled;
if (!isCommEnabled)
{
cartVoiceQueue.Clear();
cartVoiceDelayQueue.Clear();
cartTextQueue.Clear();
}
TalkingCartBase.mls.LogInfo((object)$"Is comm enabled: {isCommEnabled}");
}
private Transform CreateUIElement()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Game Hud");
GameObject val2 = GameObject.Find("Tax Haul");
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
return null;
}
TMP_FontAsset font = val2.GetComponent<TMP_Text>().font;
GameObject val3 = new GameObject("Cart Mode HUD");
val3.SetActive(false);
val3.AddComponent<TextMeshProUGUI>();
TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).font = font;
((Graphic)component).color = Color.white;
((TMP_Text)component).fontSize = 20f;
((TMP_Text)component).enableWordWrapping = false;
((TMP_Text)component).alignment = (TextAlignmentOptions)260;
((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)4;
((TMP_Text)component).verticalAlignment = (VerticalAlignmentOptions)256;
val3.transform.SetParent(val.transform, false);
RectTransform component2 = val3.GetComponent<RectTransform>();
component2.pivot = new Vector2(1f, 1f);
component2.anchoredPosition = new Vector2(-4f, -11f);
component2.anchorMin = new Vector2(1f, 1f);
component2.anchorMax = new Vector2(1f, 1f);
component2.sizeDelta = new Vector2(200f, 50f);
return val3.transform;
}
private void HandleCartUI()
{
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)PlayerControllerPatch.GetGrabbedCart() != (Object)(object)this)
{
if ((Object)(object)enableInstructionTMP != (Object)null && ((TMP_Text)enableInstructionTMP).text != "" && (Object)(object)PlayerControllerPatch.GetGrabbedCart() == (Object)null)
{
((TMP_Text)enableInstructionTMP).text = "";
}
if ((Object)(object)itemsInstructionTMP != (Object)null && ((TMP_Text)itemsInstructionTMP).text != "" && (Object)(object)PlayerControllerPatch.GetGrabbedCart() == (Object)null)
{
((TMP_Text)itemsInstructionTMP).text = "";
}
return;
}
if ((Object)(object)enableInstructionTMP == (Object)null)
{
Transform val = CreateUIElement();
RectTransform component = ((Component)val).GetComponent<RectTransform>();
enableInstructionTMP = ((Component)val).GetComponent<TextMeshProUGUI>();
((Component)val).gameObject.SetActive(true);
component.anchoredPosition = new Vector2(-4f, -80f);
}
if ((Object)(object)itemsInstructionTMP == (Object)null)
{
Transform val2 = CreateUIElement();
RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
itemsInstructionTMP = ((Component)val2).GetComponent<TextMeshProUGUI>();
((Component)val2).gameObject.SetActive(true);
component2.anchoredPosition = new Vector2(-4f, -110f);
}
if (isCommEnabled)
{
if (((TMP_Text)enableInstructionTMP).text != "Click '" + ConfigManager.toggleCommunicationsKey.Value + "' to disable cart voice.")
{
((TMP_Text)enableInstructionTMP).text = "Click '" + ConfigManager.toggleCommunicationsKey.Value + "' to disable cart voice.";
}
}
else if (((TMP_Text)enableInstructionTMP).text != "Click '" + ConfigManager.toggleCommunicationsKey.Value + "' to enable cart voice.")
{
((TMP_Text)enableInstructionTMP).text = "Click '" + ConfigManager.toggleCommunicationsKey.Value + "' to enable cart voice.";
}
if (((TMP_Text)itemsInstructionTMP).text != "Click '" + ConfigManager.communicateNearbyItemsKey.Value + "' for items count.")
{
((TMP_Text)itemsInstructionTMP).text = "Click '" + ConfigManager.communicateNearbyItemsKey.Value + "' for items count.";
}
}
}
[HarmonyPatch(typeof(PhysGrabCart))]
internal class CartVocalPatch
{
public static List<CartTalkingManager> carts = new List<CartTalkingManager>();
private static List<PhysGrabObject> cartsPhysGrabObjects = new List<PhysGrabObject>();
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(PhysGrabCart __instance, ref PhysGrabObject ___physGrabObject)
{
if (!__instance.isSmallCart)
{
CartTalkingManager cartTalkingManager = ((Component)__instance).gameObject.AddComponent<CartTalkingManager>();
(cartTalkingManager.cartRoastSync = ((Component)__instance).gameObject.AddComponent<CartRoastSync>()).cart = cartTalkingManager;
carts.Add(cartTalkingManager);
cartsPhysGrabObjects.Add(___physGrabObject);
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(PhysGrabCart __instance, ref bool ___cartBeingPulled)
{
if (!__instance.isSmallCart)
{
CartTalkingManager component = ((Component)__instance).GetComponent<CartTalkingManager>();
component.isCartBeingPulled = ___cartBeingPulled;
}
}
public static void AddEnemyRecordToAllCarts()
{
foreach (CartTalkingManager cart in carts)
{
cart.isEnemyNearby.Add(item: false);
cart.lastCommunicatedStatus.Add(RoundDirectorPatch.EnemyCommState.None);
cart.despawnRespawnTimer.Add(0);
}
}
private static int GetNearestCartToPlayer()
{
//IL_000e: 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)
int result = 0;
float num = float.PositiveInfinity;
for (int i = 0; i < carts.Count; i++)
{
float num2 = Vector3.Distance(PlayerControllerPatch.playerPosition, ((Component)carts[i]).transform.position);
if (num2 < num)
{
result = i;
num = num2;
}
}
return result;
}
}
[HarmonyPatch(typeof(ChatManager))]
internal class ChatManagerPatch
{
public static ChatState chatState;
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(ref ChatState ___chatState)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
chatState = ___chatState;
}
}
internal class ConfigManager
{
public static ConfigEntry<string> communicateNearbyItemsKey;
public static ConfigEntry<string> toggleCommunicationsKey;
public static ConfigEntry<float> cartVoiceFalloffMultiplier;
public static ConfigEntry<bool> alwaysUseGameTTSToVoiceCart;
public static ConfigEntry<float> cartChanceToReactToDamagingItems;
public static ConfigEntry<bool> warnAboutEnemies;
public static void Initialize(ConfigFile cfg)
{
communicateNearbyItemsKey = cfg.Bind<string>("Controls", "CommunicateNearbyItemsKey", "x", "The key used to make the cart communicate how many valuables are nearby.");
toggleCommunicationsKey = cfg.Bind<string>("Controls", "ToggleCommunicationsKey", "z", "The key used to toggle the cart's vocal communications (on/off).");
cartVoiceFalloffMultiplier = cfg.Bind<float>("Audio", "CartVoiceFalloffMultiplier", 1.5f, "This number indicates how far away the player can hear the cart from.");
alwaysUseGameTTSToVoiceCart = cfg.Bind<bool>("Audio", "AlwaysUseGameTTSToVoiceCart", false, "Turning this on will make the cart always communicate using the in-game TTS instead of Google's TTS. It's not recommended to turn this option on because the in-game tts can sound inaudible when voicing some of the voicelines.");
cartChanceToReactToDamagingItems = cfg.Bind<float>("Behaviour", "CartChanceToReactToDamagingItems", 0.1f, "This number indicates how likely the cart is to roast a player if they damage or break an item next to it. Set to 0 if you want it disabled.");
warnAboutEnemies = cfg.Bind<bool>("Behaviour", "WarnAboutEnemies", true, "When this is turned off, the cart will no longer warn the player about enemies.");
}
}
[HarmonyPatch(typeof(EnemyHealth))]
internal class EnemyHealthPatch
{
[HarmonyPatch("Death")]
[HarmonyPrefix]
private static void EnemyDeathPatch(Enemy ___enemy)
{
if (!ConfigManager.warnAboutEnemies.Value)
{
return;
}
int enemyInd = RoundDirectorPatch.enemyList.IndexOf(___enemy);
foreach (CartTalkingManager cart in CartVocalPatch.carts)
{
cart.HandleDeadEnemy(enemyInd);
}
}
}
[HarmonyPatch(typeof(EnemyParent))]
internal class EnemyParentPatch
{
[HarmonyPatch("Despawn")]
[HarmonyPostfix]
private static void EnemyDespawnPatch(EnemyParent __instance)
{
if (RoundDirectorPatch.initialEnemiesCommunicated)
{
int num = Array.IndexOf(RoundDirectorPatch.enemyNames, __instance.enemyName);
if (num != 1 && num != 6)
{
int index = RoundDirectorPatch.enemyParentList.IndexOf(__instance);
RoundDirectorPatch.currentEnemyStatus[index] = RoundDirectorPatch.EnemyStatus.Absent;
TalkingCartBase.mls.LogInfo((object)("Enemy Despawned Start: " + __instance.enemyName));
}
}
}
[HarmonyPatch("Spawn")]
[HarmonyPostfix]
private static void EnemyRespawnPatch(EnemyParent __instance)
{
if (RoundDirectorPatch.initialEnemiesCommunicated)
{
int num = Array.IndexOf(RoundDirectorPatch.enemyNames, __instance.enemyName);
if (num != 1 && num != 6)
{
int index = RoundDirectorPatch.enemyParentList.IndexOf(__instance);
RoundDirectorPatch.currentEnemyStatus[index] = RoundDirectorPatch.EnemyStatus.Present;
TalkingCartBase.mls.LogInfo((object)("Enemy Respawned Start: " + __instance.enemyName));
}
}
}
}
[HarmonyPatch(typeof(Enemy))]
internal class EnemyPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void GetEnemyListedPatch(Enemy __instance, ref EnemyParent ___EnemyParent)
{
TalkingCartBase.mls.LogInfo((object)("Enemy Spawned: " + ___EnemyParent.enemyName));
RoundDirectorPatch.AddEnemy(___EnemyParent, __instance);
CartVocalPatch.AddEnemyRecordToAllCarts();
}
}
[HarmonyPatch(typeof(PhysGrabObject))]
internal class PhysGrabObjectPatch
{
[CompilerGenerated]
private sealed class <DisableRoastValidity>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public int itemInd;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DisableRoastValidity>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
ValuableObjectsRecords.isValidForRoast[itemInd] = false;
ValuableObjectsRecords.roastValidityCoroutines[itemInd] = null;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(PhysGrabObject __instance, ref bool ___grabbed, ref bool ___isValuable)
{
if (!___isValuable)
{
return;
}
ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>();
int num = ValuableObjectsRecords.levelValuables.IndexOf(component);
if (___grabbed)
{
if (ValuableObjectsRecords.roastValidityCoroutines[num] != null)
{
((MonoBehaviour)__instance).StopCoroutine(ValuableObjectsRecords.roastValidityCoroutines[num]);
}
ValuableObjectsRecords.isValidForRoast[num] = true;
}
else if (ValuableObjectsRecords.isValidForRoast[num] && ValuableObjectsRecords.roastValidityCoroutines[num] == null)
{
ValuableObjectsRecords.roastValidityCoroutines[num] = ((MonoBehaviour)__instance).StartCoroutine(DisableRoastValidity(num));
}
}
[IteratorStateMachine(typeof(<DisableRoastValidity>d__1))]
private static IEnumerator DisableRoastValidity(int itemInd)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DisableRoastValidity>d__1(0)
{
itemInd = itemInd
};
}
}
[HarmonyPatch(typeof(PlayerAvatar))]
internal class PlayerAvatarPatch
{
public static PlayerAvatar localPlayerAvatar;
public static PhysGrabber localPlayerPhysGrabber;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(PlayerAvatar __instance, ref bool ___isLocal)
{
if (___isLocal)
{
localPlayerAvatar = __instance;
localPlayerPhysGrabber = ((Component)__instance).GetComponent<PhysGrabber>();
}
}
}
[HarmonyPatch(typeof(RoundDirector))]
internal class RoundDirectorPatch
{
public enum EnemyStatus
{
Present,
Absent
}
public enum EnemyCommState
{
None,
Nearby,
Left,
Despawned,
Respawned,
Dead
}
public static string[] enemyNames = new string[19]
{
"Animal", "Banger", "Bowtie", "Chef", "Clown", "Apex Predator", "Gnome", "Headman", "Hidden", "Huntsman",
"Mentalist", "Peeper", "Reaper", "Robe", "Rugrat", "Shadow Child", "Spewer", "Trudge", "Upscream"
};
public static string[] enemyNamesTextSingular = new string[19]
{
"Animal", "Banger", "Bowtie", "Chef", "Clown", "Duck", "Gnome", "Headman", "Hidden", "Huntsman",
"Mentalist", "Peeper", "Reaper", "Robe", "Rugrat", "Shadow Child", "Spewer", "Trudge", "Upscream"
};
public static string[] enemyNamesTextPlural = new string[19]
{
"Animals", "Bangers", "Bowties", "Chefs", "Clowns", "Ducks", "Gnomes", "Headmen", "Hiddens", "Huntsmen",
"Mentalists", "Peepers", "Reapers", "Robes", "Rugrats", "Shadow Children", "Spewers", "Trudges", "Upscreams"
};
public static bool initialEnemiesCommunicated = false;
public static List<EnemyParent> enemyParentList = new List<EnemyParent>();
public static List<Enemy> enemyList = new List<Enemy>();
public static List<string> roundEnemyNamesList = new List<string>();
public static List<EnemyStatus> currentEnemyStatus = new List<EnemyStatus>();
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch()
{
ValuableObjectsRecords.ResetLists();
enemyParentList.Clear();
enemyList.Clear();
roundEnemyNamesList.Clear();
currentEnemyStatus.Clear();
initialEnemiesCommunicated = false;
CartVocalPatch.carts.Clear();
TalkingCartBase.mls.LogInfo((object)"Resetting enemy lists!");
}
public static void AddEnemy(EnemyParent enemyParent, Enemy enemy)
{
enemyParentList.Add(enemyParent);
enemyList.Add(enemy);
currentEnemyStatus.Add(EnemyStatus.Present);
if (!roundEnemyNamesList.Contains(enemyParent.enemyName))
{
roundEnemyNamesList.Add(enemyParent.enemyName);
}
}
}
[HarmonyPatch(typeof(PlayerController))]
internal class PlayerControllerPatch
{
public static Vector3 playerPosition = default(Vector3);
private static List<string> mouseBtns = new List<string> { "leftButton", "rightButton", "middleButton", "forwardButton", "backButton" };
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(PlayerController __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
playerPosition = ((Component)__instance).transform.position;
if ((int)ChatManagerPatch.chatState == 1)
{
return;
}
if (WasButtonPressedThisFrame(ConfigManager.communicateNearbyItemsKey.Value))
{
CartTalkingManager grabbedCart = GetGrabbedCart();
if ((Object)(object)grabbedCart != (Object)null)
{
grabbedCart.CommunicateNearbyItems();
}
}
if (WasButtonPressedThisFrame(ConfigManager.toggleCommunicationsKey.Value))
{
CartTalkingManager grabbedCart2 = GetGrabbedCart();
if ((Object)(object)grabbedCart2 != (Object)null)
{
grabbedCart2.ToggleComms();
}
}
}
public static CartTalkingManager GetGrabbedCart()
{
if ((Object)(object)PlayerAvatarPatch.localPlayerPhysGrabber.grabbedObjectTransform != (Object)null)
{
return ((Component)PlayerAvatarPatch.localPlayerPhysGrabber.grabbedObjectTransform).GetComponent<CartTalkingManager>();
}
return null;
}
private static bool WasButtonPressedThisFrame(string btn)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
InputControl val = ((!mouseBtns.Contains(btn)) ? ((InputControl)Keyboard.current)[btn] : ((InputControl)Mouse.current)[btn]);
return ((ButtonControl)val).wasPressedThisFrame;
}
}
[HarmonyPatch(typeof(ValuableObject))]
internal class ValuableObjectsRecords
{
public static List<ValuableObject> levelValuables = new List<ValuableObject>();
public static List<float> valuableLastValue = new List<float>();
public static List<bool> isValidForRoast = new List<bool>();
public static List<Coroutine> roastValidityCoroutines = new List<Coroutine>();
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void ValuableStartPatch(ValuableObject __instance)
{
levelValuables.Add(__instance);
isValidForRoast.Add(item: false);
roastValidityCoroutines.Add(null);
valuableLastValue.Add(100f);
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(ValuableObject __instance)
{
//IL_0062: 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)
int index = levelValuables.IndexOf(__instance);
float privateField = ReflectionHelper.GetPrivateField<float>(__instance, "dollarValueCurrent");
if (privateField < valuableLastValue[index])
{
CartTalkingManager cartTalkingManager = CartVocalPatch.carts[0];
float num = float.PositiveInfinity;
foreach (CartTalkingManager cart in CartVocalPatch.carts)
{
float num2 = Vector3.Distance(((Component)cart).transform.position, ((Component)__instance).transform.position);
if (num2 < num)
{
cartTalkingManager = cart;
num = num2;
}
}
if (num <= 12f && isValidForRoast[index])
{
cartTalkingManager.cartRoastSync.AttemptRoast();
}
}
if (privateField != valuableLastValue[index])
{
valuableLastValue[index] = privateField;
}
}
public static void ResetLists()
{
levelValuables.Clear();
isValidForRoast.Clear();
roastValidityCoroutines.Clear();
valuableLastValue.Clear();
}
}
}