using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using On.RoR2;
using On.RoR2.Projectile;
using RoR2;
using RoR2.Projectile;
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.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MediocratesProjectileRandomizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MediocratesProjectileRandomizer")]
[assembly: AssemblyTitle("MediocratesProjectileRandomizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MediocratesProjectileRandomizer;
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);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("MediocratesLIVE.MediocratesProjectileRandomizerPlugin", "MediocratesProjectileRandomizerPlugin", "1.3.0")]
public class MediocratesProjectileRandomizerPlugin : BaseUnityPlugin
{
public const string PluginGUID = "MediocratesLIVE.MediocratesProjectileRandomizerPlugin";
public const string PluginAuthor = "MediocratesLIVE";
public const string PluginName = "MediocratesProjectileRandomizerPlugin";
public const string PluginVersion = "1.3.0";
private List<ProjectilePair> projectilePairs = new List<ProjectilePair>();
public void Awake()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
ProjectileManager.FireProjectile_FireProjectileInfo += new hook_FireProjectile_FireProjectileInfo(ProjectileManager_FireProjectile_FireProjectileInfo);
PreGameController.OnEnable += new hook_OnEnable(PreGameController_OnEnable);
projectilePairs.Clear();
}
private void PreGameController_OnEnable(orig_OnEnable orig, PreGameController self)
{
Debug.Log((object)"Player returned to the character selection screen!");
projectilePairs.Clear();
orig.Invoke(self);
}
private void Update()
{
}
private void OnDestroy()
{
projectilePairs.Clear();
}
private void ProjectileManager_FireProjectile_FireProjectileInfo(orig_FireProjectile_FireProjectileInfo orig, ProjectileManager self, FireProjectileInfo fireProjectileInfo)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if (projectilePairs.Any((ProjectilePair x) => ((object)x.OriginalProjectilePrefab).ToString() == ((object)fireProjectileInfo.projectilePrefab).ToString()))
{
ProjectilePair projectilePair = projectilePairs.FirstOrDefault((ProjectilePair x) => ((object)x.OriginalProjectilePrefab).ToString() == ((object)fireProjectileInfo.projectilePrefab).ToString());
Log.Info($"found saved {((object)projectilePair.OriginalProjectilePrefab).ToString()}");
fireProjectileInfo.projectilePrefab = projectilePair.RandomProjectilePrefab;
Log.Info($"transformed to {((object)projectilePair.RandomProjectilePrefab).ToString()}");
}
else
{
GameObject[] projectilePrefabs = ProjectileCatalog.projectilePrefabs;
GameObject randomItem = GetRandomItem(projectilePrefabs.ToList());
Log.Info($"NEW NEW NEW saved {((object)randomItem).ToString()}");
projectilePairs.Add(new ProjectilePair
{
OriginalProjectilePrefab = fireProjectileInfo.projectilePrefab,
RandomProjectilePrefab = randomItem
});
fireProjectileInfo.projectilePrefab = randomItem;
}
orig.Invoke(self, fireProjectileInfo);
}
private static T GetRandomItem<T>(List<T> list)
{
Random random = new Random();
return list[random.Next(list.Count)];
}
}
public class ProjectilePair
{
public GameObject OriginalProjectilePrefab { get; set; }
public GameObject RandomProjectilePrefab { get; set; }
}