diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index a6d46d672..a2eae6222 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -408,15 +408,27 @@ namespace Barotrauma break; } } - + + //cache connections into a dictionary for faster lookups + var connectionPanel = GetComponent(); + if (connectionPanel != null) + { + connections = new Dictionary(); + 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 - if (ImpactTolerance > 0.0f || GetComponent() != null) + var itemContainer = GetComponent(); + if (ImpactTolerance > 0.0f || itemContainer != null) { if (body != null) body.FarseerBody.OnCollision += OnCollision; } - var itemContainer = GetComponent(); - if (itemContainer!=null) + if (itemContainer != null) { ownInventory = itemContainer.Inventory; } @@ -2244,17 +2256,6 @@ namespace Barotrauma { ic.OnMapLoaded(); } - - //cache connections into a dictionary for faster lookups - var connectionPanel = GetComponent(); - connections = new Dictionary(); - - if (connectionPanel == null) return; - foreach (Connection c in connectionPanel.Connections) - { - if (!connections.ContainsKey(c.Name)) - connections.Add(c.Name, c); - } }