Fixed far-away AI characters staying disabled when switching control to them + minor optimization

This commit is contained in:
Joonas Rikkonen
2017-07-11 20:01:49 +03:00
parent 935b1ff837
commit af1a681da0
3 changed files with 8 additions and 6 deletions
@@ -842,7 +842,7 @@ namespace Barotrauma.Networking
if (!character.Enabled) continue;
if (c.Character != null &&
Vector2.DistanceSquared(character.WorldPosition, c.Character.WorldPosition) >=
NetConfig.CharacterIgnoreDistance * NetConfig.CharacterIgnoreDistance)
NetConfig.CharacterIgnoreDistanceSqr)
{
continue;
}
@@ -1876,6 +1876,7 @@ namespace Barotrauma.Networking
newCharacter.LastNetworkUpdateID = client.Character.LastNetworkUpdateID;
newCharacter.IsRemotePlayer = true;
newCharacter.Enabled = true;
client.Character = newCharacter;
CreateEntityEvent(newCharacter, new object[] { NetEntityEvent.Type.Control, client });
}
@@ -14,6 +14,7 @@
//if a Character is further than this from the sub, the server will ignore it
//(in display units)
public const float CharacterIgnoreDistance = 20000.0f;
public const float CharacterIgnoreDistanceSqr = CharacterIgnoreDistance * CharacterIgnoreDistance;
//how much the physics body of an item has to move until the server
//send a position update to clients (in sim units)