Transforming in-sub MemPos/MemLocalPos coordinates to outside coordinates if the character is outside and vice versa, server doesn't start sending ingame updates until they receive the first ingame update message from the client (no need to send updates while the client is loading or if they fail to start the round)

This commit is contained in:
Regalis
2017-01-05 18:16:58 +02:00
parent ba4ee843f3
commit 518eea746e
5 changed files with 82 additions and 13 deletions
+36
View File
@@ -37,6 +37,42 @@ namespace Barotrauma
Timestamp = time;
}
public static PosInfo TransformOutToInside(PosInfo posInfo, Submarine submarine)
{
//transform outside coordinates to in-sub coordinates
return new PosInfo(
posInfo.Position - ConvertUnits.ToSimUnits(submarine.Position),
posInfo.Direction,
posInfo.ID,
posInfo.Timestamp);
}
public static PosInfo TransformInToOutside(PosInfo posInfo)
{
Submarine closestSub = null;
foreach (Submarine sub in Submarine.Loaded)
{
Rectangle subBorders = sub.Borders;
subBorders.Location += sub.HiddenSubPosition.ToPoint() - new Point(0, sub.Borders.Height);
subBorders.Inflate(500.0f, 500.0f);
if (subBorders.Contains(ConvertUnits.ToDisplayUnits(posInfo.Position)))
{
closestSub = sub;
break;
}
}
if (closestSub == null) return posInfo;
return new PosInfo(
posInfo.Position + ConvertUnits.ToSimUnits(closestSub.Position),
posInfo.Direction,
posInfo.ID,
posInfo.Timestamp);
}
}
class PhysicsBody