(048b753e6) Merge branch 'dev' into human-ai
This commit is contained in:
@@ -293,6 +293,27 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
|
||||
{
|
||||
//stop dragging if there's something between the pull limb and the target
|
||||
Vector2 sourceSimPos = mouthLimb.SimPosition;
|
||||
Vector2 targetSimPos = target.SimPosition;
|
||||
if (character.Submarine != null && character.SelectedCharacter.Submarine == null)
|
||||
{
|
||||
targetSimPos -= character.Submarine.SimPosition;
|
||||
}
|
||||
else if (character.Submarine == null && character.SelectedCharacter.Submarine != null)
|
||||
{
|
||||
sourceSimPos -= character.SelectedCharacter.Submarine.SimPosition;
|
||||
}
|
||||
var body = Submarine.CheckVisibility(sourceSimPos, targetSimPos, ignoreSubs: true);
|
||||
if (body != null)
|
||||
{
|
||||
character.DeselectCharacter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Character targetCharacter = target;
|
||||
float eatSpeed = character.Mass / targetCharacter.Mass * 0.1f;
|
||||
eatTimer += deltaTime * eatSpeed;
|
||||
@@ -712,6 +733,12 @@ namespace Barotrauma
|
||||
|
||||
limb.body.ApplyForce(diff * (float)(Math.Sin(WalkPos) * Math.Sqrt(limb.Mass)) * 30.0f * animStrength, maxVelocity: 10.0f);
|
||||
}
|
||||
while (referenceLimb.Rotation - angle < -MathHelper.TwoPi)
|
||||
{
|
||||
angle -= MathHelper.TwoPi;
|
||||
}
|
||||
|
||||
limb?.body.SmoothRotate(angle, torque, wrapAngle: false);
|
||||
}
|
||||
|
||||
private void SmoothRotateWithoutWrapping(Limb limb, float angle, Limb referenceLimb, float torque)
|
||||
|
||||
@@ -1188,7 +1188,8 @@ namespace Barotrauma
|
||||
isClimbing = false;
|
||||
}
|
||||
}
|
||||
else if (character.IsKeyDown(InputType.Left) || character.IsKeyDown(InputType.Right))
|
||||
else if ((character.IsKeyDown(InputType.Left) || character.IsKeyDown(InputType.Right)) &&
|
||||
(!character.IsKeyDown(InputType.Up) && !character.IsKeyDown(InputType.Down)))
|
||||
{
|
||||
isClimbing = false;
|
||||
}
|
||||
|
||||
@@ -1379,35 +1379,25 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
closestBody = Submarine.CheckVisibility(seeingLimb.SimPosition, seeingLimb.SimPosition + diff);
|
||||
if (!IsBlocking(closestBody))
|
||||
if (closestBody != null)
|
||||
{
|
||||
closestBody = Submarine.CheckVisibility(target.SimPosition, target.SimPosition - diff);
|
||||
}
|
||||
}
|
||||
return !IsBlocking(closestBody);
|
||||
|
||||
bool IsBlocking(Body body)
|
||||
{
|
||||
if (body == null) { return false; }
|
||||
if (body.UserData is Structure wall && wall.CastShadow)
|
||||
{
|
||||
return wall != target;
|
||||
}
|
||||
else if (body.UserData is Item item && item != target)
|
||||
{
|
||||
var door = item.GetComponent<Door>();
|
||||
if (door != null)
|
||||
if (closestBody.UserData is Structure wall && wall.CastShadow)
|
||||
{
|
||||
return !door.IsOpen;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
closestBody = Submarine.CheckVisibility(target.SimPosition, target.SimPosition - diff);
|
||||
}
|
||||
if (closestBody != null)
|
||||
{
|
||||
if (closestBody.UserData is Structure wall && wall.CastShadow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TODO: ensure that works. CheckVisibility takes positions in sim space, but this method uses world positions
|
||||
/// </summary>
|
||||
public bool CanSeeCharacter(Character target, Vector2 sourceWorldPos)
|
||||
{
|
||||
Vector2 diff = ConvertUnits.ToSimUnits(target.WorldPosition - sourceWorldPos);
|
||||
@@ -1422,28 +1412,6 @@ namespace Barotrauma
|
||||
closestBody = Submarine.CheckVisibility(target.WorldPosition, target.WorldPosition - diff);
|
||||
if (closestBody == null) return true;
|
||||
}
|
||||
Structure wall = closestBody.UserData as Structure;
|
||||
Item item = closestBody.UserData as Item;
|
||||
Door door = item?.GetComponent<Door>();
|
||||
return (wall == null || !wall.CastShadow) && (door == null || door.IsOpen);
|
||||
}
|
||||
|
||||
public bool CanSeeCharacter(Character character, Vector2 sourceWorldPos)
|
||||
{
|
||||
Vector2 diff = ConvertUnits.ToSimUnits(character.WorldPosition - sourceWorldPos);
|
||||
|
||||
Body closestBody = null;
|
||||
if (character.Submarine == null)
|
||||
{
|
||||
closestBody = Submarine.CheckVisibility(sourceWorldPos, sourceWorldPos + diff);
|
||||
if (closestBody == null) return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
closestBody = Submarine.CheckVisibility(character.WorldPosition, character.WorldPosition - diff);
|
||||
if (closestBody == null) return true;
|
||||
}
|
||||
|
||||
Structure wall = closestBody.UserData as Structure;
|
||||
return wall == null || !wall.CastShadow;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
partial class Limb : ISerializableEntity
|
||||
partial class Limb : ISerializableEntity, ISpatialEntity
|
||||
{
|
||||
// Note: not used
|
||||
private const float LimbDensity = 15;
|
||||
@@ -155,6 +155,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Submarine Submarine => character.Submarine;
|
||||
|
||||
public Vector2 WorldPosition
|
||||
{
|
||||
get { return character.Submarine == null ? Position : Position + character.Submarine.Position; }
|
||||
|
||||
Reference in New Issue
Block a user