using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Gup;
using HG.Reflection;
using On.EntityStates.Gup;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OopsAllGup")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d05a7845cf9be38a1892519457ef7b2d51d529bc")]
[assembly: AssemblyProduct("OopsAllGup")]
[assembly: AssemblyTitle("OopsAllGup")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OopsAllGup;
internal class GupDetails : MonoBehaviour
{
public int livesLeft;
public void CopyFrom(GupDetails gupDetails)
{
livesLeft = gupDetails.livesLeft;
}
}
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 Exception(Exception data)
{
_logSource.LogError((object)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.justinderby.oopsallgup", "OopsAllGup", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class OopsAllGup : BaseUnityPlugin
{
public const string GUID = "com.justinderby.oopsallgup";
public const string ModName = "OopsAllGup";
public const string Version = "1.0.1";
public static ConfigEntry<bool> ModEnabled;
public static ConfigEntry<int> SplitCount;
public static ConfigEntry<int> Lives;
public static ConfigEntry<bool> KinForcesGup;
public void Awake()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "Enable mod. (Default: true)");
SplitCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SplitCount", 2, "When undergoing mitosis, how many should spawn. (Default: 2)");
Lives = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Lives", 3, "How many lives a gup has. (Default: 3)");
KinForcesGup = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OverrideArtifactOfKin", true, "When Artifact of Kin is enabled, force Gup as the monster. (Default: true)");
BaseSplitDeath.OnEnter += new hook_OnEnter(BaseSplitDeath_OnEnter);
ClassicStageInfo.HandleSingleMonsterTypeArtifact += new hook_HandleSingleMonsterTypeArtifact(ClassicStageInfo_HandleSingleMonsterTypeArtifact);
BodySplitter.PerformInternal += new hook_PerformInternal(BodySplitter_PerformInternal);
try
{
if (RiskOfOptionsCompatibility.Enabled)
{
RiskOfOptionsCompatibility.InstallRiskOfOptions();
}
}
catch (Exception data)
{
Log.Exception(data);
}
}
public void Destroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
BaseSplitDeath.OnEnter -= new hook_OnEnter(BaseSplitDeath_OnEnter);
ClassicStageInfo.HandleSingleMonsterTypeArtifact -= new hook_HandleSingleMonsterTypeArtifact(ClassicStageInfo_HandleSingleMonsterTypeArtifact);
BodySplitter.PerformInternal -= new hook_PerformInternal(BodySplitter_PerformInternal);
}
private CharacterSpawnCard GetGeepCard()
{
return LegacyResourcesAPI.Load<CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscGeepBody");
}
private CharacterSpawnCard GetGupCard()
{
return LegacyResourcesAPI.Load<CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscGupBody");
}
private void BaseSplitDeath_OnEnter(orig_OnEnter orig, BaseSplitDeath self)
{
orig.Invoke(self);
if (NetworkServer.active && ModEnabled.Value && (self is GupDeath || self is GeepDeath))
{
GupDetails gupDetails = ((EntityState)self).outer.commonComponents.characterBody.masterObject.gameObject.GetComponent<GupDetails>();
if (!Object.op_Implicit((Object)(object)gupDetails))
{
gupDetails = ((EntityState)self).outer.commonComponents.characterBody.masterObject.gameObject.AddComponent<GupDetails>();
gupDetails.livesLeft = Lives.Value;
Log.Debug($"Adding new life counter to gup. livesLeft = {gupDetails.livesLeft}");
}
gupDetails.livesLeft--;
if (gupDetails.livesLeft > 1)
{
Log.Debug($"Forcing a new split! livesLeft = {gupDetails.livesLeft}");
ForceGupSplit(self);
}
}
}
private void ForceGupSplit(BaseSplitDeath entity)
{
entity.characterSpawnCard = GetGeepCard();
entity.spawnCount = SplitCount.Value;
}
private void BodySplitter_PerformInternal(orig_PerformInternal orig, BodySplitter self, MasterSummon masterSummon)
{
if (!NetworkServer.active || !ModEnabled.Value)
{
orig.Invoke(self, masterSummon);
return;
}
GupDetails detailsOldBody = self.body.masterObject.gameObject.GetComponent<GupDetails>();
if ((Object)(object)detailsOldBody == (Object)null)
{
Log.Error("Cannot find GupDetails on Gup!");
orig.Invoke(self, masterSummon);
return;
}
Action<CharacterMaster> oldAction = masterSummon.preSpawnSetupCallback;
masterSummon.preSpawnSetupCallback = (Action<CharacterMaster>)Delegate.Combine(masterSummon.preSpawnSetupCallback, (Action<CharacterMaster>)delegate(CharacterMaster characterMaster)
{
GupDetails gupDetails = ((Component)characterMaster).gameObject.GetComponent<GupDetails>();
if (!Object.op_Implicit((Object)(object)gupDetails))
{
gupDetails = ((Component)characterMaster).gameObject.AddComponent<GupDetails>();
}
gupDetails.CopyFrom(detailsOldBody);
Log.Debug($"Copying over gup lives! livesLeft = {gupDetails.livesLeft}");
oldAction?.Invoke(characterMaster);
});
orig.Invoke(self, masterSummon);
}
private void ClassicStageInfo_HandleSingleMonsterTypeArtifact(orig_HandleSingleMonsterTypeArtifact orig, DirectorCardCategorySelection monsterCategories, Xoroshiro128Plus rng)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active)
{
orig.Invoke(monsterCategories, rng);
return;
}
if (!ModEnabled.Value || !KinForcesGup.Value)
{
orig.Invoke(monsterCategories, rng);
return;
}
if (!Run.instance.IsExpansionEnabled(((IEnumerable<ExpansionDef>)(object)ExpansionCatalog.expansionDefs).FirstOrDefault((Func<ExpansionDef, bool>)((ExpansionDef def) => def.nameToken == "DLC1_NAME"))))
{
Log.Warning("Survivors of the Void expansion not enabled; not enabling Gups with Artifact of Kin");
orig.Invoke(monsterCategories, rng);
return;
}
monsterCategories.Clear();
int num = monsterCategories.AddCategory("Gup", 1f);
CharacterSpawnCard gupCard = GetGupCard();
monsterCategories.AddCard(num, new DirectorCard
{
spawnCard = (SpawnCard)(object)gupCard,
selectionWeight = 1,
spawnDistance = (MonsterSpawnDistance)0,
preventOverhead = false,
minimumStageCompletions = 0
});
BodyIndex body = ((SpawnCard)gupCard).prefab.GetComponent<CharacterMaster>().bodyPrefab.GetComponent<CharacterBody>().bodyIndex;
if (Object.op_Implicit((Object)(object)Stage.instance))
{
Stage.instance.singleMonsterTypeBodyIndex = body;
return;
}
Stage.onServerStageBegin += delegate(Stage stage)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
stage.singleMonsterTypeBodyIndex = body;
};
}
}
internal class RiskOfOptionsCompatibility
{
private static bool? _enabled;
public static bool Enabled
{
get
{
if (!_enabled.HasValue)
{
_enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
}
return _enabled.Value;
}
}
public static void InstallRiskOfOptions()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_0040: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
AddOption((BaseOption)new CheckBoxOption(OopsAllGup.ModEnabled));
AddOption((BaseOption)new CheckBoxOption(OopsAllGup.KinForcesGup));
AddOption((BaseOption)new IntSliderOption(OopsAllGup.Lives, new IntSliderConfig
{
min = 3,
max = 50
}));
AddOption((BaseOption)new IntSliderOption(OopsAllGup.SplitCount, new IntSliderConfig
{
min = 1,
max = 50
}));
ModSettingsManager.SetModDescription("Control how Gups split during a run.", "com.justinderby.oopsallgup", "OopsAllGup");
static void AddOption(BaseOption option)
{
ModSettingsManager.AddOption(option, "com.justinderby.oopsallgup", "OopsAllGup");
}
}
}