using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Missions.AccessCodes.Node;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.EntityStates.Missions.AccessCodes.Node;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2BepInExPack.GameAssetPaths.Version_1_35_0;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChangeWingStageNumber")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6e6f3a6fae61fdb3adc9985a55872bde9273d877")]
[assembly: AssemblyProduct("ChangeWingStageNumber")]
[assembly: AssemblyTitle("ChangeWingStageNumber")]
[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 ChangeWingStageNumber
{
public class AccessNodeControllerNux : NetworkBehaviour
{
private PurchaseInteraction purchaseInteraction;
private EntityStateMachine esm;
private GameObject fightPrefab = Main.portalPrefab;
private SolusFight solusFight;
public void Start()
{
purchaseInteraction = ((Component)this).GetComponent<PurchaseInteraction>();
esm = ((Component)this).GetComponent<EntityStateMachine>();
GameObject val = Object.Instantiate<GameObject>(fightPrefab, ((Component)this).transform);
solusFight = ((Component)val.transform.GetChild(0)).GetComponent<SolusFight>();
if (NetworkServer.active && Object.op_Implicit((Object)(object)purchaseInteraction))
{
purchaseInteraction.SetAvailable(true);
((UnityEvent<Interactor>)(object)purchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)OnPurchase);
}
}
private void OnEnable()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
TeleporterInteraction.onTeleporterBeginChargingGlobal += TurnOffNode;
if (NetworkServer.active)
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "ACCESSCODES_SPAWNED"
});
}
}
private void OnDisable()
{
TeleporterInteraction.onTeleporterBeginChargingGlobal -= TurnOffNode;
}
[Server]
public void TurnOffNode(TeleporterInteraction interaction)
{
if (!NetworkServer.active)
{
Debug.LogWarning((object)"[Server] function 'AccessNodeControllerNux::TurnOffNode(RoR2.TeleporterInteraction)' called on client");
}
else
{
purchaseInteraction.SetAvailable(false);
}
}
[Server]
public void OnPurchase(Interactor interactor)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
if (!NetworkServer.active)
{
Debug.LogWarning((object)"[Server] function 'AccessNodeControllerNux::OnPurchase(RoR2.Interactor)' called on client");
return;
}
purchaseInteraction.SetAvailable(false);
esm.SetState((EntityState)new NodeActive());
((OverrideFightBase)solusFight).TriggerServer();
}
}
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
{
int num = callerPath.LastIndexOf("ChangeWingStageNumber");
if (num >= 0)
{
callerPath = callerPath.Substring(num + "ChangeWingStageNumber".Length + 1);
}
return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
}
internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Error_NoCallerPrefix(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Fatal_NoCallerPrefix(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Info_NoCallerPrefix(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Message_NoCallerPrefix(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Warning_NoCallerPrefix(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("Nuxlar.ChangeWingStageNumber", "ChangeWingStageNumber", "1.0.0")]
public class Main : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__BaseStateOnEnterCallerMethodModifier;
}
public const string PluginGUID = "Nuxlar.ChangeWingStageNumber";
public const string PluginAuthor = "Nuxlar";
public const string PluginName = "ChangeWingStageNumber";
public const string PluginVersion = "1.0.0";
private const BindingFlags allFlags = (BindingFlags)(-1);
private static ConfigEntry<bool> goToMoon;
public static GameObject portalPrefab;
private static GameObject nodePrefab;
private static InteractableSpawnCard interactableSpawnCard = ScriptableObject.CreateInstance<InteractableSpawnCard>();
internal static Main Instance { get; private set; }
public static string PluginDirectory { get; private set; }
private static ConfigFile CWSNConfig { get; set; }
public void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
Instance = this;
CWSNConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.ChangeWingStageNumber.cfg", true);
goToMoon = CWSNConfig.Bind<bool>("General", "Moon Portal", true, "Portal after Solus Heart goes to the Moon.");
Log.Init(((BaseUnityPlugin)this).Logger);
MethodInfo? method = typeof(Main).GetMethod("BaseStateOnEnterCaller", (BindingFlags)(-1));
object obj = <>O.<0>__BaseStateOnEnterCallerMethodModifier;
if (obj == null)
{
Manipulator val = BaseStateOnEnterCallerMethodModifier;
<>O.<0>__BaseStateOnEnterCallerMethodModifier = val;
obj = (object)val;
}
new ILHook((MethodBase)method, (Manipulator)obj);
LoadAssets();
AccessCodesMissionController.OnStartServer += new hook_OnStartServer(DieInAFire);
AccessNodesBaseState.OnEnter += new hook_OnEnter(ReplaceOnEnter);
NodeActive.OnEnter += new hook_OnEnter(KillMe);
if (goToMoon.Value)
{
SolusWebMissionController.SpawnPortal += new hook_SpawnPortal(ChangeDestination);
}
}
private void KillMe(orig_OnEnter orig, NodeActive self)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_0052: 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_005d: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)((AccessNodesBaseState)self).childLocator))
{
((AccessNodesBaseState)self).childLocator = ((EntityState)self).GetComponent<ChildLocator>();
}
((AccessNodesBaseState)self).SwapMaterials((NodeStates)1);
GameObject completedEffectPrefab = AccessNodesBaseState.completedEffectPrefab;
if (Object.op_Implicit((Object)(object)completedEffectPrefab))
{
Transform val = ((AccessNodesBaseState)self).childLocator.FindChild(AccessNodesBaseState.effectAttachString);
EffectData val2 = new EffectData
{
origin = val.position,
rotation = val.rotation
};
val2.SetChildLocatorTransformReference(((Component)val).gameObject, 0);
EffectManager.SpawnEffect(completedEffectPrefab, val2, true);
}
BaseStateOnEnterCaller((AccessNodesBaseState)(object)self);
}
private void ChangeDestination(orig_SpawnPortal orig, SolusWebMissionController self, GameObject prefab, Transform spawnPoint, bool setRunNextStage)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)prefab == (Object)null) && !((Object)(object)spawnPoint == (Object)null))
{
GameObject val = Object.Instantiate<GameObject>(prefab, spawnPoint.position, spawnPoint.rotation);
if (setRunNextStage)
{
val.GetComponent<SceneExitController>().destinationScene = SceneCatalog.GetSceneDefFromSceneName("moon2");
}
NetworkServer.Spawn(val);
}
}
private void ReplaceOnEnter(orig_OnEnter orig, AccessNodesBaseState self)
{
Transform val = self.childLocator.FindChild("OFF");
if (Object.op_Implicit((Object)(object)val))
{
self._nodeMeshAnimator = ((Component)val).GetComponent<Animator>();
}
}
private void DieInAFire(orig_OnStartServer orig, AccessCodesMissionController self)
{
}
private static void LoadAssets()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
AssetReferenceT<GameObject> obj = new AssetReferenceT<GameObject>(RoR2_DLC3_AccessCodesNode.Access_Codes_Node_prefab);
AssetReferenceT<GameObject> obj2 = new AssetReferenceT<GameObject>(RoR2_DLC3_AccessCodesNode.Access_Codes_Portals_prefab);
new AssetReferenceT<GameObject>(RoR2_DLC3_AccessCodesNode.GROUP__Access_Codes_prefab);
AssetReferenceT<ExpansionDef> val = new AssetReferenceT<ExpansionDef>(RoR2_DLC3.DLC3_asset);
ExpansionDef def = AssetAsyncReferenceManager<ExpansionDef>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2).WaitForCompletion();
portalPrefab = AssetAsyncReferenceManager<GameObject>.LoadAsset(obj2, (AsyncReferenceHandleUnloadType)2).WaitForCompletion();
AsyncOperationHandle<GameObject> val2 = AssetAsyncReferenceManager<GameObject>.LoadAsset(obj, (AsyncReferenceHandleUnloadType)2);
val2.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
nodePrefab = PrefabAPI.InstantiateClone(x.Result, "AccessNodeNux", true);
Object.Destroy((Object)(object)nodePrefab.GetComponent<ProxyInteraction>());
Object.Destroy((Object)(object)nodePrefab.GetComponent<AccessCodesNodeController>());
Object.Destroy((Object)(object)nodePrefab.GetComponent<EventLockableInteractable>());
nodePrefab.AddComponent<ExpansionRequirementComponent>().requiredExpansion = def;
nodePrefab.GetComponent<EntityStateMachine>().initialStateType = new SerializableEntityStateType(typeof(NodesOnAndReady));
PurchaseInteraction obj3 = nodePrefab.AddComponent<PurchaseInteraction>();
obj3.contextToken = "ACCESSCODES_NAME";
obj3.NetworkdisplayNameToken = "ACCESSCODES_NAME";
nodePrefab.AddComponent<AccessNodeControllerNux>();
nodePrefab.GetComponent<Highlight>().targetRenderer = (Renderer)(object)((Component)nodePrefab.transform.Find("Model/AccessCodeNodeModel/mdlAccessCodesNode/meshBody")).GetComponent<SkinnedMeshRenderer>();
((Object)interactableSpawnCard).name = "iscPointOfInterestTheseNutsOnYourChin";
((SpawnCard)interactableSpawnCard).prefab = nodePrefab;
((SpawnCard)interactableSpawnCard).sendOverNetwork = true;
((SpawnCard)interactableSpawnCard).hullSize = (HullClassification)1;
((SpawnCard)interactableSpawnCard).nodeGraphType = (GraphType)0;
((SpawnCard)interactableSpawnCard).requiredFlags = (NodeFlags)0;
((SpawnCard)interactableSpawnCard).forbiddenFlags = (NodeFlags)16;
((SpawnCard)interactableSpawnCard).directorCreditCost = 0;
((SpawnCard)interactableSpawnCard).occupyPosition = true;
interactableSpawnCard.orientToFloor = true;
interactableSpawnCard.skipSpawnWhenSacrificeArtifactEnabled = false;
interactableSpawnCard.maxSpawnsPerStage = 1;
DirectorCard card = new DirectorCard
{
selectionWeight = 1000,
spawnCard = (SpawnCard)(object)interactableSpawnCard
};
DirectorCardHolder val3 = new DirectorCardHolder
{
Card = card,
InteractableCategory = (InteractableCategory)2
};
foreach (Stage item in new List<Stage>
{
(Stage)16384,
(Stage)1099511627776L
})
{
Helpers.AddNewInteractableToStage(val3, item, "");
}
};
}
private static void BaseStateOnEnterCaller(AccessNodesBaseState self)
{
}
private static void BaseStateOnEnterCallerMethodModifier(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Call, (MethodBase)typeof(AccessNodesBaseState).GetMethod("OnEnter", (BindingFlags)(-1)));
}
}
}