private void Inventory_ResetItem(On.RoR2.Inventory.orig_ResetItem orig, Inventory inventory, ItemIndex itemIndex) { orig(inventory, itemIndex); if (itemIndex == Definition.itemIndex) { NetworkedSI si = inventory.GetComponentInParent <CharacterBody>()?.GetComponent <NetworkedSI>(); if (si != null) { si.SetItemCount(0); } } }
private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) { orig(self); if (self.inventory.HasItem(this, out int itemCount)) { NetworkedSI si = self.GetComponent <NetworkedSI>(); if (!si) { Log("Missing si component!"); return; } si.SetItemCount(itemCount); self.OnLevelChanged();//hack to avoid reflecting for a bool. } }