MonsterEvent spawns monsters at start, writing networkeventtype using WriteRangedInt instead of WriteByte

This commit is contained in:
Regalis11
2016-01-31 17:39:50 +02:00
parent 92a162cbf5
commit 7f78582df7
6 changed files with 16 additions and 8 deletions

Binary file not shown.

View File

@@ -953,7 +953,7 @@ namespace Barotrauma
Vector2 targetMovement = character.GetTargetMovement();
Vector2 currPosition = prevPosition + targetMovement * timePassed/1000.0f;
Vector2 currPosition = prevPosition + targetMovement * timePassed/500.0f;
return currPosition;
}

View File

@@ -827,7 +827,7 @@ namespace Barotrauma
foreach (Limb limb in Limbs)
{
limb.body.LinearVelocity = Vector2.Zero;
limb.body.AngularVelocity = Vector2.Zero;
limb.body.AngularVelocity = 0.0f;
// if (limb.body.TargetPosition == Vector2.Zero)
// {
// limb.body.SetTransform(limb.body.SimPosition + diff, limb.body.Rotation);

View File

@@ -25,6 +25,11 @@ namespace Barotrauma
spawnDeep = ToolBox.GetAttributeBool(element, "spawndeep", false);
}
protected override void Start()
{
SpawnMonsters();
}
private void SpawnMonsters()
{
WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Enemy);
@@ -63,13 +68,13 @@ namespace Barotrauma
{
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;
break;
}
if (monstersDead) Finished();
if (monstersDead) Finished();
}
}
}

View File

@@ -125,7 +125,7 @@ namespace Barotrauma.Networking
public bool FillData(NetBuffer message)
{
message.Write((byte)eventType);
message.WriteRangedInteger(0, Enum.GetValues(typeof(NetworkEventType)).Length, (int)eventType);
Entity e = Entity.FindEntityByID(id);
if (e == null) return false;
@@ -182,7 +182,7 @@ namespace Barotrauma.Networking
try
{
eventType = (NetworkEventType)message.ReadByte();
eventType = (NetworkEventType)message.ReadRangedInteger(0, Enum.GetValues(typeof(NetworkEventType)).Length);
id = message.ReadUInt16();
}
catch

View File

@@ -188,7 +188,9 @@ namespace Barotrauma.Networking.ReliableMessages
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;
}
}
@@ -246,8 +248,9 @@ namespace Barotrauma.Networking.ReliableMessages
receiver.SendMessage(resendRequest, recipient,
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++;
}