Monster syncing fixes:
- clients freeze and disable AI characters if no updates have been received in a while (due to the monster being far away from player-controlled characters at the servers side for example) - server disables AI characters that are too far for updates to be sent to clients (-> targets of monster missions can't swim away from the spawnpos and cause the clients' sonars to point to an incorrect position)
This commit is contained in:
@@ -472,18 +472,19 @@ namespace Barotrauma.Networking
|
||||
// }
|
||||
//}
|
||||
|
||||
float ignoreDistance = FarseerPhysics.ConvertUnits.ToDisplayUnits(NetConfig.CharacterIgnoreDistance);
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (c.IsDead) continue;
|
||||
|
||||
if (c is AICharacter)
|
||||
{
|
||||
//todo: take multiple subs into account
|
||||
//Vector2 diff = c.WorldPosition - Submarine.MainSub.WorldPosition;
|
||||
|
||||
//if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
||||
c.Enabled =
|
||||
(myCharacter != null && Vector2.Distance(myCharacter.WorldPosition, c.WorldPosition) < ignoreDistance) ||
|
||||
Character.CharacterList.Any(c2 => c2.IsRemotePlayer && Vector2.Distance(c2.WorldPosition, c.WorldPosition) < ignoreDistance);
|
||||
}
|
||||
|
||||
if (c.IsDead) continue;
|
||||
|
||||
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, c.ID, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user