private void Awake() { _logger = Logger; Logger.LogDebug("Loading assets..."); //BundleInfo bundleInfo = new BundleInfo("@RiskOfBulletstorm", "RiskOfBulletstorm.riskofgungeonassets", BundleType.UnityAssetBundle); BundleInfo bundleInfo = new BundleInfo("RiskOfBulletstorm.riskofgungeonassets", BundleType.UnityAssetBundle); assetBundle = new AssetsManager(bundleInfo).Register() as AssetBundle; ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = displayName, longIdentifier = "RISKOFBULLETSTORMMOD", shortIdentifier = "RBS", mainConfigFile = ConfigFile }); T2Module.SetupAll_PluginAwake(masterItemList); Shared.Buffs.BuffsController.Init(); R2API.Utils.CommandHelper.AddToConsoleWhenReady(); }
private void Awake() { logger = Logger; Logger.LogDebug($"Initialising plugin -- Version {ModVersion}"); Logger.LogDebug("Loading configuration..."); config = new ConfigFile(Path.Combine(Paths.ConfigPath, $"{ModGuid}.cfg"), true); Logger.LogDebug("Loading assets..."); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MoreItems.moreitems")) { AssetBundle bundle = AssetBundle.LoadFromStream(stream); AssetBundleResourcesProvider provider = new AssetBundleResourcesProvider("@MoreItems", bundle); ResourcesAPI.AddProvider(provider); } masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "More Items", longIdentifier = "MoreItems", shortIdentifier = "More", mainConfigFile = config }); T2Module.SetupAll_PluginAwake(masterItemList); }
private void Awake() //Sourced almost entirely from ThinkInvis' Classic Items. It is also extremely handy. { _logger = Logger; #if DEBUG Logger.LogWarning("DEBUG mode is enabled! Ignore this message if you are actually debugging."); On.RoR2.Networking.GameNetworkManager.OnClientConnect += (self, user, t) => { }; #endif using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Aetherium.aetherium_assets")) { var bundle = AssetBundle.LoadFromStream(stream); var provider = new AssetBundleResourcesProvider("@Aetherium", bundle); ResourcesAPI.AddProvider(provider); } ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Aetherium", longIdentifier = "AETHERIUMMOD", shortIdentifier = "ATHRM", mainConfigFile = ConfigFile }); T2Module.SetupAll_PluginAwake(masterItemList); T2Module.SetupAll_PluginStart(masterItemList); }
private void Awake() { #if DEBUG On.RoR2.Networking.GameNetworkManager.OnClientConnect += (self, user, t) => { }; #endif _logger = Logger; Logger.LogDebug("Loading assets..."); ResourcesAPI.AddProvider(Assets.PopulateAssets()); cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); Logger.LogDebug("Replacing Item Shaders with Hopoo shaders..."); Assets.ReplaceShaders(); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Kevin's Additional Items", longIdentifier = "KevinsAdditions", shortIdentifier = "KAI", mainConfigFile = cfgFile }); T2Module.SetupAll_PluginAwake(masterItemList); Logger.LogDebug("Adding Imp Mechanics..."); ImpPlayerAdjustments.AddExtras(); }
private void Awake() { _logger = Logger; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TinkersSatchel.tinkerssatchel_assets")) { resources = AssetBundle.LoadFromStream(stream); } try { UnstubShaders(); } catch (Exception ex) { _logger.LogError($"Shader unstub failed: {ex} {ex.Message}"); } cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); var modInfo = new T2Module.ModInfo { displayName = "Tinker's Satchel", longIdentifier = "TinkersSatchel", shortIdentifier = "TKSAT", mainConfigFile = cfgFile }; allModules = T2Module.InitAll <T2Module>(modInfo); var earlyLoad = new[] { CommonCode.instance }; T2Module.SetupAll_PluginAwake(earlyLoad); T2Module.SetupAll_PluginAwake(allModules.Except(earlyLoad)); }
private void Awake() { Debug.Log("Loading assets."); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ArtifactOfHaste.artifactofhaste")) { var bundle = AssetBundle.LoadFromStream(stream); var provider = new AssetBundleResourcesProvider("@ArtifactOfHaste", bundle); ResourcesAPI.AddProvider(provider); } config = new ConfigFile(Path.Combine(Paths.ConfigPath, modGuid + ".cfg"), true); Debug.Log("Creating mod info."); itemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Artifact of Haste", longIdentifier = "ArtifactOfHaste", shortIdentifier = "AOH", mainConfigFile = config }); Debug.Log("Initializing mod."); T2Module.SetupAll_PluginAwake(itemList); T2Module.SetupAll_PluginStart(itemList); }
private void Awake() { Log = new Log(Logger); #if DEBUG MultiplayerTest.Enable(Logger, "Running test build with debug enabled! Report to CHEN if you're seeing this!"); #endif Log.Debug("Loading assets..."); BundleInfo bundleInfo = new BundleInfo("ChensBombasticMod.chensbombasticmod_assets", BundleType.UnityAssetBundle); assetBundle = new AssetsManager(bundleInfo).Register(); cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); Log.Debug("Instantiating item classes..."); chensItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Chen's Bombastic Mod", longIdentifier = "ChensBombasticMod", shortIdentifier = "CBM", mainConfigFile = cfgFile }); T2Module.SetupAll_PluginAwake(chensItemList); T2Module.SetupAll_PluginStart(chensItemList); }
private void Awake() { _logger = Logger; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SupplyDrop.supplydrop_assets")) { MainAssets = AssetBundle.LoadFromStream(stream); } ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Supply Drop", longIdentifier = "SUPPLYDROP", shortIdentifier = "SUPPDRP", mainConfigFile = ConfigFile }); using (var bankStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SupplyDrop.SupplyDropSounds.bnk")) { var bytes = new byte[bankStream.Length]; bankStream.Read(bytes, 0, bytes.Length); SoundAPI.SoundBanks.Add(bytes); } T2Module.SetupAll_PluginAwake(masterItemList); T2Module.SetupAll_PluginStart(masterItemList); }
/// <summary> /// Call to scan your plugin's assembly for classes inheriting from ItemBoilerplate, initialize all of them, and prepare a list for further setup. /// </summary> /// <param name="modDisplayName">A display name to use for your mod. Mostly used to name config categories in the stock ItemBoilerplate implementations.</param> /// <returns>A FilingDictionary containing all instances that this method just initialized.</returns> public static FilingDictionary <ItemBoilerplate> InitAll(string modDisplayName) { FilingDictionary <ItemBoilerplate> f = new FilingDictionary <ItemBoilerplate>(); foreach (Type type in Assembly.GetCallingAssembly().GetTypes().Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(ItemBoilerplate)))) { var newBpl = (ItemBoilerplate)Activator.CreateInstance(type); newBpl.modName = modDisplayName; f.Add(newBpl); } return(f); //:regional_indicator_f: }
public static void ConsoleDump(BepInEx.Logging.ManualLogSource logger, FilingDictionary <CatalogBoilerplate> instances) { int longestClassName = 0; int longestObjectName = 0; var allStrings = new List <ConsoleStrings>(); foreach (CatalogBoilerplate x in instances) { var strings = x.GetConsoleStrings(); allStrings.Add(strings); longestClassName = Mathf.Max(strings.className.Length, longestClassName); longestObjectName = Mathf.Max(strings.objectName.Length, longestObjectName); } logger.LogMessage("Index dump follows (pairs of name / index):"); foreach (ConsoleStrings strings in allStrings) { logger.LogMessage($"{strings.className.PadLeft(longestClassName)} {strings.objectName.PadRight(longestObjectName)} / {strings.formattedIndex}"); } }
private void Awake() { _logger = Logger; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SupplyDrop.supplydrop_assets")) { var bundle = AssetBundle.LoadFromStream(stream); var provider = new AssetBundleResourcesProvider("@SupplyDrop", bundle); ResourcesAPI.AddProvider(provider); } ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Supply Drop", longIdentifier = "SUPPLYDROP", shortIdentifier = "SUPPDRP", mainConfigFile = ConfigFile }); T2Module.SetupAll_PluginAwake(masterItemList); }
public void Awake() { _logger = Logger; cfgFile = new ConfigFile(System.IO.Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); T2Module.SetupModuleClass(); allModules = T2Module.InitModules(new T2Module.ModInfo { displayName = "TILER2", mainConfigFile = cfgFile, longIdentifier = "TILER2", shortIdentifier = "TILER2" }); T2Module.SetupAll_PluginAwake(allModules); MiscUtil.Setup(); DebugUtil.Setup(); CommandHelper.AddToConsoleWhenReady(); }
/// <summary> /// Creates a new ReadOnlyFilingDictionary wrapping a specific FilingDictionary. /// </summary> /// <param name="baseCollection">The FilingDictionary to create a readonly wrapper for.</param> public ReadOnlyFilingDictionary(FilingDictionary <T> baseCollection) { this.baseCollection = baseCollection; }
private void Awake() { _logger = Logger; Logger.LogDebug("Performing plugin setup..."); #if DEBUG Logger.LogWarning("Running test build with debug enabled! If you're seeing this after downloading the mod from Thunderstore, please panic."); #endif Logger.LogDebug("Loading assets..."); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ClassicItems.classicitems_assets")) { var bundle = AssetBundle.LoadFromStream(stream); var provider = new AssetBundleResourcesProvider("@ClassicItems", bundle); ResourcesAPI.AddProvider(provider); } cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); Logger.LogDebug("Loading global configs..."); globalConfig.BindAll(cfgFile, "ClassicItems", "Global"); globalConfig.ConfigEntryChanged += (sender, args) => { if (args.target.boundProperty.Name == nameof(globalConfig.hSV2NoStomp)) { var toBind = (bool)args.newValue == true; if (toBind && !globalConfig.hSV2Bound) { IL.EntityStates.Headstompers.HeadstompersIdle.FixedUpdate += IL_ESHeadstompersIdleFixedUpdate; } else if (!toBind) { IL.EntityStates.Headstompers.HeadstompersIdle.FixedUpdate -= IL_ESHeadstompersIdleFixedUpdate; } } }; Logger.LogDebug("Instantiating item classes..."); masterItemList = ItemBoilerplate.InitAll("ClassicItems"); Logger.LogDebug("Loading item configs..."); foreach (ItemBoilerplate x in masterItemList) { x.ConfigEntryChanged += (sender, args) => { if ((args.flags & (AutoUpdateEventFlags.InvalidateNameToken | (globalConfig.longDesc ? AutoUpdateEventFlags.InvalidateDescToken : AutoUpdateEventFlags.InvalidatePickupToken))) == 0) { return; } if (x.pickupDef != null) { var ctsf = x.pickupDef.displayPrefab?.transform; if (!ctsf) { return; } var cfront = ctsf.Find("cardfront"); if (!cfront) { return; } cfront.Find("carddesc").GetComponent <TextMeshPro>().text = Language.GetString(globalConfig.longDesc ? x.descToken : x.pickupToken); cfront.Find("cardname").GetComponent <TextMeshPro>().text = Language.GetString(x.nameToken); } if (x.logbookEntry != null) { x.logbookEntry.modelPrefab = x.pickupDef.displayPrefab; } }; x.SetupConfig(cfgFile); } Logger.LogDebug("Registering item attributes..."); int longestName = 0; foreach (ItemBoilerplate x in masterItemList) { string mpnOvr = null; if (x is Item item) { mpnOvr = "@ClassicItems:Assets/ClassicItems/models/" + modelNameMap[item.itemTier] + ".prefab"; } else if (x is Equipment eqp) { mpnOvr = "@ClassicItems:Assets/ClassicItems/models/" + (eqp.eqpIsLunar ? "LqpCard.prefab" : "EqpCard.prefab"); } var ipnOvr = "@ClassicItems:Assets/ClassicItems/icons/" + x.itemCodeName + "_icon.png"; if (mpnOvr != null) { typeof(ItemBoilerplate).GetProperty(nameof(ItemBoilerplate.modelPathName)).SetValue(x, mpnOvr); typeof(ItemBoilerplate).GetProperty(nameof(ItemBoilerplate.iconPathName)).SetValue(x, ipnOvr); } x.SetupAttributes("CLASSICITEMS", "CI"); if (x.itemCodeName.Length > longestName) { longestName = x.itemCodeName.Length; } } Logger.LogMessage("Index dump follows (pairs of name / index):"); foreach (ItemBoilerplate x in masterItemList) { if (x is Equipment eqp) { Logger.LogMessage("Equipment CI" + x.itemCodeName.PadRight(longestName) + " / " + ((int)eqp.regIndex).ToString()); } else if (x is Item item) { Logger.LogMessage(" Item CI" + x.itemCodeName.PadRight(longestName) + " / " + ((int)item.regIndex).ToString()); } else if (x is Artifact afct) { Logger.LogMessage(" Artifact CI" + x.itemCodeName.PadRight(longestName) + " / " + ((int)afct.regIndex).ToString()); } else { Logger.LogMessage(" Other CI" + x.itemCodeName.PadRight(longestName) + " / N/A"); } } Logger.LogDebug("Tweaking vanilla stuff..."); //Remove the H3AD-5T V2 state transition from idle to stomp, as Headstompers has similar functionality if (globalConfig.hSV2NoStomp && !globalConfig.hSV2Bound) { globalConfig.hSV2Bound = true; IL.EntityStates.Headstompers.HeadstompersIdle.FixedUpdate += IL_ESHeadstompersIdleFixedUpdate; } On.RoR2.PickupCatalog.Init += On_PickupCatalogInit; On.RoR2.UI.LogBook.LogBookController.BuildPickupEntries += On_LogbookBuildPickupEntries; if (globalConfig.spinMod) { IL.RoR2.PickupDisplay.Update += IL_PickupDisplayUpdate; } Logger.LogDebug("Registering shared buffs..."); //used only for purposes of Death Mark; applied by Permafrost and Snowglobe var freezeBuffDef = new CustomBuff(new BuffDef { buffColor = Color.cyan, canStack = false, isDebuff = true, name = "CIFreeze", iconPath = "@ClassicItems:Assets/ClassicItems/icons/permafrost_icon.png" }); freezeBuff = BuffAPI.Add(freezeBuffDef); var fearBuffDef = new CustomBuff(new BuffDef { buffColor = Color.red, canStack = false, isDebuff = true, name = "CIFear", iconPath = "textures/miscicons/texSprintIcon" }); fearBuff = BuffAPI.Add(fearBuffDef); IL.EntityStates.AI.Walker.Combat.UpdateAI += IL_ESAIWalkerCombatUpdateAI; Logger.LogDebug("Registering item behaviors..."); foreach (ItemBoilerplate x in masterItemList) { x.SetupBehavior(); } Logger.LogDebug("Initial setup done!"); }
private void Awake() { _logger = Logger; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ArtifactOfDoom.artifactofdoom")) { var bundle = AssetBundle.LoadFromStream(stream); var provider = new AssetBundleResourcesProvider("@ArtifactOfDoom", bundle); ResourcesAPI.AddProvider(provider); } cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); masterItemList = ItemBoilerplate.InitAll("ArtifactOfDoom"); foreach (ItemBoilerplate x in masterItemList) { x.SetupConfig(cfgFile); } averageItemsPerStage = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "averageItemsPerStage"), 3, new ConfigDescription( "Base chance in percent that enemys steal items from you ((totalItems - currentStage * averageItemsPerStage) ^ exponentTriggerItems; \nIf that value is lower you'll need to kill more enemies to get an item")); exponentTriggerItems = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "exponentTriggerItems"), 2.0, new ConfigDescription( "The exponent for calculation when you'll get an item. If it's 1 you have a linear increase. Default is 2")); minItemsPerStage = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "minItemsPerStage"), 2, new ConfigDescription( "The expected minimum item count per stage. If you have less Items than that you'll have a decreased chance that you lose items")); maxItemsPerStage = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "maxItemsPerStage"), 7, new ConfigDescription( "The expected maximum item count per stage. If you have more Items than that you'll have a chance to lose more than one item per hit")); exponentailFactorToCalculateSumOfLostItems = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "exponentailFactorToCalculateSumOfLostItems"), 1.5, new ConfigDescription( "The exponent to Calculate how many items you'll lose if you're over maxItemsPerStage")); exponentailFactorIfYouAreUnderAverageItemsPerStage = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "exponentailFactorIfYouAreUnderAverageItemsPerStage"), 0.0, new ConfigDescription( "The exponent to Calculate how many kills you'll need if you're under averageItemsPerStage. The formula is totalitems^exponentailFactorIfYouAreUnderAverageItemsPerStage. Default is 0 so you'll need always two kills.")); artifactOfSwarmNerf = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "artifactOfSwarmNerf"), false, new ConfigDescription( "Enable the nerf for Artifact of Swarm where you've to kill double as many enemies")); useArtifactOfSacrificeCalculation = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "useArtifactOfSacreficeCalculation"), false, new ConfigDescription( "Chance the item gain to a specific drop rate of enemys")); multiplayerForArtifactOfSacrificeDropRate = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "multiplayerForArtifactOfSacrificeDropRate"), 2.0, new ConfigDescription( "Multiplier for the drop rate (base Chance is 5)")); disableItemProgressBar = cfgFile.Bind(new ConfigDefinition("UI Settings", "disableItemProgressBar"), false, new ConfigDescription( "If true it disables the Progress bar in the bottom of the UI")); disableSideBars = cfgFile.Bind(new ConfigDefinition("UI Settings", "disableSideBars"), false, new ConfigDescription( "Disables the item Sidebars")); enableChatItemOutput = cfgFile.Bind(new ConfigDefinition("UI Settings", "enableChatItemOutput"), false, new ConfigDescription( "Enables the chat output for gained/lost Items. This setting is not synced.")); sizeOfSideBars = cfgFile.Bind(new ConfigDefinition("UI Settings", "sizeOfSideBars"), 0.02, new ConfigDescription( "Spezifies the size of the sidebars. 1 is whole window 0 is invisible (but for that plase use the disable setting).")); timeAfterHitToNotLoseItemDrizzly = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "timeAfterHitToNotLooseItemDrizzly"), 0.8, new ConfigDescription( "The time in seconds where you will not lose items after you lost one on drizzly")); timeAfterHitToNotLoseItemRainstorm = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "timeAfterHitToNotLooseItemRainstorm"), 0.2, new ConfigDescription( "The time in seconds where you will not lose items after you lost one on rainstorm")); timeAfterHitToNotLoseItemMonsoon = cfgFile.Bind(new ConfigDefinition("Gameplay Settings", "timeAfterHitToNotLooseItemMonsoon"), 0.05, new ConfigDescription( "The time in seconds where you will not lose items after you lost one on monsoon")); CommandoBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "CommandoBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); CommandoMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "commandoMultiplyerForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); HuntressBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "HuntressBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); HuntressMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "HuntressMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); MULTBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "MULTBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); MULTMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "MULTMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); EngineerBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "EngineerBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); EngineerMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "EngineerMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); ArtificerBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "ArtificerBonusItems"), 2.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); ArtificerMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "ArtificerMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); MercenaryBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "MercenaryBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); MercenaryMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "MercenaryMultiplierForTimedBuff"), 4.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); RexBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "RexBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); RexMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "RexMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); LoaderBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "LoaderBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); LoaderMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "LoaderMultiplierForTimedBuff"), 4.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); AcridBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "AcridBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); AcridMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "AcridMultiplierForTimedBuff"), 4.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); CaptainBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "CaptainBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); CaptainMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "CaptainMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLooseItems")); CustomSurvivorBonusItems = cfgFile.Bind(new ConfigDefinition("Character specific settings", "CustomSurvivorBonusItems"), 1.0, new ConfigDescription( "The count of items which you get if you kill enough enemies")); CustomSurvivorMultiplierForTimedBuff = cfgFile.Bind(new ConfigDefinition("Character specific settings", "CustomSurvivorMultiplierForTimedBuff"), 1.0, new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLoseItems")); CustomChars = cfgFile.Bind(new ConfigDefinition("Character specific settings", "CustomCharacters"), "[{\"Name\": \"CUSTOM_CHAR_BODY_NAME1\", \"MultiplierForTimedBuff\": 1.0, \"BonusItems\": 1.0},{\"Name\": \"CUSTOM_CHAR_BODY_NAME2\", \"MultiplierForTimedBuff\": 2.0, \"BonusItems\": 2.0}]", new ConfigDescription( "The Multiplier for that specific character for the length of timeAfterHitToNotLoseItems")); int longestName = 0; foreach (ItemBoilerplate x in masterItemList) { x.SetupAttributes("ARTDOOM", "ADOOM"); if (x.itemCodeName.Length > longestName) { longestName = x.itemCodeName.Length; } } Logger.LogMessage("Index dump follows (pairs of name / index):"); foreach (ItemBoilerplate x in masterItemList) { if (x is Artifact afct) { Logger.LogMessage(" Artifact ADOOM" + x.itemCodeName.PadRight(longestName) + " / " + ((int)afct.regIndex).ToString()); } else { Logger.LogMessage("Other ADOOM" + x.itemCodeName.PadRight(longestName) + " / N/A"); } } var didLoseItem = new R2API.CustomBuff("didLoseItem", "", Color.black, false, false); buffIndexDidLoseItem = BuffAPI.Add(didLoseItem); foreach (ItemBoilerplate x in masterItemList) { x.SetupBehavior(); } //On.RoR2.UI.HUD.Awake +=myFunc // ArtifactOfDoomUI test = new ArtifactOfDoomUI(); }
private void Awake() { _logger = Logger; Logger.LogDebug("Performing plugin setup:"); #if DEBUG Logger.LogWarning("Running test build with debug enabled! If you're seeing this after downloading the mod from Thunderstore, please panic."); #endif Logger.LogDebug("Loading assets..."); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ClassicItems.classicitems_assets")) { var bundle = AssetBundle.LoadFromStream(stream); var provider = new AssetBundleResourcesProvider("@ClassicItems", bundle); ResourcesAPI.AddProvider(provider); } cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); Logger.LogDebug("Loading global configs..."); globalConfig.BindAll(cfgFile, "ClassicItems", "Global"); globalConfig.ConfigEntryChanged += (sender, args) => { if (args.target.boundProperty.Name == nameof(globalConfig.hSV2NoStomp)) { var toBind = (bool)args.newValue == true; if (toBind && !globalConfig.hSV2Bound) { IL.EntityStates.Headstompers.HeadstompersIdle.FixedUpdate += IL_ESHeadstompersIdleFixedUpdate; } else if (!toBind) { IL.EntityStates.Headstompers.HeadstompersIdle.FixedUpdate -= IL_ESHeadstompersIdleFixedUpdate; } } }; Logger.LogDebug("Instantiating item classes..."); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Classic Items", longIdentifier = "ClassicItems", shortIdentifier = "CI", mainConfigFile = cfgFile }); var itemType = typeof(Item <>); var scep = (Scepter)FormatterServices.GetUninitializedObject(typeof(Scepter)); var embryo = (Embryo)FormatterServices.GetUninitializedObject(typeof(Embryo)); var scepGenType = itemType.MakeGenericType(typeof(Scepter)); var embGenType = itemType.MakeGenericType(typeof(Embryo)); scepGenType.GetProperty("instance", BindingFlags.Public | BindingFlags.Static).GetSetMethod(true).Invoke(null, new[] { scep }); embGenType.GetProperty("instance", BindingFlags.Public | BindingFlags.Static).GetSetMethod(true).Invoke(null, new[] { embryo }); Logger.LogDebug("Loading item configs..."); foreach (CatalogBoilerplate x in masterItemList) { x.SetupConfig(); } Logger.LogDebug("Registering item attributes..."); foreach (CatalogBoilerplate x in masterItemList) { string mpnOvr = null; if (x is Item_V2 item) { mpnOvr = "@ClassicItems:Assets/ClassicItems/models/" + modelNameMap[item.itemTier] + ".prefab"; } else if (x is Equipment_V2 eqp) { mpnOvr = "@ClassicItems:Assets/ClassicItems/models/" + (eqp.isLunar ? "LqpCard.prefab" : "EqpCard.prefab"); } var ipnOvr = "@ClassicItems:Assets/ClassicItems/icons/" + x.name.Replace("_V2", "") + "_icon.png"; if (mpnOvr != null) { typeof(CatalogBoilerplate).GetProperty(nameof(CatalogBoilerplate.modelResourcePath)).SetValue(x, mpnOvr); typeof(CatalogBoilerplate).GetProperty(nameof(CatalogBoilerplate.iconResourcePath)).SetValue(x, ipnOvr); } x.SetupAttributes(); } Logger.LogDebug("Tweaking vanilla stuff..."); //Remove the H3AD-5T V2 state transition from idle to stomp, as Headstompers has similar functionality if (globalConfig.hSV2NoStomp && !globalConfig.hSV2Bound) { globalConfig.hSV2Bound = true; IL.EntityStates.Headstompers.HeadstompersIdle.FixedUpdate += IL_ESHeadstompersIdleFixedUpdate; } On.RoR2.PickupCatalog.Init += On_PickupCatalogInit; On.RoR2.UI.LogBook.LogBookController.BuildPickupEntries += On_LogbookBuildPickupEntries; Language.onCurrentLanguageChanged += Language_onCurrentLanguageChanged; if (globalConfig.spinMod) { IL.RoR2.PickupDisplay.Update += IL_PickupDisplayUpdate; } Logger.LogDebug("Registering shared buffs..."); //used only for purposes of Death Mark; applied by Permafrost and Snowglobe var freezeBuffDef = new CustomBuff(new BuffDef { buffColor = Color.cyan, canStack = false, isDebuff = true, name = "CIFreeze", iconPath = "@ClassicItems:Assets/ClassicItems/icons/permafrost_icon.png" }); freezeBuff = BuffAPI.Add(freezeBuffDef); var fearBuffDef = new CustomBuff(new BuffDef { buffColor = Color.red, canStack = false, isDebuff = true, name = "CIFear", iconPath = "textures/miscicons/texSprintIcon" }); fearBuff = BuffAPI.Add(fearBuffDef); IL.EntityStates.AI.Walker.Combat.UpdateAI += IL_ESAIWalkerCombatUpdateAI; Logger.LogDebug("Registering item behaviors..."); foreach (CatalogBoilerplate x in masterItemList) { x.SetupBehavior(); } Logger.LogDebug("Initial setup done!"); }
private void Awake() { Log = new Log(Logger); Log.Debug("Performing plugin setup:"); #if DEBUG MultiplayerTest.Enable(Logger, "Running test build with debug enabled! Report to CHEN if you're seeing this!"); #endif Log.Debug("Loading assets..."); BundleInfo bundleInfo = new BundleInfo("Chen.ClassicItems.chensclassicitems_assets", BundleType.UnityAssetBundle); assetBundle = new AssetsManager(bundleInfo).Register(); assetBundle.ConvertShaders(); cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); Log.Debug("Loading global configs..."); globalCfg.BindAll(cfgFile, ModName, "Global"); Log.Debug("Instantiating item classes..."); chensItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Chen's Classic Items", longIdentifier = "ChensClassicItems", shortIdentifier = "CCI", mainConfigFile = cfgFile }); Log.Debug("Loading item configs..."); foreach (CatalogBoilerplate x in chensItemList) { x.SetupConfig(); x.ConfigEntryChanged += (sender, args) => { if ((args.flags & AutoConfigUpdateActionTypes.InvalidateLanguage) == 0) { return; } var y = sender as CatalogBoilerplate; if (y.pickupDef != null) { var c = y.pickupDef.displayPrefab; if (!c) { return; } var ctsf = c.transform; var cfront = ctsf.Find("cardfront"); if (!cfront) { return; } cfront.Find("carddesc").GetComponent <TextMeshPro>().text = Language.GetString(longDesc ? y.descToken : y.pickupToken); cfront.Find("cardname").GetComponent <TextMeshPro>().text = Language.GetString(y.nameToken); } if (y.logbookEntry != null) { y.logbookEntry.modelPrefab = y.pickupDef.displayPrefab; } }; } Log.Debug("Registering item attributes..."); foreach (CatalogBoilerplate x in chensItemList) { string mpnOvr = null; if (x is Item item) { mpnOvr = "Assets/ClassicItems/models/" + modelNameMap[item.itemTier] + ".prefab"; } else if (x is Equipment eqp) { mpnOvr = "Assets/ClassicItems/models/" + (eqp.isLunar ? "LqpCard.prefab" : "EqpCard.prefab"); } var ipnOvr = "Assets/ClassicItems/icons/" + x.name + "_icon.png"; if (mpnOvr != null) { typeof(CatalogBoilerplate).GetProperty(nameof(CatalogBoilerplate.modelResource)).SetValue(x, assetBundle.LoadAsset <GameObject>(mpnOvr)); typeof(CatalogBoilerplate).GetProperty(nameof(CatalogBoilerplate.iconResource)).SetValue(x, assetBundle.LoadAsset <Sprite>(ipnOvr)); } x.SetupAttributes(); } Log.Debug("Registering item behaviors..."); foreach (CatalogBoilerplate x in chensItemList) { x.SetupBehavior(); } Log.Debug("Performing early finalization..."); T2Module.SetupAll_PluginStart(chensItemList); new ContentProvider().Initialize(); if (globalCfg.logEvolutionItemList) { RunArtifactManager.onArtifactEnabledGlobal += OnEvolutionEnable; RunArtifactManager.onArtifactDisabledGlobal += OnEvolutionDisable; } Log.Debug("Initial setup done!"); }
private void Awake() { _logger = Logger; Logger.LogDebug("Performing plugin setup:"); Logger.LogDebug("Loading assets..."); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ClassicItems.classicitems_assets")) { resources = AssetBundle.LoadFromStream(stream); } cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); Logger.LogDebug("Loading global configs..."); globalConfig.BindAll(cfgFile, "ClassicItems", "Global"); Logger.LogDebug("Instantiating item classes..."); masterItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo { displayName = "Classic Items", longIdentifier = "ClassicItems", shortIdentifier = "CI", mainConfigFile = cfgFile }); Logger.LogDebug("Loading item configs..."); foreach (CatalogBoilerplate x in masterItemList) { x.SetupConfig(); } Logger.LogDebug("Registering item attributes..."); foreach (CatalogBoilerplate x in masterItemList) { x.SetupAttributes(); } Logger.LogDebug("Registering shared buffs..."); //used only for purposes of Death Mark; applied by Permafrost and Snowglobe freezeBuff = ScriptableObject.CreateInstance <BuffDef>(); freezeBuff.buffColor = Color.cyan; freezeBuff.canStack = false; freezeBuff.isDebuff = true; freezeBuff.name = "CIFreeze"; freezeBuff.iconSprite = resources.LoadAsset <Sprite>("Assets/ClassicItems/Textures/ClassicIcons/permafrost_icon.png"); ContentAddition.AddBuffDef(freezeBuff); fearBuff = ScriptableObject.CreateInstance <BuffDef>(); fearBuff.buffColor = Color.red; fearBuff.canStack = false; fearBuff.isDebuff = true; fearBuff.name = "CIFear"; fearBuff.iconSprite = LegacyResourcesAPI.Load <Sprite>("textures/miscicons/texSprintIcon"); ContentAddition.AddBuffDef(fearBuff); IL.EntityStates.AI.Walker.Combat.UpdateAI += IL_ESAIWalkerCombatUpdateAI; Logger.LogDebug("Registering item behaviors..."); foreach (CatalogBoilerplate x in masterItemList) { x.SetupBehavior(); } Logger.LogDebug("Initial setup done!"); }