Exemple #1
0
 void Awake()
 {
     using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UIModifier." + bundleName))
     {
         var bundle   = AssetBundle.LoadFromStream(stream);
         var provider = new R2API.AssetBundleResourcesProvider(assetPrefix, bundle);
         R2API.ResourcesAPI.AddProvider(provider);
     }
     On.RoR2.UI.HealthBar.Awake += HealthBarAwakeAddon;
     On.RoR2.UI.ExpBar.Awake    += ExpBarAwakeAddon;
     //On.RoR2.LocalUserManager.
 }
Exemple #2
0
        public void Awake()
        {
            //acquire my assetbundle and give it to the resource api.
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Diluvian.diluvian"))
            {
                var bundle   = AssetBundle.LoadFromStream(stream);
                var provider = new R2API.AssetBundleResourcesProvider(assetPrefix, bundle);
                R2API.ResourcesAPI.AddProvider(provider);
            }
            //Check ESO existence.
            if (BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey("com.jarlyk.eso"))
            {
                ESOenabled = true;
                Logger.LogWarning("ESO detected: Delegating Elite modifications to them. Future support planned.");
            }
            //Index tierDef array.
            CombatDirectorTierDefs = (EliteDef[])typeof(RoR2.CombatDirector).GetFieldCached("eliteTiers").GetValue(null);
            //Init array because we now know the size.
            vanillaEliteMultipliers = new float[CombatDirectorTierDefs.Length];
            //Cache the BloodshrineBehaviour field.
            BloodShrineWaitingForRefresh   = typeof(RoR2.ShrineBloodBehavior).GetField("waitingForRefresh", BindingFlags.Instance | BindingFlags.NonPublic);
            BloodShrinePurchaseInteraction = typeof(RoR2.ShrineBloodBehavior).GetField("purchaseInteraction", BindingFlags.Instance | BindingFlags.NonPublic);

            //Acquire my index from R2API.
            DiluvianIndex = R2API.DifficultyAPI.AddDifficulty(DiluvianDef);

            //Create my description.
            R2API.AssetPlus.Languages.AddToken("DIFFICULTY_DILUVIAN_NAME", "Diluvian");
            string description = "For those found wanting. <style=cDeath>N'Kuhana</style> watches with interest.<style=cStack>\n";

            description = string.Join("\n",
                                      description,
                                      $">Difficulty Scaling: +{DiluvianDef.scalingValue * 50 - 100}%",
                                      $">Player Health Regeneration: {(int)(HealthRegenMultiplier * 100)}%",
                                      ">Player luck: Reduced in some places.",
                                      $">Monster Health Regeneration: +{MonsterRegen * 100}% of MaxHP per second (out of danger)",
                                      ">Oneshot Protection: Also applies to monsters",
                                      $">Oneshot Protection: Protects only {100 - 100 * NewOSPTreshold}%",
                                      $">Elites: {(1 - EliteModifier) * 100}% cheaper.",
                                      ">Shrine of Blood: Cost hidden and random."

                                      );
            description += "</style>";
            R2API.AssetPlus.Languages.AddToken("DIFFICULTY_DILUVIAN_DESCRIPTION", description);

            //This is where my hooks live. They themselves are events, not ONhooks
            RoR2.Run.onRunStartGlobal   += Run_onRunStartGlobal;
            RoR2.Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
        }
            static public void LoadResources()
            {
                string pluginfolder = System.IO.Path.GetDirectoryName(typeof(Resources).Assembly.Location);

                System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(modName + "." + assetBundleLocation);
                AssetBundle      bundle = AssetBundle.LoadFromStream(stream);

                R2API.AssetBundleResourcesProvider provider = new R2API.AssetBundleResourcesProvider(assetPrefix, bundle);
                R2API.ResourcesAPI.AddProvider(provider);

                foreach (string tierTextureName in tierTextureNames)
                {
                    tierTextures.Add(bundle.LoadAsset <Sprite>(tierTextureName));
                }
                foreach (string panelTextureName in panelTextureNames)
                {
                    panelTextures.Add(bundle.LoadAsset <Sprite>(panelTextureName));
                }
                foreach (string fontName in fontNames)
                {
                    fonts.Add(bundle.LoadAsset <TMPro.TMP_FontAsset>(fontName));
                }
                bundle.Unload(false);
            }