(9bd8db487) Allow to aim in ladders when not moving.
This commit is contained in:
@@ -200,13 +200,9 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
cam.OffsetAmount = 0.0f;
|
cam.OffsetAmount = 0.0f;
|
||||||
}
|
}
|
||||||
else if (SelectedConstruction != null && ViewTarget == null &&
|
else if (SelectedConstruction != null && SelectedConstruction.Components.Any(ic => (ic.GuiFrame != null && GUI.IsMouseOn(ic.GuiFrame))))
|
||||||
SelectedConstruction.Components.Any(ic => ic?.GuiFrame != null && ic.ShouldDrawHUD(this)))
|
|
||||||
{
|
{
|
||||||
cam.OffsetAmount = 0.0f;
|
cam.OffsetAmount = 0.0f;
|
||||||
cursorPosition =
|
|
||||||
SelectedConstruction.Position +
|
|
||||||
new Vector2(cursorPosition.X % 10.0f, cursorPosition.Y % 10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking
|
|
||||||
}
|
}
|
||||||
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||||
{
|
{
|
||||||
@@ -214,7 +210,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (deltaTime > 0.0f) cam.OffsetAmount = 0.0f;
|
if (deltaTime > 0.0f) cam.OffsetAmount = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||||
{
|
{
|
||||||
Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||||
Structure structure = body == null ? null : body.UserData as Structure;
|
Structure structure = body == null ? null : body.UserData as Structure;
|
||||||
|
|||||||
@@ -11,16 +11,19 @@ namespace Barotrauma
|
|||||||
protected override void ControlInput(Camera cam)
|
protected override void ControlInput(Camera cam)
|
||||||
{
|
{
|
||||||
base.ControlInput(cam);
|
base.ControlInput(cam);
|
||||||
cam.OffsetAmount = 0;
|
if (BackgroundFrame.Contains(PlayerInput.MousePosition))
|
||||||
//if this is used, we need to implement syncing this inventory with the server
|
|
||||||
/*Character.DisableControls = true;
|
|
||||||
if (Character.Controlled != null)
|
|
||||||
{
|
{
|
||||||
if (PlayerInput.KeyHit(InputType.Select))
|
cam.OffsetAmount = 0;
|
||||||
|
//if this is used, we need to implement syncing this inventory with the server
|
||||||
|
/*Character.DisableControls = true;
|
||||||
|
if (Character.Controlled != null)
|
||||||
{
|
{
|
||||||
Character.Controlled.SelectedConstruction = null;
|
if (PlayerInput.KeyHit(InputType.Select))
|
||||||
}
|
{
|
||||||
}*/
|
Character.Controlled.SelectedConstruction = null;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CalculateBackgroundFrame()
|
protected override void CalculateBackgroundFrame()
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ namespace Barotrauma.Lights
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the segments that are facing towards viewPosition
|
/// Returns the segments that are facing towards viewPosition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetVisibleSegments(Vector2 viewPosition, List<Segment> visibleSegments, bool ignoreEdges)
|
public void GetVisibleSegments(Vector2 viewPosition, List<Segment> visibleSegments)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ namespace Barotrauma.Lights
|
|||||||
foreach (ConvexHull hull in hulls)
|
foreach (ConvexHull hull in hulls)
|
||||||
{
|
{
|
||||||
hull.RefreshWorldPositions();
|
hull.RefreshWorldPositions();
|
||||||
hull.GetVisibleSegments(drawPos, visibleSegments, ignoreEdges: false);
|
hull.GetVisibleSegments(drawPos, visibleSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate new points at the intersections between segments
|
//Generate new points at the intersections between segments
|
||||||
|
|||||||
+1
-4
@@ -84,12 +84,9 @@ namespace Barotrauma
|
|||||||
useExtinquisherTimer += deltaTime;
|
useExtinquisherTimer += deltaTime;
|
||||||
if (useExtinquisherTimer > 2.0f) useExtinquisherTimer = 0.0f;
|
if (useExtinquisherTimer > 2.0f) useExtinquisherTimer = 0.0f;
|
||||||
|
|
||||||
|
character.AIController.SteeringManager.Reset();
|
||||||
character.CursorPosition = fs.Position;
|
character.CursorPosition = fs.Position;
|
||||||
character.SetInput(InputType.Aim, false, true);
|
character.SetInput(InputType.Aim, false, true);
|
||||||
if (!character.IsClimbing)
|
|
||||||
{
|
|
||||||
character.AIController.SteeringManager.Reset();
|
|
||||||
}
|
|
||||||
extinguisher.Use(deltaTime, character);
|
extinguisher.Use(deltaTime, character);
|
||||||
|
|
||||||
if (!targetHull.FireSources.Contains(fs))
|
if (!targetHull.FireSources.Contains(fs))
|
||||||
|
|||||||
+5
-2
@@ -168,8 +168,11 @@ namespace Barotrauma
|
|||||||
// Too close -> steer away
|
// Too close -> steer away
|
||||||
character.AIController.SteeringManager.SteeringManual(deltaTime, Vector2.Normalize(character.SimPosition - Item.SimPosition) / 2);
|
character.AIController.SteeringManager.SteeringManual(deltaTime, Vector2.Normalize(character.SimPosition - Item.SimPosition) / 2);
|
||||||
}
|
}
|
||||||
if (character.IsClimbing ||
|
else
|
||||||
VectorExtensions.Angle(VectorExtensions.Forward(repairTool.Item.body.TransformedRotation), fromToolToTarget) < MathHelper.PiOver4)
|
{
|
||||||
|
character.AIController.SteeringManager.Reset();
|
||||||
|
}
|
||||||
|
if (VectorExtensions.Angle(VectorExtensions.Forward(repairTool.Item.body.TransformedRotation), fromToolToTarget) < MathHelper.PiOver4)
|
||||||
{
|
{
|
||||||
repairTool.Use(deltaTime, character);
|
repairTool.Use(deltaTime, character);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1122,18 +1122,22 @@ namespace Barotrauma
|
|||||||
//prevent the hands from going above the top of the ladders
|
//prevent the hands from going above the top of the ladders
|
||||||
handPos.Y = Math.Min(-0.5f, handPos.Y);
|
handPos.Y = Math.Min(-0.5f, handPos.Y);
|
||||||
|
|
||||||
MoveLimb(leftHand,
|
// TODO: lock only one hand when aiming?
|
||||||
new Vector2(handPos.X,
|
if (!PlayerInput.KeyDown(InputType.Aim) || Math.Abs(movement.Y) > 0.01f)
|
||||||
(slide ? handPos.Y : MathUtils.Round(handPos.Y - stepHeight, stepHeight * 2.0f) + stepHeight) + ladderSimPos.Y),
|
{
|
||||||
5.2f);
|
MoveLimb(leftHand,
|
||||||
|
new Vector2(handPos.X,
|
||||||
|
(slide ? handPos.Y : MathUtils.Round(handPos.Y - stepHeight, stepHeight * 2.0f) + stepHeight) + ladderSimPos.Y),
|
||||||
|
5.2f);
|
||||||
|
|
||||||
MoveLimb(rightHand,
|
MoveLimb(rightHand,
|
||||||
new Vector2(handPos.X,
|
new Vector2(handPos.X,
|
||||||
(slide ? handPos.Y : MathUtils.Round(handPos.Y, stepHeight * 2.0f)) + ladderSimPos.Y),
|
(slide ? handPos.Y : MathUtils.Round(handPos.Y, stepHeight * 2.0f)) + ladderSimPos.Y),
|
||||||
5.2f);
|
5.2f);
|
||||||
|
|
||||||
leftHand.body.ApplyTorque(Dir * 2.0f);
|
leftHand.body.ApplyTorque(Dir * 2.0f);
|
||||||
rightHand.body.ApplyTorque(Dir * 2.0f);
|
rightHand.body.ApplyTorque(Dir * 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 footPos = new Vector2(
|
Vector2 footPos = new Vector2(
|
||||||
handPos.X - Dir * 0.05f,
|
handPos.X - Dir * 0.05f,
|
||||||
@@ -1647,12 +1651,13 @@ namespace Barotrauma
|
|||||||
Vector2 itemPos = aim ? aimPos : holdPos;
|
Vector2 itemPos = aim ? aimPos : holdPos;
|
||||||
|
|
||||||
bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Controller>() != null;
|
bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Controller>() != null;
|
||||||
|
bool isClimbing = character.IsClimbing && Math.Abs(character.AnimController.TargetMovement.Y) > 0.01f;
|
||||||
|
|
||||||
float itemAngle;
|
float itemAngle;
|
||||||
|
|
||||||
Holdable holdable = item.GetComponent<Holdable>();
|
Holdable holdable = item.GetComponent<Holdable>();
|
||||||
|
|
||||||
if (!character.IsClimbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero)
|
if (!isClimbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero)
|
||||||
{
|
{
|
||||||
Vector2 mousePos = ConvertUnits.ToSimUnits(character.SmoothedCursorPosition);
|
Vector2 mousePos = ConvertUnits.ToSimUnits(character.SmoothedCursorPosition);
|
||||||
|
|
||||||
@@ -1682,7 +1687,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector2 transformedHoldPos = shoulder.WorldAnchorA;
|
Vector2 transformedHoldPos = shoulder.WorldAnchorA;
|
||||||
if (itemPos == Vector2.Zero || character.IsClimbing || usingController)
|
if (itemPos == Vector2.Zero || isClimbing || usingController)
|
||||||
{
|
{
|
||||||
if (character.SelectedItems[0] == item)
|
if (character.SelectedItems[0] == item)
|
||||||
{
|
{
|
||||||
@@ -1771,16 +1776,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
item.SetTransform(currItemPos, itemAngle + itemAngleRelativeToHoldAngle * Dir);
|
item.SetTransform(currItemPos, itemAngle + itemAngleRelativeToHoldAngle * Dir);
|
||||||
|
|
||||||
if (character.IsClimbing) return;
|
if (!isClimbing)
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
{
|
||||||
if (character.SelectedItems[i] != item) continue;
|
for (int i = 0; i < 2; i++)
|
||||||
if (itemPos == Vector2.Zero) continue;
|
{
|
||||||
|
if (character.SelectedItems[i] != item) continue;
|
||||||
|
if (itemPos == Vector2.Zero) continue;
|
||||||
|
|
||||||
Limb hand = (i == 0) ? rightHand : leftHand;
|
Limb hand = (i == 0) ? rightHand : leftHand;
|
||||||
|
|
||||||
HandIK(hand, transformedHoldPos + transformedHandlePos[i]);
|
HandIK(hand, transformedHoldPos + transformedHandlePos[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1147,7 +1147,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
//Limb head = AnimController.GetLimb(LimbType.Head);
|
//Limb head = AnimController.GetLimb(LimbType.Head);
|
||||||
// Values lower than this seem to cause constantious flipping when the mouse is near the player and the player is running, because the root collider moves after flipping.
|
// Values lower than this seem to cause constantious flipping when the mouse is near the player and the player is running, because the root collider moves after flipping.
|
||||||
float followMargin = 40;
|
float followMargin = 30;
|
||||||
if (dontFollowCursor)
|
if (dontFollowCursor)
|
||||||
{
|
{
|
||||||
AnimController.TargetDir = Direction.Right;
|
AnimController.TargetDir = Direction.Right;
|
||||||
|
|||||||
@@ -303,10 +303,8 @@ namespace Barotrauma.Items.Components
|
|||||||
// Too close -> steer away
|
// Too close -> steer away
|
||||||
character.AIController.SteeringManager.SteeringManual(deltaTime, Vector2.Normalize(character.SimPosition - leak.SimPosition) / 2);
|
character.AIController.SteeringManager.SteeringManual(deltaTime, Vector2.Normalize(character.SimPosition - leak.SimPosition) / 2);
|
||||||
}
|
}
|
||||||
else if (!character.IsClimbing)
|
else
|
||||||
{
|
{
|
||||||
// Close enough -> stop if not in ladders.
|
|
||||||
// In ladders, we most likely want to move back and forth, because we cannot aim -> if the leak is on the side, it should get fixed.
|
|
||||||
character.AIController.SteeringManager.Reset();
|
character.AIController.SteeringManager.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,7 +315,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
// Press the trigger only when the tool is approximately facing the target.
|
// Press the trigger only when the tool is approximately facing the target.
|
||||||
// If the character is climbing, ignore the check, because we cannot aim while climbing.
|
// If the character is climbing, ignore the check, because we cannot aim while climbing.
|
||||||
if (character.IsClimbing || VectorExtensions.Angle(VectorExtensions.Forward(item.body.TransformedRotation), fromItemToLeak) < MathHelper.PiOver4)
|
if (VectorExtensions.Angle(VectorExtensions.Forward(item.body.TransformedRotation), fromItemToLeak) < MathHelper.PiOver4)
|
||||||
{
|
{
|
||||||
Use(deltaTime, character);
|
Use(deltaTime, character);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user