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 Microsoft.CodeAnalysis;
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("MultiTrackDriftingSurvivors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MultiTrackDriftingSurvivors")]
[assembly: AssemblyTitle("MultiTrackDriftingSurvivors")]
[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 MultiTrackDriftingSurvivors
{
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.multitrackdriftingsurvivors", "MultiTrackDriftingSurvivors", "2.0.1")]
public class MultiTrackDriftingSurvivors : BaseUnityPlugin
{
public const string MOD_NAME = "MultiTrackDriftingSurvivors";
private const uint START_RUNNING = 3580630223u;
private const uint EVERYBODY_FREEZE = 3365085556u;
private const uint BRIEF_RESPITE = 1249098644u;
private const uint KEEP_GOING = 2606526925u;
private static List<SurvivorStatus> SurvivorsToTrack = new List<SurvivorStatus>();
public const float DEFAULT_BASE_SPEED = 7f;
public const float HOOF_FACTOR = 0.14f;
public const float WHIP_FACTOR = 0.3f;
public const float PADDING = 1.15f;
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
Log.Init(((BaseUnityPlugin)this).Logger);
PInfo = ((BaseUnityPlugin)this).Info;
Stage.Start += new hook_Start(Stage_Start);
}
public void Start()
{
SoundBank.Init();
}
private void Stage_Start(orig_Start orig, Stage self)
{
orig.Invoke(self);
AkSoundEngine.PostEvent(3365085556u, (GameObject)null);
SurvivorsToTrack.Clear();
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
SurvivorsToTrack.Add(new SurvivorStatus(instance, musicPlaying: false));
}
}
public void FixedUpdate()
{
//IL_00a9: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
List<SurvivorStatus> list = new List<SurvivorStatus>();
int num = SurvivorsToTrack.RemoveAll((SurvivorStatus status) => (Object)(object)status.Controller == (Object)null || !status.Controller.isConnected);
foreach (SurvivorStatus item in SurvivorsToTrack)
{
if (!((Object)(object)item.ControllerGameObject != (Object)null))
{
continue;
}
float speed = item.Speed;
float value = (float)item.NumSpeedItems * 0.4f + speed / 12f + (float)Math.Sqrt(item.NumSpeedItems) * speed / 16f - 1f;
RtpcSetter val = new RtpcSetter("Speeds", item.ControllerGameObject);
val.value = value;
RtpcSetter val2 = val;
((RtpcSetter)(ref val2)).FlushIfChanged();
float num2 = MoveSpeedThreshold(item.Inventory.GetItemCount(Items.Hoof.itemIndex), item.Inventory.GetItemCount(Items.SprintOutOfCombat.itemIndex), item.Controller.networkUser.GetCurrentBody().outOfCombat);
if (speed <= num2 && item.MusicPlaying)
{
item.MusicPlaying = false;
AkSoundEngine.PostEvent(1249098644u, item.ControllerGameObject);
}
else if (speed > num2 && !item.MusicPlaying)
{
if (item.MusicStarted)
{
AkSoundEngine.PostEvent(2606526925u, item.ControllerGameObject);
}
else
{
AkSoundEngine.PostEvent(3580630223u, item.ControllerGameObject);
}
item.MusicPlaying = true;
}
item.RecordLastPosition();
}
}
public static float MoveSpeedThreshold(int hooves, int whips, bool outOfCombat, float baseMoveSpeed = 7f)
{
float num = 1f + 0.14f * (float)hooves;
if (outOfCombat)
{
num += 0.3f * (float)whips;
}
return baseMoveSpeed * num * 1.15f;
}
}
public class SurvivorStatus
{
private bool mMusicPlaying = false;
public PlayerCharacterMasterController Controller { get; set; }
public GameObject ControllerGameObject
{
get
{
if (Controller == null)
{
return null;
}
if (Controller.networkUser == null)
{
return null;
}
if (Controller.networkUser.GetCurrentBody() == null)
{
return null;
}
return ((Component)Controller.networkUser.GetCurrentBody()).gameObject;
}
}
public CharacterBody CharacterBody
{
get
{
if (Controller == null)
{
return null;
}
if (Controller.networkUser == null)
{
return null;
}
return Controller.networkUser.GetCurrentBody();
}
}
public Inventory Inventory
{
get
{
if (CharacterBody == null)
{
return null;
}
return CharacterBody.inventory;
}
}
public int NumSpeedItems
{
get
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (Inventory == null)
{
return 0;
}
return Inventory.GetItemCount(Items.Hoof.itemIndex);
}
}
public bool MusicPlaying
{
get
{
return mMusicPlaying;
}
set
{
mMusicPlaying = value;
if (value)
{
MusicStarted = true;
}
}
}
public bool MusicStarted { get; private set; } = false;
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)
//IL_0037: 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_0049: Unknown result type (might be due to invalid IL or missing references)
_ = LastPosition;
if ((Object)(object)ControllerGameObject != (Object)null)
{
Vector3 val = ControllerGameObject.transform.position - LastPosition;
((Vector3)(ref val))..ctor(val.x, val.y / 3f, val.z);
return ((Vector3)(ref val)).magnitude / Time.fixedDeltaTime;
}
return 0f;
}
}
public SurvivorStatus(PlayerCharacterMasterController controller, bool musicPlaying)
{
Controller = controller;
MusicPlaying = musicPlaying;
}
public void RecordLastPosition()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Controller != (Object)null)
{
LastPosition = ControllerGameObject.transform.position;
}
}
}
public static class SoundBank
{
public const string soundBankFolder = "SoundBanks";
public const string soundBankFileName = "Nineties_Soundbank.bnk";
public const string soundBankName = "MySoundBank";
public static string SoundBankDirectory => Path.Combine(Path.GetDirectoryName(MultiTrackDriftingSurvivors.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("Nineties_Soundbank.bnk", ref num);
if ((int)val == 1)
{
Log.Info("Added bank : Nineties_Soundbank.bnk");
}
else
{
Log.Error("Error loading bank : Nineties_Soundbank.bnk " + $"Error code : {val}");
}
}
}
}