Merge branch 'master' into animcontroller-overhaul
Conflicts: Subsurface/Content/Characters/Crawler/crawler.xml Subsurface/Source/Characters/AICharacter.cs Subsurface/Source/Characters/Animation/FishAnimController.cs Subsurface/Source/Characters/Animation/Ragdoll.cs Subsurface/Source/Characters/Character.cs Subsurface/Source/Map/Submarine.cs Subsurface/Source/Map/SubmarineBody.cs Subsurface/Source/Networking/GameClient.cs Subsurface/Source/Networking/GameServer.cs Subsurface/Source/Physics/PhysicsBody.cs
This commit is contained in:
@@ -76,7 +76,7 @@ namespace Barotrauma
|
||||
|
||||
private Vector2 prevPosition;
|
||||
|
||||
private float lastNetworkUpdate, networkUpdateTimer;
|
||||
private float networkUpdateTimer;
|
||||
|
||||
private EntityGrid entityGrid = null;
|
||||
|
||||
@@ -150,6 +150,11 @@ namespace Barotrauma
|
||||
get { return subBody; }
|
||||
}
|
||||
|
||||
public PhysicsBody PhysicsBody
|
||||
{
|
||||
get { return subBody.Body; }
|
||||
}
|
||||
|
||||
public Rectangle Borders
|
||||
{
|
||||
get
|
||||
@@ -299,6 +304,7 @@ namespace Barotrauma
|
||||
{
|
||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void DrawFront(SpriteBatch spriteBatch, bool editing = false)
|
||||
@@ -308,6 +314,32 @@ namespace Barotrauma
|
||||
if (MapEntity.mapEntityList[i].DrawOverWater)
|
||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
|
||||
}
|
||||
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
if (sub.subBody.MemPos.Count < 2) continue;
|
||||
|
||||
Vector2 prevPos = ConvertUnits.ToDisplayUnits(sub.subBody.MemPos[0].Position);
|
||||
prevPos.Y = -prevPos.Y;
|
||||
|
||||
for (int i = 1; i < sub.subBody.MemPos.Count; i++)
|
||||
{
|
||||
Vector2 currPos = ConvertUnits.ToDisplayUnits(sub.subBody.MemPos[i].Position);
|
||||
currPos.Y = -currPos.Y;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)currPos.X - 10, (int)currPos.Y - 10, 20, 20), Color.Blue * 0.6f, true, 0.01f);
|
||||
GUI.DrawLine(spriteBatch, prevPos, currPos, Color.Cyan * 0.5f, 0, 5);
|
||||
|
||||
prevPos = currPos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing = false)
|
||||
@@ -540,9 +572,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Vector2 pos = new Vector2(subBody.Position.X, subBody.Position.Y);
|
||||
SubmarineBody newSubBody = new SubmarineBody(this);
|
||||
GameMain.World.RemoveBody(subBody.Body);
|
||||
subBody = newSubBody;
|
||||
subBody.Body.Remove();
|
||||
subBody = new SubmarineBody(this);
|
||||
SetPosition(pos);
|
||||
|
||||
if (entityGrid != null)
|
||||
@@ -590,7 +621,7 @@ namespace Barotrauma
|
||||
if (this != MainSub && MainSub.DockedTo.Contains(this)) return;
|
||||
|
||||
//send updates more frequently if moving fast
|
||||
networkUpdateTimer -= MathHelper.Clamp(Velocity.Length(), 0.1f, 5.0f) * deltaTime;
|
||||
networkUpdateTimer -= MathHelper.Clamp(Velocity.Length()*10.0f, 0.1f, 5.0f) * deltaTime;
|
||||
|
||||
if (networkUpdateTimer < 0.0f)
|
||||
{
|
||||
@@ -655,7 +686,7 @@ namespace Barotrauma
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
|
||||
//saving/loading ----------------------------------------------------
|
||||
|
||||
public bool Save()
|
||||
@@ -1080,17 +1111,30 @@ namespace Barotrauma
|
||||
|
||||
public void ServerWrite(NetOutgoingMessage msg, Client c)
|
||||
{
|
||||
msg.Write(subBody.Position.X);
|
||||
msg.Write(subBody.Position.Y);
|
||||
|
||||
msg.Write(Velocity.X);
|
||||
msg.Write(Velocity.Y);
|
||||
msg.Write(PhysicsBody.SimPosition.X);
|
||||
msg.Write(PhysicsBody.SimPosition.Y);
|
||||
}
|
||||
|
||||
public void ClientRead(NetIncomingMessage msg, float sendingTime)
|
||||
{
|
||||
subBody.TargetPosition = new Vector2(msg.ReadSingle(), msg.ReadSingle());
|
||||
subBody.Velocity = new Vector2(msg.ReadSingle(), msg.ReadSingle());
|
||||
var newTargetPosition = new Vector2(
|
||||
msg.ReadFloat(),
|
||||
msg.ReadFloat());
|
||||
|
||||
|
||||
//already interpolating with more up-to-date data -> ignore
|
||||
if (subBody.MemPos.Count > 1 && subBody.MemPos[0].Timestamp > sendingTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while (index < subBody.MemPos.Count && sendingTime > subBody.MemPos[index].Timestamp)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
|
||||
subBody.MemPos.Insert(index, new PosInfo(newTargetPosition, Direction.Right, sendingTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user