using System;
using System.Collections.Generic;
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.Logging;
using EntityStates;
using EntityStates.Turret1;
using Microsoft.CodeAnalysis;
using On.EntityStates.Turret1;
using On.RoR2;
using RoR2;
using RoR2.WwiseUtils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("MultiTrackDriftingTurrets")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MultiTrackDriftingTurrets")]
[assembly: AssemblyTitle("MultiTrackDriftingTurrets")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MultiTrackDriftingTurrets
{
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("com.prismism.multitrackdriftingturrets", "MultiTrackDriftingTurrets", "3.0.0")]
public class MultiTrackDriftingTurrets : BaseUnityPlugin
{
public const string MOD_NAME = "MultiTrackDriftingTurrets";
private const uint DEJA_VU_TIME = 3263900111u;
private const uint DEJA_VU_TIME_STOPS = 4064506877u;
private const uint DEJA_VU_TIME_PAUSES = 1412652099u;
private const uint DEJA_VU_TIME_CONTINUES = 1519326796u;
private static List<TurretStatus> EngiTurretsToTrack = new List<TurretStatus>();
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
PInfo = ((BaseUnityPlugin)this).Info;
Stage.Start += new hook_Start(Stage_Start);
SpawnState.OnEnter += new hook_OnEnter(SpawnState_OnEnter);
}
public void Start()
{
SoundBank.Init();
}
private void SpawnState_OnEnter(orig_OnEnter orig, SpawnState self)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
CharacterBody component = ((Component)((EntityState)self).outer).GetComponent<CharacterBody>();
Inventory inventory = component.master.minionOwnership.ownerMaster.inventory;
int itemCount = inventory.GetItemCount(Items.Hoof.itemIndex);
AkSoundEngine.PostEvent(3263900111u, ((Component)((EntityState)self).outer).gameObject);
EngiTurretsToTrack.Add(new TurretStatus(((Component)((EntityState)self).outer).gameObject, itemCount, musicPlaying: true));
}
private void Stage_Start(orig_Start orig, Stage self)
{
orig.Invoke(self);
AkSoundEngine.PostEvent(4064506877u, (GameObject)null);
}
public void FixedUpdate()
{
//IL_00c0: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
List<TurretStatus> list = new List<TurretStatus>();
int num = EngiTurretsToTrack.RemoveAll((TurretStatus status) => (Object)(object)status.TurretGameObject == (Object)null);
foreach (TurretStatus item in EngiTurretsToTrack)
{
if (item.TurretGameObject == null || !item.TurretGameObject.activeInHierarchy)
{
list.Add(item);
continue;
}
float speed = item.Speed;
float value = (float)item.NumSpeedItems * 0.25f + speed / 20f + (float)Math.Sqrt(item.NumSpeedItems) * speed / 22f - 1f;
RtpcSetter val = new RtpcSetter("Speeds", item.TurretGameObject);
val.value = value;
RtpcSetter val2 = val;
((RtpcSetter)(ref val2)).FlushIfChanged();
if ((double)speed <= 0.0001 && item.MusicPlaying)
{
item.MusicPlaying = false;
AkSoundEngine.PostEvent(1412652099u, item.TurretGameObject);
}
else if ((double)speed > 0.0001 && !item.MusicPlaying)
{
item.MusicPlaying = true;
AkSoundEngine.PostEvent(1519326796u, item.TurretGameObject);
}
item.RecordLastPosition();
}
}
}
public class TurretStatus
{
public GameObject TurretGameObject { get; set; }
public int NumSpeedItems { get; set; }
public bool MusicPlaying { get; set; }
private Vector3 LastPosition { get; set; }
public float Speed
{
get
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
_ = LastPosition;
if ((Object)(object)TurretGameObject != (Object)null)
{
Vector3 val = TurretGameObject.transform.position - LastPosition;
return ((Vector3)(ref val)).magnitude / Time.fixedDeltaTime;
}
return 0f;
}
}
public TurretStatus(GameObject gameObj, int numSpeedItems, bool musicPlaying)
{
TurretGameObject = gameObj;
NumSpeedItems = numSpeedItems;
MusicPlaying = musicPlaying;
}
public void RecordLastPosition()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)TurretGameObject != (Object)null)
{
LastPosition = TurretGameObject.transform.position;
}
}
}
public static class SoundBank
{
public const string soundBankFolder = "SoundBanks";
public const string soundBankFileName = "DEJAVU_Soundbank.bnk";
public const string soundBankName = "MySoundBank";
public static string SoundBankDirectory => Path.Combine(Path.GetDirectoryName(MultiTrackDriftingTurrets.PInfo.Location), "SoundBanks");
public static void Init()
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0042: 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_0065: 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_0068: Invalid comparison between Unknown and I4
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
AKRESULT val = AkSoundEngine.AddBasePath(SoundBankDirectory);
if ((int)val == 1)
{
Log.Info("Added bank base path : " + SoundBankDirectory);
}
else
{
Log.Error("Error adding base path : " + SoundBankDirectory + " " + $"Error code : {val}");
}
uint num = default(uint);
val = AkSoundEngine.LoadBank("DEJAVU_Soundbank.bnk", ref num);
if ((int)val == 1)
{
Log.Info("Added bank : DEJAVU_Soundbank.bnk");
}
else
{
Log.Error("Error loading bank : DEJAVU_Soundbank.bnk " + $"Error code : {val}");
}
}
}
}