private void TestArmorSlots(ISet <Type> equippedAbilityEnablingItemTypes) { int maxAccSlot = PlayerItemLibraries.GetCurrentVanillaMaxAccessories(this.player) + PlayerItemLibraries.VanillaAccessorySlotFirst; string alert; // Test each item against equipped ability items for (int slot = 0; slot < maxAccSlot; slot++) { Item item = this.player.armor[slot]; if (item == null || item.IsAir) { continue; } if (!this.TestArmorAgainstMissingAbilities(equippedAbilityEnablingItemTypes, slot, out alert)) { Main.NewText(alert, Color.Yellow); PlayerItemLibraries.DropEquippedArmorItem(this.player, slot, 0); continue; } } this.TestAccessorySlotCapacity(); }
/*public override void PostDrawInterface( SpriteBatch sb ) { * if( Main.playerInventory && Main.EquipPage == 0 ) { //== 2 is misc page * this.DrawAccessoryOverlays( sb ); * } * }*/ private void DrawDisabledAccessorySlotOverlays(SpriteBatch sb) { var myplayer = TmlLibraries.SafelyGetModPlayer <LockedAbilitiesPlayer>(Main.LocalPlayer); if (myplayer.TotalAllowedAccessorySlots < 0) { return; } int firstAccSlot = PlayerItemLibraries.VanillaAccessorySlotFirst; int maxAcc = PlayerItemLibraries.GetCurrentVanillaMaxAccessories(Main.LocalPlayer) + firstAccSlot; int myMaxAcc = myplayer.TotalAllowedAccessorySlots; for (int i = firstAccSlot; i < maxAcc; i++) { if ((i - firstAccSlot) < myMaxAcc) { continue; } var pos = HUDElementLibraries.GetVanillaAccessorySlotScreenPosition(i - firstAccSlot); pos.X += 8; pos.Y += 8; sb.Draw(this.DisabledItemTex, pos, Color.White); } }
//////////////// public static bool IsAmmoSourceAvailable(Player player, bool skipSpeedloaders, out string result) { var config = TMRConfig.Instance; if (config.Get <bool>(nameof(TMRConfig.InfiniteAmmoCheat))) { result = "Cheater."; return(true); } if (!skipSpeedloaders) { int speedloaderType = ModContent.ItemType <SpeedloaderItem>(); for (int i = 0; i < player.inventory.Length; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || item.type != speedloaderType) { continue; } var myitem = item.modItem as SpeedloaderItem; if ((myitem?.LoadedRounds ?? 0) > 0) { result = " Speedloader available."; return(true); } } result = "Loaded speedloader needed."; } else { result = "Cannot reload."; } if (config.Get <bool>(nameof(TMRConfig.BandolierNeededToReload))) { int bandolierType = ModContent.ItemType <BandolierItem>(); int max = PlayerItemLibraries.VanillaAccessorySlotFirst + PlayerItemLibraries.GetCurrentVanillaMaxAccessories(player); for (int i = PlayerItemLibraries.VanillaAccessorySlotFirst; i < max; i++) { Item item = player.armor[i]; if (item == null || item.IsAir || item.type != bandolierType) { continue; } result = "Bandolier available."; return(true); } result = "Bandolier needed."; } return(false); }
public override bool ConsumeItem(Player player) { var myplayer = TmlLibraries.SafelyGetModPlayer <LockedAbilitiesPlayer>(player); int vanillaMaxAcc = PlayerItemLibraries.GetCurrentVanillaMaxAccessories(player); bool canIncreaseAccSlots = myplayer.InternalAllowedAccessorySlots >= 0 && myplayer.InternalAllowedAccessorySlots < vanillaMaxAcc; if (canIncreaseAccSlots) { myplayer.IncreaseAllowedAccessorySlots(); } return(canIncreaseAccSlots); }
//////////////// public override void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff) { int maxAccSlot = 3 + PlayerItemLibraries.GetCurrentVanillaMaxAccessories(this.player); int hookBracerType = ModContent.ItemType <TensionedHookBracerItem>(); this.IsEquippingTensionedHookBracer = false; for (int i = 3; i < maxAccSlot; i++) { if (!(this.player.armor[i]?.IsAir ?? false) && this.player.armor[i].type == hookBracerType) { this.IsEquippingTensionedHookBracer = true; break; } } }
//////////////// private IList <Item> GetEquippedAbilityItems() { int firstAccSlot = PlayerItemLibraries.VanillaAccessorySlotFirst; int maxAccSlot = PlayerItemLibraries.GetCurrentVanillaMaxAccessories(player) + firstAccSlot; var items = new List <Item>(); for (int i = firstAccSlot; i < maxAccSlot; i++) { Item item = player.armor[i]; if (item == null || item.IsAir || item.modItem == null || !(item.modItem is IAbilityAccessoryItem)) { continue; } items.Add(item); } return(items); }
//////////////// public override bool PreItemCheck() { if (!Main.mouseLeft && !Main.mouseRight) { return(base.PreItemCheck()); } string timerName = "LockedAbilitiesEquipCheck_" + this.player.whoAmI; if (Timers.GetTimerTickDuration(timerName) > 0) { Timers.SetTimer(timerName, 2, false, () => false); return(false); } int firstAccSlot = PlayerItemLibraries.VanillaAccessorySlotFirst; int maxAccSlot = PlayerItemLibraries.GetCurrentVanillaMaxAccessories(this.player) + firstAccSlot; ISet <Type> equippedAbilityItemTypes = new HashSet <Type>(); // Find equipped ability items for (int i = firstAccSlot; i < maxAccSlot; i++) { Item item = this.player.armor[i]; if (item == null || item.IsAir || item.modItem == null || !(item.modItem is IAbilityAccessoryItem)) { continue; } equippedAbilityItemTypes.Add(item.modItem.GetType()); } if (!this.TestEquipItem(equippedAbilityItemTypes, this.player.HeldItem)) { Timers.SetTimer(timerName, 2, false, () => false); return(false); } return(base.PreItemCheck()); }
//////////////// private void TestAccessorySlotCapacity() { if (this.TotalAllowedAccessorySlots < 0) { return; } int firstAccSlot = PlayerItemLibraries.VanillaAccessorySlotFirst; int maxAccSlot = PlayerItemLibraries.GetCurrentVanillaMaxAccessories(this.player) + firstAccSlot; // Test max accessory slots for (int slot = (firstAccSlot + this.TotalAllowedAccessorySlots); slot < maxAccSlot; slot++) { Item item = this.player.armor[slot]; if (item == null || item.IsAir) { continue; } Main.NewText("Invalid accessory slot.", Color.Yellow); PlayerItemLibraries.DropEquippedArmorItem(this.player, slot, 0); break; } }