Character death syncing, characters don't reselect items when they receive a network msg about an item they have already selected
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Barotrauma
|
|||||||
AnimController.SimplePhysicsEnabled = false;
|
AnimController.SimplePhysicsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDead || Health <= 0.0f) return;
|
if (IsDead || Health <= 0.0f) return;
|
||||||
|
|
||||||
if (Controlled == this || !aiController.Enabled) return;
|
if (Controlled == this || !aiController.Enabled) return;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
base.DrawFront(spriteBatch,cam);
|
base.DrawFront(spriteBatch,cam);
|
||||||
|
|
||||||
if (GameMain.DebugDraw && !isDead) aiController.DebugDraw(spriteBatch);
|
if (GameMain.DebugDraw && !IsDead) aiController.DebugDraw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
|
public override void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private Dictionary<object, HUDProgressBar> hudProgressBars;
|
private Dictionary<object, HUDProgressBar> hudProgressBars;
|
||||||
|
|
||||||
protected bool isDead;
|
private bool isDead;
|
||||||
private CauseOfDeath lastAttackCauseOfDeath;
|
private CauseOfDeath lastAttackCauseOfDeath;
|
||||||
private CauseOfDeath causeOfDeath;
|
private CauseOfDeath causeOfDeath;
|
||||||
|
|
||||||
@@ -360,6 +360,8 @@ namespace Barotrauma
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!MathUtils.IsValid(value)) return;
|
if (!MathUtils.IsValid(value)) return;
|
||||||
|
if (GameMain.Client != null) return;
|
||||||
|
|
||||||
float newBleeding = MathHelper.Clamp(value, 0.0f, 5.0f);
|
float newBleeding = MathHelper.Clamp(value, 0.0f, 5.0f);
|
||||||
if (newBleeding == bleeding) return;
|
if (newBleeding == bleeding) return;
|
||||||
|
|
||||||
@@ -1888,6 +1890,7 @@ namespace Barotrauma
|
|||||||
PlaySound(CharacterSound.SoundType.Die);
|
PlaySound(CharacterSound.SoundType.Die);
|
||||||
|
|
||||||
isDead = true;
|
isDead = true;
|
||||||
|
|
||||||
this.causeOfDeath = causeOfDeath;
|
this.causeOfDeath = causeOfDeath;
|
||||||
AnimController.movement = Vector2.Zero;
|
AnimController.movement = Vector2.Zero;
|
||||||
AnimController.TargetMovement = Vector2.Zero;
|
AnimController.TargetMovement = Vector2.Zero;
|
||||||
@@ -2154,8 +2157,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else if (selectedEntity is Item)
|
else if (selectedEntity is Item)
|
||||||
{
|
{
|
||||||
selectedConstruction = (Item)selectedEntity;
|
var newSelectedConstruction = (Item)selectedEntity;
|
||||||
if (selectedConstruction != null) selectedConstruction.Pick(this, true, true);
|
if (newSelectedConstruction != null && selectedConstruction != newSelectedConstruction)
|
||||||
|
{
|
||||||
|
newSelectedConstruction.Pick(this, true, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2219,25 +2225,33 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.WriteRangedSingle(health, minHealth, maxHealth, 8);
|
msg.Write(isDead);
|
||||||
|
if (isDead)
|
||||||
msg.Write(oxygen < 100.0f);
|
|
||||||
if (oxygen < 100.0f)
|
|
||||||
{
|
{
|
||||||
msg.WriteRangedSingle(oxygen, -100.0f, 100.0f, 8);
|
msg.Write((byte)causeOfDeath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
msg.Write(bleeding > 0.0f);
|
|
||||||
if (bleeding > 0.0f)
|
|
||||||
{
|
{
|
||||||
msg.WriteRangedSingle(bleeding, 0.0f, 5.0f, 8);
|
msg.WriteRangedSingle(health, minHealth, maxHealth, 8);
|
||||||
}
|
|
||||||
|
|
||||||
msg.Write(Stun > 0.0f);
|
msg.Write(oxygen < 100.0f);
|
||||||
if (Stun > 0.0f)
|
if (oxygen < 100.0f)
|
||||||
{
|
{
|
||||||
Stun = MathHelper.Clamp(Stun, 0.0f, 60.0f);
|
msg.WriteRangedSingle(oxygen, -100.0f, 100.0f, 8);
|
||||||
msg.WriteRangedSingle(Stun, 0.0f, 60.0f, 8);
|
}
|
||||||
|
|
||||||
|
msg.Write(bleeding > 0.0f);
|
||||||
|
if (bleeding > 0.0f)
|
||||||
|
{
|
||||||
|
msg.WriteRangedSingle(bleeding, 0.0f, 5.0f, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.Write(Stun > 0.0f);
|
||||||
|
if (Stun > 0.0f)
|
||||||
|
{
|
||||||
|
Stun = MathHelper.Clamp(Stun, 0.0f, 60.0f);
|
||||||
|
msg.WriteRangedSingle(Stun, 0.0f, 60.0f, 8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2249,25 +2263,41 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
health = msg.ReadRangedSingle(minHealth, maxHealth, 8);
|
bool isDead = msg.ReadBoolean();
|
||||||
|
if (isDead)
|
||||||
bool lowOxygen = msg.ReadBoolean();
|
|
||||||
if (lowOxygen)
|
|
||||||
{
|
{
|
||||||
Oxygen = msg.ReadRangedSingle(-100.0f, 100.0f, 8);
|
causeOfDeath = (CauseOfDeath)msg.ReadByte();
|
||||||
|
if (causeOfDeath == CauseOfDeath.Pressure)
|
||||||
|
{
|
||||||
|
Implode(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Kill(causeOfDeath, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
bool isBleeding = msg.ReadBoolean();
|
|
||||||
if (isBleeding)
|
|
||||||
{
|
{
|
||||||
Bleeding = msg.ReadRangedSingle(0.0f, 5.0f, 8);
|
health = msg.ReadRangedSingle(minHealth, maxHealth, 8);
|
||||||
}
|
|
||||||
|
|
||||||
bool stunned = msg.ReadBoolean();
|
bool lowOxygen = msg.ReadBoolean();
|
||||||
if (stunned)
|
if (lowOxygen)
|
||||||
{
|
{
|
||||||
float newStunTimer = msg.ReadRangedSingle(0.0f, 60.0f, 8);
|
Oxygen = msg.ReadRangedSingle(-100.0f, 100.0f, 8);
|
||||||
StartStun(newStunTimer, true);
|
}
|
||||||
|
|
||||||
|
bool isBleeding = msg.ReadBoolean();
|
||||||
|
if (isBleeding)
|
||||||
|
{
|
||||||
|
bleeding = msg.ReadRangedSingle(0.0f, 5.0f, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stunned = msg.ReadBoolean();
|
||||||
|
if (stunned)
|
||||||
|
{
|
||||||
|
float newStunTimer = msg.ReadRangedSingle(0.0f, 60.0f, 8);
|
||||||
|
StartStun(newStunTimer, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user