diff --git a/Subsurface/Content/Items/Containers/containers.xml b/Subsurface/Content/Items/Containers/containers.xml index 53d8a3c4d..b892ccd08 100644 --- a/Subsurface/Content/Items/Containers/containers.xml +++ b/Subsurface/Content/Items/Containers/containers.xml @@ -4,7 +4,7 @@ linkable="true" pickdistance ="150"> - + @@ -16,7 +16,7 @@ linkable="true" pickdistance ="150"> - + @@ -29,7 +29,7 @@ linkable="true" pickdistance ="150"> - + diff --git a/Subsurface/Content/Map/StructurePrefabs.xml b/Subsurface/Content/Map/StructurePrefabs.xml index 243d0625f..edeb72c34 100644 --- a/Subsurface/Content/Map/StructurePrefabs.xml +++ b/Subsurface/Content/Map/StructurePrefabs.xml @@ -21,31 +21,31 @@ description="A decorative structure with no collision detection" width = "32" height ="128" resizevertical="true"/> - - - - - - - - - - - - + + + + + + + + + - - - + + + - - diff --git a/Subsurface/Content/Map/testroom.png b/Subsurface/Content/Map/testroom.png index 164744960..00f2787d5 100644 Binary files a/Subsurface/Content/Map/testroom.png and b/Subsurface/Content/Map/testroom.png differ diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index ca7dde0cc..207edfa6d 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -454,7 +454,7 @@ namespace Barotrauma { MapEntity me = MapEntity.mapEntityList[i]; - if (me.SimPosition.Length()>200.0f) + if (me.SimPosition.Length()>2000.0f) { DebugConsole.NewMessage("Removed "+me.Name+" (simposition "+me.SimPosition+")", Color.Orange); MapEntity.mapEntityList.RemoveAt(i); @@ -464,6 +464,19 @@ namespace Barotrauma DebugConsole.NewMessage("Removed " + me.Name + " (MoveWithLevel==true)", Color.Orange); MapEntity.mapEntityList.RemoveAt(i); } + else if (me is Item) + { + Item item = me as Item; + var wire = item.GetComponent(); + if (wire == null) continue; + + if (wire.Nodes.Any() && !wire.Connections.Any(c => c != null)) + { + wire.Item.Drop(null); + DebugConsole.NewMessage("Dropped wire (ID: "+wire.Item.ID+") - attached on wall but no connections found", Color.Orange); + } + } + } break; case "messagebox": diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index 80f6070d6..b31d39bb9 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -118,6 +118,26 @@ namespace Barotrauma.Items.Components loadedConnections[i].wireId.CopyTo(Connections[i].wireId, 0); } } + + protected override void RemoveComponentSpecific() + { + foreach (Connection c in Connections) + { + foreach (Wire wire in c.Wires) + { + if (wire == null) continue; + + if (wire.OtherConnection(c) == null) //wire not connected to anything else + { + wire.Item.Drop(null); + } + else + { + wire.RemoveConnection(item); + } + } + } + } public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) { diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index 36b9c7317..daa21b21b 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -23,6 +23,11 @@ namespace Barotrauma.Items.Components private static Wire draggingWire; private static int? selectedNodeIndex; + + public Connection[] Connections + { + get { return connections; } + } public Wire(Item item, XElement element) : base(item, element) diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 5c967f7bb..169794a58 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -857,22 +857,25 @@ namespace Barotrauma return; } - GUI.DrawRectangle(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), Color.Green); - - foreach (Rectangle t in prefab.Triggers) + if (isSelected || isHighlighted) { - Rectangle transformedTrigger = TransformTrigger(t); + GUI.DrawRectangle(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), Color.Green); - Vector2 rectWorldPos = new Vector2(transformedTrigger.X, transformedTrigger.Y); - if (Submarine!=null) rectWorldPos += Submarine.Position; - rectWorldPos.Y = -rectWorldPos.Y; + foreach (Rectangle t in prefab.Triggers) + { + Rectangle transformedTrigger = TransformTrigger(t); - GUI.DrawRectangle(spriteBatch, - rectWorldPos, - new Vector2(transformedTrigger.Width, transformedTrigger.Height), - Color.Green); + Vector2 rectWorldPos = new Vector2(transformedTrigger.X, transformedTrigger.Y); + if (Submarine!=null) rectWorldPos += Submarine.Position; + rectWorldPos.Y = -rectWorldPos.Y; + + GUI.DrawRectangle(spriteBatch, + rectWorldPos, + new Vector2(transformedTrigger.Width, transformedTrigger.Height), + Color.Green); + } } - + if (!ShowLinks) return; foreach (MapEntity e in linkedTo) diff --git a/Subsurface/Source/Map/MapEntity.cs b/Subsurface/Source/Map/MapEntity.cs index bb9453d03..0e9867f99 100644 --- a/Subsurface/Source/Map/MapEntity.cs +++ b/Subsurface/Source/Map/MapEntity.cs @@ -291,20 +291,23 @@ namespace Barotrauma MapEntity highLightedEntity = null; - foreach (MapEntity e in mapEntityList) + if (startMovingPos == Vector2.Zero) { - if (!e.SelectableInEditor) continue; - - if (highLightedEntity == null || e.Sprite == null || - (highLightedEntity.Sprite!=null && e.Sprite.Depth < highLightedEntity.Sprite.Depth)) + foreach (MapEntity e in mapEntityList) { + if (!e.SelectableInEditor) continue; - if (e.IsMouseOn(position)) highLightedEntity = e; + if (highLightedEntity == null || e.Sprite == null || + (highLightedEntity.Sprite != null && e.Sprite.Depth < highLightedEntity.Sprite.Depth)) + { + if (e.IsMouseOn(position)) highLightedEntity = e; + } + e.isSelected = false; } - e.isSelected = false; - } - if (highLightedEntity != null) highLightedEntity.isHighlighted = true; + if (highLightedEntity != null) highLightedEntity.isHighlighted = true; + + } foreach (MapEntity e in selectedList) { @@ -551,13 +554,6 @@ namespace Barotrauma { resizing = false; } - - //if (resizeHorizontal) placeSize.X = position.X - placePosition.X; - //if (resizeVertical) placeSize.Y = placePosition.Y - position.Y; - - //Rectangle newRect = Submarine.AbsRect(placePosition, placeSize); - //newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X); - //newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y); } }