diff --git a/Subsurface/Content/Items/Weapons/explosives.xml b/Subsurface/Content/Items/Weapons/explosives.xml index 4ad9d22c6..6c87ff27a 100644 --- a/Subsurface/Content/Items/Weapons/explosives.xml +++ b/Subsurface/Content/Items/Weapons/explosives.xml @@ -118,13 +118,13 @@ - + - + diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index b6d15bf26..14e2d0e92 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1043,23 +1043,7 @@ namespace Barotrauma lowPassMultiplier = MathHelper.Lerp(lowPassMultiplier, 1.0f, 0.1f); - if (needsAir) - { - Oxygen += deltaTime * (oxygenAvailable < 30.0f ? -5.0f : 10.0f); - - PressureProtection -= deltaTime*100.0f; - - float hullAvailableOxygen = 0.0f; - - if (!AnimController.HeadInWater && AnimController.CurrentHull != null) - { - hullAvailableOxygen = AnimController.CurrentHull.OxygenPercentage; - - AnimController.CurrentHull.Oxygen -= Hull.OxygenConsumptionSpeed * deltaTime; - } - - OxygenAvailable += Math.Sign(hullAvailableOxygen - oxygenAvailable) * deltaTime * 50.0f; - } + if (needsAir) UpdateOxygen(deltaTime); Health -= bleeding * deltaTime; Bleeding -= BleedingDecreaseSpeed * deltaTime; @@ -1069,6 +1053,24 @@ namespace Barotrauma if (!IsDead) LockHands = false; } + private void UpdateOxygen(float deltaTime) + { + Oxygen += deltaTime * (oxygenAvailable < 30.0f ? -5.0f : 10.0f); + + PressureProtection -= deltaTime * 100.0f; + + float hullAvailableOxygen = 0.0f; + + if (!AnimController.HeadInWater && AnimController.CurrentHull != null) + { + hullAvailableOxygen = AnimController.CurrentHull.OxygenPercentage; + + AnimController.CurrentHull.Oxygen -= Hull.OxygenConsumptionSpeed * deltaTime; + } + + OxygenAvailable += Math.Sign(hullAvailableOxygen - oxygenAvailable) * deltaTime * 50.0f; + } + private void UpdateUnconscious(float deltaTime) { Stun = Math.Max(5.0f, Stun); @@ -1076,7 +1078,7 @@ namespace Barotrauma AnimController.ResetPullJoints(); selectedConstruction = null; - if (oxygen <= 0.0f) Oxygen -= deltaTime; + if (oxygen <= 0.0f) Oxygen -= deltaTime * 0.5f; if (health <= 0.0f) { diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index b29c00b3c..4c93b5c3f 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -94,8 +94,11 @@ namespace Barotrauma if (Items[slotIndex] == null) return false; + //save the ID in a variable in case the statuseffect causes the item to be dropped/destroyed + int itemID = Items[slotIndex].ID; + Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character); - new NetworkEvent(NetworkEventType.ApplyStatusEffect, character.ID, true, Items[slotIndex].ID); + new NetworkEvent(NetworkEventType.ApplyStatusEffect, character.ID, true, itemID); return true; } diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index 5413c3ff9..7be456bac 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -319,15 +319,36 @@ namespace Barotrauma Item[] containedItems = null; if (Items[slotIndex] != null) containedItems = Items[slotIndex].ContainedItems; + string toolTip = ""; + Rectangle highlightedRect = Rectangle.Empty; + if (containedItems != null) { for (int i = 0; i < itemCapacity; i++) { subRect.Y = subRect.Y - subRect.Height - 10; - UpdateSlot(spriteBatch, subRect, selectedSlot, i < containedItems.Count() ? containedItems[i] : null, true); + highlightedRect = subRect; + UpdateSlot(spriteBatch, subRect, selectedSlot, i < containedItems.Length ? containedItems[i] : null, true); + + if (i >= containedItems.Length || containedItems[i] == null) continue; + + if (highlightedRect.Contains(PlayerInput.MousePosition)) + { + if (GameMain.DebugDraw) + { + toolTip = containedItems[i].ToString(); + } + else + { + toolTip = string.IsNullOrEmpty(containedItems[i].Description) ? + containedItems[i].Name : + containedItems[i].Name + '\n' + containedItems[i].Description; + } + } } } - + + if (!string.IsNullOrWhiteSpace(toolTip)) DrawToolTip(spriteBatch, toolTip, highlightedRect); }