Fixed NullReferenceException when attempting to send an ApplyStatusEffect update for an item that was removed from the inventory by the statuseffect (eg syringe with nitroglyserine which was dropped because of the explosion), oxygen level detoriates more slowly when unconscious, showing a tooltip for items in a subinventory, nitroglyserine explodes on first injection (instead of after a few injections when condition drops to zero)
This commit is contained in:
@@ -118,13 +118,13 @@
|
||||
|
||||
<Holdable slots="Any,RightHand,LeftHand">
|
||||
<StatusEffect type="OnImpact" target="This" Condition="0.0" setvalue="true"/>
|
||||
|
||||
<StatusEffect type="OnFire" target="This" Condition="-50.0"/>
|
||||
|
||||
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
|
||||
<Explosion range="600.0" structuredamage="400" damage="300" stun="5" force="20.0"/>
|
||||
</StatusEffect>
|
||||
|
||||
<StatusEffect type="OnUse" target="Character" Health="-0.5" Oxygen="5.0" duration="10.0">
|
||||
<StatusEffect type="OnUse" target="This" Condition="-100.0">
|
||||
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||
</StatusEffect>
|
||||
</Holdable>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user