(cef39af84) Fixed server creating "attempted to create a network event for an item that hasn't been fully initialized yet" console errors when spawning LightComponents mid-round. + Simplified ragdoll collider null check

This commit is contained in:
Joonas Rikkonen
2019-04-03 16:21:06 +03:00
parent e4eb6c131c
commit 5d7dba0f70
2 changed files with 13 additions and 3 deletions
@@ -110,7 +110,7 @@ namespace Barotrauma
{
get
{
return collider == null ? null : collider[colliderIndex];
return collider?[colliderIndex];
}
}
@@ -22,6 +22,10 @@ namespace Barotrauma.Items.Components
private float blinkTimer;
private bool itemLoaded;
private float blinkTimer;
public PhysicsBody ParentBody;
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]
@@ -77,7 +81,7 @@ namespace Barotrauma.Items.Components
IsActive = value;
#if SERVER
if (GameMain.Server != null && GameMain.Server.GameStarted) { item.CreateServerEvent(this); }
if (GameMain.Server != null && itemLoaded) { item.CreateServerEvent(this); }
#endif
}
}
@@ -156,7 +160,13 @@ namespace Barotrauma.Items.Components
IsActive = IsOn;
item.AddTag("light");
}
public override void OnItemLoaded()
{
base.OnItemLoaded();
itemLoaded = true;
}
public override void Update(float deltaTime, Camera cam)
{
UpdateOnActiveEffects(deltaTime);