internal override void Start() { char[] bad_characters = new char[] { '\n', '\t', '\\', '"', '\'', '[', ']' }; bool first = true; foreach (var itemIndex in RoR2.ItemCatalog.allItems) { ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); if (String.IsNullOrWhiteSpace(itemDef.nameToken)) { continue; } int itemValue = mod.config.ItemCountersTierScores[(int)itemDef.tier]; String safe_name = String.Join("", itemDef.nameToken.Split(bad_characters)); ConfigEntry <int> itemScore; if (first) { itemScore = mod.config.ConfigFileItemCounters.Bind <int>("ItemScores", safe_name, itemValue, $"Score of each item for the ItemScore.\n{Language.GetString(itemDef.nameToken)}"); first = false; } else { itemScore = mod.config.ConfigFileItemCounters.Bind <int>("ItemScores", safe_name, itemValue, Language.GetString(itemDef.nameToken)); } mod.config.ItemCountersItemScores.Add(itemDef.nameToken, itemScore.Value); } }
public static void AddItems() { Debug.LogFormat("[ROR2ML] Attempting to load {0} mod items.", new object[] { ModLoader.ItemMods.Count }); uint num = 1u; foreach (ItemModInfo itemModInfo in ModLoader.ItemMods) { Debug.LogFormat("[ROR2ML] Adding mod item... (Name: {0})", new object[] { itemModInfo.nameTokenString }); if (itemModInfo.toReplace == -1) { ItemCatalog.RegisterItem(ItemIndex.DrizzlePlayerHelper + (int)num, itemModInfo.RegisterModItem()); num += 1u; } else { ItemCatalog.RegisterItem((ItemIndex)itemModInfo.toReplace, itemModInfo.RegisterModItem()); } } }
private static void FixItemCountStatHook() { IL.RoR2.Stats.StatManager.ProcessItemCollectedEvents += (il) => { ILCursor c = new ILCursor(il); bool found = c.TryGotoNext( x => x.MatchLdloc(0), x => x.MatchLdfld("RoR2.Stats.StatManager/ItemCollectedEvent", "quantity") ); if (found) { c.Index += 2; c.Emit(OpCodes.Ldloc, 0); c.EmitDelegate <Func <int, StatManager.ItemCollectedEvent, int> >((count, ice) => { ItemDef itemDef = ItemCatalog.GetItemDef(ice.itemIndex); if (itemDef.hidden) { return(0); } return(count); }); } else { Logger.Warn("FixItemCountStatHook Failed"); } }; }
public static void customItemCap(CharacterMaster cm) { // Custom item caps string[] customItemCaps = DII.CustomItemCapsAll.Value.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in customItemCaps) { string[] temp = item.Split(new[] { '-' }); if (temp.Length == 2) { if (Int32.TryParse(temp[0], out int itemId) && Int32.TryParse(temp[1], out int cap)) { if (cm.inventory.GetItemCount((ItemIndex)itemId) > cap) { cm.inventory.ResetItem((ItemIndex)itemId); cm.inventory.GiveItem((ItemIndex)itemId, cap); } } else if (Int32.TryParse(temp[1], out cap)) { ItemIndex index = ItemCatalog.FindItemIndex(temp[0]); if (index != ItemIndex.None) { if (cm.inventory.GetItemCount(index) > cap) { cm.inventory.ResetItem(index); cm.inventory.GiveItem(index, cap); } } } } } }
public void Update() { if (Utils.Cfg_PlantsForHire) { if (Input.GetKeyDown(KeyCode.F2)) { TestSpawnItem((int)ItemCatalog.FindItemIndex("CritGlasses"));//ItemIndex.CritGlasses); } //if (Input.GetKeyDown(KeyCode.F3)) //{ // Chat.AddMessage("kek"); // TestSpawnItem((int)ItemIndex.TreasureCache); //} if (Input.GetKeyDown(KeyCode.F6)) { TestSpawnItem(); } if (Input.GetKeyDown(KeyCode.F7)) { TestSpawnItem(Utils.Cfg_CheatItem); } if (Input.GetKeyDown(KeyCode.F9)) { TestSpawnItemRed(); } } }
public async Task <ActionResult <MethodResponse> > PostCreateItemCatalog([FromBody] ItemCatalog itemCatalogData) { var lastItemCatalog = await context.ItemCatalogs.OrderByDescending(p => p.ItemCatalogId).FirstOrDefaultAsync(); var itemCatalogId = 0; if (lastItemCatalog == null) { itemCatalogId = 1; } else { itemCatalogId = lastItemCatalog.ItemCatalogId + 1; } var itemCatalog = new ItemCatalog { ItemCatalogId = itemCatalogId, ItemCatalogDescription = itemCatalogData.ItemCatalogDescription, ItemCatalogStatus = itemCatalogData.ItemCatalogStatus, StoreId = itemCatalogData.StoreId, ItemCatalogCreationDate = DateTime.UtcNow, ItemCatalogModifiedDate = DateTime.UtcNow }; context.Add(itemCatalog); await context.SaveChangesAsync(); return(Ok(new MethodResponse { State = "Created", Comment = $"Item Catalog : {itemCatalog.ItemCatalogId} has been created for the Store {itemCatalog.StoreId}." })); }
public static void ShowWindow(int windowID) { firstNetworkUser = PlayerCharacterMasterController.instances[0].networkUser; firstPlayer = PlayerCharacterMasterController.instances[0].master; var viewModel = AugmentShop.GetShopViewModel(firstPlayer.netId); GUILayout.BeginHorizontal(); foreach (var item in viewModel.Items) { var itemDef = ItemCatalog.GetItemDef(item.ItemIndex); GUILayout.Label($"Item name: {itemDef.name}, Points to spend: {item.PointsToSpend}"); foreach (var augment in item.Augments) { if (GUILayout.Button(new GUIContent(augment.Name, itemDef.pickupIconTexture))) { AugmentResolver.TryAddOrUpgradeAugmentToPlayer(firstPlayer.netId, itemDef.itemIndex, augment.AugmentId); Chat.AddMessage($"{firstNetworkUser.userName} unlocked augment {augment.Name}"); } } } GUILayout.EndHorizontal(); }
////// Non-Public Methods ////// private static int GetTotalItemTypes(Inventory inv) { if (validItemTypeCache == null) { validItemTypeCache = new HashSet <int>(); for (var i = 0; i < inv.itemStacks.Length; i++) { var idef = ItemCatalog.GetItemDef((ItemIndex)i); if (idef == null || idef.hidden) { continue; } var itier = ItemTierCatalog.GetItemTierDef(idef.tier); if (itier != null && itier.isDroppable) { validItemTypeCache.Add(i); } } } int retv = 0; for (var i = 0; i < inv.itemStacks.Length; i++) { if (inv.itemStacks[i] > 0 && validItemTypeCache.Contains(i)) { retv++; } } return(retv); }
private void UserDied(On.RoR2.GlobalEventManager.orig_OnPlayerCharacterDeath orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim, NetworkUser victimNetworkUser) { var killer = damageInfo.attacker.GetComponent <CharacterBody>(); if (killer != null && teams.ContainsKey(killer.master)) { teams[killer.master].kills++; } var char_master = victimNetworkUser.master; if (!teams.ContainsKey(char_master)) { return; } teams[char_master].time_to_revive = Run.TimeStamp.now.t + respawn_delay; teams[char_master].deaths++; // Give the user something nice :) var availableItems = selection.Evaluate(Run.instance.treasureRng.nextNormalizedFloat); var item = availableItems[Run.instance.treasureRng.RangeInt(0, availableItems.Count)]; char_master.inventory.GiveItem(item); Chat.SendBroadcastChat(new Chat.UserChatMessage { sender = victimNetworkUser.gameObject, text = String.Format("{0} murdered me. Grabbing [{1}] for a boost.", killer.master.GetComponent <PlayerCharacterMasterController>().networkUser.userName, ItemCatalog.GetItemDef(item).unlockableName) }); orig(self, damageInfo, victim, victimNetworkUser); }
private void MaybeAwardLoot(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) { orig(self); var amount = self.inventory.GetItemCount(Definition.itemIndex); if (amount > 0 && amount % 3 == 0) { self.inventory.RemoveItem(Definition.itemIndex, 3); PickupIndex loot; if (Util.CheckRoll(5, self.master)) { loot = Run.instance.treasureRng.NextElementUniform(Run.instance.availableTier3DropList); } else { loot = Run.instance.treasureRng.NextElementUniform(Run.instance.availableTier2DropList); } if (self.isPlayerControlled) { PickupDropletController.CreatePickupDroplet(loot, self.corePosition, Vector3.up * 5); } else { PickupDef def = PickupCatalog.GetPickupDef(loot); self.inventory.GiveItem(def.itemIndex); var lootCount = self.inventory.GetItemCount(def.itemIndex); Chat.AddPickupMessage(self, def.nameToken, ColorCatalog.GetColor(ItemCatalog.GetItemDef(def.itemIndex).colorIndex), (uint)lootCount); } } }
private void CreateTooltip(Transform parent, PickupDef pickupDefinition, int count) { ItemDef itemDefinition = ItemCatalog.GetItemDef(pickupDefinition.itemIndex); EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDefinition.equipmentIndex); bool isItem = itemDefinition != null; TooltipContent content = new TooltipContent(); content.titleColor = pickupDefinition.darkColor; content.titleToken = isItem ? itemDefinition.nameToken : equipmentDef.nameToken; content.bodyToken = isItem ? itemDefinition.descriptionToken : equipmentDef.descriptionToken; if (isItem && ItemStatsMod.enabled) { CharacterMaster master = PlayerCharacterMasterController.instances[0].master; string stats = ItemStatsMod.GetStats(itemDefinition.itemIndex, count, master); if (stats != null) { content.overrideBodyText = $"{Language.GetString(content.bodyToken)}{stats}"; } } TooltipProvider tooltipProvider = parent.gameObject.AddComponent <TooltipProvider>(); tooltipProvider.SetContent(content); }
public static void GiveAveragedItems(NetworkUser joiningPlayer, bool includeRed, bool includeLunar, bool includeBoss) { var targetInventory = joiningPlayer?.master?.inventory; var otherPlayerInventories = NetworkUser.readOnlyInstancesList .Where(player => !player.id.Equals(joiningPlayer.id) && player?.master?.inventory != null) // Don't include self or any other players who don't have a character .Select(p => p.master.inventory) .ToArray(); if (targetInventory == null || // The new player does not have character yet otherPlayerInventories.Length <= 0) // We are the only player { return; } AddToItemsToMatch(targetInventory, otherPlayerInventories, ItemCatalog.tier1ItemList, ItemTier.Tier1); AddToItemsToMatch(targetInventory, otherPlayerInventories, ItemCatalog.tier2ItemList, ItemTier.Tier2); if (includeRed) { AddToItemsToMatch(targetInventory, otherPlayerInventories, ItemCatalog.tier3ItemList, ItemTier.Tier3); } if (includeLunar) { AddToItemsToMatch(targetInventory, otherPlayerInventories, ItemCatalog.lunarItemList, ItemTier.Lunar); } if (includeBoss) { if (_bossItems == null) { _bossItems = ItemCatalog.allItems.Select(idx => ItemCatalog.GetItemDef(idx)).Where(item => item.tier == ItemTier.Boss).Select(item => item.itemIndex).ToList(); } AddToItemsToMatch(targetInventory, otherPlayerInventories, _bossItems, ItemTier.Boss); } }
// Methods // Builds the quest description used for messaging data across clients. public static string GetDescription(ClientMessage clientMessage, ServerMessage serverMessage) // TODO: Maybe move some of this data to individual message componenents { return string.Format("{0},{1},{2},{3},{4},{5}", (int)serverMessage.type, string.Format("{0} {1}{2}", serverMessage.objective, clientMessage.target, serverMessage.type == Type.KillEnemies ? "s" : ""), string.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGBA(serverMessage.drop.baseColor), Language.GetString(ItemCatalog.GetItemDef(serverMessage.drop.itemIndex).nameToken)), serverMessage.progress, serverMessage.objective, ItemCatalog.GetItemDef(serverMessage.drop.itemIndex).pickupIconPath); }
internal void ScoreboardStrip_Update(On.RoR2.UI.ScoreboardStrip.orig_Update orig, ScoreboardStrip self) { orig(self); if (self.master && self.master.inventory) { BetterUI.sharedStringBuilder.Clear(); BetterUI.sharedStringBuilder.Append(Util.GetBestMasterName(self.master)); BetterUI.sharedStringBuilder.Append("\n<#F8FC97>"); BetterUI.sharedStringBuilder.Append(self.master.money); BetterUI.sharedStringBuilder.Append("</color>"); self.nameLabel.text = BetterUI.sharedStringBuilder.ToString(); BetterUI.sharedStringBuilder.Clear(); BetterUI.sharedStringBuilder.Append("<#FFFFFF>"); if (mod.config.ItemCountersShowItemSum.Value) { itemSum = 0; foreach (var tier in mod.config.ItemCountersItemSumTiers) { itemSum += self.master.inventory.GetTotalItemCountOfTier(tier); } BetterUI.sharedStringBuilder.Append(itemSum); if (mod.config.ItemCountersShowItemScore.Value) { BetterUI.sharedStringBuilder.Append(" | "); } } if (mod.config.ItemCountersShowItemScore.Value) { itemScore = 0; foreach (var item in self.master.inventory.itemAcquisitionOrder) { int value; itemScore += mod.config.ItemCountersItemScores.TryGetValue(ItemCatalog.GetItemDef(item).nameToken, out value) ? value * self.master.inventory.GetItemCount(item) : 0; } BetterUI.sharedStringBuilder.Append(itemScore); } if (mod.config.ItemCountersShowItemsByTier.Value) { BetterUI.sharedStringBuilder.Append("\n"); foreach (var tier in mod.config.ItemCountersItemsByTierOrder) { BetterUI.sharedStringBuilder.Append(" <#"); BetterUI.sharedStringBuilder.Append(tierColorMap[(int)tier]); BetterUI.sharedStringBuilder.Append(">"); BetterUI.sharedStringBuilder.Append(self.master.inventory.GetTotalItemCountOfTier(tier)); BetterUI.sharedStringBuilder.Append("</color>"); } } BetterUI.sharedStringBuilder.Append("</color>"); self.moneyText.text = BetterUI.sharedStringBuilder.ToString(); } }
public void ShowShopInventory() { ItemCatalog.Clear(); ListWeapons(); ListArmors(); ListPotions(); }
private static void ScrappingToIdle_OnEnter(On.EntityStates.Scrapper.ScrappingToIdle.orig_OnEnter orig, EntityStates.Scrapper.ScrappingToIdle self) { if (!(ShareSuite.PrinterCauldronFixEnabled.Value && NetworkServer.active && GeneralHooks.IsMultiplayer())) { orig(self); return; } _itemLock = true; orig(self); ScrapperController scrapperController = GetInstanceField(typeof(ScrapperBaseState), self, "scrapperController") as ScrapperController; Debug.Log(scrapperController); if (scrapperController) { PickupIndex pickupIndex = PickupIndex.none; ItemDef itemDef = ItemCatalog.GetItemDef(scrapperController.lastScrappedItemIndex); if (itemDef != null) { switch (itemDef.tier) { case ItemTier.Tier1: pickupIndex = PickupCatalog.FindPickupIndex("ItemIndex.ScrapWhite"); break; case ItemTier.Tier2: pickupIndex = PickupCatalog.FindPickupIndex("ItemIndex.ScrapGreen"); break; case ItemTier.Tier3: pickupIndex = PickupCatalog.FindPickupIndex("ItemIndex.ScrapRed"); break; case ItemTier.Boss: pickupIndex = PickupCatalog.FindPickupIndex("ItemIndex.ScrapYellow"); break; } } if (pickupIndex == PickupIndex.none) { return; } var interactor = GetInstanceField(typeof(ScrapperController), scrapperController, "interactor") as Interactor; Debug.Log("Interactor Established"); PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (!interactor) { return; } CharacterBody component = interactor.GetComponent <CharacterBody>(); component.inventory.GiveItem(pickupDef.itemIndex, scrapperController.itemsEaten); ChatHandler.SendRichCauldronMessage(component.inventory.GetComponent <CharacterMaster>(), pickupIndex); } }
public ItemList() : base(itemsList) { if (UmbraMenu.characterCollected) { int buttonPlacement = 1; List <Button> buttons = new List <Button>(); for (int i = 0; i < UmbraMenu.items.Count; i++) { ItemIndex itemIndex = UmbraMenu.items[i]; void ButtonAction() => GiveItem(itemIndex); Color32 itemColor = ColorCatalog.GetColor(ItemCatalog.GetItemDef(itemIndex).colorIndex); if (itemColor.r <= 105 && itemColor.g <= 105 && itemColor.b <= 105) { string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), new Color32(255, 255, 255, 255)); Button button = new Button(new NormalButton(this, buttonPlacement, itemName, ButtonAction)); buttons.Add(button); buttonPlacement++; } else { string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), itemColor); Button button = new Button(new NormalButton(this, buttonPlacement, itemName, ButtonAction)); buttons.Add(button); buttonPlacement++; } } AddButtons(buttons); SetActivatingButton(Utility.FindButtonById(3, 3)); SetPrevMenuId(3); } }
public static void Postfix(ItemIcon __instance) { if (__instance.tooltipProvider) { __instance.tooltipProvider.bodyToken = ItemCatalog.GetItemDef(Traverse.Create(__instance).Field("itemIndex").GetValue <ItemIndex>()).descriptionToken; } }
public static bool PickupIsNonBlacklistedItem(PickupIndex pickupIndex) { var pickupDef = PickupCatalog.GetPickupDef(pickupIndex); var itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); return(itemDef.DoesNotContainTag(ItemTag.AIBlacklist)); }
private void ItemStealController_RpcOnStealFinishClient(On.RoR2.ItemStealController.orig_RpcOnStealFinishClient orig, ItemStealController self) { orig(self); bool activate = false; foreach (var invInfo in self.stolenInventoryInfos) { if (invInfo.stolenItemStacks[(int)HonoredItem] > 0) { activate = true; break; } } if (activate) { var brother = GameObject.Find("BrotherHurtBody(Clone)"); if (brother) { var component = brother.AddComponent <MithrixKneel>(); component.characterBody = brother.GetComponent <CharacterBody>(); component.question = Language.GetString(ItemCatalog.GetItemDef(HonoredItem).nameToken); } } }
/// <summary> /// Add an item to the item pool from a string. /// </summary> /// <param name="unlockableRewardIdentifier">The AchievementDef.unlockableRewardIdentifier, e.g. "Item.Bear"</param> public void AddItemFromString(string unlockableRewardIdentifier) { string pattern = @"\w+\."; //this just means "[infinite letters until]." bool equipment = false; unlockableRewardIdentifier = Regex.Replace(unlockableRewardIdentifier, pattern, ""); //remove "[infinite letters until]." so we have the itemname remaining foreach (EquipmentIndex i in EquipmentCatalog.equipmentList) { EquipmentDef EqDef = EquipmentCatalog.GetEquipmentDef(i); string equipmentString = EqDef.name; if (unlockableRewardIdentifier == equipmentString) { Run.instance.availableEquipment.Add(EquipmentCatalog.FindEquipmentIndex(unlockableRewardIdentifier)); equipment = true; break; //So we don't search everything if we already have it } } if (!equipment) //it doesn't matter if we try to find itemindex for characters or logs, due to the fact that they won't have the same name as an available item, and will not result in an ItemIndex that we can use { Run.instance.availableItems.Add(ItemCatalog.FindItemIndex(unlockableRewardIdentifier)); //Add the item from this string into the available items } Run.instance.BuildDropTable(); //Makes it so that everything we added actually gets put into the game pool so we can get it on the next items, you can see it that old items do not have it with command, but hopefully that won't matter :] UpdateDroppedCommandDroplets(); }
// Token: 0x0600235E RID: 9054 RVA: 0x0009AAB4 File Offset: 0x00098CB4 protected override void Awake() { base.Awake(); this.rectTransform = (RectTransform)base.transform; this.itemStacks = ItemCatalog.RequestItemStackArray(); this.itemOrder = ItemCatalog.RequestItemOrderBuffer(); }
private GameObject PickupIndex_GetPickupDisplayPrefab(On.RoR2.PickupIndex.orig_GetPickupDisplayPrefab orig, ref PickupIndex self) { PickupIndex dio = new PickupIndex(ItemIndex.ExtraLife); if (self != dio) { return(orig.Invoke(ref self)); } else { List <PickupIndex> tier3Items = Run.instance.availableTier3DropList; if (!tier3Items.Contains(self)) { return(orig.Invoke(ref self)); } int rng = random.Next(0, tier3Items.Count); if (tier3Items[rng] == dio) { rng++; } ItemIndex rngItem = tier3Items[rng].itemIndex; GameObject gameObject = Resources.Load <GameObject>(ItemCatalog.GetItemDef(rngItem).pickupModelPath); return(gameObject); } }
// Token: 0x06002362 RID: 9058 RVA: 0x0009AB3C File Offset: 0x00098D3C public void UpdateDisplay() { this.updateRequestPending = false; if (!this || !base.isActiveAndEnabled) { return; } ItemIndex[] array = ItemCatalog.RequestItemOrderBuffer(); int num = 0; for (int i = 0; i < this.itemOrderCount; i++) { if (ItemInventoryDisplay.ItemIsVisible(this.itemOrder[i])) { array[num++] = this.itemOrder[i]; } } this.AllocateIcons(num); for (int j = 0; j < num; j++) { ItemIndex itemIndex = array[j]; this.itemIcons[j].SetItemIndex(itemIndex, this.itemStacks[(int)itemIndex]); } ItemCatalog.ReturnItemOrderBuffer(array); }
private void CharacterMaster_OnBodyStart(On.RoR2.CharacterMaster.orig_OnBodyStart orig, CharacterMaster self, CharacterBody body) { orig(self, body); CharacterBody body2 = PlayerCharacterMasterController.instances[0].master.GetBody(); if (body == body2) { if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarPrimaryReplacement")) == 0) { body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarPrimaryReplacement")); } if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarSecondaryReplacement")) == 0) { body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarSecondaryReplacement")); } if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarUtilityReplacement")) == 0) { body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarUtilityReplacement")); } if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarSpecialReplacement")) == 0) { body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarSpecialReplacement")); } } }
public void OnUndoPickUpInStore() { var orderModel = OrderService.OrderModel; if (orderModel == null || orderModel.LastStoreModelByClientAddress == null || orderModel.LastStoreModelByClientAddress.IdKey.HasValue == false || (orderModel.StoreModel != null && orderModel.LastStoreModelByClientAddress.IdKey == orderModel.StoreModel.IdKey)) { return; } var item = new ItemCatalog { Id = (int)orderModel.LastStoreModelByClientAddress.IdKey.Value, Name = String.Format("{0} ({1})", orderModel.LastStoreModelByClientAddress.Value, orderModel.LastStoreModelByClientAddress.MainAddress), Value = orderModel.LastStoreModelByClientAddress.MainAddress }; LookingAvailability(item); DisposeSubscription(); _subscription = _client.ExecutionProxy.ExecuteRequest <ItemCatalog, ItemCatalog, ResponseMessageData <StoreModel>, ResponseMessageData <StoreModel> >(item, TransferDto.TransferDto.SameType, SharedConstants.Server.STORE_HUB, SharedConstants.Server.AVAILABLE_BY_STORE_STORE_HUB_METHOD, TransferDto.TransferDto.SameType) .Subscribe(obj => OnResultStoreAvailableOk(obj), OnResultStoreAvailableError); }
public static List <ItemIndex> GetDefaultDropList(ItemTier itemTier) { if (itemTier == ItemTier.NoTier) { return(null); } var list = new List <ItemIndex>(); for (var itemIndex = ItemIndex.Syringe; itemIndex < ItemIndex.Count; itemIndex++) { if (!Run.instance.availableItems.HasItem(itemIndex)) { continue; } if (ItemCatalog.GetItemDef(itemIndex).tier == itemTier) { list.Add(itemIndex); } } list.AddRange(AdditionalTierItems[itemTier]); return(list); }
//TODO: Add method to pick random item private ItemDef RandomItem(ItemTier tier) { ItemDef[] array = (from item in ItemCatalog.allItems where Run.instance.IsItemAvailable(item) && ItemCatalog.GetItemDef(item).tier == tier select ItemCatalog.GetItemDef(item)).ToArray <ItemDef>(); return(array[random.Next(0, array.Length)]); }
void Buy() { var selection = ""; while (string.IsNullOrEmpty(selection)) { Console.WriteLine(""); Console.WriteLine("What Would you like to purchase? "); selection = Console.ReadLine(); } if (!ItemCatalog.ContainsKey(selection)) { Console.WriteLine(""); Console.WriteLine("That selection is not valid please try again."); Buy(); } if (VerifyFunds(selection)) { FinalizeBuy(selection); } this.Menu(); }
internal static void GiveScavsLunarsAndBossItems(On.RoR2.ScavengerItemGranter.orig_Start orig, RoR2.ScavengerItemGranter self) { orig(self); Inventory inventory = self.GetComponent <Inventory>(); if (inventory.GetTotalItemCountOfTier(ItemTier.Lunar) == 0) { var list = Run.instance.availableLunarDropList.Where(new System.Func <PickupIndex, bool>(PickupIsNonBlacklistedItem)).ToList(); var randomIndex = Random.Range(0, list.Count); inventory.GiveItem(PickupCatalog.GetPickupDef(list[randomIndex]).itemIndex, 2); } if (inventory.GetTotalItemCountOfTier(ItemTier.Boss) == 0) { var list = PickupCatalog.allPickups.Where(def => def.isBoss).ToList(); var randomIndex = Random.Range(0, list.Count); inventory.GiveItem(list[randomIndex].itemIndex, 1); } bool PickupIsNonBlacklistedItem(PickupIndex pickupIndex) { PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef != null ? pickupDef.itemIndex : ItemIndex.None); if (itemDef == null) { return(false); } return(itemDef.DoesNotContainTag(ItemTag.AIBlacklist)); } }