using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using FMOD;
using FMOD.Studio;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Fields;
using Il2CppSystem;
using Il2CppSystem.Runtime.InteropServices;
using Sons.Gameplay.GameSetup;
using Sons.Gameplay.TreeCutting;
using Sons.Save;
using SonsApi;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ThomasTheDestroyer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("as a small chance of spawning a friend on a set interval. Single player only.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("ThomasTheDestroyer")]
[assembly: AssemblyTitle("ThomasTheDestroyer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace SonsApi
{
public static class GameStateApi
{
public enum HostMode
{
SinglePlayer,
Multiplayer,
MultiplayerClient
}
public static bool IsInGame()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
Scene sceneByName = SceneManager.GetSceneByName("SonsMain");
if (((Scene)(ref sceneByName)).IsValid())
{
sceneByName = SceneManager.GetSceneByName("SonsMainLoading");
return !((Scene)(ref sceneByName)).IsValid();
}
return false;
}
public static HostMode? GetHostMode()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0018: Expected I4, but got Unknown
SaveGameType saveGameType = GameSetupManager.GetSaveGameType();
return (int)saveGameType switch
{
0 => HostMode.SinglePlayer,
1 => HostMode.Multiplayer,
2 => HostMode.MultiplayerClient,
_ => null,
};
}
}
}
namespace ThomasTheDestroyer
{
public class FMODManager
{
private static void LoadBank(TextAsset asset)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_003f: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_007f: 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_00b6: Invalid comparison between Unknown and I4
FMOD_StudioSystem val = default(FMOD_StudioSystem);
bool flag = FMOD_StudioSystem.TryGetInstance(ref val, false);
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag2 = default(bool);
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(29, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD system loading success: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag);
}
log.LogDebug(val2);
System system = val.System;
Bank val3 = default(Bank);
RESULT val4 = ((System)(ref system)).loadBankMemory(asset.bytes, (LOAD_BANK_FLAGS)4, ref val3);
ManualLogSource log2 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(26, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD bank loading result: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(val4);
}
log2.LogDebug(val2);
ManualLogSource log3 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(27, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD bank loading success: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>((int)val4 == 0);
}
log3.LogDebug(val2);
}
public static void LoadBankFile(string filepath)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_003f: 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_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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
//IL_007a: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
FMOD_StudioSystem val = default(FMOD_StudioSystem);
bool flag = FMOD_StudioSystem.TryGetInstance(ref val, false);
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag2 = default(bool);
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(29, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD system loading success: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag);
}
log.LogDebug(val2);
System system = val.System;
Bank val3 = default(Bank);
RESULT val4 = ((System)(ref system)).loadBankFile(filepath, (LOAD_BANK_FLAGS)4, ref val3);
ManualLogSource log2 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(26, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD bank loading result: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(val4);
}
log2.LogDebug(val2);
ManualLogSource log3 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(27, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD bank loading success: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>((int)val4 == 0);
}
log3.LogDebug(val2);
RESULT val5 = ((Bank)(ref val3)).loadSampleData();
ManualLogSource log4 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(30, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD samples loading success: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(val5);
}
log4.LogDebug(val2);
system = val.System;
EventDescription val6 = default(EventDescription);
RESULT @event = ((System)(ref system)).getEvent("event:/ThomasBgm", ref val6);
ManualLogSource log5 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(20, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Event fetch result: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((object)(RESULT)(ref @event)).ToString());
}
log5.LogDebug(val2);
ManualLogSource log6 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(16, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Event is valid: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(((EventDescription)(ref val6)).isValid());
}
log6.LogDebug(val2);
}
public static void PlayMp3(string filepath)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_003f: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_0078: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00ba: 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_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
FMOD_StudioSystem val = default(FMOD_StudioSystem);
bool flag = FMOD_StudioSystem.TryGetInstance(ref val, false);
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag2 = default(bool);
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(21, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD system loading: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag);
}
log.LogDebug(val2);
System system = val.System;
System val3 = default(System);
RESULT coreSystem = ((System)(ref system)).getCoreSystem(ref val3);
ManualLogSource log2 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(26, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD core system loading: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(coreSystem);
}
log2.LogDebug(val2);
Sound val4 = default(Sound);
RESULT val5 = ((System)(ref val3)).createSound(filepath, (MODE)0, ref val4);
ManualLogSource log3 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(20, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD sound loading: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(val5);
}
log3.LogDebug(val2);
ChannelGroup val6 = default(ChannelGroup);
RESULT masterChannelGroup = ((System)(ref val3)).getMasterChannelGroup(ref val6);
ManualLogSource log4 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(37, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD channel group discovery result: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(masterChannelGroup);
}
log4.LogDebug(val2);
Channel val7 = default(Channel);
RESULT val8 = ((System)(ref val3)).playSound(val4, val6, false, ref val7);
ManualLogSource log5 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(18, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD play result: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(val8);
}
log5.LogDebug(val2);
}
public static void DebugBuses()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_007d: 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_00e1: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
FMOD_StudioSystem val = default(FMOD_StudioSystem);
bool flag = FMOD_StudioSystem.TryGetInstance(ref val, false);
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag2 = default(bool);
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(21, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD system loading: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag);
}
log.LogDebug(val2);
System system = val.System;
Bus val3 = default(Bus);
RESULT bus = ((System)(ref system)).getBus("bus:/", ref val3);
ManualLogSource log2 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(23, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD system bus fetch: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(bus);
}
log2.LogDebug(val2);
Guid val4 = default(Guid);
RESULT iD = ((Bus)(ref val3)).getID(ref val4);
ManualLogSource log3 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(24, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("FMOD system guid fetch: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<RESULT>(iD);
}
log3.LogDebug(val2);
ManualLogSource log4 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(17, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Master bus GUID: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((object)(Guid)(ref val4)).ToString());
}
log4.LogDebug(val2);
system = val.System;
EventDescription val5 = default(EventDescription);
RESULT @event = ((System)(ref system)).getEvent("event:/ThomasBgm", ref val5);
ManualLogSource log5 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(20, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Event fetch result: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((object)(RESULT)(ref @event)).ToString());
}
log5.LogDebug(val2);
ManualLogSource log6 = ((BasePlugin)ThomasPlugin.Instance).Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(16, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Event is valid: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(((EventDescription)(ref val5)).isValid());
}
log6.LogDebug(val2);
}
}
[BepInPlugin("dev.mythic.sotf.thomas", "ThomasTheDestroyer", "0.1.0")]
public class ThomasPlugin : BasePlugin
{
public static ThomasPlugin Instance;
private ConfigEntry<uint> _spawnCheckInterval;
private ConfigEntry<float> _spawnChance;
public override void Load()
{
Instance = this;
_spawnCheckInterval = ((BasePlugin)this).Config.Bind<uint>("General", "SpawnCheckInterval", 1800u, "The amount of seconds to wait between thomas spawn attempts. 30 minutes by default.");
_spawnChance = ((BasePlugin)this).Config.Bind<float>("General", "SpawnChance", 0.2f, "The chance for thomas to spawn when the interval is checked (0.2 = 20%)");
((BasePlugin)Instance).Log.LogInfo((object)Assembly.GetExecutingAssembly().Location);
ClassInjector.RegisterTypeInIl2Cpp(typeof(ThomasController));
((BasePlugin)this).AddComponent<ThomasManager>().StartScheduler(_spawnCheckInterval.Value, _spawnChance.Value);
}
}
public class ThomasManager : MonoBehaviour
{
private Il2CppReferenceField<GameObject> thomasPrefab;
private Il2CppReferenceField<AssetBundle> bundle;
private GCHandle thomasPrefabHandle;
private GCHandle bundleHandle;
private bool lastInputState;
private bool _audioLoaded;
private void Awake()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: 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)
//IL_00e4: Expected O, but got Unknown
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(17, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading assets...");
}
log.LogDebug(val);
((BasePlugin)ThomasPlugin.Instance).Log.LogDebug((object)Assembly.GetExecutingAssembly().Location);
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
bundle.Set(AssetBundle.LoadFromFile(Path.Join(directoryName, "StreamingAssets", "mythic", "thomas")));
bundleHandle = GCHandle.Alloc((Object)(object)Il2CppReferenceField<AssetBundle>.op_Implicit(bundle), (GCHandleType)2);
thomasPrefab.Set(((Il2CppObjectBase)bundle.Value.LoadAsset("Assets/ThomasTheTankEngine/ThomasTheDestroyer.prefab", Il2CppType.Of<GameObject>())).TryCast<GameObject>());
thomasPrefabHandle = GCHandle.Alloc((Object)(object)Il2CppReferenceField<GameObject>.op_Implicit(thomasPrefab), (GCHandleType)2);
ManualLogSource log2 = ((BasePlugin)ThomasPlugin.Instance).Log;
val = new BepInExDebugLogInterpolatedStringHandler(24, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Finished loading asset: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((object)thomasPrefab).ToString());
}
log2.LogDebug(val);
}
public void StartScheduler(uint intervalSeconds, float spawnChance)
{
((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ThomasSchedule(intervalSeconds, spawnChance)));
}
private void LoadAudio()
{
if (!_audioLoaded)
{
string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
FMODManager.LoadBankFile(Path.Join(directoryName, "StreamingAssets", "mythic", "Thomas.strings.bank"));
FMODManager.LoadBankFile(Path.Join(directoryName, "StreamingAssets", "mythic", "Thomas.bank"));
_audioLoaded = true;
}
}
private void OnDestroy()
{
((GCHandle)(ref thomasPrefabHandle)).Free();
((GCHandle)(ref bundleHandle)).Free();
}
private void SpawnThomas()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00b4: Unknown result type (might be due to invalid IL or missing references)
if (GameStateApi.IsInGame() && GameStateApi.GetHostMode() == GameStateApi.HostMode.SinglePlayer)
{
LoadAudio();
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Instantiating thomas: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)thomasPrefab.Value).ToString());
}
log.LogInfo(val);
GameObject val2 = GameObject.FindWithTag("MainCamera");
if ((Object)(object)val2 != (Object)null)
{
GameObject obj = Object.Instantiate<GameObject>(Il2CppReferenceField<GameObject>.op_Implicit(thomasPrefab), val2.transform.position + ((Component)this).transform.forward * 50f, val2.transform.rotation);
FMOD_StudioEventEmitter obj2 = obj.AddComponent<FMOD_StudioEventEmitter>();
obj2.SetEventPath("event:/ThomasBgm");
obj2.Play();
((Il2CppObjectBase)obj.AddComponent(Il2CppType.Of<ThomasController>())).TryCast<ThomasController>().SetTarget(val2.transform);
}
}
}
private IEnumerator ThomasSchedule(uint intervalSeconds, float spawnChance)
{
ManualLogSource log = ((BasePlugin)ThomasPlugin.Instance).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(67, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Starting thomas schedule, running every ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(intervalSeconds);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" seconds with spawn chance ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(spawnChance);
}
log.LogInfo(val);
while (true)
{
yield return (object)new WaitForSeconds((float)intervalSeconds);
try
{
if (!GameStateApi.IsInGame() || GameStateApi.GetHostMode() != GameStateApi.HostMode.SinglePlayer)
{
((BasePlugin)ThomasPlugin.Instance).Log.LogDebug((object)"Not valid game state, skipping");
}
else if (Random.value < spawnChance)
{
SpawnThomas();
}
}
catch (Exception ex)
{
((BasePlugin)ThomasPlugin.Instance).Log.LogError((object)ex.Message);
}
}
}
}
public class ThomasController : MonoBehaviour
{
private Il2CppReferenceField<Transform> _target;
public float speed = 4f;
private float endTime;
private Il2CppReferenceField<FallingTreeDamage> _damage;
private Il2CppReferenceField<MeleeImpactData> _impact;
private void Awake()
{
//IL_0083: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
endTime = Time.fixedTime + 75f;
_damage.Set(((Component)this).gameObject.AddComponent<FallingTreeDamage>());
_damage.Value._damage = 1000f;
_damage.Value._minImpactForce = 100f;
_damage.Value._fallingTreeRoot = ((Component)this).transform;
_impact.Set(new MeleeImpactData(((Il2CppObjectBase)_damage.Value).TryCast<IImpactSender>(), (ImpactMeleeType)3, 1000f, Vector3.forward, Vector3.forward));
}
public void SetTarget(Transform target)
{
_target.Set(target);
}
private void OnCollisionEnter(Collision collision)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
FallingTreeDamageReceiver component = collision.gameObject.GetComponent<FallingTreeDamageReceiver>();
if ((Object)(object)component != (Object)null)
{
component.OnImpact(((Il2CppObjectBase)_damage.Value).TryCast<IImpactSender>(), ((Il2CppObjectBase)_impact.Value).TryCast<IImpactData>());
}
Vitals component2 = collision.other.GetComponent<Vitals>();
if ((Object)(object)component2 != (Object)null)
{
component2.ApplyDamage(100000f);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
TreeSwapper component3 = collision.gameObject.GetComponent<TreeSwapper>();
if ((Object)(object)component3 != (Object)null)
{
component3.InstantCutForceFall(Vector3.fwd);
return;
}
TreeCutManager component4 = collision.gameObject.GetComponent<TreeCutManager>();
if ((Object)(object)component4 != (Object)null)
{
component4.InstantCut(true);
}
}
private void FixedUpdate()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0059: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_0093: Unknown result type (might be due to invalid IL or missing references)
if (Time.fixedTime > endTime)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Vector3 val = _target.Value.position + Vector3.down * 0.75f;
if (!((Object)(object)_target.Value == (Object)null))
{
Vector3 val2 = val - ((Component)this).transform.position;
((Component)this).transform.rotation = Quaternion.LookRotation(val2);
((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, val, speed * Time.fixedDeltaTime);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "dev.mythic.sotf.thomas";
public const string PLUGIN_NAME = "ThomasTheDestroyer";
public const string PLUGIN_VERSION = "0.1.0";
}
}