Some new wall sprites, wires are automatically dropped if both items they're attached to are removed, other items aren't highlighted while dragging an item in editor
This commit is contained in:
@@ -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<Wire>();
|
||||
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":
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user