internal static void EarlyLoad() { RoR2Content = new RoR2Content(); RoR2Content.contentPack.identifier = RoR2Content.identifier; RoR2Content.contentPack.bodyPrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/CharacterBodies/")); RoR2Content.contentPack.masterPrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/CharacterMasters/")); RoR2Content.contentPack.projectilePrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/Projectiles/")); RoR2Content.contentPack.gameModePrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/GameModes/")); RoR2Content.contentPack.networkedObjectPrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/NetworkedObjects/")); RoR2Content.contentPack.skillDefs.Add(Resources.LoadAll <SkillDef>("SkillDefs/")); RoR2Content.contentPack.skillFamilies.Add(Resources.LoadAll <SkillFamily>("SkillDefs/")); RoR2Content.contentPack.unlockableDefs.Add(Resources.LoadAll <UnlockableDef>("UnlockableDefs/")); RoR2Content.contentPack.surfaceDefs.Add(Resources.LoadAll <SurfaceDef>("SurfaceDefs/")); RoR2Content.contentPack.sceneDefs.Add(Resources.LoadAll <SceneDef>("SceneDefs/")); RoR2Content.contentPack.networkSoundEventDefs.Add(Resources.LoadAll <NetworkSoundEventDef>("NetworkSoundEventDefs/")); RoR2Content.contentPack.musicTrackDefs.Add(Resources.LoadAll <MusicTrackDef>("MusicTrackDefs/")); RoR2Content.contentPack.gameEndingDefs.Add(Resources.LoadAll <GameEndingDef>("GameEndingDefs/")); RoR2Content.contentPack.itemDefs.Add(Resources.LoadAll <ItemDef>("ItemDefs/")); RoR2Content.contentPack.equipmentDefs.Add(Resources.LoadAll <EquipmentDef>("EquipmentDefs/")); RoR2Content.contentPack.buffDefs.Add(Resources.LoadAll <BuffDef>("BuffDefs/")); RoR2Content.contentPack.eliteDefs.Add(Resources.LoadAll <EliteDef>("EliteDefs/")); RoR2Content.contentPack.survivorDefs.Add(Resources.LoadAll <SurvivorDef>("SurvivorDefs/")); RoR2Content.contentPack.artifactDefs.Add(Resources.LoadAll <ArtifactDef>("ArtifactDefs/")); var effectDefs = new List <EffectDef>(); foreach (var effect in Resources.LoadAll <GameObject>("Prefabs/Effects/")) { var effectDef = new EffectDef(effect); effectDefs.Add(effectDef); } RoR2Content.contentPack.effectDefs.Add(effectDefs.ToArray()); RoR2Content.contentPack.entityStateConfigurations.Add(Resources.LoadAll <EntityStateConfiguration>("EntityStateConfigurations/")); RoR2Content.contentPack.entityStateTypes.Add((from type in typeof(EntityState).Assembly.GetTypes() where typeof(EntityState).IsAssignableFrom(type) select type).ToArray()); ContentLoadHelper.PopulateTypeFields <ArtifactDef>(typeof(RoR2Content.Artifacts), RoR2Content.contentPack.artifactDefs); ContentLoadHelper.PopulateTypeFields <ItemDef>(typeof(RoR2Content.Items), RoR2Content.contentPack.itemDefs); ContentLoadHelper.PopulateTypeFields <EquipmentDef>(typeof(RoR2Content.Equipment), RoR2Content.contentPack.equipmentDefs); ContentLoadHelper.PopulateTypeFields <BuffDef>(typeof(RoR2Content.Buffs), RoR2Content.contentPack.buffDefs); ContentLoadHelper.PopulateTypeFields <EliteDef>(typeof(RoR2Content.Elites), RoR2Content.contentPack.eliteDefs); ContentLoadHelper.PopulateTypeFields <GameEndingDef>(typeof(RoR2Content.GameEndings), RoR2Content.contentPack.gameEndingDefs); ContentLoadHelper.PopulateTypeFields <SurvivorDef>(typeof(RoR2Content.Survivors), RoR2Content.contentPack.survivorDefs); RoR2Content.contentPack.effectDefs.Find("CoinEmitter").cullMethod = (EffectData effectData) => SettingsConVars.cvExpAndMoneyEffects.value; _ror2ContentLoaded = true; }
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.identifier = identifier; MysticsRisky2Utils.ContentManagement.ContentLoadHelper contentLoadHelper = new MysticsRisky2Utils.ContentManagement.ContentLoadHelper(); // Add content loading dispatchers to the content load helper System.Action[] loadDispatchers = new System.Action[] { () => contentLoadHelper.DispatchLoad <ItemDef>(Main.executingAssembly, typeof(MysticsRisky2Utils.BaseAssetTypes.BaseItem), x => contentPack.itemDefs.Add(x)), () => contentLoadHelper.DispatchLoad <EquipmentDef>(Main.executingAssembly, typeof(MysticsRisky2Utils.BaseAssetTypes.BaseEquipment), x => contentPack.equipmentDefs.Add(x)), () => contentLoadHelper.DispatchLoad <BuffDef>(Main.executingAssembly, typeof(MysticsRisky2Utils.BaseAssetTypes.BaseBuff), x => contentPack.buffDefs.Add(x)), () => contentLoadHelper.DispatchLoad <GameObject>(Main.executingAssembly, typeof(MysticsRisky2Utils.BaseAssetTypes.BaseInteractable), null) }; int num = 0; for (int i = 0; i < loadDispatchers.Length; i = num) { loadDispatchers[i](); args.ReportProgress(Util.Remap((float)(i + 1), 0f, (float)loadDispatchers.Length, 0f, 0.05f)); yield return(null); num = i + 1; } // Start loading content. Longest part of the loading process, so we will dedicate most of the progress bar to it while (contentLoadHelper.coroutine.MoveNext()) { args.ReportProgress(Util.Remap(contentLoadHelper.progress.value, 0f, 1f, 0.05f, 0.9f)); yield return(contentLoadHelper.coroutine.Current); } // Populate static content pack fields and add various prefabs and scriptable objects generated during the content loading part to the content pack loadDispatchers = new System.Action[] { () => ContentLoadHelper.PopulateTypeFields <ItemDef>(typeof(Items), contentPack.itemDefs), () => ContentLoadHelper.PopulateTypeFields <EquipmentDef>(typeof(Equipment), contentPack.equipmentDefs), () => ContentLoadHelper.PopulateTypeFields <BuffDef>(typeof(Buffs), contentPack.buffDefs), () => contentPack.bodyPrefabs.Add(Resources.bodyPrefabs.ToArray()), () => contentPack.masterPrefabs.Add(Resources.masterPrefabs.ToArray()), () => contentPack.projectilePrefabs.Add(Resources.projectilePrefabs.ToArray()), () => contentPack.effectDefs.Add(Resources.effectPrefabs.ConvertAll(x => new EffectDef(x)).ToArray()), () => contentPack.networkSoundEventDefs.Add(Resources.networkSoundEventDefs.ToArray()), () => contentPack.unlockableDefs.Add(Resources.unlockableDefs.ToArray()), () => contentPack.entityStateTypes.Add(Resources.entityStateTypes.ToArray()), () => contentPack.skillDefs.Add(Resources.skillDefs.ToArray()), () => contentPack.skillFamilies.Add(Resources.skillFamilies.ToArray()) }; for (int i = 0; i < loadDispatchers.Length; i = num) { loadDispatchers[i](); args.ReportProgress(Util.Remap((float)(i + 1), 0f, (float)loadDispatchers.Length, 0.9f, 0.95f)); yield return(null); num = i + 1; } // Call "AfterContentPackLoaded" methods loadDispatchers = new System.Action[] { () => MysticsRisky2Utils.ContentManagement.ContentLoadHelper.InvokeAfterContentPackLoaded <MysticsRisky2Utils.BaseAssetTypes.BaseItem>(Main.executingAssembly), () => MysticsRisky2Utils.ContentManagement.ContentLoadHelper.InvokeAfterContentPackLoaded <MysticsRisky2Utils.BaseAssetTypes.BaseEquipment>(Main.executingAssembly), () => MysticsRisky2Utils.ContentManagement.ContentLoadHelper.InvokeAfterContentPackLoaded <MysticsRisky2Utils.BaseAssetTypes.BaseBuff>(Main.executingAssembly), () => MysticsRisky2Utils.ContentManagement.ContentLoadHelper.InvokeAfterContentPackLoaded <MysticsRisky2Utils.BaseAssetTypes.BaseInteractable>(Main.executingAssembly) }; for (int i = 0; i < loadDispatchers.Length; i = num) { loadDispatchers[i](); args.ReportProgress(Util.Remap((float)(i + 1), 0f, (float)loadDispatchers.Length, 0.95f, 0.99f)); yield return(null); num = i + 1; } loadDispatchers = null; yield break; }