private bool EquipmentSlotOnExecuteIfReady(On.RoR2.EquipmentSlot.orig_ExecuteIfReady orig, EquipmentSlot self) { var origStock = self.stock; var executed = orig(self); if (executed && self.stock < origStock) { var tracker = self.characterBody.master.GetComponent <DurabilityTracker>(); if (tracker == null) { tracker = self.characterBody.masterObject.AddComponent <DurabilityTracker>(); } var durability = self.activeEquipmentSlot == 0 ? tracker.durability : tracker.durabilityAlt; var inv = self.characterBody.inventory; var equipDef = inv.currentEquipmentState.equipmentDef; var lifetime = equipDef.isLunar ? DurabilityConfig.LunarEquipLifetime.Value : DurabilityConfig.RegEquipLifetime.Value; var decay = 100 * equipDef.cooldown / lifetime; var fuelCells = inv.GetItemCount(ItemIndex.EquipmentMagazine); if (fuelCells > 0) { decay *= Mathf.Pow(0.85f, fuelCells); } durability -= decay; if (durability <= 0) { self.characterBody.inventory.SetEquipment(EquipmentState.empty, self.activeEquipmentSlot); durability = FullDurability; } if (self.activeEquipmentSlot == 0) { tracker.durability = durability; } else { tracker.durabilityAlt = durability; } var networkUser = self.characterBody.master?.playerCharacterMasterController?.networkUser; if (networkUser != null && !networkUser.isLocalPlayer) { var message = new UpdateDurabilityMessage { durability = tracker.durability, durabilityAlt = tracker.durabilityAlt }; _cmdUpdateDurability.Invoke(message, networkUser); } } return(executed); }
private bool EquipmentSlotExecuteIfReady(On.RoR2.EquipmentSlot.orig_ExecuteIfReady orig, RoR2.EquipmentSlot self) { if (self.equipmentIndex == EquipmentIndex.Lightning && SceneManager.GetActiveScene().name == "bazaar" && self.characterBody.master.inventory.GetItemCount(ItemIndex.AutoCastEquipment) > 0) { return(false); } return(orig(self)); }
private bool EquipmentSlot_ExecuteIfReady(On.RoR2.EquipmentSlot.orig_ExecuteIfReady orig, EquipmentSlot self) { if (self.equipmentIndex == equipmentDef.equipmentIndex) { var component = self.GetComponent <MysticsItemsOmarHackToolBehaviour>(); if (component && component.usesLeft <= 0) { return(false); } } return(orig(self)); }