Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop
This commit is contained in:
@@ -112,6 +112,7 @@ namespace Barotrauma
|
||||
private float sendConditionUpdateTimer;
|
||||
private bool conditionUpdatePending;
|
||||
|
||||
private float prevCondition;
|
||||
private float condition;
|
||||
|
||||
private bool inWater;
|
||||
@@ -897,7 +898,7 @@ namespace Barotrauma
|
||||
defaultRect = newRect;
|
||||
rect = newRect;
|
||||
|
||||
condition = MaxCondition = Prefab.Health;
|
||||
condition = MaxCondition = prevCondition = Prefab.Health;
|
||||
ConditionPercentage = 100.0f;
|
||||
|
||||
lastSentCondition = condition;
|
||||
@@ -999,13 +1000,6 @@ namespace Barotrauma
|
||||
if (ic == null) break;
|
||||
|
||||
AddComponent(ic);
|
||||
|
||||
if (ic is IDrawableComponent && ic.Drawable)
|
||||
{
|
||||
drawableComponents.Add(ic as IDrawableComponent);
|
||||
hasComponentsToDraw = true;
|
||||
}
|
||||
if (ic is Repairable) repairables.Add((Repairable)ic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1020,6 +1014,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (ic is Repairable repairable) { repairables.Add(repairable); }
|
||||
|
||||
if (ic is IDrawableComponent && ic.Drawable)
|
||||
{
|
||||
drawableComponents.Add(ic as IDrawableComponent);
|
||||
hasComponentsToDraw = true;
|
||||
}
|
||||
|
||||
if (ic.statusEffectLists == null) { continue; }
|
||||
if (ic.InheritStatusEffects)
|
||||
{
|
||||
@@ -1584,7 +1586,7 @@ namespace Barotrauma
|
||||
tags.Add(newTag);
|
||||
}
|
||||
|
||||
public IEnumerable<Identifier> GetTags()
|
||||
public IReadOnlyCollection<Identifier> GetTags()
|
||||
{
|
||||
return tags;
|
||||
}
|
||||
@@ -1746,15 +1748,15 @@ namespace Barotrauma
|
||||
if (Indestructible) { return; }
|
||||
if (InvulnerableToDamage && value <= condition) { return; }
|
||||
|
||||
float prev = condition;
|
||||
bool wasInFullCondition = IsFullCondition;
|
||||
|
||||
condition = MathHelper.Clamp(value, 0.0f, MaxCondition);
|
||||
if (MathUtils.NearlyEqual(prev, condition, epsilon: 0.000001f)) { return; }
|
||||
if (MathUtils.NearlyEqual(prevCondition, condition, epsilon: 0.000001f)) { return; }
|
||||
|
||||
RecalculateConditionValues();
|
||||
|
||||
if (condition == 0.0f && prev > 0.0f)
|
||||
bool wasPreviousConditionChanged = false;
|
||||
if (condition == 0.0f && prevCondition > 0.0f)
|
||||
{
|
||||
//Flag connections to be updated as device is broken
|
||||
flagChangedConnections(connections);
|
||||
@@ -1766,9 +1768,11 @@ namespace Barotrauma
|
||||
}
|
||||
if (Screen.Selected == GameMain.SubEditorScreen) { return; }
|
||||
#endif
|
||||
// Have to set the previous condition here or OnBroken status effects that reduce the condition will keep triggering the status effects, resulting in a stack overflow.
|
||||
SetPreviousCondition();
|
||||
ApplyStatusEffects(ActionType.OnBroken, 1.0f, null);
|
||||
}
|
||||
else if (condition > 0.0f && prev <= 0.0f)
|
||||
else if (condition > 0.0f && prevCondition <= 0.0f)
|
||||
{
|
||||
//Flag connections to be updated as device is now working again
|
||||
flagChangedConnections(connections);
|
||||
@@ -1796,8 +1800,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
LastConditionChange = condition - prev;
|
||||
ConditionLastUpdated = Timing.TotalTime;
|
||||
if (!wasPreviousConditionChanged)
|
||||
{
|
||||
SetPreviousCondition();
|
||||
}
|
||||
|
||||
void SetPreviousCondition()
|
||||
{
|
||||
LastConditionChange = condition - prevCondition;
|
||||
ConditionLastUpdated = Timing.TotalTime;
|
||||
prevCondition = condition;
|
||||
wasPreviousConditionChanged = true;
|
||||
}
|
||||
|
||||
static void flagChangedConnections(Dictionary<string, Connection> connections)
|
||||
{
|
||||
@@ -2162,8 +2176,9 @@ namespace Barotrauma
|
||||
var projectile = GetComponent<Projectile>();
|
||||
if (projectile != null)
|
||||
{
|
||||
//ignore character colliders (a projectile only hits limbs)
|
||||
if (f2.CollisionCategories == Physics.CollisionCharacter && f2.Body.UserData is Character) { return false; }
|
||||
// Ignore characters so that the impact sound only plays when the item hits a a wall or a door.
|
||||
// Projectile collisions are handled in Projectile.OnProjectileCollision(), so it should be safe to do this.
|
||||
if (f2.CollisionCategories == Physics.CollisionCharacter) { return false; }
|
||||
if (projectile.IgnoredBodies != null && projectile.IgnoredBodies.Contains(f2.Body)) { return false; }
|
||||
if (projectile.ShouldIgnoreSubmarineCollision(f2, contact)) { return false; }
|
||||
}
|
||||
@@ -2697,13 +2712,12 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (condition == 0.0f) { return; }
|
||||
if (condition <= 0.0f) { return; }
|
||||
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("item.use", new object[] { this, character, targetLimb });
|
||||
|
||||
if (should != null && should.Value)
|
||||
return;
|
||||
|
||||
if (should != null && should.Value) { return; }
|
||||
|
||||
bool remove = false;
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
@@ -2719,7 +2733,7 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
ic.PlaySound(ActionType.OnUse, character);
|
||||
#endif
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character, targetLimb);
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character, targetLimb, useTarget: character, user: character);
|
||||
|
||||
if (ic.DeleteOnUse) { remove = true; }
|
||||
}
|
||||
@@ -2733,7 +2747,7 @@ namespace Barotrauma
|
||||
|
||||
public void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (condition == 0.0f) { return; }
|
||||
if (condition <= 0.0f) { return; }
|
||||
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("item.secondaryUse", this, character);
|
||||
|
||||
@@ -2755,7 +2769,7 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
ic.PlaySound(ActionType.OnSecondaryUse, character);
|
||||
#endif
|
||||
ic.ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, character);
|
||||
ic.ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, character: character, user: character);
|
||||
|
||||
if (ic.DeleteOnUse) { remove = true; }
|
||||
}
|
||||
@@ -2774,6 +2788,13 @@ namespace Barotrauma
|
||||
if (!UseInHealthInterface) { return; }
|
||||
|
||||
#if CLIENT
|
||||
if (user == Character.Controlled)
|
||||
{
|
||||
if (HealingCooldown.IsOnCooldown) { return; }
|
||||
|
||||
HealingCooldown.PutOnCooldown();
|
||||
}
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.CreateEntityEvent(this, new TreatmentEventData(character, targetLimb));
|
||||
@@ -2794,13 +2815,13 @@ namespace Barotrauma
|
||||
#endif
|
||||
ic.WasUsed = true;
|
||||
|
||||
ic.ApplyStatusEffects(conditionalActionType, 1.0f, character, targetLimb, user: user);
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, 1.0f, character, targetLimb, user: user);
|
||||
ic.ApplyStatusEffects(conditionalActionType, 1.0f, character, targetLimb, useTarget: character, user: user);
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, 1.0f, character, targetLimb, useTarget: character, user: user);
|
||||
|
||||
if (GameMain.NetworkMember is { IsServer: true })
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new ApplyStatusEffectEventData(conditionalActionType, ic, character, targetLimb));
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new ApplyStatusEffectEventData(ActionType.OnUse, ic, character, targetLimb));
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new ApplyStatusEffectEventData(conditionalActionType, ic, character, targetLimb, useTarget: character));
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new ApplyStatusEffectEventData(ActionType.OnUse, ic, character, targetLimb, useTarget: character));
|
||||
}
|
||||
|
||||
if (ic.DeleteOnUse) { remove = true; }
|
||||
@@ -3465,7 +3486,7 @@ namespace Barotrauma
|
||||
item.condition = MathHelper.Clamp(item.condition, 0, item.MaxCondition);
|
||||
}
|
||||
}
|
||||
item.lastSentCondition = item.condition;
|
||||
item.lastSentCondition = item.prevCondition = item.condition;
|
||||
item.RecalculateConditionValues();
|
||||
item.SetActiveSprite();
|
||||
|
||||
@@ -3539,15 +3560,10 @@ namespace Barotrauma
|
||||
upgrade.Save(element);
|
||||
}
|
||||
|
||||
if (condition < MaxCondition)
|
||||
{
|
||||
element.Add(new XAttribute("conditionpercentage", ConditionPercentage.ToString("G", CultureInfo.InvariantCulture)));
|
||||
}
|
||||
else
|
||||
{
|
||||
var conditionAttribute = element.GetAttribute("condition");
|
||||
if (conditionAttribute != null) { conditionAttribute.Remove(); }
|
||||
}
|
||||
element.Add(new XAttribute("conditionpercentage", ConditionPercentage.ToString("G", CultureInfo.InvariantCulture)));
|
||||
|
||||
var conditionAttribute = element.GetAttribute("condition");
|
||||
if (conditionAttribute != null) { conditionAttribute.Remove(); }
|
||||
|
||||
parentElement.Add(element);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user