Merge branch 'master' into moRags

This commit is contained in:
Alex Noir
2017-12-17 22:41:45 +03:00
81 changed files with 770 additions and 256 deletions
@@ -84,9 +84,13 @@ namespace Barotrauma
{
levitatingCollider = false;
Collider.FarseerBody.FixedRotation = false;
Collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - Collider.SimPosition) * 20.0f;
Collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation);
if (Math.Abs(Collider.Rotation-GetLimb(LimbType.Torso).Rotation)>Math.PI*0.6f)
{
Collider.SetTransform(Collider.SimPosition, MathHelper.WrapAngle(Collider.Rotation + (float)Math.PI));
}
Collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation);
Collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - Collider.SimPosition) * 20.0f;
return;
}
@@ -1083,8 +1087,6 @@ namespace Barotrauma
public override void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle)
{
Holdable holdable = item.GetComponent<Holdable>();
if (character.IsUnconscious || character.Stun > 0.0f) aim = false;
//calculate the handle positions
@@ -1102,7 +1104,6 @@ namespace Barotrauma
bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Controller>() != null;
float itemAngle;
if (Anim != Animation.Climbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero)
{
@@ -1114,6 +1115,7 @@ namespace Barotrauma
itemAngle = (torso.body.Rotation + holdAngle * Dir);
Holdable holdable = item.GetComponent<Holdable>();
if (holdable.ControlPose)
{
head.body.SmoothRotate(itemAngle);
@@ -1339,13 +1339,34 @@ namespace Barotrauma
}
}
Vector2 positionError = serverPos.Position - localPos.Position;
for (int i = localPosIndex; i < character.MemLocalState.Count; i++)
Hull serverHull = Hull.FindHull(serverPos.Position, character.CurrentHull, false);
Hull clientHull = Hull.FindHull(localPos.Position, serverHull, false);
Vector2 positionError = serverPos.Position - localPos.Position;
float rotationError = serverPos.Rotation - localPos.Rotation;
if (serverHull!=clientHull && ((serverHull==null) || (clientHull==null) || (serverHull.Submarine != clientHull.Submarine)))
{
character.MemLocalState[i].Translate(positionError);
//hull subs don't match => just teleport the player to exactly this position to avoid mismatches,
//since this would completely break the camera
positionError = Collider.SimPosition - serverPos.Position;
character.MemLocalState.Clear();
}
else
{
for (int i = localPosIndex; i < character.MemLocalState.Count; i++)
{
Hull pointHull = Hull.FindHull(character.MemLocalState[i].Position, clientHull, false);
if (pointHull != clientHull && ((pointHull == null) || (clientHull == null) || (pointHull.Submarine == clientHull.Submarine))) break;
character.MemLocalState[i].Translate(positionError, rotationError);
}
}
Collider.SetTransform(Collider.SimPosition + positionError, Collider.Rotation);
Collider.SetTransform(Collider.SimPosition + positionError, Collider.Rotation + rotationError);
foreach (Limb limb in Limbs)
{
limb.body.SetTransform(limb.body.SimPosition + positionError, limb.body.Rotation);
}
}
if (character.MemLocalState.Count > 120) character.MemLocalState.RemoveRange(0, character.MemLocalState.Count - 120);
@@ -138,6 +138,27 @@ namespace Barotrauma
return info != null && !string.IsNullOrWhiteSpace(info.Name) ? info.Name : SpeciesName;
}
}
//Only used by server logs to determine "true identity" of the player for cases when they're disguised
public string LogName
{
get
{
return info != null && !string.IsNullOrWhiteSpace(info.Name) ? info.Name + (info.DisplayName != info.Name ? " (as " + info.DisplayName + ")" : "") : SpeciesName;
}
}
private float hideFaceTimer;
public bool HideFace
{
get
{
return hideFaceTimer > 0.0f;
}
set
{
hideFaceTimer = MathHelper.Clamp(hideFaceTimer + (value ? 1.0f : -0.5f), 0.0f, 10.0f);
}
}
public string ConfigPath
{
@@ -591,7 +612,7 @@ namespace Barotrauma
{
AnimController = new HumanoidAnimController(this, doc.Root.Element("ragdoll"));
AnimController.TargetDir = Direction.Right;
inventory = new CharacterInventory(16, this);
inventory = new CharacterInventory(17, this);
}
else
{
@@ -926,13 +947,16 @@ namespace Barotrauma
}
}
for (int i = 0; i < selectedItems.Length; i++ )
if (SelectedConstruction == null || !SelectedConstruction.Prefab.DisableItemUsageWhenSelected)
{
if (selectedItems[i] == null) continue;
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
for (int i = 0; i < selectedItems.Length; i++ )
{
if (selectedItems[i] == null) continue;
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this);
if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this);
if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
}
}
if (selectedConstruction != null)
@@ -1406,6 +1430,8 @@ namespace Barotrauma
item.Submarine = Submarine;
}
}
HideFace = false;
if (isDead) return;
@@ -1633,7 +1659,7 @@ namespace Barotrauma
var attackingCharacter = attacker as Character;
if (attackingCharacter != null && attackingCharacter.AIController == null)
{
GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, ServerLog.MessageType.Attack);
GameServer.Log(LogName + " attacked by " + attackingCharacter.LogName +". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, ServerLog.MessageType.Attack);
}
if (GameMain.Client == null &&
@@ -1798,7 +1824,7 @@ namespace Barotrauma
AnimController.Frozen = false;
GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", ServerLog.MessageType.Attack);
GameServer.Log(LogName+" has died (Cause of death: "+causeOfDeath+")", ServerLog.MessageType.Attack);
if (OnDeath != null) OnDeath(this, causeOfDeath);
@@ -12,7 +12,34 @@ namespace Barotrauma
partial class CharacterInfo
{
public string Name;
public string DisplayName
{
get {
string disguiseName = "?";
if (Character != null && Character.HideFace)
{
if (Character.Inventory != null)
{
var idCard = Character.Inventory.FindItem("ID Card");
if (idCard != null && Character.Inventory.IsInLimbSlot(idCard, InvSlotType.Card)) //Disguise as the ID card name if it's equipped
{
string[] readTags = idCard.Tags.Split(',');
foreach (string tag in readTags)
{
string[] s = tag.Split(':');
if (s[0] == "name")
{
disguiseName = s[1];
break;
}
}
}
}
return disguiseName;
}
return Name;
}
}
public Character Character;
public readonly string File;
@@ -15,18 +15,18 @@ namespace Barotrauma
public readonly AnimController.Animation Animation;
public CharacterStateInfo(Vector2 pos, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
: this(pos, 0, time, dir, interact, animation)
public CharacterStateInfo(Vector2 pos, float rotation, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
: this(pos, rotation, 0, time, dir, interact, animation)
{
}
public CharacterStateInfo(Vector2 pos, UInt16 ID, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
: this(pos, ID, 0.0f, dir, interact, animation)
public CharacterStateInfo(Vector2 pos, float rotation, UInt16 ID, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
: this(pos, rotation, ID, 0.0f, dir, interact, animation)
{
}
protected CharacterStateInfo(Vector2 pos, UInt16 ID, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
: base(pos, ID, time)
protected CharacterStateInfo(Vector2 pos, float rotation, UInt16 ID, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
: base(pos, rotation, ID, time)
{
Direction = dir;
Interact = interact;
@@ -197,6 +197,7 @@ namespace Barotrauma
{
var posInfo = new CharacterStateInfo(
SimPosition,
AnimController.Collider.Rotation,
LastNetworkUpdateID,
AnimController.TargetDir,
SelectedCharacter == null ? (Entity)selectedConstruction : (Entity)SelectedCharacter,
@@ -471,6 +472,7 @@ namespace Barotrauma
tempBuffer.Write(SimPosition.X);
tempBuffer.Write(SimPosition.Y);
tempBuffer.Write(AnimController.Collider.Rotation);
tempBuffer.WritePadBits();
@@ -130,6 +130,10 @@ namespace Barotrauma
{
item.AddTag(s);
}
item.AddTag("name:" + character.Name);
item.AddTag("job:" + Name);
if (!string.IsNullOrWhiteSpace(spawnPoint.IdCardDesc))
item.Description = spawnPoint.IdCardDesc;
}
if (parentItem != null) parentItem.Combine(item);
@@ -265,7 +265,7 @@ namespace Barotrauma
{
SerializableProperty property;
if (!target.SerializableProperties.TryGetValue(propertyNames[i], out property)) continue;
if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(propertyNames[i], out property)) continue;
if (duration > 0.0f)
{