Fixed monsters not taking damage when they're far enough from the host's camera (or the main sub when using the dedicated server). The limbs of the monsters were disabled when 8000 units away, causing them to become invincible because the collider does not register damage.
Closes #50
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class AICharacter : Character
|
||||
{
|
||||
//characters that are further than this from the camera (and all clients)
|
||||
//have all their limb physics bodies disabled
|
||||
const float EnableSimplePhysicsDist = 10000.0f;
|
||||
const float DisableSimplePhysicsDist = EnableSimplePhysicsDist * 0.9f;
|
||||
|
||||
const float EnableSimplePhysicsDistSqr = EnableSimplePhysicsDist * EnableSimplePhysicsDist;
|
||||
const float DisableSimplePhysicsDistSqr = DisableSimplePhysicsDist * DisableSimplePhysicsDist;
|
||||
|
||||
private AIController aiController;
|
||||
|
||||
public override AIController AIController
|
||||
@@ -32,17 +39,34 @@ namespace Barotrauma
|
||||
|
||||
if (!IsRemotePlayer)
|
||||
{
|
||||
float dist = Vector2.DistanceSquared(cam.WorldViewCenter, WorldPosition);
|
||||
if (dist > 8000.0f * 8000.0f)
|
||||
float characterDist = Vector2.DistanceSquared(cam.WorldViewCenter, WorldPosition);
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
//get the distance from the closest player to this character
|
||||
foreach (Character c in CharacterList)
|
||||
{
|
||||
if (c != this && (c.IsRemotePlayer || c == GameMain.Server.Character))
|
||||
{
|
||||
float dist = Vector2.DistanceSquared(c.WorldPosition, WorldPosition);
|
||||
if (dist < characterDist)
|
||||
{
|
||||
characterDist = dist;
|
||||
if (characterDist < DisableSimplePhysicsDistSqr) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (characterDist > EnableSimplePhysicsDistSqr)
|
||||
{
|
||||
AnimController.SimplePhysicsEnabled = true;
|
||||
}
|
||||
else if (dist < 7000.0f * 7000.0f)
|
||||
else if (characterDist < DisableSimplePhysicsDistSqr)
|
||||
{
|
||||
AnimController.SimplePhysicsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsDead || Health <= 0.0f || IsUnconscious || Stun > 0.0f) return;
|
||||
if (Controlled == this || !aiController.Enabled) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user