Item connections are cached in the Item constructor instead of OnMapLoaded (-> buttons created mid-round work now)
This commit is contained in:
@@ -408,15 +408,27 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//cache connections into a dictionary for faster lookups
|
||||||
|
var connectionPanel = GetComponent<ConnectionPanel>();
|
||||||
|
if (connectionPanel != null)
|
||||||
|
{
|
||||||
|
connections = new Dictionary<string, Connection>();
|
||||||
|
foreach (Connection c in connectionPanel.Connections)
|
||||||
|
{
|
||||||
|
if (!connections.ContainsKey(c.Name))
|
||||||
|
connections.Add(c.Name, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//containers need to handle collision events to notify items inside them about the impact
|
//containers need to handle collision events to notify items inside them about the impact
|
||||||
if (ImpactTolerance > 0.0f || GetComponent<ItemContainer>() != null)
|
var itemContainer = GetComponent<ItemContainer>();
|
||||||
|
if (ImpactTolerance > 0.0f || itemContainer != null)
|
||||||
{
|
{
|
||||||
if (body != null) body.FarseerBody.OnCollision += OnCollision;
|
if (body != null) body.FarseerBody.OnCollision += OnCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemContainer = GetComponent<ItemContainer>();
|
if (itemContainer != null)
|
||||||
if (itemContainer!=null)
|
|
||||||
{
|
{
|
||||||
ownInventory = itemContainer.Inventory;
|
ownInventory = itemContainer.Inventory;
|
||||||
}
|
}
|
||||||
@@ -2244,17 +2256,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
ic.OnMapLoaded();
|
ic.OnMapLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
//cache connections into a dictionary for faster lookups
|
|
||||||
var connectionPanel = GetComponent<ConnectionPanel>();
|
|
||||||
connections = new Dictionary<string, Connection>();
|
|
||||||
|
|
||||||
if (connectionPanel == null) return;
|
|
||||||
foreach (Connection c in connectionPanel.Connections)
|
|
||||||
{
|
|
||||||
if (!connections.ContainsKey(c.Name))
|
|
||||||
connections.Add(c.Name, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user