Setting ragdoll position without limbs going through walls, rotating entire ragdoll, using combined network messages client->server, fixed fabricators

This commit is contained in:
Regalis
2015-11-08 22:20:29 +02:00
parent 5a21d64b3a
commit cd48d12be6
31 changed files with 551 additions and 313 deletions

View File

@@ -449,6 +449,8 @@ namespace Barotrauma
if (Submarine.Loaded != null && Submarine.Loaded.GodMode) return;
if (!prefab.HasBody) return;
if (!MathUtils.IsValid(damage)) return;
if (damage != sections[sectionIndex].damage && Math.Abs(sections[sectionIndex].lastSentDamage - damage)>5.0f)
{
new NetworkEvent(NetworkEventType.WallDamage, ID, false);
@@ -640,9 +642,16 @@ namespace Barotrauma
{
message.Write((float)NetTime.Now);
for (int i = 0; i < sections.Length; i++)
var updateSections = Array.FindAll(sections, s => s != null && Math.Abs(s.damage - s.lastSentDamage)/Health > 0.01f);
if (updateSections.Length == 0) return false;
Debug.Assert(updateSections.Length<255);
message.Write((byte)updateSections.Length);
for (int i = 0; i < updateSections.Length; i++)
{
if (Math.Abs(sections[i].damage - sections[i].lastSentDamage) < 0.1f) continue;
message.Write((byte)i);
message.WriteRangedSingle(sections[i].damage / Health, 0.0f, 1.0f, 8);
@@ -652,16 +661,22 @@ namespace Barotrauma
return true;
}
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
{
data = null;
float updateTime = message.ReadFloat();
if (updateTime < lastUpdate) return;
while (message.Position <= message.LengthBits-8)
int sectionCount = message.ReadByte();
for (int i = 0; i<sectionCount; i++)
{
byte sectionIndex = message.ReadByte();
float damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health;
if (sectionIndex < 0 || sectionIndex >= sections.Length) continue;
SetDamage(sectionIndex, damage);
}
}