Added checks for character removal to a bunch of places. Some of these may not necessary, but at least MeleeWeapon, Projectile and Controller still accessed the user after the user had been removed.

This commit is contained in:
Joonas Rikkonen
2018-02-28 17:37:20 +02:00
parent e29655c81b
commit c803e23c50
9 changed files with 49 additions and 20 deletions
@@ -200,7 +200,7 @@ namespace Barotrauma
public bool CanInteract
{
get { return AllowInput && IsHumanoid && !LockHands; }
get { return AllowInput && IsHumanoid && !LockHands && !Removed; }
}
public Vector2 CursorPosition
@@ -495,7 +495,7 @@ namespace Barotrauma
{
get
{
return isDead || Stun > 0.0f || LockHands || IsUnconscious || Removed;
return !Removed && (isDead || Stun > 0.0f || LockHands || IsUnconscious);
}
}
@@ -1129,7 +1129,7 @@ namespace Barotrauma
public bool CanInteractWith(Character c, float maxDist = 200.0f)
{
if (c == this || !c.Enabled || !c.IsHumanoid || !c.CanBeSelected) return false;
if (c == this || Removed || !c.Enabled || !c.IsHumanoid || !c.CanBeSelected) return false;
maxDist = ConvertUnits.ToSimUnits(maxDist);
if (Vector2.DistanceSquared(SimPosition, c.SimPosition) > maxDist * maxDist) return false;
@@ -1955,6 +1955,12 @@ namespace Barotrauma
public void Revive(bool isNetworkMessage)
{
if (Removed)
{
DebugConsole.ThrowError("Attempting to revive an already removed character\n" + Environment.StackTrace);
return;
}
isDead = false;
if (aiTarget != null)