using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Video;
[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Orbits")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+75324d47ad02f82ec737b96ea9802aa80eb669c7")]
[assembly: AssemblyProduct("Orbits")]
[assembly: AssemblyTitle("Orbits")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 orbits
{
[BepInPlugin("com.fiufki.orbits", "Orbits", "1.0.4")]
public class plugin : BaseUnityPlugin
{
public const string PluginGUID = "com.fiufki.orbits";
public const string PluginName = "Orbits";
public const string PluginVersion = "1.0.4";
internal static ManualLogSource Log;
internal static AssetBundle OrbitsBundle;
internal static Dictionary<int, LevelPatchData> LevelPatches = new Dictionary<int, LevelPatchData>
{
{
0,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: Arid. Thick haze, worsened by industrial artifacts.\nFAUNA: Dominated by a few species.",
ClipName = null
}
},
{
1,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: Jagged and weathered terrain with great foundation.\nFAUNA: Ecosystem supports territorial behaviour.",
ClipName = null
}
},
{
2,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: Humid. Rough terrain. Teeming with plant-life.\nFAUNA: A competitive ecosystem supports aggressive lifeforms.",
ClipName = "MapView56Vow"
}
},
{
3,
new LevelPatchData
{
Description = "POPULATION: Unknown.\nCONDITIONS: Continual storms. A complete water mass without any land masses. This is where The Company resides.\nFAUNA: Unknown.",
ClipName = "MapView71Gor"
}
},
{
4,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: Dense holt, expansive terrain. Persistent rain.\nFAUNA: Manifold of danger and valid ecosystem.",
ClipName = "MapView61Mar"
}
},
{
5,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: A landscape of deep valleys and mountains.\nFAUNA: Home to a lively, diverse ecosystem of smaller-sized omnivores.",
ClipName = "MapView20Ada"
}
},
{
6,
new LevelPatchData
{
Description = "POPULATION: None.\nCONDITIONS: Frozen, rocky. Deep mist causes adrift, hard to navigate.\nFAUNA: Orbiting a forlorn ecosystem.",
ClipName = "MapView85Ren"
}
},
{
7,
new LevelPatchData
{
Description = "POPULATION: None.\nCONDITIONS: Orbits a white dwarf star. Prior monitoring, for security measures.\nFAUNA: Unlikely for complex life to exist.",
ClipName = "MapView7Din"
}
},
{
8,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: Rocky, bare foundry. With a ragged countryside.\nFAUNA: A ecosystem, gazes for survival.",
ClipName = "MapView21Off"
}
},
{
9,
new LevelPatchData
{
Description = "POPULATION: None.\nCONDITIONS: Recent constant snow and hot temperatures underground. Thick smog.\nFAUNA: Danger upon every corner.",
ClipName = "MapView8Tit"
}
},
{
10,
new LevelPatchData
{
Description = "POPULATION: None.\nCONDITIONS: Waning forests. Abandoned facilities littered across the landscape.\nFAUNA: Rumored active machinery left behind.",
ClipName = "MapView68Art"
}
},
{
12,
new LevelPatchData
{
Description = "POPULATION: Abandoned.\nCONDITIONS: Desolate, mostly made out of amethyst and similar crystals.\nFAUNA: Devoided of biological life.",
ClipName = "MapView5Emb"
}
}
};
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Orbits is loaded.");
try
{
Harmony val = new Harmony("com.fiufki.orbits");
val.PatchAll();
}
catch (Exception arg)
{
Log.LogError((object)$"Failed to initialize Harmony patches: {arg}");
}
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "orbits");
OrbitsBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)OrbitsBundle == (Object)null)
{
Log.LogError((object)("Failed to load assets from " + text + "."));
}
}
}
public class LevelPatchData
{
public string Description;
public string ClipName;
}
[HarmonyPatch(typeof(RoundManager), "Start")]
public class RoundManager_Start_Patch
{
private static Dictionary<string, VideoClip> _cachedVideoClips = new Dictionary<string, VideoClip>();
private static void Postfix(RoundManager __instance)
{
try
{
if ((Object)(object)plugin.OrbitsBundle == (Object)null)
{
plugin.Log.LogWarning((object)"AssetBundle not loaded; skipping level updates.");
return;
}
SelectableLevel[] array = StartOfRound.Instance?.levels;
if (array == null)
{
plugin.Log.LogWarning((object)"No levels found; skipping updates.");
return;
}
SelectableLevel[] array2 = array;
foreach (SelectableLevel val in array2)
{
if (!plugin.LevelPatches.TryGetValue(val.levelID, out var value))
{
continue;
}
val.LevelDescription = value.Description;
plugin.Log.LogInfo((object)$"Updated description of level ID {val.levelID}.");
if (string.IsNullOrEmpty(value.ClipName))
{
continue;
}
if (!_cachedVideoClips.TryGetValue(value.ClipName, out var value2))
{
value2 = plugin.OrbitsBundle.LoadAsset<VideoClip>(value.ClipName);
if ((Object)(object)value2 != (Object)null)
{
_cachedVideoClips[value.ClipName] = value2;
}
}
if ((Object)(object)value2 != (Object)null)
{
val.videoReel = value2;
plugin.Log.LogInfo((object)$"Updated the video reel for level ID {val.levelID}.");
}
else
{
plugin.Log.LogWarning((object)("Could not find '" + value.ClipName + "' in the 'orbits' asset bundle."));
}
}
}
catch (Exception arg)
{
plugin.Log.LogError((object)$"Error in RoundManager_Start_Patch Postfix: {arg}");
}
}
}
}