Workaround to null reference exceptions in Character.WriteStatus: it seems AnimController can be null when reading the message, which suggests that the character has been removed (e.g. turned to a husk, eaten by something).

This commit is contained in:
Joonas Rikkonen
2017-07-26 21:35:50 +03:00
parent 61b90464dd
commit affb43e7a5
2 changed files with 27 additions and 11 deletions
@@ -21,11 +21,18 @@ namespace Barotrauma
{
get
{
return enabled;
return enabled && !Removed;
}
set
{
if (value == enabled) return;
if (Removed)
{
enabled = false;
return;
}
enabled = value;
foreach (Limb limb in AnimController.Limbs)
@@ -980,7 +987,7 @@ namespace Barotrauma
public bool CanInteractWith(Character c, float maxDist = 200.0f)
{
if (c == this || !c.enabled || c.info == null || !c.IsHumanoid || !c.CanBeSelected) return false;
if (c == this || !c.Enabled || c.info == null || !c.IsHumanoid || !c.CanBeSelected) return false;
maxDist = ConvertUnits.ToSimUnits(maxDist);
if (Vector2.DistanceSquared(SimPosition, c.SimPosition) > maxDist * maxDist) return false;