Added UpdateUseItem method from d253863
This commit is contained in:
@@ -68,6 +68,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual void DragCharacter(Character target) { }
|
||||
|
||||
public virtual void UpdateUseItem(bool allowMovement, Vector2 handPos) { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Barotrauma
|
||||
|
||||
private float inWaterTimer;
|
||||
private bool swimming;
|
||||
|
||||
private float useItemTimer;
|
||||
|
||||
protected override float TorsoPosition
|
||||
{
|
||||
@@ -180,6 +182,12 @@ namespace Barotrauma
|
||||
case Animation.UsingConstruction:
|
||||
default:
|
||||
|
||||
if (Anim == Animation.UsingConstruction)
|
||||
{
|
||||
useItemTimer -= deltaTime;
|
||||
if (useItemTimer <= 0.0f) Anim = Animation.None;
|
||||
}
|
||||
|
||||
if (character.SelectedCharacter != null) DragCharacter(character.SelectedCharacter);
|
||||
|
||||
//0.5 second delay for switching between swimming and walking
|
||||
@@ -1277,6 +1285,33 @@ namespace Barotrauma
|
||||
hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f * force);
|
||||
}
|
||||
|
||||
public override void UpdateUseItem(bool allowMovement, Vector2 handPos)
|
||||
{
|
||||
var leftHand = GetLimb(LimbType.LeftHand);
|
||||
var rightHand = GetLimb(LimbType.RightHand);
|
||||
|
||||
useItemTimer = 0.5f;
|
||||
Anim = Animation.UsingConstruction;
|
||||
|
||||
if (!allowMovement)
|
||||
{
|
||||
TargetMovement = Vector2.Zero;
|
||||
TargetDir = handPos.X > character.SimPosition.X ? Direction.Right : Direction.Left;
|
||||
if (Vector2.Distance(character.SimPosition, handPos) > 1.0f)
|
||||
{
|
||||
TargetMovement = Vector2.Normalize(handPos - character.SimPosition);
|
||||
}
|
||||
}
|
||||
|
||||
leftHand.Disabled = true;
|
||||
leftHand.pullJoint.Enabled = true;
|
||||
leftHand.pullJoint.WorldAnchorB = handPos;
|
||||
|
||||
rightHand.Disabled = true;
|
||||
rightHand.pullJoint.Enabled = true;
|
||||
rightHand.pullJoint.WorldAnchorB = handPos;
|
||||
}
|
||||
|
||||
public override void Flip()
|
||||
{
|
||||
base.Flip();
|
||||
|
||||
@@ -127,18 +127,8 @@ namespace Barotrauma.Items.Components
|
||||
Color.Red, Color.Green);
|
||||
#endif
|
||||
|
||||
picker.AnimController.Anim = AnimController.Animation.UsingConstruction;
|
||||
|
||||
picker.AnimController.TargetMovement = Vector2.Zero;
|
||||
|
||||
leftHand.Disabled = true;
|
||||
leftHand.pullJoint.Enabled = true;
|
||||
leftHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * ((pickTimer / 10.0f) % 0.1f);
|
||||
|
||||
rightHand.Disabled = true;
|
||||
rightHand.pullJoint.Enabled = true;
|
||||
rightHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * ((pickTimer / 10.0f) % 0.1f);
|
||||
|
||||
picker.AnimController.UpdateUseItem(true, item.SimPosition + Vector2.UnitY * ((pickTimer / 10.0f) % 0.1f));
|
||||
|
||||
pickTimer += CoroutineManager.DeltaTime;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
@@ -258,7 +258,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (currLength > MaxLength)
|
||||
{
|
||||
Vector2 pullBackDir = Vector2.Normalize(nodes[nodes.Count - 1] - newNodePos);
|
||||
Vector2 diff = nodes[nodes.Count - 1] - newNodePos;
|
||||
Vector2 pullBackDir = diff == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(diff);
|
||||
user.AnimController.Collider.ApplyForce(pullBackDir * user.Mass * 50.0f);
|
||||
user.AnimController.UpdateUseItem(true, user.SimPosition + pullBackDir * 2.0f);
|
||||
if (currLength > MaxLength * 1.5f)
|
||||
|
||||
Reference in New Issue
Block a user