using System;
using System.Collections;
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.Bootstrap;
using BepInEx.Logging;
using EntityStates;
using HG;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API.AutoVersionGen;
using R2API.ContentManagement;
using R2API.ScriptableObjects;
using R2API.Utils;
using RoR2;
using RoR2.Audio;
using RoR2.ContentManagement;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("R2API.Items")]
[assembly: InternalsVisibleTo("R2API.Elites")]
[assembly: InternalsVisibleTo("R2API.Unlockable")]
[assembly: InternalsVisibleTo("R2API.TempVisualEffect")]
[assembly: InternalsVisibleTo("R2API.Loadout")]
[assembly: InternalsVisibleTo("R2API.Sound")]
[assembly: InternalsVisibleTo("R2API.Stages")]
[assembly: InternalsVisibleTo("R2API.Prefab")]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R2API.ContentManagement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyInformationalVersion("1.0.6+cbfbbf89b23c174d24a88a3248fdf0fe57d48eec")]
[assembly: AssemblyProduct("R2API.ContentManagement")]
[assembly: AssemblyTitle("R2API.ContentManagement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
}
namespace R2API
{
public static class ContentAddition
{
public static bool AddBody(GameObject bodyPrefab)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<CharacterBody>())
{
if (!HasComponent<CharacterBody>(bodyPrefab))
{
RejectContent(bodyPrefab, nonAPICaller, "BodyPrefab", "but it has no CharacterBody component!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)bodyPrefab);
return true;
}
RejectContent(bodyPrefab, nonAPICaller, "BodyPrefab", "but the BodyCatalog has already initialized!");
return false;
}
public static bool AddMaster(GameObject masterPrefab)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<CharacterMaster>())
{
if (!HasComponent<CharacterMaster>(masterPrefab))
{
RejectContent(masterPrefab, nonAPICaller, "MasterPrefab", "but it has no CharacterMaster component!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)masterPrefab);
return true;
}
RejectContent(masterPrefab, nonAPICaller, "MasterPrefab", "but the MasterCatalog has already initialized!");
return false;
}
public static bool AddProjectile(GameObject projectilePrefab)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ProjectileController>())
{
if (!HasComponent<ProjectileController>(projectilePrefab))
{
RejectContent(projectilePrefab, nonAPICaller, "ProjectilePrefab", "but it has no ProjectileController component!");
return false;
}
if (!Object.op_Implicit((Object)(object)projectilePrefab.GetComponent<ProjectileController>().ghostPrefab))
{
ContentManagementPlugin.Logger.LogWarning((object)$"Projectile {projectilePrefab} has no ghost prefab assigned! is this intentional?");
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)projectilePrefab);
return true;
}
RejectContent(projectilePrefab, nonAPICaller, "ProjectilePrefab", "but the ProjectileCatalog has already initialized!");
return false;
}
public static bool AddGameMode(GameObject gameModePrefab)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<Run>())
{
if (!HasComponent<Run>(gameModePrefab))
{
RejectContent(gameModePrefab, nonAPICaller, "GameMode", "but it has no Run component!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)gameModePrefab);
return true;
}
RejectContent(gameModePrefab, nonAPICaller, "GameMode", "but the GameModeCatalog has already initialized!");
return false;
}
public static bool AddNetworkedObject(GameObject networkedObject)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<NetworkIdentity>())
{
if (!HasComponent<NetworkIdentity>(networkedObject))
{
RejectContent(networkedObject, nonAPICaller, "NetworkedObject", "but it has no NetworkIdentity component!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)networkedObject);
return true;
}
RejectContent(networkedObject, nonAPICaller, "NetworkedObject", "but the GameNetworkManager has already networked all the prefabs!");
return false;
}
public static bool AddEffect(GameObject effectPrefab)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<EffectComponent>())
{
if (!HasComponent<EffectComponent>(effectPrefab))
{
RejectContent(effectPrefab, nonAPICaller, "EffectPrefab", "but it has no EffectComponent component!");
return false;
}
if (!HasComponent<VFXAttributes>(effectPrefab))
{
ContentManagementPlugin.Logger.LogWarning((object)string.Format("Effect {0} has no {1} component! is this intentional?", effectPrefab, "VFXAttributes"));
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)effectPrefab);
return true;
}
RejectContent(effectPrefab, nonAPICaller, "EffectPrefab", "but the EffectCatalog has already initialized!");
return false;
}
public static bool AddSkillDef(SkillDef skillDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<SkillDef>())
{
if (((SerializableEntityStateType)(ref skillDef.activationState)).stateType == null)
{
RejectContent(skillDef, nonAPICaller, "SkillDef", "but it's activation state type is null!");
return false;
}
if (string.IsNullOrEmpty(skillDef.activationStateMachineName) || string.IsNullOrWhiteSpace(skillDef.activationStateMachineName))
{
RejectContent(skillDef, nonAPICaller, "SkillDef", "but it's activation state machine name is Null, Whitespace or Empty!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)skillDef);
return true;
}
RejectContent(skillDef, nonAPICaller, "SkillDef", "but the SkillCatalog has already initialized!");
return false;
}
public static bool AddSkillFamily(SkillFamily skillFamily)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<SkillFamily>())
{
if (skillFamily.variants.Any((Variant v) => (Object)(object)v.skillDef == (Object)null))
{
RejectContent(skillFamily, nonAPICaller, "SkillFamily", "but one of it's variant's skillDefs is null!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)skillFamily);
return true;
}
RejectContent(skillFamily, nonAPICaller, "SkillFamily", "but the SkillCatalog has already initialized!");
return false;
}
public static bool AddSceneDef(SceneDef sceneDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<SceneDef>())
{
ContentManagementPlugin.Logger.LogInfo((object)("Assembly " + nonAPICaller.GetName().Name + " is trying to add a SceneDef, R2API does not support weaving of Scenes, Use RainOfStages instead for weaving SceneDefs."));
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)sceneDef);
return true;
}
RejectContent(sceneDef, nonAPICaller, "SceneDef", "but the SceneCatalog has already initialized!");
return false;
}
public static bool AddItemDef(ItemDef itemDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ItemDef>())
{
ContentManagementPlugin.Logger.LogInfo((object)(string.Format("Assembly {0} is adding an {1} via {2}.{3}()", nonAPICaller.GetName().Name, itemDef, "ContentAddition", "AddItemDef") + "The assembly should ideally add them via ItemAPI so that they can use ItemAPI's IDRS systems, adding anyways."));
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)itemDef);
return true;
}
RejectContent(itemDef, nonAPICaller, "ItemDef", "but the ItemCatalog has already initialized!");
return false;
}
public static bool AddItemTierDef(ItemTierDef itemTierDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ItemTierDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)itemTierDef);
return true;
}
RejectContent(itemTierDef, nonAPICaller, "ItemTierDef", "but the ItemTierCatalog has already initialized!");
return false;
}
public static bool AddItemRelationshipProvider(ItemRelationshipProvider itemRelationshipProvider)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ItemRelationshipProvider>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)itemRelationshipProvider);
return true;
}
RejectContent(itemRelationshipProvider, nonAPICaller, "ItemRelationshipProvider", "but the ItemCatalog has already initialized!");
return false;
}
public static bool AddItemRelationshipType(ItemRelationshipType itemRelationshipType)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ItemRelationshipType>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)itemRelationshipType);
return true;
}
RejectContent(itemRelationshipType, nonAPICaller, "ItemRelationshipType", "but the ItemCatalog has already initialized!");
return false;
}
public static bool AddEquipmentDef(EquipmentDef equipmentDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<EquipmentDef>())
{
ContentManagementPlugin.Logger.LogInfo((object)(string.Format("Assembly {0} is adding an {1} via {2}.{3}()", nonAPICaller.GetName().Name, equipmentDef, "ContentAddition", "AddEquipmentDef") + "The assembly should ideally add them via ItemAPI so that they can use ItemAPI's IDRS systems, adding anyways."));
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)equipmentDef);
return true;
}
RejectContent(equipmentDef, nonAPICaller, "EquipmentDef", "but the EquipmnetCatalog has already initialized!");
return false;
}
public static bool AddBuffDef(BuffDef buffDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<BuffDef>())
{
if (Object.op_Implicit((Object)(object)buffDef.eliteDef) && Object.op_Implicit((Object)(object)buffDef.eliteDef.eliteEquipmentDef) && (Object)(object)buffDef.eliteDef.eliteEquipmentDef.passiveBuffDef != (Object)(object)buffDef)
{
ContentManagementPlugin.Logger.LogWarning((object)$"Assembly {nonAPICaller.GetName().Name} is adding an {buffDef} which has an eliteDef assigned, but said eliteDef's equipmentDef's passiveBuffDef is not {buffDef}! is this intentional?");
}
if (Object.op_Implicit((Object)(object)buffDef.startSfx) && (string.IsNullOrEmpty(buffDef.startSfx.eventName) || string.IsNullOrWhiteSpace(buffDef.startSfx.eventName)))
{
ContentManagementPlugin.Logger.LogWarning((object)$"Assembly {nonAPICaller.GetName().Name} is adding an {buffDef} that has a startSFX, but the startSFX's NetworkedSoundEventDef's eventName is Null, Empty or Whitespace! is this intentional?");
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)buffDef);
return true;
}
RejectContent(buffDef, nonAPICaller, "BuffDef", "but the BuffCatalog has already initialized!");
return false;
}
public static bool AddEliteDef(EliteDef eliteDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<EliteDef>())
{
ContentManagementPlugin.Logger.LogInfo((object)(string.Format("Assembly {0} is adding an {1} via {2}.{3}()", nonAPICaller.GetName().Name, eliteDef, "ContentAddition", "AddEliteDef") + "The assembly should ideally add them via EliteAPI so that they can use EliteAPI's elite tier systems, adding anyways."));
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)eliteDef);
return true;
}
RejectContent(eliteDef, nonAPICaller, "EliteDef", "but the EliteCatalog has already initialized!");
return false;
}
public static bool AddUnlockableDef(UnlockableDef unlockableDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<UnlockableDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)unlockableDef);
return true;
}
RejectContent(unlockableDef, nonAPICaller, "UnlockableDef", "but the UnlockableCatalog has already initialized");
return false;
}
public static bool AddSurvivorDef(SurvivorDef survivorDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<SurvivorDef>())
{
if (!Object.op_Implicit((Object)(object)survivorDef.bodyPrefab))
{
RejectContent(survivorDef, nonAPICaller, "SurvivorDef", "but it's bodyPrefab is not assigned!");
return false;
}
if (!Object.op_Implicit((Object)(object)survivorDef.bodyPrefab.GetComponent<CharacterBody>()))
{
RejectContent(survivorDef, nonAPICaller, "SurvivorDef", "but it's bodyPrefab does not have a CharacterBody component!");
return false;
}
if (!Object.op_Implicit((Object)(object)survivorDef.displayPrefab))
{
ContentManagementPlugin.Logger.LogWarning((object)$"Assembly {nonAPICaller.GetName().Name} is adding an {survivorDef} that does not have a displayPrefab! is this intentional?");
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)survivorDef);
return true;
}
RejectContent(survivorDef, nonAPICaller, "SurvivorDef", "but the SurvivorCatalog has already initialized!");
return false;
}
public static bool AddArtifactDef(ArtifactDef artifactDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ArtifactDef>())
{
if ((Object)(object)artifactDef.smallIconDeselectedSprite == (Object)null || (Object)(object)artifactDef.smallIconSelectedSprite == (Object)null)
{
RejectContent(artifactDef, nonAPICaller, "ArtifactDef", "but one of it's icons are null! this is not allowed!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)artifactDef);
return true;
}
RejectContent(artifactDef, nonAPICaller, "ArtifactDef", "but the ArtifactCatalog has already initialized!");
return false;
}
public static bool AddSurfaceDef(SurfaceDef surfaceDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<SurfaceDef>())
{
if ((Object)(object)surfaceDef.impactEffectPrefab == (Object)null || (Object)(object)surfaceDef.footstepEffectPrefab == (Object)null)
{
RejectContent(surfaceDef, nonAPICaller, "SurfaceDef", "but one of it's effect prefabs are null! this is not allowed!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)surfaceDef);
return true;
}
RejectContent(surfaceDef, nonAPICaller, "SurfaceDef", "but the SurfaceDefCatalog has already initialized!");
return false;
}
public static bool AddNetworkSoundEventDef(NetworkSoundEventDef networkSoundEventDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<NetworkSoundEventDef>())
{
if (string.IsNullOrEmpty(networkSoundEventDef.eventName) || string.IsNullOrWhiteSpace(networkSoundEventDef.eventName))
{
RejectContent(networkSoundEventDef, nonAPICaller, "NetworkSoundEventDef", "but it's eventName is Null, Empty or Whitespace!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)networkSoundEventDef);
return true;
}
RejectContent(networkSoundEventDef, nonAPICaller, "NetworkSoundEventDef", "but the NetworkSoundEventCatalog has already initialized!");
return false;
}
public static bool AddMusicTrackDef(MusicTrackDef musicTrackDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<MusicTrackDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)musicTrackDef);
return true;
}
RejectContent(musicTrackDef, nonAPICaller, "MusicTrackDef", "but the MusicTrackCatalog has already initialized!");
return false;
}
public static bool AddGameEndingDef(GameEndingDef gameEndingDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<GameEndingDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)gameEndingDef);
return true;
}
RejectContent(gameEndingDef, nonAPICaller, "GameEndingDef", "but the GameEndingCatalog has already initalized!");
return false;
}
public static bool AddEntityStateConfiguration(EntityStateConfiguration entityStateConfiguration)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<EntityStateConfiguration>())
{
Type type = Type.GetType(entityStateConfiguration.targetType.assemblyQualifiedName);
if (!type.IsSubclassOf(typeof(EntityState)))
{
RejectContent(entityStateConfiguration, nonAPICaller, "EntityStateConfiguration", "but it's targetType (" + type.Name + ") is not a type that derives from EntityState!");
return false;
}
if (type.IsAbstract)
{
RejectContent(entityStateConfiguration, nonAPICaller, "EntityStateConfiguration", "but it's targetType (" + type.Name + ") is abstract!");
return false;
}
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)entityStateConfiguration);
return true;
}
RejectContent(entityStateConfiguration, nonAPICaller, "EntityStateConfiguration", "but the EntityStateCatalog has already initialized!");
return false;
}
public static bool AddExpansionDef(ExpansionDef expansionDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<ExpansionDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)expansionDef);
return true;
}
RejectContent(expansionDef, nonAPICaller, "ExpansionDef", "But the ExpansionCatalog has already initialized!");
return false;
}
public static bool AddEntitlementDef(EntitlementDef entitlementDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<EntitlementDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)entitlementDef);
return true;
}
RejectContent(entitlementDef, nonAPICaller, "EntitlementDef", "But the EntitlementCatalog has already initialized!");
return false;
}
public static bool AddMiscPickupDef(MiscPickupDef miscPickupDef)
{
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<MiscPickupDef>())
{
R2APIContentManager.HandleContentAddition(nonAPICaller, (Object)(object)miscPickupDef);
return true;
}
RejectContent(miscPickupDef, nonAPICaller, "MiscPickupDef", "But the MiscPickupCatalog has already initailized!");
return false;
}
public static SerializableEntityStateType AddEntityState<T>(out bool wasAdded) where T : EntityState
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return AddEntityState(typeof(T), out wasAdded);
}
public static SerializableEntityStateType AddEntityState(Type entityStateType, out bool wasAdded)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
Assembly nonAPICaller = GetNonAPICaller();
if (CatalogBlockers.GetAvailability<EntityState>())
{
if (entityStateType.IsAbstract)
{
RejectContent(entityStateType, nonAPICaller, "EntityStateType", "but the entity state type is marked as abstract!");
wasAdded = false;
return default(SerializableEntityStateType);
}
if (!typeof(EntityState).IsAssignableFrom(entityStateType))
{
RejectContent(entityStateType, nonAPICaller, "EntityStateType", "but the provided entity state type does not inherit from EntityState!");
wasAdded = false;
return default(SerializableEntityStateType);
}
wasAdded = true;
R2APIContentManager.HandleEntityState(nonAPICaller, entityStateType);
return new SerializableEntityStateType(entityStateType);
}
RejectContent(entityStateType, nonAPICaller, "EntityStateType", "but the EntityStateCatalog has already initialized!");
wasAdded = false;
return default(SerializableEntityStateType);
}
private static void RejectContent(object content, Assembly assembly, string contentType, string problem)
{
try
{
throw new InvalidOperationException($"Assembly {assembly.GetName().Name} is trying to add a {content} as a {contentType}, {problem}");
}
catch (Exception ex)
{
ContentManagementPlugin.Logger.LogError((object)ex);
}
}
private static bool HasComponent<T>(GameObject obj) where T : Component
{
return Object.op_Implicit((Object)(object)obj.GetComponent<T>());
}
private static Assembly GetNonAPICaller()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
for (int i = 0; i < 99; i++)
{
Assembly assembly = new StackFrame(i, needFileInfo: false).GetMethod()?.DeclaringType.Assembly;
if (assembly != executingAssembly)
{
return assembly;
}
}
return null;
}
}
}
namespace R2API.AutoVersionGen
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal class AutoVersionAttribute : Attribute
{
}
}
namespace R2API.ScriptableObjects
{
[CreateAssetMenu(fileName = "new R2APISerializableContentPack", menuName = "R2API/R2APISerializableContentPack", order = 0)]
public class R2APISerializableContentPack : ScriptableObject
{
[Header("Prefabs")]
[Tooltip("Prefabs with a CharacterBody component")]
public GameObject[] bodyPrefabs = Array.Empty<GameObject>();
[Tooltip("Prefabs with a CharacterMaster component")]
public GameObject[] masterPrefabs = Array.Empty<GameObject>();
[Tooltip("Prefabs with a ProjectileController component")]
public GameObject[] projectilePrefabs = Array.Empty<GameObject>();
[Tooltip("Prefabs with a component that inherits from \"Run\"")]
public GameObject[] gameModePrefabs = Array.Empty<GameObject>();
[Tooltip("Prefabs with an EffectComponent component")]
public GameObject[] effectPrefabs = Array.Empty<GameObject>();
[Tooltip("Prefabs with a NetworkIdentity component that dont apply to the arrays above")]
public GameObject[] networkedObjectPrefabs = Array.Empty<GameObject>();
[Space(5f)]
[Header("Scriptable Objects")]
public SkillDef[] skillDefs = Array.Empty<SkillDef>();
public SkillFamily[] skillFamilies = Array.Empty<SkillFamily>();
public SceneDef[] sceneDefs = Array.Empty<SceneDef>();
public ItemDef[] itemDefs = Array.Empty<ItemDef>();
public ItemTierDef[] itemTierDefs = Array.Empty<ItemTierDef>();
public ItemRelationshipProvider[] itemRelationshipProviders = Array.Empty<ItemRelationshipProvider>();
public ItemRelationshipType[] itemRelationshipTypes = Array.Empty<ItemRelationshipType>();
public EquipmentDef[] equipmentDefs = Array.Empty<EquipmentDef>();
public BuffDef[] buffDefs = Array.Empty<BuffDef>();
public EliteDef[] eliteDefs = Array.Empty<EliteDef>();
public UnlockableDef[] unlockableDefs = Array.Empty<UnlockableDef>();
public SurvivorDef[] survivorDefs = Array.Empty<SurvivorDef>();
public ArtifactDef[] artifactDefs = Array.Empty<ArtifactDef>();
public SurfaceDef[] surfaceDefs = Array.Empty<SurfaceDef>();
public NetworkSoundEventDef[] networkSoundEventDefs = Array.Empty<NetworkSoundEventDef>();
public MusicTrackDef[] musicTrackDefs = Array.Empty<MusicTrackDef>();
public GameEndingDef[] gameEndingDefs = Array.Empty<GameEndingDef>();
public MiscPickupDef[] miscPickupDefs = Array.Empty<MiscPickupDef>();
[Space(5f)]
[Header("EntityState Related")]
public EntityStateConfiguration[] entityStateConfigurations = Array.Empty<EntityStateConfiguration>();
[Tooltip("Types inheriting from EntityState")]
public SerializableEntityStateType[] entityStateTypes = Array.Empty<SerializableEntityStateType>();
[Space(5f)]
[Header("Expansion Related")]
public ExpansionDef[] expansionDefs = Array.Empty<ExpansionDef>();
public EntitlementDef[] entitlementDefs = Array.Empty<EntitlementDef>();
private ContentPack contentPack;
private ContentPack CreateContentPackPrivate()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
EnsureNoFieldsAreNull();
ContentPack val = new ContentPack();
val.bodyPrefabs.Add(bodyPrefabs);
val.masterPrefabs.Add(masterPrefabs);
val.projectilePrefabs.Add(projectilePrefabs);
val.gameModePrefabs.Add(gameModePrefabs);
val.effectDefs.Add(((IEnumerable<GameObject>)effectPrefabs).Select((Func<GameObject, EffectDef>)((GameObject go) => new EffectDef(go))).ToArray());
val.networkedObjectPrefabs.Add(networkedObjectPrefabs);
val.skillDefs.Add(skillDefs);
val.skillFamilies.Add(skillFamilies);
val.sceneDefs.Add(sceneDefs);
val.itemDefs.Add(itemDefs);
val.itemTierDefs.Add(itemTierDefs);
val.itemRelationshipTypes.Add(itemRelationshipTypes);
val.equipmentDefs.Add(equipmentDefs);
val.buffDefs.Add(buffDefs);
val.eliteDefs.Add(eliteDefs);
val.unlockableDefs.Add(unlockableDefs);
val.survivorDefs.Add(survivorDefs);
val.artifactDefs.Add(artifactDefs);
val.surfaceDefs.Add(surfaceDefs);
val.networkSoundEventDefs.Add(networkSoundEventDefs);
val.musicTrackDefs.Add(musicTrackDefs);
val.gameEndingDefs.Add(gameEndingDefs);
val.miscPickupDefs.Add(miscPickupDefs);
val.entityStateConfigurations.Add(entityStateConfigurations);
List<Type> list = new List<Type>();
for (int i = 0; i < entityStateTypes.Length; i++)
{
Type stateType = ((SerializableEntityStateType)(ref entityStateTypes[i])).stateType;
if (stateType != null)
{
list.Add(stateType);
continue;
}
Debug.LogWarning((object)("SerializableContentPack \"" + ((Object)this).name + "\" could not resolve type with name \"" + ((SerializableEntityStateType)(ref entityStateTypes[i])).typeName + "\". The type will not be available in the content pack."));
}
val.entityStateTypes.Add(list.ToArray());
val.expansionDefs.Add(expansionDefs);
val.entitlementDefs.Add(entitlementDefs);
return val;
}
public ContentPack GetOrCreateContentPack()
{
if (contentPack != null)
{
return contentPack;
}
contentPack = CreateContentPackPrivate();
return contentPack;
}
private void EnsureNoFieldsAreNull()
{
RemoveNullFields<GameObject>(ref bodyPrefabs);
RemoveNullFields<GameObject>(ref masterPrefabs);
RemoveNullFields<GameObject>(ref projectilePrefabs);
RemoveNullFields<GameObject>(ref gameModePrefabs);
RemoveNullFields<GameObject>(ref effectPrefabs);
RemoveNullFields<GameObject>(ref networkedObjectPrefabs);
RemoveNullFields<SkillDef>(ref skillDefs);
RemoveNullFields<SkillFamily>(ref skillFamilies);
RemoveNullFields<SceneDef>(ref sceneDefs);
RemoveNullFields<ItemDef>(ref itemDefs);
RemoveNullFields<ItemTierDef>(ref itemTierDefs);
RemoveNullFields<ItemRelationshipProvider>(ref itemRelationshipProviders);
RemoveNullFields<ItemRelationshipType>(ref itemRelationshipTypes);
RemoveNullFields<EquipmentDef>(ref equipmentDefs);
RemoveNullFields<BuffDef>(ref buffDefs);
RemoveNullFields<EliteDef>(ref eliteDefs);
RemoveNullFields<UnlockableDef>(ref unlockableDefs);
RemoveNullFields<SurvivorDef>(ref survivorDefs);
RemoveNullFields<ArtifactDef>(ref artifactDefs);
RemoveNullFields<SurfaceDef>(ref surfaceDefs);
RemoveNullFields<NetworkSoundEventDef>(ref networkSoundEventDefs);
RemoveNullFields<GameEndingDef>(ref gameEndingDefs);
RemoveNullFields<MusicTrackDef>(ref musicTrackDefs);
RemoveNullFields<MiscPickupDef>(ref miscPickupDefs);
RemoveNullFields<EntityStateConfiguration>(ref entityStateConfigurations);
RemoveNullFields<ExpansionDef>(ref expansionDefs);
RemoveNullFields<EntitlementDef>(ref entitlementDefs);
static void RemoveNullFields<T>(ref T[] array) where T : notnull, Object
{
IEnumerable<T> source = array.Where((T obj) => Object.op_Implicit((Object)(object)obj));
array = source.ToArray();
}
}
}
}
namespace R2API.ContentManagement
{
internal static class CatalogBlockers
{
private static Dictionary<Type, bool> CanAddContentToCatalog = new Dictionary<Type, bool>
{
{
typeof(CharacterBody),
true
},
{
typeof(CharacterMaster),
true
},
{
typeof(ProjectileController),
true
},
{
typeof(Run),
true
},
{
typeof(NetworkIdentity),
true
},
{
typeof(EffectComponent),
true
},
{
typeof(SkillDef),
true
},
{
typeof(SkillFamily),
true
},
{
typeof(SceneDef),
true
},
{
typeof(ItemDef),
true
},
{
typeof(ItemTierDef),
true
},
{
typeof(ItemRelationshipProvider),
true
},
{
typeof(ItemRelationshipType),
true
},
{
typeof(EquipmentDef),
true
},
{
typeof(BuffDef),
true
},
{
typeof(EliteDef),
true
},
{
typeof(UnlockableDef),
true
},
{
typeof(SurvivorDef),
true
},
{
typeof(ArtifactDef),
true
},
{
typeof(SurfaceDef),
true
},
{
typeof(NetworkSoundEventDef),
true
},
{
typeof(MusicTrackDef),
true
},
{
typeof(GameEndingDef),
true
},
{
typeof(EntityStateConfiguration),
true
},
{
typeof(EntityState),
true
},
{
typeof(ExpansionDef),
true
},
{
typeof(EntitlementDef),
true
},
{
typeof(MiscPickupDef),
true
}
};
internal static bool GetAvailability<T>()
{
Type typeFromHandle = typeof(T);
if (CanAddContentToCatalog.ContainsKey(typeFromHandle))
{
return CanAddContentToCatalog[typeFromHandle];
}
return false;
}
private static void SetAvailability<T>(bool availability)
{
Type typeFromHandle = typeof(T);
if (CanAddContentToCatalog.ContainsKey(typeFromHandle))
{
CanAddContentToCatalog[typeFromHandle] = availability;
}
}
[SystemInitializer(new Type[] { typeof(BodyCatalog) })]
private static void BlockBodies()
{
SetAvailability<CharacterBody>(availability: false);
}
[SystemInitializer(new Type[] { typeof(MasterCatalog) })]
private static void BlockMasters()
{
SetAvailability<CharacterMaster>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ProjectileCatalog) })]
private static void BlockProjectiles()
{
SetAvailability<ProjectileController>(availability: false);
}
[SystemInitializer(new Type[] { typeof(GameModeCatalog) })]
private static void BlockGameModes()
{
SetAvailability<Run>(availability: false);
}
[SystemInitializer(new Type[] { typeof(SkillCatalog) })]
private static void BlockSkills()
{
SetAvailability<SkillDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(SkillCatalog) })]
private static void BlockSkillFamilies()
{
SetAvailability<SkillFamily>(availability: false);
}
[SystemInitializer(new Type[] { typeof(SceneCatalog) })]
private static void BlockScenes()
{
SetAvailability<SceneDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ItemCatalog) })]
private static void BlockItems()
{
SetAvailability<ItemDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ItemTierCatalog) })]
private static void BlockItemTiers()
{
SetAvailability<ItemTierDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ItemCatalog) })]
private static void BlockItemRelationshipProviders()
{
SetAvailability<ItemRelationshipProvider>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ItemCatalog) })]
private static void BlockItemRelationshipTypes()
{
SetAvailability<ItemRelationshipType>(availability: false);
}
[SystemInitializer(new Type[] { typeof(EquipmentCatalog) })]
private static void BlockEquipments()
{
SetAvailability<EquipmentDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(BuffCatalog) })]
private static void BlockBuffs()
{
SetAvailability<BuffDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(EliteCatalog) })]
private static void BlockElites()
{
SetAvailability<EliteDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(UnlockableCatalog) })]
private static void BlockUnlockables()
{
SetAvailability<UnlockableDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(SurvivorCatalog) })]
private static void BlockSurvivors()
{
SetAvailability<SurvivorDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ArtifactCatalog) })]
private static void BlockArtifacts()
{
SetAvailability<ArtifactDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(EffectCatalog) })]
private static void BlockEffects()
{
SetAvailability<EffectComponent>(availability: false);
}
[SystemInitializer(new Type[] { typeof(SurfaceDefCatalog) })]
private static void BlockSurfaceDefs()
{
SetAvailability<SurfaceDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(NetworkSoundEventCatalog) })]
private static void BlockNetworkSoundEvent()
{
SetAvailability<NetworkSoundEventDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(MusicTrackCatalog) })]
private static void BlockMusicTracks()
{
SetAvailability<MusicTrackDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(GameEndingCatalog) })]
private static void BlockGameEndings()
{
SetAvailability<GameEndingDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(ExpansionCatalog) })]
private static void BlockExpansionDefs()
{
SetAvailability<ExpansionDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(EntitlementCatalog) })]
private static void BlockEntitlementDefs()
{
SetAvailability<EntitlementDef>(availability: false);
}
[SystemInitializer(new Type[] { typeof(MiscPickupCatalog) })]
private static void BlockMiscPickupDefs()
{
SetAvailability<MiscPickupDef>(availability: false);
}
}
[BepInPlugin("com.bepis.r2api.content_management", "R2API.ContentManagement", "1.0.6")]
internal sealed class ContentManagementPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
R2APIContentPackProvider.Init();
}
private void OnDestroy()
{
R2APIContentManager.UnsetHooks();
}
}
public struct ManagedSerializableContentPack
{
public R2APISerializableContentPack serializableContentPack;
public bool AutoCreateIContentPackProvider { get; }
public Assembly AssemblyThatCreatedContentPack { get; }
internal ManagedSerializableContentPack(R2APISerializableContentPack serializableContentPack, bool autoCreateIContentPackProvider, Assembly assemblyThatCreatedContentPack)
{
this.serializableContentPack = serializableContentPack;
AutoCreateIContentPackProvider = autoCreateIContentPackProvider;
AssemblyThatCreatedContentPack = assemblyThatCreatedContentPack;
}
}
public struct ManagedReadOnlyContentPack
{
internal ContentPack _contentPack;
internal R2APIGenericContentPack contentPackProvider;
public ReadOnlyContentPack ContentPack { get; }
public string Identifier => _contentPack.identifier;
public Assembly TiedAssembly { get; }
public bool HasAutoCreatedIContentPackProvider { get; }
internal ManagedReadOnlyContentPack(R2APISerializableContentPack scp, bool autoCreateIContentPackProvider, Assembly assemblyThatCreatedContentPack)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
_contentPack = scp.GetOrCreateContentPack();
_contentPack.identifier = ((Object)scp).name;
ContentPack = new ReadOnlyContentPack(_contentPack);
TiedAssembly = assemblyThatCreatedContentPack;
if (autoCreateIContentPackProvider)
{
HasAutoCreatedIContentPackProvider = true;
contentPackProvider = new R2APIGenericContentPack(_contentPack);
}
else
{
HasAutoCreatedIContentPackProvider = false;
contentPackProvider = null;
}
}
}
[AutoVersion]
public static class R2APIContentManager
{
public const string PluginGUID = "com.bepis.r2api.content_management";
public const string PluginName = "R2API.ContentManagement";
private static ReadOnlyArray<ManagedReadOnlyContentPack> _managedContentPacks = ReadOnlyArray<ManagedReadOnlyContentPack>.op_Implicit((ManagedReadOnlyContentPack[])null);
public static Action OnContentPacksCreated;
private static bool _contentPacksCreated = false;
private static readonly Dictionary<string, ManagedSerializableContentPack> BepInModNameToSerializableContentPack = new Dictionary<string, ManagedSerializableContentPack>();
private static readonly Dictionary<Assembly, string> AssemblyToBepInModName = new Dictionary<Assembly, string>();
private static readonly Dictionary<ContentPack, Assembly> ContentPackToAssembly = new Dictionary<ContentPack, Assembly>();
private static bool _hooksEnabled = false;
public const string PluginVersion = "1.0.6";
public static bool Loaded => true;
public static ReadOnlyArray<ManagedReadOnlyContentPack> ManagedContentPacks
{
get
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
if (!_contentPacksCreated)
{
ContentManagementPlugin.Logger.LogError((object)"Cannot return ContentPacks when they havent been created!");
return ReadOnlyArray<ManagedReadOnlyContentPack>.op_Implicit((ManagedReadOnlyContentPack[])null);
}
return _managedContentPacks;
}
}
public static void AddPreExistingSerializableContentPack(R2APISerializableContentPack contentPack, bool createIContentPackProvider = true)
{
SetHooks();
try
{
Assembly callingAssembly = Assembly.GetCallingAssembly();
if (!AssemblyToBepInModName.ContainsKey(callingAssembly))
{
Type[] source = default(Type[]);
Reflection.GetTypesSafe(callingAssembly, ref source);
Type type = source.Where((Type t) => ((MemberInfo)t).GetCustomAttribute<BepInPlugin>() != null).FirstOrDefault();
if (type != null)
{
BepInPlugin customAttribute = ((MemberInfo)type).GetCustomAttribute<BepInPlugin>();
if (customAttribute != null)
{
AssemblyToBepInModName.Add(callingAssembly, customAttribute.Name);
}
}
}
if (AssemblyToBepInModName.TryGetValue(callingAssembly, out string value))
{
((Object)contentPack).name = value;
if (!BepInModNameToSerializableContentPack.ContainsKey(value))
{
BepInModNameToSerializableContentPack.Add(value, new ManagedSerializableContentPack(contentPack, createIContentPackProvider, callingAssembly));
ContentManagementPlugin.Logger.LogInfo((object)("Added Pre-Existing SerializableContentPack from mod " + value));
return;
}
throw new InvalidOperationException("The Mod " + value + " already has a Serializable Content Pack assigned to it!");
}
throw new NullReferenceException($"The assembly {callingAssembly} does not have a class that has a BepInPlugin attribute! Cannot assign Serializable Content Pack for {value}!");
}
catch (Exception ex)
{
ContentManagementPlugin.Logger.LogError((object)ex);
}
}
public static R2APISerializableContentPack ReserveSerializableContentPack()
{
return GetOrCreateSerializableContentPack(Assembly.GetCallingAssembly());
}
public static Assembly GetAssemblyFromContentPack(ContentPack contentPack)
{
SetHooks();
if (ContentPackToAssembly.TryGetValue(contentPack, out Assembly value))
{
return value;
}
return null;
}
internal static void SetHooks()
{
if (!_hooksEnabled)
{
_hooksEnabled = true;
}
}
internal static void UnsetHooks()
{
_hooksEnabled = false;
}
private static void ChangeAssetNameIfNeeded(ReadOnlyContentPack firstContentPack, Object firstAsset, ref int firstAssetIndex, ReadOnlyContentPack secondContentPack, Object secondAsset, ref int secondAssetIndex, bool isFirstContentPackVanilla, bool isSecondContentPackVanilla)
{
//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_0029: 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)
if (firstAsset.name.Equals(secondAsset.name, StringComparison.InvariantCulture))
{
if (isFirstContentPackVanilla)
{
ChangeAssetName(secondContentPack, ref secondAssetIndex, secondAsset, firstContentPack);
}
else if (isSecondContentPackVanilla)
{
ChangeAssetName(firstContentPack, ref firstAssetIndex, firstAsset, secondContentPack);
}
}
}
private static bool IsVanillaContentPack(this ReadOnlyContentPack contentPack)
{
return ((ReadOnlyContentPack)(ref contentPack)).identifier.StartsWith("RoR2.");
}
private static void ChangeAssetName(ReadOnlyContentPack changingContentPack, ref int assetIndex, Object changingAsset, ReadOnlyContentPack notChangingContentPack)
{
string text = $"{((ReadOnlyContentPack)(ref changingContentPack)).identifier}_{changingAsset.name}_{assetIndex++}";
ContentManagementPlugin.Logger.LogWarning((object)("Asset name from " + ((ReadOnlyContentPack)(ref changingContentPack)).identifier + " is conflicting with " + ((ReadOnlyContentPack)(ref notChangingContentPack)).identifier + ". Old name : " + changingAsset.name + ", new name : " + text));
changingAsset.name = text;
}
private static IEnumerable<PropertyInfo> GetAllAssetCollectionPropertiesOfAReadOnlyContentPack()
{
return from p in typeof(ReadOnlyContentPack).GetProperties((BindingFlags)(-1))
where p.PropertyType.GenericTypeArguments.Length != 0 && (p.PropertyType.GenericTypeArguments[0].IsSubclassOf(typeof(Object)) || typeof(Object) == p.PropertyType.GenericTypeArguments[0])
select p;
}
internal static void HandleContentAddition(Assembly assembly, Object content)
{
SetHooks();
R2APISerializableContentPack orCreateSerializableContentPack = GetOrCreateSerializableContentPack(assembly);
if (!Object.op_Implicit((Object)(object)orCreateSerializableContentPack))
{
return;
}
try
{
bool flag = false;
GameObject val = (GameObject)(object)((content is GameObject) ? content : null);
if (val == null)
{
SkillDef val2 = (SkillDef)(object)((content is SkillDef) ? content : null);
if (val2 == null)
{
SkillFamily val3 = (SkillFamily)(object)((content is SkillFamily) ? content : null);
if (val3 == null)
{
SceneDef val4 = (SceneDef)(object)((content is SceneDef) ? content : null);
if (val4 == null)
{
ItemDef val5 = (ItemDef)(object)((content is ItemDef) ? content : null);
if (val5 == null)
{
ItemTierDef val6 = (ItemTierDef)(object)((content is ItemTierDef) ? content : null);
if (val6 == null)
{
ItemRelationshipProvider val7 = (ItemRelationshipProvider)(object)((content is ItemRelationshipProvider) ? content : null);
if (val7 == null)
{
ItemRelationshipType val8 = (ItemRelationshipType)(object)((content is ItemRelationshipType) ? content : null);
if (val8 == null)
{
EquipmentDef val9 = (EquipmentDef)(object)((content is EquipmentDef) ? content : null);
if (val9 == null)
{
BuffDef val10 = (BuffDef)(object)((content is BuffDef) ? content : null);
if (val10 == null)
{
EliteDef val11 = (EliteDef)(object)((content is EliteDef) ? content : null);
if (val11 == null)
{
UnlockableDef val12 = (UnlockableDef)(object)((content is UnlockableDef) ? content : null);
if (val12 == null)
{
SurvivorDef val13 = (SurvivorDef)(object)((content is SurvivorDef) ? content : null);
if (val13 == null)
{
ArtifactDef val14 = (ArtifactDef)(object)((content is ArtifactDef) ? content : null);
if (val14 == null)
{
SurfaceDef val15 = (SurfaceDef)(object)((content is SurfaceDef) ? content : null);
if (val15 == null)
{
NetworkSoundEventDef val16 = (NetworkSoundEventDef)(object)((content is NetworkSoundEventDef) ? content : null);
if (val16 == null)
{
MusicTrackDef val17 = (MusicTrackDef)(object)((content is MusicTrackDef) ? content : null);
if (val17 == null)
{
GameEndingDef val18 = (GameEndingDef)(object)((content is GameEndingDef) ? content : null);
if (val18 == null)
{
EntityStateConfiguration val19 = (EntityStateConfiguration)(object)((content is EntityStateConfiguration) ? content : null);
if (val19 == null)
{
ExpansionDef val20 = (ExpansionDef)(object)((content is ExpansionDef) ? content : null);
if (val20 == null)
{
EntitlementDef val21 = (EntitlementDef)(object)((content is EntitlementDef) ? content : null);
if (val21 == null)
{
MiscPickupDef val22 = (MiscPickupDef)(object)((content is MiscPickupDef) ? content : null);
if (val22 != null)
{
AddSafe<MiscPickupDef>(ref orCreateSerializableContentPack.miscPickupDefs, val22, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<EntitlementDef>(ref orCreateSerializableContentPack.entitlementDefs, val21, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<ExpansionDef>(ref orCreateSerializableContentPack.expansionDefs, val20, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<EntityStateConfiguration>(ref orCreateSerializableContentPack.entityStateConfigurations, val19, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<GameEndingDef>(ref orCreateSerializableContentPack.gameEndingDefs, val18, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<MusicTrackDef>(ref orCreateSerializableContentPack.musicTrackDefs, val17, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<NetworkSoundEventDef>(ref orCreateSerializableContentPack.networkSoundEventDefs, val16, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<SurfaceDef>(ref orCreateSerializableContentPack.surfaceDefs, val15, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<ArtifactDef>(ref orCreateSerializableContentPack.artifactDefs, val14, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<SurvivorDef>(ref orCreateSerializableContentPack.survivorDefs, val13, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<UnlockableDef>(ref orCreateSerializableContentPack.unlockableDefs, val12, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<EliteDef>(ref orCreateSerializableContentPack.eliteDefs, val11, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<BuffDef>(ref orCreateSerializableContentPack.buffDefs, val10, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<EquipmentDef>(ref orCreateSerializableContentPack.equipmentDefs, val9, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<ItemRelationshipType>(ref orCreateSerializableContentPack.itemRelationshipTypes, val8, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<ItemRelationshipProvider>(ref orCreateSerializableContentPack.itemRelationshipProviders, val7, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<ItemTierDef>(ref orCreateSerializableContentPack.itemTierDefs, val6, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<ItemDef>(ref orCreateSerializableContentPack.itemDefs, val5, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<SceneDef>(ref orCreateSerializableContentPack.sceneDefs, val4, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<SkillFamily>(ref orCreateSerializableContentPack.skillFamilies, val3, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
AddSafe<SkillDef>(ref orCreateSerializableContentPack.skillDefs, val2, ((Object)orCreateSerializableContentPack).name);
flag = true;
}
}
else
{
HandleGameObject(val, orCreateSerializableContentPack);
flag = true;
}
if (!flag)
{
throw new ArgumentException($"The content {content.name} ({((object)content).GetType()}) is not supported by the ContentManager! \n" + "If you think this is an Error and it should be supported, please file a bug report.");
}
}
catch (Exception ex)
{
ContentManagementPlugin.Logger.LogError((object)ex);
}
}
internal static void HandleEntityState(Assembly assembly, Type type)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
R2APISerializableContentPack orCreateSerializableContentPack = GetOrCreateSerializableContentPack(assembly);
if (Object.op_Implicit((Object)(object)orCreateSerializableContentPack))
{
AddSafeType(ref orCreateSerializableContentPack.entityStateTypes, new SerializableEntityStateType(type), ((Object)orCreateSerializableContentPack).name);
}
}
private static void HandleGameObject(GameObject go, R2APISerializableContentPack scp)
{
try
{
bool flag = false;
bool flag2 = false;
if (Object.op_Implicit((Object)(object)go.GetComponent<CharacterBody>()))
{
AddSafe<GameObject>(ref scp.bodyPrefabs, go, ((Object)scp).name);
flag = true;
flag2 = true;
}
if (Object.op_Implicit((Object)(object)go.GetComponent<CharacterMaster>()))
{
AddSafe<GameObject>(ref scp.masterPrefabs, go, ((Object)scp).name);
flag = true;
flag2 = true;
}
if (Object.op_Implicit((Object)(object)go.GetComponent<ProjectileController>()))
{
AddSafe<GameObject>(ref scp.projectilePrefabs, go, ((Object)scp).name);
flag = true;
flag2 = true;
}
if (Object.op_Implicit((Object)(object)go.GetComponent<Run>()))
{
AddSafe<GameObject>(ref scp.gameModePrefabs, go, ((Object)scp).name);
flag = true;
flag2 = true;
}
if (!flag && Object.op_Implicit((Object)(object)go.GetComponent<NetworkIdentity>()))
{
AddSafe<GameObject>(ref scp.networkedObjectPrefabs, go, ((Object)scp).name);
flag2 = true;
}
if (Object.op_Implicit((Object)(object)go.GetComponent<EffectComponent>()))
{
AddSafe<GameObject>(ref scp.effectPrefabs, go, ((Object)scp).name);
flag2 = true;
}
if (!flag2)
{
throw new ArgumentException($"The GameObject {((Object)go).name} ({((object)go).GetType()}) does not have any components that are supported by the ContentManager! \n" + "If you think this is an Error and it should be supported, please file a bug report.");
}
}
catch (Exception ex)
{
ContentManagementPlugin.Logger.LogError((object)ex);
}
}
internal static void CreateContentPacks()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
if (!_contentPacksCreated)
{
ContentManagementPlugin.Logger.LogInfo((object)$"Generating a total of {BepInModNameToSerializableContentPack.Values.Count} ContentPacks...");
List<ManagedReadOnlyContentPack> list = new List<ManagedReadOnlyContentPack>();
foreach (var (arg, managedSerializableContentPack2) in BepInModNameToSerializableContentPack)
{
try
{
list.Add(new ManagedReadOnlyContentPack(managedSerializableContentPack2.serializableContentPack, managedSerializableContentPack2.AutoCreateIContentPackProvider, managedSerializableContentPack2.AssemblyThatCreatedContentPack));
ContentPackToAssembly.Add(managedSerializableContentPack2.serializableContentPack.GetOrCreateContentPack(), managedSerializableContentPack2.AssemblyThatCreatedContentPack);
}
catch (Exception arg2)
{
Debug.LogError((object)$"[R2API CreateContentPacks] {arg} {arg2}");
}
}
_contentPacksCreated = true;
_managedContentPacks = new ReadOnlyArray<ManagedReadOnlyContentPack>(list.ToArray());
if (OnContentPacksCreated == null)
{
return;
}
Delegate[] invocationList = OnContentPacksCreated.GetInvocationList();
for (int i = 0; i < invocationList.Length; i++)
{
Action action = (Action)invocationList[i];
try
{
action();
}
catch (Exception ex)
{
ContentManagementPlugin.Logger.LogError((object)ex);
}
}
return;
}
throw new InvalidOperationException("The Content Pack collection has already been created!");
}
internal static R2APISerializableContentPack GetOrCreateSerializableContentPack(Assembly assembly)
{
if (!AssemblyToBepInModName.TryGetValue(assembly, out string value))
{
string location = assembly.Location;
value = Chainloader.PluginInfos.FirstOrDefault((KeyValuePair<string, PluginInfo> x) => location == x.Value.Location).Key;
if (value == null)
{
ContentManagementPlugin.Logger.LogWarning((object)("The assembly " + assembly.FullName + " is not a loaded BepInEx plugin, falling back to looking for attribute in assembly"));
try
{
Type[] source = default(Type[]);
Reflection.GetTypesSafe(assembly, ref source);
value = source.Select((Type x) => ((MemberInfo)x).GetCustomAttribute<BepInPlugin>()).First((BepInPlugin x) => x != null).GUID;
}
catch
{
ContentManagementPlugin.Logger.LogWarning((object)"Assembly did not have a BepInPlugin attribute or couldn't load its types, falling back to assembly name");
value = assembly.GetName().Name;
}
}
AssemblyToBepInModName[assembly] = value;
}
if (!BepInModNameToSerializableContentPack.ContainsKey(value))
{
R2APISerializableContentPack r2APISerializableContentPack = ScriptableObject.CreateInstance<R2APISerializableContentPack>();
((Object)r2APISerializableContentPack).name = value;
BepInModNameToSerializableContentPack.Add(value, new ManagedSerializableContentPack(r2APISerializableContentPack, autoCreateIContentPackProvider: true, assembly));
ContentManagementPlugin.Logger.LogInfo((object)("Created a SerializableContentPack for mod " + value));
}
return BepInModNameToSerializableContentPack[value].serializableContentPack;
}
private static void AddSafe<T>(ref T[] assetArray, T asset, string identifier) where T : Object
{
if (!assetArray.Contains(asset))
{
ArrayUtils.ArrayAppend<T>(ref assetArray, ref asset);
}
else
{
ContentManagementPlugin.Logger.LogWarning((object)$"Cannot add {asset} to content pack {identifier} because the asset has already been added to it's corresponding array!");
}
}
private static void AddSafeType<T>(ref T[] assetArray, T asset, string identifier)
{
if (!assetArray.Contains(asset))
{
ArrayUtils.ArrayAppend<T>(ref assetArray, ref asset);
}
else
{
ContentManagementPlugin.Logger.LogWarning((object)$"Cannot add {asset} to content pack {identifier} because the asset has already been added to it's corresponding array!");
}
}
}
internal class R2APIGenericContentPack : IContentPackProvider
{
private ContentPack contentPack;
private bool logged;
public string identifier => contentPack.identifier;
internal R2APIGenericContentPack(ContentPack finalizedContentPack)
{
contentPack = finalizedContentPack;
}
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
LogContentsFromContentPack();
args.ReportProgress(1f);
yield break;
}
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
ContentPack.Copy(contentPack, args.output);
args.ReportProgress(1f);
yield break;
}
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
args.ReportProgress(1f);
yield break;
}
private void LogContentsFromContentPack()
{
if (!logged)
{
logged = true;
List<string> list = new List<string>();
list.Add("Content added from " + contentPack.identifier + ":");
list.AddRange(contentPack.bodyPrefabs.assetInfos.Select((AssetInfo<GameObject> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.masterPrefabs.assetInfos.Select((AssetInfo<GameObject> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.projectilePrefabs.assetInfos.Select((AssetInfo<GameObject> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.gameModePrefabs.assetInfos.Select((AssetInfo<GameObject> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.networkedObjectPrefabs.assetInfos.Select((AssetInfo<GameObject> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.skillDefs.assetInfos.Select((AssetInfo<SkillDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.skillFamilies.assetInfos.Select((AssetInfo<SkillFamily> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.sceneDefs.assetInfos.Select((AssetInfo<SceneDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.itemDefs.assetInfos.Select((AssetInfo<ItemDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.itemTierDefs.assetInfos.Select((AssetInfo<ItemTierDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.itemRelationshipProviders.assetInfos.Select((AssetInfo<ItemRelationshipProvider> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.itemRelationshipTypes.assetInfos.Select((AssetInfo<ItemRelationshipType> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.equipmentDefs.assetInfos.Select((AssetInfo<EquipmentDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.buffDefs.assetInfos.Select((AssetInfo<BuffDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.eliteDefs.assetInfos.Select((AssetInfo<EliteDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.unlockableDefs.assetInfos.Select((AssetInfo<UnlockableDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.survivorDefs.assetInfos.Select((AssetInfo<SurvivorDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.artifactDefs.assetInfos.Select((AssetInfo<ArtifactDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.effectDefs.assetInfos.Select((AssetInfo<EffectDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.surfaceDefs.assetInfos.Select((AssetInfo<SurfaceDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.networkSoundEventDefs.assetInfos.Select((AssetInfo<NetworkSoundEventDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.musicTrackDefs.assetInfos.Select((AssetInfo<MusicTrackDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.gameEndingDefs.assetInfos.Select((AssetInfo<GameEndingDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.entityStateConfigurations.assetInfos.Select((AssetInfo<EntityStateConfiguration> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.entityStateTypes.assetInfos.Select((AssetInfo<Type> ai) => ai.assetName + " (" + ai.asset.GetType().Name + ")"));
list.AddRange(contentPack.expansionDefs.assetInfos.Select((AssetInfo<ExpansionDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.entitlementDefs.assetInfos.Select((AssetInfo<EntitlementDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
list.AddRange(contentPack.miscPickupDefs.assetInfos.Select((AssetInfo<MiscPickupDef> ai) => ai.assetName + " (" + ((object)ai.asset).GetType().Name + ")"));
ContentManagementPlugin.Logger.LogDebug((object)string.Join("\n", list));
}
}
}
internal class R2APIContentPackProvider
{
[CompilerGenerated]
private static class <>O
{
public static CollectContentPackProvidersDelegate <0>__AddCustomContent;
}
internal static Action WhenAddingContentPacks;
internal static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
object obj = <>O.<0>__AddCustomContent;
if (obj == null)
{
CollectContentPackProvidersDelegate val = AddCustomContent;
<>O.<0>__AddCustomContent = val;
obj = (object)val;
}
ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
}
private static void AddCustomContent(AddContentPackProviderDelegate addContentPackProvider)
{
//IL_0044: 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)
//IL_004d: 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)
if (WhenAddingContentPacks != null)
{
Delegate[] invocationList = WhenAddingContentPacks.GetInvocationList();
for (int i = 0; i < invocationList.Length; i++)
{
Action action = (Action)invocationList[i];
try
{
action();
}
catch (Exception ex)
{
ContentManagementPlugin.Logger.LogError((object)ex);
}
}
}
R2APIContentManager.CreateContentPacks();
Enumerator<ManagedReadOnlyContentPack> enumerator = R2APIContentManager.ManagedContentPacks.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ManagedReadOnlyContentPack current = enumerator.Current;
if (current.HasAutoCreatedIContentPackProvider)
{
try
{
addContentPackProvider.Invoke((IContentPackProvider)(object)current.contentPackProvider);
}
catch (Exception ex2)
{
ContentManagementPlugin.Logger.LogError((object)ex2);
}
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
}
}
}