Fixed character colliders sinking/floating away when using a railgun controller underwater
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<Body width="32" height="32" density="40"/>
|
<Body width="32" height="32" density="40"/>
|
||||||
|
|
||||||
<Controller userpos="0" direction ="None" canbepicked = "true" msg="Open [E]">
|
<Controller direction ="None" canbepicked = "true" msg="Open [E]">
|
||||||
<RequiredItem name="ID Card" type="Picked" msg="UNAUTHORIZED ACCESS"/>
|
<RequiredItem name="ID Card" type="Picked" msg="UNAUTHORIZED ACCESS"/>
|
||||||
<sound file="beep.ogg" type="OnUse" range="500.0"/>
|
<sound file="beep.ogg" type="OnUse" range="500.0"/>
|
||||||
</Controller>
|
</Controller>
|
||||||
|
|||||||
@@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
<Sprite texture ="railgunetc.png" depth="0.8" sourcerect="182,0,61,97"/>
|
<Sprite texture ="railgunetc.png" depth="0.8" sourcerect="182,0,61,97"/>
|
||||||
|
|
||||||
<Controller UserPos="-1.0" direction ="Right" canbeselected = "true">
|
<Controller UserPos="-35.0, -50.0" direction ="Right" canbeselected = "true">
|
||||||
<limbposition limb="Head" position="-5,-62"/>
|
<limbposition limb="Head" position="-5,-62"/>
|
||||||
|
<limbposition limb="Torso" position="-5,-108"/>
|
||||||
<limbposition limb="LeftHand" position="43,-85"/>
|
<limbposition limb="LeftHand" position="43,-85"/>
|
||||||
<limbposition limb="RightHand" position="43,-85"/>
|
<limbposition limb="RightHand" position="43,-85"/>
|
||||||
</Controller>
|
</Controller>
|
||||||
|
|||||||
@@ -173,12 +173,10 @@ namespace Barotrauma
|
|||||||
levitatingCollider = false;
|
levitatingCollider = false;
|
||||||
UpdateClimbing();
|
UpdateClimbing();
|
||||||
break;
|
break;
|
||||||
case Animation.UsingConstruction:
|
|
||||||
UpdateStanding();
|
|
||||||
break;
|
|
||||||
case Animation.CPR:
|
case Animation.CPR:
|
||||||
UpdateCPR(deltaTime);
|
UpdateCPR(deltaTime);
|
||||||
break;
|
break;
|
||||||
|
case Animation.UsingConstruction:
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if (character.SelectedCharacter != null) DragCharacter(character.SelectedCharacter);
|
if (character.SelectedCharacter != null) DragCharacter(character.SelectedCharacter);
|
||||||
@@ -567,7 +565,7 @@ namespace Barotrauma
|
|||||||
rotation = MathHelper.ToDegrees(rotation);
|
rotation = MathHelper.ToDegrees(rotation);
|
||||||
if (rotation < 0.0f) rotation += 360;
|
if (rotation < 0.0f) rotation += 360;
|
||||||
|
|
||||||
if (!character.IsRemotePlayer && !aiming)
|
if (!character.IsRemotePlayer && !aiming && Anim != Animation.UsingConstruction)
|
||||||
{
|
{
|
||||||
if (rotation > 20 && rotation < 170)
|
if (rotation > 20 && rotation < 170)
|
||||||
TargetDir = Direction.Left;
|
TargetDir = Direction.Left;
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private Direction dir;
|
private Direction dir;
|
||||||
|
|
||||||
//the x-position where the user walks to when using the controller
|
//the position where the user walks to when using the controller
|
||||||
private float userPos;
|
//(relative to the position of the item)
|
||||||
|
private Vector2 userPos;
|
||||||
|
|
||||||
private Camera cam;
|
private Camera cam;
|
||||||
|
|
||||||
private Character character;
|
private Character character;
|
||||||
|
|
||||||
[HasDefaultValue(0.0f, false)]
|
public Vector2 UserPos
|
||||||
public float UserPos
|
|
||||||
{
|
{
|
||||||
get { return userPos; }
|
get { return userPos; }
|
||||||
set { userPos = value; }
|
set { userPos = value; }
|
||||||
@@ -45,13 +45,16 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
limbPositions = new List<LimbPos>();
|
limbPositions = new List<LimbPos>();
|
||||||
|
|
||||||
dir = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "direction", "None"), true);
|
userPos = ToolBox.GetAttributeVector2(element, "UserPos", Vector2.Zero);
|
||||||
|
|
||||||
|
Enum.TryParse<Direction>(ToolBox.GetAttributeString(element, "direction", "None"), out dir);
|
||||||
|
|
||||||
foreach (XElement el in element.Elements())
|
foreach (XElement el in element.Elements())
|
||||||
{
|
{
|
||||||
if (el.Name != "limbposition") continue;
|
if (el.Name != "limbposition") continue;
|
||||||
|
|
||||||
LimbPos lp = new LimbPos();
|
LimbPos lp = new LimbPos();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lp.limbType = (LimbType)Enum.Parse(typeof(LimbType), el.Attribute("limb").Value, true);
|
lp.limbType = (LimbType)Enum.Parse(typeof(LimbType), el.Attribute("limb").Value, true);
|
||||||
@@ -90,22 +93,33 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
character.AnimController.Anim = AnimController.Animation.UsingConstruction;
|
character.AnimController.Anim = AnimController.Animation.UsingConstruction;
|
||||||
|
|
||||||
if (userPos != 0.0f)
|
if (userPos != Vector2.Zero)
|
||||||
{
|
{
|
||||||
float torsoX = character.Position.X;
|
float torsoX = character.Position.X;
|
||||||
|
|
||||||
Vector2 diff = new Vector2(item.Rect.X + UserPos - torsoX, 0.0f);
|
Vector2 diff = (item.WorldPosition + userPos) - character.WorldPosition;
|
||||||
|
|
||||||
if (diff!= Vector2.Zero && diff.Length() > 10.0f)
|
if (character.AnimController.InWater)
|
||||||
{
|
{
|
||||||
//character.AnimController.Anim = AnimController.Animation.None;
|
if (diff.Length() > 30.0f)
|
||||||
|
{
|
||||||
character.AnimController.TargetMovement = new Vector2(Math.Sign(diff.X), 0.0f);
|
character.AnimController.TargetMovement = Vector2.Clamp(diff*0.01f, -Vector2.One, Vector2.One);
|
||||||
character.AnimController.TargetDir = (Math.Sign(diff.X) == 1) ? Direction.Right : Direction.Left;
|
character.AnimController.TargetDir = diff.X > 0.0f ? Direction.Right : Direction.Left;
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
character.AnimController.TargetMovement = Vector2.Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
diff.Y = 0.0f;
|
||||||
|
if (diff != Vector2.Zero && diff.Length() > 10.0f)
|
||||||
|
{
|
||||||
|
character.AnimController.TargetMovement = Vector2.Normalize(diff);
|
||||||
|
character.AnimController.TargetDir = diff.X > 0.0f ? Direction.Right : Direction.Left;
|
||||||
|
return;
|
||||||
|
}
|
||||||
character.AnimController.TargetMovement = Vector2.Zero;
|
character.AnimController.TargetMovement = Vector2.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +129,7 @@ namespace Barotrauma.Items.Components
|
|||||||
if (limbPositions.Count == 0) return;
|
if (limbPositions.Count == 0) return;
|
||||||
|
|
||||||
character.AnimController.Anim = AnimController.Animation.UsingConstruction;
|
character.AnimController.Anim = AnimController.Animation.UsingConstruction;
|
||||||
|
|
||||||
character.AnimController.ResetPullJoints();
|
character.AnimController.ResetPullJoints();
|
||||||
|
|
||||||
if (dir != 0) character.AnimController.TargetDir = dir;
|
if (dir != 0) character.AnimController.TargetDir = dir;
|
||||||
@@ -256,10 +271,10 @@ namespace Barotrauma.Items.Components
|
|||||||
dir = dir == Direction.Left ? Direction.Right : Direction.Left;
|
dir = dir == Direction.Left ? Direction.Right : Direction.Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userPos != 0.0f)
|
if (userPos.X != 0.0f)
|
||||||
{
|
{
|
||||||
float diff = (item.Rect.X + UserPos) - item.Rect.Center.X;
|
float diff = (item.Rect.X + UserPos.X) - item.Rect.Center.X;
|
||||||
userPos = item.Rect.Center.X - diff - item.Rect.X;
|
userPos.X = item.Rect.Center.X - diff - item.Rect.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < limbPositions.Count; i++)
|
for (int i = 0; i < limbPositions.Count; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user