public override bool UseItem(Player player) { var mymod = (LicensesMod)this.mod; int savings; int oldStack = this.item.stack; ItemDefinition randItemDef = this.AttemptToLicenseRandomItem(player, out savings); if (randItemDef == null) { Main.NewText("No items of the given tier left to license.", Color.Red); return(false); } int targetRarity = WildcardLicenseItem.ComputeTargetRarityOfLicenseStackSize(oldStack); Color color = ItemRarityAttributeHelpers.RarityColor[targetRarity]; string randItemName = ItemAttributeHelpers.GetQualifiedName(randItemDef.Type); string msg = randItemName + " licensed"; if (savings > 0) { msg += " - " + savings + " discounted"; } PlayerMessages.AddPlayerLabel(player, msg, color, 2 * 60, true); Main.NewText(msg, color); if (LicensesMod.Config.DebugModeInfo) { LogHelpers.Alert(randItemName + " unlocked"); } return(true); }
public static int ComputeCost(Item item) { Item defaultOfItem = new Item(); defaultOfItem.SetDefaults(item.type, true); int rarity = Math.Max(0, defaultOfItem.rare); float cost = (float)LicensesMod.Config.LicenseCostBase; cost += (float)rarity * LicensesMod.Config.LicenseCostRarityMultiplier; if (LicensesMod.Config.LicenseCostArmorMultiplier != 1f) { if (ItemAttributeHelpers.IsArmor(defaultOfItem)) { cost = (float)cost * LicensesMod.Config.LicenseCostArmorMultiplier; } } if (LicensesMod.Config.LicenseCostAccessoryMultiplier != 1f) { if (defaultOfItem.accessory) { cost = (float)cost * LicensesMod.Config.LicenseCostAccessoryMultiplier; } } return((int)Math.Max(cost, LicensesMod.Config.LicenseCostBase)); }
public static int ComputeCost(Item item, out int savings) { int rarity = Math.Max(0, item.rare); float totalSavings = 0; float cost = (float)LicensesMod.Config.WildcardLicenseCostBase; cost += (float)item.stack * (float)rarity * (float)LicensesMod.Config.WildcardLicenseCostRarityMultiplier; if (LicensesMod.Config.LicenseCostArmorMultiplier != 1f) { if (ItemAttributeHelpers.IsArmor(item)) { float armorCost = (float)cost * LicensesMod.Config.LicenseCostArmorMultiplier; totalSavings += cost - armorCost; cost = armorCost; } } if (LicensesMod.Config.LicenseCostAccessoryMultiplier != 1f) { if (item.accessory) { float accCost = (float)cost * LicensesMod.Config.LicenseCostAccessoryMultiplier; totalSavings += cost - accCost; cost = accCost; } } savings = (int)totalSavings; return((int)Math.Max(cost, LicensesMod.Config.WildcardLicenseCostBase)); }
/// <summary> /// Loosely assesses player's relative level of power. Factors include appraisals of inventory items, player's defense, /// and player's life. /// </summary> /// <param name="player"></param> /// <returns></returns> public static float LooselyAssessPower(Player player) { float armorCount = 0, miscCount = 0; float hotbarTech = 0, armorTech = 0, miscTech = 0; for (int i = 0; i < PlayerHelpers.InventoryHotbarSize; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } float tech = ItemAttributeHelpers.LooselyAppraise(item); hotbarTech = hotbarTech > tech ? hotbarTech : tech; } int maxArmorSlot = 8 + player.extraAccessorySlots; for (int i = 0; i < maxArmorSlot; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } armorTech += ItemAttributeHelpers.LooselyAppraise(item); armorCount += 1; } for (int i = 0; i < player.miscEquips.Length; i++) { Item item = player.miscEquips[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } miscTech += ItemAttributeHelpers.LooselyAppraise(item); miscCount += 1; } float techFactor = armorTech / (armorCount * ItemRarityAttributeHelpers.HighestVanillaRarity); techFactor += miscTech / (miscCount * ItemRarityAttributeHelpers.HighestVanillaRarity); techFactor += hotbarTech + hotbarTech; techFactor /= 4; float defenseFactor = 1f + ((float)player.statDefense * 0.01f); float addedVitality = (float)player.statLifeMax / 20f; float vitalityFactor = addedVitality * defenseFactor; return((techFactor + techFactor + vitalityFactor) / 3f); }
public void UnloadModules() { this.Loadables.OnModsUnload(); this.Loadables = null; this.ReflectionHelpers = null; this.PacketProtocolMngr = null; this.ExceptionMngr = null; this.Timers = null; this.LogHelpers = null; this.ModFeaturesHelpers = null; this.BuffHelpers = null; this.NetHelpers = null; this.NPCAttributeHelpers = null; this.ProjectileAttributeHelpers = null; this.BuffIdentityHelpers = null; this.NPCBannerHelpers = null; this.RecipeFinderHelpers = null; this.RecipeGroupHelpers = null; this.PlayerHooks = null; this.LoadHelpers = null; this.GetModInfo = null; this.GetModTags = null; this.WorldStateHelpers = null; this.ModLock = null; this.EntityGroups = null; this.AnimatedColors = null; this.AnimatedTextures = null; this.PlayerMessages = null; this.Inbox = null; this.ControlPanel = null; this.MenuItemMngr = null; this.MenuContextMngr = null; this.MusicHelpers = null; this.PlayerIdentityHelpers = null; this.LoadHooks = null; this.CustomLoadHooks = null; this.DataStore = null; this.CustomHotkeys = null; this.XnaHelpers = null; this.Server = null; //this.PlayerDataMngr = null; this.SupportInfo = null; this.RecipeHack = null; this.ModListHelpers = null; this.ItemAttributeHelpers = null; this.WorldTimeHooks = null; this.ControlPanelHotkey = null; this.DataDumpHotkey = null; }
//////////////// public static Item GetGrappleItem(Player player) { if (ItemAttributeHelpers.IsGrapple(player.miscEquips[4])) { return(player.miscEquips[4]); } for (int i = 0; i < PlayerItemHelpers.VanillaInventorySize; i++) { if (Main.projHook[player.inventory[i].shoot]) { return(player.inventory[i]); } } return(null); }
public static float LooselyAssessPower(Player player) { float itemCount = 0; float tally = 0; for (int i = 0; i < PlayerHelpers.InventoryHotbarSize; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } tally += ItemAttributeHelpers.LooselyAppraise(item); itemCount += 1; } for (int i = 0; i < player.armor.Length; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } tally += ItemAttributeHelpers.LooselyAppraise(item); itemCount += 1; } for (int i = 0; i < player.miscEquips.Length; i++) { Item item = player.miscEquips[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } tally += ItemAttributeHelpers.LooselyAppraise(item); itemCount += 1; } float techFactor = tally / (itemCount * ItemAttributeHelpers.HighestVanillaRarity); float defenseFactor = 1f + ((float)player.statDefense * 0.01f); float vitality = (float)player.statLifeMax / 20f; float vitalityFactor = (vitality / (4f * ItemAttributeHelpers.HighestVanillaRarity)) * defenseFactor; return((techFactor + vitalityFactor) / 2f); }
public static IntrinsicType GetItemIntrinsicType(Item item) { if (item.accessory) { return(IntrinsicType.Accessory); } if (ItemAttributeHelpers.IsArmor(item)) { return(IntrinsicType.Armor); } if (item.buffType != 0) { return(IntrinsicType.Buff); } return(0); }
private void LoadModules() { this.Loadables.OnModsLoad(); this.ReflectionHelpers = new ReflectionHelpers(); this.DataStore = new DataStore(); this.LoadHooks = new LoadHooks(); this.CustomLoadHooks = new CustomLoadHooks(); this.LoadHelpers = new LoadHelpers(); this.Timers = new Timers(); this.LogHelpers = new LogHelpers(); this.ModFeaturesHelpers = new ModFeaturesHelpers(); this.PacketProtocolMngr = new PacketProtocolManager(); this.BuffHelpers = new BuffHelpers(); this.NetHelpers = new NetPlayHelpers(); this.NPCAttributeHelpers = new NPCAttributeHelpers(); this.ProjectileAttributeHelpers = new ProjectileAttributeHelpers(); this.BuffIdentityHelpers = new BuffAttributesHelpers(); this.NPCBannerHelpers = new NPCBannerHelpers(); this.RecipeFinderHelpers = new RecipeFinderHelpers(); this.RecipeGroupHelpers = new RecipeGroupHelpers(); this.PlayerHooks = new ExtendedPlayerHooks(); this.WorldTimeHooks = new WorldTimeHooks(); this.WorldStateHelpers = new WorldStateHelpers(); this.ControlPanel = new UIControlPanel(); this.ModLock = new ModLockService(); this.EntityGroups = new EntityGroups(); this.PlayerMessages = new PlayerMessages(); this.Inbox = new InboxControl(); this.GetModInfo = new GetModInfo(); this.GetModTags = new GetModTags(); this.MenuItemMngr = new MenuItemManager(); this.MenuContextMngr = new MenuContextServiceManager(); this.MusicHelpers = new MusicHelpers(); this.PlayerIdentityHelpers = new PlayerIdentityHelpers(); this.CustomHotkeys = new CustomHotkeys(); this.XnaHelpers = new XNAHelpers(); this.Server = new Server(); //this.PlayerDataMngr = new PlayerDataManager(); this.SupportInfo = new SupportInfoDisplay(); this.RecipeHack = new RecipeHack(); this.ModListHelpers = new ModListHelpers(); this.ItemAttributeHelpers = new ItemAttributeHelpers(); }
//////////////// internal void TrialLicenseItemByDefinition(ItemDefinition itemDef, bool playSound) { var mymod = (LicensesMod)this.mod; if (this.TrialLicensedItem != null) { string itemName = ItemAttributeHelpers.GetQualifiedName(this.TrialLicensedItem.Type); Main.NewText(itemName + " trial cancelled.", Color.Yellow); if (!this.LicensedItems.Contains(itemDef)) { NihilismAPI.UnsetItemWhitelistEntry(this.TrialLicensedItem, true); } } this.TrialLicensedItems.Add(itemDef); this.TrialLicensedItem = itemDef; NihilismAPI.SetItemWhitelistEntry(itemDef, true); Timers.UnsetTimer("LicensesTrialPeriod"); Timers.SetTimer("LicensesTrialPeriod", LicensesMod.Config.TrialLicenseDurationInTicks, () => { var myplayer = (LicensesPlayer)TmlHelpers.SafelyGetModPlayer(Main.LocalPlayer, mymod, "LicensesPlayer"); if (!myplayer.LicensedItems.Contains(itemDef)) { string itemName = ItemAttributeHelpers.GetQualifiedName(itemDef.Type); Main.NewText(itemName + " trial has expired.", Color.Yellow); NihilismAPI.UnsetItemWhitelistEntry(itemDef, true); myplayer.TrialLicensedItem = null; } return(false); }); if (playSound) { Main.PlaySound(SoundID.Unlock, player.position); } }
//////////////// /// <summary> /// Gets the "qualified" name (the name the player sees) of a given entity. /// </summary> /// <param name="ent"></param> /// <returns></returns> public static string GetQualifiedName(Entity ent) { if (ent is Item) { return(ItemAttributeHelpers.GetQualifiedName((Item)ent)); } if (ent is NPC) { return(NPCAttributeHelpers.GetQualifiedName((NPC)ent)); } if (ent is Projectile) { return(ProjectileAttributeHelpers.GetQualifiedName((Projectile)ent)); } if (ent is Player) { return(((Player)ent).name); } return("...a " + ent.GetType().Name); }
//////////////// public void UpdateChatWithTip() { if (this.CurrentChat != WanderingGhostNPC.ChatText) { return; } var mymod = (IntrinsicsMod)this.mod; int itemCount = mymod.Config.TradeItemContractTatters.Count; ItemDefinition itemDef = mymod.Config.TradeItemContractTatters .Keys .ToArray() [Main.rand.Next(itemCount)]; if (itemDef.Type == 0) { return; } string itemName = ItemAttributeHelpers.GetQualifiedName(itemDef.Type); this.CurrentChat = "..." + itemName + "..."; Main.npcChatText = this.CurrentChat; }
internal static void DefineItemWeaponGroups1(Action <string, string[], Matcher> addDef) { // Weapon Classes addDef("Any Ranged Weapon", null, (item, grps) => { return(item.ranged); }); addDef("Any Magic Weapon", null, (item, grps) => { return(item.magic); }); addDef("Any Melee Weapon", null, (item, grps) => { return(item.melee); }); addDef("Any Thrown Weapon", null, (item, grps) => { return(item.thrown); }); // Melee Sub Classes addDef("Any Swingable", null, (item, grps) => { return(item.melee && item.useStyle == 1); }); addDef("Any Thrustable", null, (item, grps) => { return(item.melee && item.useStyle == 5); }); addDef("Any Flail", null, (item, grps) => { if (!item.melee || item.useStyle != 5) { return(false); } if (item.type == ItemID.Anchor) { return(true); } if (item.shoot == 0) { return(false); } var projPool = ModHelpersMod.Instance.EntityGroups.GetProjPool(); switch (projPool[item.shoot].aiStyle) { case 15: // Standard case 13: // Chain Knife, Boxing Glove case 69: // Flairon case 75: // Solar Eruption return(true); } return(false); }); addDef("Any Boomerang", null, (item, grps) => { if (!item.melee || item.useStyle != 1) { return(false); } if (item.type == ItemID.FlyingKnife) { return(true); } if (item.shoot == 0) { return(false); } var projPool = ModHelpersMod.Instance.EntityGroups.GetProjPool(); switch (projPool[item.shoot].aiStyle) { case 3: // Boomerangs case 15: // Thorn Chakram return(true); } return(false); }); addDef("Any Yoyo", null, (item, grps) => { return(ItemAttributeHelpers.IsYoyo(item)); }); // Magic Sub Classes addDef("Any Magic Staff Or Scepter Or Wand", null, (item, grps) => { if (!item.magic) { return(false); } string name = ItemIdentityHelpers.GetQualifiedName(item); return(name.Contains("Staff") || name.Contains("Scepter") || name.Contains("Wand")); }); addDef("Any Magic Rod", null, (item, grps) => { if (!item.magic) { return(false); } string name = ItemIdentityHelpers.GetQualifiedName(item); return(name.Contains("Rod")); }); addDef("Any Magic Gun", null, (item, grps) => { if (!item.magic) { return(false); } switch (item.type) { case ItemID.LeafBlower: return(true); } string name = ItemIdentityHelpers.GetQualifiedName(item); return(name.Contains("Gun") || name.Contains("Rifle") || name.Contains("Ray") || name.Contains("Cannon") || name.Contains("Laser")); }); addDef("Any Magic Tome", null, (item, grps) => { if (!item.magic) { return(false); } switch (item.type) { case ItemID.DemonScythe: case ItemID.WaterBolt: case ItemID.LunarFlareBook: case ItemID.MagnetSphere: case ItemID.RazorbladeTyphoon: return(true); } var has = RecipeHelpers.ItemHasIngredients(item.type, new HashSet <int> { ItemID.SpellTome }, 1); if (has) { return(true); } string name = ItemIdentityHelpers.GetQualifiedName(item); return(name.Contains("Book") || name.Contains("Tome")); }); // Ranged Sub Classes addDef("Any Ranger Gun", null, (item, grps) => { if (!item.ranged) { return(false); } return(item.useAmmo == AmmoID.Bullet || item.useAmmo == AmmoID.CandyCorn || item.useAmmo == AmmoID.Coin); }); addDef("Any Ranger Bow", null, (item, grps) => { if (!item.ranged) { return(false); } return(item.useAmmo == AmmoID.Arrow || item.useAmmo == AmmoID.Stake); }); addDef("Any Ranger Launcher", null, (item, grps) => { if (!item.ranged) { return(false); } return(item.useAmmo == AmmoID.Rocket || item.useAmmo == AmmoID.StyngerBolt || item.useAmmo == AmmoID.JackOLantern || item.useAmmo == AmmoID.NailFriendly); }); // Summon Sub Classes addDef("Any Minion Summon Item", null, (item, grps) => { return(item.summon && !item.sentry); }); addDef("Any Sentry Summon Item", null, (item, grps) => { return(item.summon && item.sentry); }); // Vanity Classes addDef("Any Vanity Accessory", null, (item, grps) => { if (!item.vanity) { return(false); } return(item.accessory); }); addDef("Any Vanity Garment", null, (item, grps) => { if (!item.vanity) { return(false); } return(!item.accessory); }); }
internal static void DefineItemEquipmentGroups3(IList <EntityGroupMatcherDefinition <Item> > defs) { // Equipment Tiers defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Tiki Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); string name = ItemAttributeHelpers.GetQualifiedName(item); if (!hasEquip || !name.Contains("Tiki")) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Cactus Equipment", new string[] { "Any Equipment", }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.Cactus, 1 } }); if (!has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Plain Wood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.Wood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Boreal Wood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.BorealWood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Palm Wood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.PalmWood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Rich Mahogany Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.RichMahogany, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Ebonwood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.Ebonwood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Shadewood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.Shadewood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Pearlwood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.Pearlwood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Dynasty Wood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.DynastyWood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Spooky Wood Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.SpookyWood, 2 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Tin Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.TinBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Copper Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.CopperBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Iron Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.IronBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Lead Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.LeadBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Silver Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.SilverBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Tungsten Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.TungstenBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Gold Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.GoldBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Platinum Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.PlatinumBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Meteor Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.MeteoriteBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Demonite Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.DemoniteBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Crimtane Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.CrimtaneBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Jungle Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.JungleSpores, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Bee Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.BeeWax, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Bone Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.Bone, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Hellstone Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.HellstoneBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Cobalt Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.CobaltBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Palladium Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.PalladiumBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Mythril Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.MythrilBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Orichalcum Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.OrichalcumBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Adamantite Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.AdamantiteBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Titanium Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.TitaniumBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Frost Core Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.FrostCore, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Forbidden Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.AncientBattleArmorMaterial, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Hallow Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.HallowedBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Chlorophyte Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.ChlorophyteBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Shroomite Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.ShroomiteBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Spectre Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.SpectreBar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Shell Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has1 = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.BeetleShell, 1 } }); var has2 = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.TurtleShell, 1 } }); if (!hasEquip || (!has1 && !has2)) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Nebula Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.FragmentNebula, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Vortex Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.FragmentVortex, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Solar Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.FragmentSolar, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Stardust Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.FragmentStardust, 1 } }); if (!hasEquip || !has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Luminite Ore Equipment", new string[] { "Any Equipment" }, new ItemGroupMatcher((item, grps) => { var anyEquipItemDefs = grps["Any Equipment"].ToDictionary(kv => kv, kv => 1); bool hasEquip = RecipeHelpers.ItemHasIngredients(item.type, anyEquipItemDefs); var has = RecipeHelpers.ItemHasIngredients(item.type, new Dictionary <int, int> { { ItemID.LunarBar, 1 } }); if (!has) { return(false); } return(item.createTile == -1 && item.createWall == -1); }) )); }
internal static void DefineItemEquipmentGroups1(IList <EntityGroupMatcherDefinition <Item> > defs) { defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Weapon", null, new ItemGroupMatcher((item, grps) => { return(item.damage > 0); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Tool", null, new ItemGroupMatcher((item, grps) => { return(ItemAttributeHelpers.IsTool(item)); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Vanilla Explosive", null, new ItemGroupMatcher((item, grps) => { switch (item.type) { case ItemID.Bomb: case ItemID.StickyBomb: case ItemID.BouncyBomb: case ItemID.Dynamite: case ItemID.StickyDynamite: case ItemID.BouncyDynamite: case ItemID.Grenade: case ItemID.StickyGrenade: case ItemID.BouncyGrenade: case ItemID.BombFish: case ItemID.PartyGirlGrenade: case ItemID.Explosives: //? case ItemID.LandMine: //? case ItemID.RocketI: case ItemID.RocketII: case ItemID.RocketIII: case ItemID.RocketIV: case ItemID.StyngerBolt: case ItemID.HellfireArrow: case ItemID.ExplosiveJackOLantern: case ItemID.ExplosiveBunny: case ItemID.Cannonball: case ItemID.Beenade: //? return(true); } return(false); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Accessory", null, new ItemGroupMatcher((item, grps) => { return(item.accessory && !item.vanity); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Armor", null, new ItemGroupMatcher((item, grps) => { return(ItemAttributeHelpers.IsArmor(item)); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Garment", null, new ItemGroupMatcher((item, grps) => { return(item.headSlot != -1 || item.bodySlot != -1 || item.legSlot != -1); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Potion", null, new ItemGroupMatcher((item, grps) => { return(item.potion); }) )); // Vanity Classes defs.Add(new EntityGroupMatcherDefinition <Item>("Any Vanity", null, new ItemGroupMatcher((item, grps) => { return(item.vanity); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Vanity Accessory", null, new ItemGroupMatcher((item, grps) => { if (!item.vanity) { return(false); } return(item.accessory); }) )); defs.Add(new EntityGroupMatcherDefinition <Item>( "Any Vanity Garment", null, new ItemGroupMatcher((item, grps) => { if (!item.vanity) { return(false); } return(item.headSlot != -1 || item.bodySlot != -1 || item.legSlot != -1); }) )); }
public static bool ItemHasIntrinsics(Item item) { return(item.buffType != 0 || item.accessory || ItemAttributeHelpers.IsArmor(item)); }
private void DefineItemEquipmentGroups1(Action <string, Func <Item, bool> > add_def) { add_def("Any Weapon", ( Item item ) => { return(item.damage > 0); }); add_def("Any Tool", ( Item item ) => { return(ItemAttributeHelpers.IsTool(item)); }); add_def("Any Vanilla Explosive", ( Item item ) => { switch (item.type) { case ItemID.Bomb: case ItemID.StickyBomb: case ItemID.BouncyBomb: case ItemID.Dynamite: case ItemID.StickyDynamite: case ItemID.BouncyDynamite: case ItemID.Grenade: case ItemID.StickyGrenade: case ItemID.BouncyGrenade: case ItemID.BombFish: case ItemID.PartyGirlGrenade: case ItemID.Explosives: //? case ItemID.LandMine: //? case ItemID.RocketI: case ItemID.RocketII: case ItemID.RocketIII: case ItemID.RocketIV: case ItemID.StyngerBolt: case ItemID.HellfireArrow: case ItemID.ExplosiveJackOLantern: case ItemID.ExplosiveBunny: case ItemID.Cannonball: case ItemID.Beenade: //? return(true); } return(false); }); add_def("Any Accessory", ( Item item ) => { return(item.accessory && !item.vanity); }); add_def("Any Armor", ( Item item ) => { return(ItemAttributeHelpers.IsArmor(item)); }); add_def("Any Vanity", ( Item item ) => { return(item.vanity); }); add_def("Any Potion", ( Item item ) => { return(item.potion); }); // Vanity Classes add_def("Any Vanity Accessory", ( Item item ) => { if (!item.vanity) { return(false); } return(item.accessory); }); add_def("Any Vanity Garment", ( Item item ) => { if (!item.vanity) { return(false); } return(!item.accessory); }); }
private void RunLicenseCheckForItem(Item item) { if (item == null || item.IsAir) { this.LicenseMode = 0; return; } // If the item is a type of License, we engage the respective mode: if (item.type == ModContent.ItemType <LicenseItem>()) { this.LicenseMode = 1; return; } if (item.type == ModContent.ItemType <TrialLicenseItem>()) { this.LicenseMode = 2; return; } string realItemName = ItemAttributeHelpers.GetQualifiedName(item); ItemDefinition itemDef = new ItemDefinition(item.type); bool isTrialed = this.TrialLicensedItems.Contains(itemDef); bool isLicensed = this.LicensedItems.Contains(itemDef) || LicensesMod.Config.FreeStarterItems.Contains(itemDef); // When the item is NOT licenses, we apply the licensing effect to the item, if we can: switch (this.LicenseMode) { case 1: this.LicenseMode = 0; if (!isLicensed) { if (LicenseItem.AttemptToLicenseItem(this.player, item)) { Main.NewText(item.Name + " is now usable.", Color.Lime); } else { int needed = LicenseItem.ComputeCost(item); Main.NewText("Not enough licenses for " + realItemName + ": " + needed + " needed", Color.Red); } } else { Main.NewText(item.Name + " is already licensed.", Color.Yellow); } break; case 2: this.LicenseMode = 0; if (!isLicensed && (!isTrialed || !LicensesMod.Config.TrialLicenseOncePerItem)) { if (TrialLicenseItem.AttemptToTemporaryLicenseItem(this.player, item)) { Main.NewText(realItemName + " is now licensed for " + (LicensesMod.Config.TrialLicenseDurationInTicks / 60) + " seconds.", Color.LimeGreen); } else { int needed = LicenseItem.ComputeCost(item); Main.NewText("Not enough trial licenses for " + realItemName + ": " + needed + " needed", Color.Red); } } else { if (isLicensed) { Main.NewText(item.Name + " is already licensed.", Color.Yellow); } else if (isTrialed) { Main.NewText(item.Name + " has already been trialed.", Color.Yellow); } } break; } }
public static Color GetRarityColor(int rarity) { return(ItemAttributeHelpers.GetRarityColor(rarity)); }