MonsterEvent spawns monsters at start, writing networkeventtype using WriteRangedInt instead of WriteByte
This commit is contained in:
Binary file not shown.
@@ -953,7 +953,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector2 targetMovement = character.GetTargetMovement();
|
Vector2 targetMovement = character.GetTargetMovement();
|
||||||
|
|
||||||
Vector2 currPosition = prevPosition + targetMovement * timePassed/1000.0f;
|
Vector2 currPosition = prevPosition + targetMovement * timePassed/500.0f;
|
||||||
|
|
||||||
return currPosition;
|
return currPosition;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ namespace Barotrauma
|
|||||||
foreach (Limb limb in Limbs)
|
foreach (Limb limb in Limbs)
|
||||||
{
|
{
|
||||||
limb.body.LinearVelocity = Vector2.Zero;
|
limb.body.LinearVelocity = Vector2.Zero;
|
||||||
limb.body.AngularVelocity = Vector2.Zero;
|
limb.body.AngularVelocity = 0.0f;
|
||||||
// if (limb.body.TargetPosition == Vector2.Zero)
|
// if (limb.body.TargetPosition == Vector2.Zero)
|
||||||
// {
|
// {
|
||||||
// limb.body.SetTransform(limb.body.SimPosition + diff, limb.body.Rotation);
|
// limb.body.SetTransform(limb.body.SimPosition + diff, limb.body.Rotation);
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ namespace Barotrauma
|
|||||||
spawnDeep = ToolBox.GetAttributeBool(element, "spawndeep", false);
|
spawnDeep = ToolBox.GetAttributeBool(element, "spawndeep", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Start()
|
||||||
|
{
|
||||||
|
SpawnMonsters();
|
||||||
|
}
|
||||||
|
|
||||||
private void SpawnMonsters()
|
private void SpawnMonsters()
|
||||||
{
|
{
|
||||||
WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||||
@@ -63,13 +68,13 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (monsters[i].IsDead) continue;
|
if (monsters[i].IsDead) continue;
|
||||||
|
|
||||||
if (!isStarted && monsters[i].SimPosition != Vector2.Zero && monsters[i].SimPosition.Length() < 20.0) isStarted = true;
|
if (!isStarted && Vector2.Distance(monsters[i].WorldPosition, Submarine.Loaded.WorldPosition) < 5000.0f) isStarted = true;
|
||||||
|
|
||||||
monstersDead = false;
|
monstersDead = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monstersDead) Finished();
|
if (monstersDead) Finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public bool FillData(NetBuffer message)
|
public bool FillData(NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write((byte)eventType);
|
message.WriteRangedInteger(0, Enum.GetValues(typeof(NetworkEventType)).Length, (int)eventType);
|
||||||
|
|
||||||
Entity e = Entity.FindEntityByID(id);
|
Entity e = Entity.FindEntityByID(id);
|
||||||
if (e == null) return false;
|
if (e == null) return false;
|
||||||
@@ -182,7 +182,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
eventType = (NetworkEventType)message.ReadByte();
|
eventType = (NetworkEventType)message.ReadRangedInteger(0, Enum.GetValues(typeof(NetworkEventType)).Length);
|
||||||
id = message.ReadUInt16();
|
id = message.ReadUInt16();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
@@ -188,7 +188,9 @@ namespace Barotrauma.Networking.ReliableMessages
|
|||||||
|
|
||||||
sender.SendMessage(message, recipient, NetDeliveryMethod.Unreliable);
|
sender.SendMessage(message, recipient, NetDeliveryMethod.Unreliable);
|
||||||
|
|
||||||
idSendTimer = Math.Max(recipient.AverageRoundtripTime, NetConfig.IdSendInterval+idSendInterval);
|
float roundTripTime = Math.Min(recipient.AverageRoundtripTime, 0.5f);
|
||||||
|
|
||||||
|
idSendTimer = Math.Max(roundTripTime, NetConfig.IdSendInterval+idSendInterval);
|
||||||
idSendInterval += 0.1f;
|
idSendInterval += 0.1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,8 +248,9 @@ namespace Barotrauma.Networking.ReliableMessages
|
|||||||
receiver.SendMessage(resendRequest, recipient,
|
receiver.SendMessage(resendRequest, recipient,
|
||||||
missingMessage.ResendRequestsSent==0 ? NetDeliveryMethod.ReliableUnordered : NetDeliveryMethod.Unreliable);
|
missingMessage.ResendRequestsSent==0 ? NetDeliveryMethod.ReliableUnordered : NetDeliveryMethod.Unreliable);
|
||||||
|
|
||||||
|
float roundTripTime = Math.Min(recipient.AverageRoundtripTime, 0.5f);
|
||||||
|
|
||||||
missingMessage.ResendTimer = Math.Max(recipient.AverageRoundtripTime, NetConfig.RerequestInterval);
|
missingMessage.ResendTimer = Math.Max(roundTripTime, NetConfig.RerequestInterval);
|
||||||
missingMessage.ResendRequestsSent++;
|
missingMessage.ResendRequestsSent++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user