More easily readable netstats (B/kB/MB instead of just B), scrollable netstats client list, possible to wear multiple items in same limb, handcuffs

This commit is contained in:
Regalis
2016-02-20 13:00:05 +02:00
parent c605adf879
commit 058a269ecb
16 changed files with 305 additions and 148 deletions
@@ -127,6 +127,36 @@ namespace Barotrauma
character.StartStun(MathHelper.Min(strongestImpact * 0.5f, 5.0f));
}
strongestImpact = 0.0f;
if (character.LockHands)
{
var leftHand = GetLimb(LimbType.LeftHand);
var rightHand = GetLimb(LimbType.RightHand);
var waist = GetLimb(LimbType.Waist);
rightHand.Disabled = true;
leftHand.Disabled = true;
Vector2 midPos = waist.SimPosition;
Matrix torsoTransform = Matrix.CreateRotationZ(waist.Rotation);
midPos += Vector2.Transform(new Vector2(-0.3f*Dir,-0.2f), torsoTransform);
if (rightHand.pullJoint.Enabled) midPos = (midPos + rightHand.pullJoint.WorldAnchorB) / 2.0f;
HandIK(rightHand, midPos);
HandIK(leftHand, midPos);
//rightHand.pullJoint.Enabled = true;
//rightHand.pullJoint.WorldAnchorB = midPos;
//rightHand.pullJoint.Enabled = true;
//rightHand.pullJoint.WorldAnchorB = midPos;
}
if (stunTimer > 0)
{
@@ -134,10 +164,10 @@ namespace Barotrauma
return;
}
if (Anim != Animation.UsingConstruction) ResetPullJoints();
if (TargetDir != dir) Flip();
if (Anim != Animation.UsingConstruction) ResetPullJoints();
if (SimplePhysicsEnabled)
{
UpdateStandingSimple();
@@ -815,7 +845,17 @@ namespace Barotrauma
target.AnimController.IgnorePlatforms = IgnorePlatforms;
target.AnimController.TargetMovement = TargetMovement;
if (target.Stun > 0.0f || target.IsDead)
{
target.AnimController.TargetMovement = TargetMovement;
}
else if (target is AICharacter)
{
target.AnimController.TargetMovement = Vector2.Lerp(target.AnimController.TargetMovement, (character.SimPosition + Vector2.UnitX*Dir) - target.SimPosition, 0.5f);
}
}
public override void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle)
@@ -994,12 +1034,14 @@ namespace Barotrauma
case LimbType.LeftArm:
case LimbType.RightHand:
case LimbType.RightArm:
difference = limb.body.SimPosition - torso.SimPosition;
difference = Vector2.Transform(difference, torsoTransform);
difference.Y = -difference.Y;
TrySetLimbPosition(limb, limb.SimPosition, torso.SimPosition + Vector2.Transform(difference, -torsoTransform));
if (!limb.pullJoint.Enabled)
{
difference = limb.body.SimPosition - torso.SimPosition;
difference = Vector2.Transform(difference, torsoTransform);
difference.Y = -difference.Y;
TrySetLimbPosition(limb, limb.SimPosition, torso.SimPosition + Vector2.Transform(difference, -torsoTransform));
}
limb.body.SetTransform(limb.body.SimPosition, -limb.body.Rotation);
break;
default:
+71 -62
View File
@@ -149,6 +149,19 @@ namespace Barotrauma
get { return inventory; }
}
private float lockHandsTimer;
public bool LockHands
{
get
{
return lockHandsTimer > 0.0f;
}
set
{
lockHandsTimer = MathHelper.Clamp(lockHandsTimer + (value ? 1.0f : -0.5f), 0.0f, 10.0f);
}
}
public Vector2 CursorPosition
{
get { return cursorPosition; }
@@ -244,7 +257,7 @@ namespace Barotrauma
if (!MathUtils.IsValid(value)) return;
health = MathHelper.Clamp(value, 0.0f, maxHealth);
}
}
}
public float MaxHealth
{
@@ -304,14 +317,6 @@ namespace Barotrauma
public bool IsDead
{
get { return isDead; }
//set
//{
// if (isDead == value) return;
// if (isDead)
// {
// Revive(false);
// }
//}
}
public CauseOfDeath CauseOfDeath
@@ -319,6 +324,14 @@ namespace Barotrauma
get { return causeOfDeath; }
}
public bool CanBeSelected
{
get
{
return isDead || Stun > 0.0f || LockHands;
}
}
public override Vector2 SimPosition
{
get { return AnimController.RefLimb.SimPosition; }
@@ -658,8 +671,7 @@ namespace Barotrauma
if (selectedCharacter!=null)
{
if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 3.0f ||
(!selectedCharacter.isDead && selectedCharacter.Stun <= 0.0f))
if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 2.0f || !selectedCharacter.CanBeSelected)
{
DeselectCharacter();
}
@@ -765,9 +777,7 @@ namespace Barotrauma
selectedCharacter = character;
if (createNetworkEvent)
new NetworkEvent(NetworkEventType.SelectCharacter, ID, true, selectedCharacter.ID);
if (createNetworkEvent) new NetworkEvent(NetworkEventType.SelectCharacter, ID, true, selectedCharacter.ID);
}
private void DeselectCharacter(bool createNetworkEvent = true)
@@ -820,8 +830,6 @@ namespace Barotrauma
(AnimController.CurrentHull.LethalPressure - 50.0f) / 50.0f);
}
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (Submarine == null ? 400.0f : 250.0f)+pressureEffect, 0.05f);
}
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
@@ -844,69 +852,68 @@ namespace Barotrauma
}
//find the closest item if selectkey has been hit, or if the Character is being
//controlled by the player (in order to highlight it)
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
if (!LockHands)
{
closestCharacter = FindClosestCharacter(mouseSimPos);
if (closestCharacter != null && closestCharacter.info==null)
{
closestCharacter = null;
}
//find the closest item if selectkey has been hit, or if the Character is being
//controlled by the player (in order to highlight it)
closestItem = FindClosestItem(mouseSimPos);
if (closestCharacter != null && closestItem != null)
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
{
if (Vector2.Distance(closestCharacter.SimPosition, mouseSimPos) < Vector2.Distance(closestItem.SimPosition, mouseSimPos))
{
if (selectedConstruction != closestItem) closestItem = null;
}
else
closestCharacter = FindClosestCharacter(mouseSimPos);
if (closestCharacter != null && closestCharacter.info==null)
{
closestCharacter = null;
}
closestItem = FindClosestItem(mouseSimPos);
if (closestCharacter != null && closestItem != null)
{
if (Vector2.Distance(closestCharacter.SimPosition, mouseSimPos) < Vector2.Distance(closestItem.SimPosition, mouseSimPos))
{
if (selectedConstruction != closestItem) closestItem = null;
}
else
{
closestCharacter = null;
}
}
findClosestTimer = 0.1f;
}
else
{
findClosestTimer -= deltaTime;
}
findClosestTimer = 0.1f;
}
else
{
findClosestTimer -= deltaTime;
}
if (selectedCharacter == null)
{
if (closestItem != null)
if (selectedCharacter == null && closestItem != null)
{
closestItem.IsHighlighted = true;
if (closestItem.Pick(this))
if (!LockHands && closestItem.Pick(this))
{
new NetworkEvent(NetworkEventType.PickItem, ID, true,
new int[]
{
closestItem.ID,
IsKeyHit(InputType.Select) ? 1 : 0,
IsKeyHit(InputType.Use) ? 1 : 0
});
{
closestItem.ID,
IsKeyHit(InputType.Select) ? 1 : 0,
IsKeyHit(InputType.Use) ? 1 : 0
});
}
}
if (IsKeyHit(InputType.Select))
{
if (selectedCharacter != null)
{
DeselectCharacter();
}
else if (closestCharacter != null && closestCharacter.IsHumanoid && closestCharacter.CanBeSelected)
{
SelectCharacter(closestCharacter);
}
}
}
if (IsKeyHit(InputType.Select))
{
if (selectedCharacter != null)
{
DeselectCharacter();
}
else if (closestCharacter != null && closestCharacter.IsHumanoid &&
(closestCharacter.isDead || closestCharacter.AnimController.StunTimer > 0.0f))
{
SelectCharacter(closestCharacter);
}
}
DisableControls = false;
}
@@ -1003,6 +1010,8 @@ namespace Barotrauma
Health -= bleeding*deltaTime;
if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false);
if (!IsDead) LockHands = false;
}
+3 -3
View File
@@ -56,16 +56,16 @@ namespace Barotrauma
DrawStatusIcons(spriteBatch, character);
if (character.Inventory != null) character.Inventory.DrawOwn(spriteBatch);
if (character.Inventory != null && !character.LockHands) character.Inventory.DrawOwn(spriteBatch, Vector2.Zero);
if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory!=null)
{
character.SelectedCharacter.Inventory.Draw(spriteBatch);
character.SelectedCharacter.Inventory.DrawOwn(spriteBatch, new Vector2(GameMain.GraphicsWidth - 310, 0.0f));
//if (Vector2.Distance(selectedCharacter.SimPosition, SimPosition) > 2.0f) selectedCharacter = null;
}
if (character.ClosestCharacter != null && (character.ClosestCharacter.IsDead || character.ClosestCharacter.Stun > 0.0f))
if (character.ClosestCharacter != null && character.ClosestCharacter.CanBeSelected)
{
Vector2 startPos = character.DrawPosition + (character.ClosestCharacter.DrawPosition - character.DrawPosition) * 0.7f;
startPos = cam.WorldToScreen(startPos);
+31 -26
View File
@@ -6,6 +6,7 @@ using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Items.Components;
using System.Collections.Generic;
namespace Barotrauma
{
@@ -64,8 +65,7 @@ namespace Barotrauma
private Direction dir;
private Wearable wearingItem;
private WearableSprite wearingItemSprite;
private List<WearableSprite> wearingItems;
private Vector2 animTargetPos;
@@ -172,21 +172,23 @@ namespace Barotrauma
// set { bleeding = MathHelper.Clamp(value, 0.0f, 100.0f); }
//}
public Wearable WearingItem
public List<WearableSprite> WearingItems
{
get { return wearingItem; }
set { wearingItem = value; }
get { return wearingItems; }
set { wearingItems = value; }
}
public WearableSprite WearingItemSprite
{
get { return wearingItemSprite; }
set { wearingItemSprite = value; }
}
//public WearableSprite WearingItemSprite
//{
// get { return wearingItemSprite; }
// set { wearingItemSprite = value; }
//}
public Limb (Character character, XElement element, float scale = 1.0f)
{
this.character = character;
WearingItems = new List<WearableSprite>();
dir = Direction.Right;
@@ -327,13 +329,16 @@ namespace Barotrauma
totalArmorValue += armorValue;
}
if (wearingItem!=null &&
wearingItem.ArmorValue>0.0f &&
SectorHit(wearingItem.ArmorSectorLimits, position))
foreach (WearableSprite wearable in wearingItems)
{
hitArmor = true;
totalArmorValue += wearingItem.ArmorValue;
}
if (wearable.WearableComponent.ArmorValue > 0.0f &&
SectorHit(wearable.WearableComponent.ArmorSectorLimits, position))
{
hitArmor = true;
totalArmorValue += wearable.WearableComponent.ArmorValue;
}
}
if (hitArmor)
{
@@ -456,7 +461,7 @@ namespace Barotrauma
body.Dir = Dir;
if (wearingItem == null || !wearingItemSprite.HideLimb)
if (wearingItems.Find(w => w != null && w.HideLimb) == null)
{
body.Draw(spriteBatch, sprite, color, null, scale);
}
@@ -464,32 +469,32 @@ namespace Barotrauma
{
body.UpdateDrawPosition();
}
if (wearingItem != null)
foreach (WearableSprite wearable in wearingItems)
{
SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
Vector2 origin = wearingItemSprite.Sprite.Origin;
if (body.Dir == -1.0f) origin.X = wearingItemSprite.Sprite.SourceRect.Width - origin.X;
Vector2 origin = wearable.Sprite.Origin;
if (body.Dir == -1.0f) origin.X = wearable.Sprite.SourceRect.Width - origin.X;
float depth = sprite.Depth - 0.000001f;
if (wearingItemSprite.DepthLimb!=LimbType.None)
if (wearable.DepthLimb != LimbType.None)
{
Limb depthLimb = character.AnimController.GetLimb(wearingItemSprite.DepthLimb);
if (depthLimb!=null)
Limb depthLimb = character.AnimController.GetLimb(wearable.DepthLimb);
if (depthLimb != null)
{
depth = depthLimb.sprite.Depth - 0.000001f;
}
}
wearingItemSprite.Sprite.Draw(spriteBatch,
wearable.Sprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color, origin,
-body.DrawRotation,
scale, spriteEffect, depth);
}
if (damage>0.0f && damagedSprite!=null)
{
SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;