Sending multiple networkevents in one packet, removed limb updates from ImportantEntityUpdate
This commit is contained in:
@@ -1222,21 +1222,21 @@ namespace Barotrauma
|
||||
return inventory.FillNetworkData(NetworkEventType.InventoryUpdate, message, data);
|
||||
case NetworkEventType.ImportantEntityUpdate:
|
||||
|
||||
int i = 0;
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
if (limb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
//int i = 0;
|
||||
//foreach (Limb limb in AnimController.Limbs)
|
||||
//{
|
||||
// if (limb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
|
||||
message.WriteRangedSingle(limb.body.SimPosition.X, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
message.WriteRangedSingle(limb.body.SimPosition.Y, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
// message.WriteRangedSingle(limb.body.SimPosition.X, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
// message.WriteRangedSingle(limb.body.SimPosition.Y, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
|
||||
//message.Write(limb.body.LinearVelocity.X);
|
||||
//message.Write(limb.body.LinearVelocity.Y);
|
||||
// //message.Write(limb.body.LinearVelocity.X);
|
||||
// //message.Write(limb.body.LinearVelocity.Y);
|
||||
|
||||
message.Write(limb.body.Rotation);
|
||||
//message.WriteRangedSingle(MathHelper.Clamp(limb.body.AngularVelocity, -10.0f, 10.0f), -10.0f, 10.0f, 8);
|
||||
i++;
|
||||
}
|
||||
// message.Write(limb.body.Rotation);
|
||||
// //message.WriteRangedSingle(MathHelper.Clamp(limb.body.AngularVelocity, -10.0f, 10.0f), -10.0f, 10.0f, 8);
|
||||
// i++;
|
||||
//}
|
||||
|
||||
message.WriteRangedSingle(MathHelper.Clamp(AnimController.StunTimer,0.0f,60.0f), 0.0f, 60.0f, 8);
|
||||
message.Write((byte)((health/maxHealth)*255.0f));
|
||||
@@ -1366,32 +1366,32 @@ namespace Barotrauma
|
||||
inventory.ReadNetworkData(NetworkEventType.InventoryUpdate, message);
|
||||
return;
|
||||
case NetworkEventType.ImportantEntityUpdate:
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
Vector2 limbPos = limb.SimPosition, vel = Vector2.Zero;
|
||||
float rotation = limb.Rotation;
|
||||
//foreach (Limb limb in AnimController.Limbs)
|
||||
//{
|
||||
// Vector2 limbPos = limb.SimPosition, vel = Vector2.Zero;
|
||||
// float rotation = limb.Rotation;
|
||||
|
||||
try
|
||||
{
|
||||
limbPos.X = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
limbPos.Y = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
// try
|
||||
// {
|
||||
// limbPos.X = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
// limbPos.Y = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
|
||||
|
||||
rotation = message.ReadFloat();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
// rotation = message.ReadFloat();
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (limb.body != null)
|
||||
{
|
||||
limb.body.TargetVelocity = limb.body.LinearVelocity;
|
||||
limb.body.TargetPosition = limbPos;// +vel * (float)(deltaTime / 60.0);
|
||||
limb.body.TargetRotation = rotation;// +angularVel * (float)(deltaTime / 60.0);
|
||||
limb.body.TargetAngularVelocity = limb.body.AngularVelocity;
|
||||
}
|
||||
// if (limb.body != null)
|
||||
// {
|
||||
// limb.body.TargetVelocity = limb.body.LinearVelocity;
|
||||
// limb.body.TargetPosition = limbPos;// +vel * (float)(deltaTime / 60.0);
|
||||
// limb.body.TargetRotation = rotation;// +angularVel * (float)(deltaTime / 60.0);
|
||||
// limb.body.TargetAngularVelocity = limb.body.AngularVelocity;
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
float newStunTimer = 0.0f, newHealth = 0.0f, newOxygen = 0.0f;
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!character.Enabled) return;
|
||||
|
||||
UpdateNetplayerPosition();
|
||||
UpdateNetPlayerPosition();
|
||||
|
||||
Vector2 flowForce = Vector2.Zero;
|
||||
|
||||
@@ -654,7 +654,7 @@ namespace Barotrauma
|
||||
|
||||
}
|
||||
|
||||
private void UpdateNetplayerPosition()
|
||||
private void UpdateNetPlayerPosition()
|
||||
{
|
||||
if (refLimb.body.TargetPosition == Vector2.Zero)
|
||||
{
|
||||
@@ -662,18 +662,13 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
//if the limb is further away than resetdistance, all limbs are immediately snapped to their targetpositions
|
||||
float resetDistance = NetConfig.ResetRagdollDistance;
|
||||
|
||||
//if the limb is closer than alloweddistance, just ignore the difference
|
||||
float allowedDistance = NetConfig.AllowedRagdollDistance * ((inWater) ? 2.0f : 1.0f);
|
||||
|
||||
float dist = Vector2.Distance(refLimb.body.SimPosition, refLimb.body.TargetPosition);
|
||||
bool resetAll = dist > resetDistance;
|
||||
if (resetAll)
|
||||
{
|
||||
if (Limbs.FirstOrDefault(limb => !limb.ignoreCollisions && limb.body.TargetPosition == Vector2.Zero) != null) resetAll = false;
|
||||
}
|
||||
|
||||
//if the limb is further away than resetdistance, all limbs are immediately snapped to their targetpositions
|
||||
bool resetAll = dist > NetConfig.ResetRagdollDistance;
|
||||
|
||||
Vector2 diff = (refLimb.body.TargetPosition - refLimb.body.SimPosition);
|
||||
|
||||
@@ -717,16 +712,16 @@ namespace Barotrauma
|
||||
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (limb.body.TargetPosition == Vector2.Zero)
|
||||
{
|
||||
//if (limb.body.TargetPosition == Vector2.Zero)
|
||||
//{
|
||||
limb.body.SetTransform(limb.body.SimPosition + diff, limb.body.Rotation);
|
||||
continue;
|
||||
}
|
||||
//continue;
|
||||
//}
|
||||
|
||||
limb.body.LinearVelocity = limb.body.TargetVelocity;
|
||||
limb.body.AngularVelocity = limb.body.TargetAngularVelocity;
|
||||
//limb.body.LinearVelocity = limb.body.TargetVelocity;
|
||||
//limb.body.AngularVelocity = limb.body.TargetAngularVelocity;
|
||||
|
||||
limb.body.SetTransform(limb.body.TargetPosition, limb.body.TargetRotation);
|
||||
//limb.body.SetTransform(limb.body.TargetPosition, limb.body.TargetRotation);
|
||||
limb.body.TargetPosition = Vector2.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user