Wires can be cloned and moved if both items it's connected to are selected
This commit is contained in:
@@ -267,7 +267,7 @@ namespace Barotrauma.Items.Components
|
||||
item.NewComponentEvent(this, true, true);
|
||||
}
|
||||
|
||||
Drawable = Nodes.Any();
|
||||
Drawable = sections.Count > 0;
|
||||
}
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
@@ -277,6 +277,20 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
{
|
||||
if (item.IsSelected) MoveNodes(amount);
|
||||
}
|
||||
|
||||
public void MoveNodes(Vector2 amount)
|
||||
{
|
||||
for (int i = 0; i < Nodes.Count; i++)
|
||||
{
|
||||
Nodes[i] += amount;
|
||||
}
|
||||
UpdateSections();
|
||||
}
|
||||
|
||||
public void UpdateSections()
|
||||
{
|
||||
sections.Clear();
|
||||
@@ -285,6 +299,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
sections.Add(new WireSection(Nodes[i], Nodes[i + 1]));
|
||||
}
|
||||
Drawable = sections.Count > 0;
|
||||
}
|
||||
|
||||
private void ClearConnections()
|
||||
@@ -303,7 +318,7 @@ namespace Barotrauma.Items.Components
|
||||
connections[i] = null;
|
||||
}
|
||||
|
||||
Drawable = false;
|
||||
Drawable = sections.Count > 0;
|
||||
}
|
||||
|
||||
private Vector2 RoundNode(Vector2 position, Hull hull)
|
||||
@@ -365,7 +380,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (!Nodes.Any())
|
||||
if (sections.Count == 0)
|
||||
{
|
||||
Drawable = false;
|
||||
return;
|
||||
@@ -386,6 +401,13 @@ namespace Barotrauma.Items.Components
|
||||
section.Draw(spriteBatch, Color.Gold, drawOffset, depth, 0.5f);
|
||||
}
|
||||
}
|
||||
else if (item.IsSelected)
|
||||
{
|
||||
foreach (WireSection section in sections)
|
||||
{
|
||||
section.Draw(spriteBatch, Color.Red, drawOffset, depth, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (WireSection section in sections)
|
||||
{
|
||||
|
||||
@@ -423,12 +423,21 @@ namespace Barotrauma
|
||||
clone.properties[property.Key].TrySetValue(property.Value.GetValue());
|
||||
}
|
||||
|
||||
if (ContainedItems!=null)
|
||||
for (int i = 0; i < components.Count; i++)
|
||||
{
|
||||
foreach (KeyValuePair<string, ObjectProperty> property in components[i].properties)
|
||||
{
|
||||
if (!property.Value.Attributes.OfType<Editable>().Any()) continue;
|
||||
clone.components[i].properties[property.Key].TrySetValue(property.Value.GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (ContainedItems != null)
|
||||
{
|
||||
foreach (Item containedItem in ContainedItems)
|
||||
{
|
||||
var containedClone = containedItem.Clone();
|
||||
clone.ownInventory.TryPutItem(containedItem);
|
||||
clone.ownInventory.TryPutItem(containedClone as Item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,7 +889,7 @@ namespace Barotrauma
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (!Visible) return;
|
||||
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
||||
Color color = (IsSelected && editing) ? color = Color.Red : spriteColor;
|
||||
if (isHighlighted) color = Color.Orange;
|
||||
|
||||
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||
@@ -943,7 +952,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSelected || isHighlighted)
|
||||
if (IsSelected || isHighlighted)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), Color.Green,false,0,(int)Math.Max((1.5f/GameScreen.Selected.Cam.Zoom),1.0f));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user