diff --git a/Subsurface/Content/UI/inventoryIcons.png b/Subsurface/Content/UI/inventoryIcons.png new file mode 100644 index 000000000..c4c5339c4 Binary files /dev/null and b/Subsurface/Content/UI/inventoryIcons.png differ diff --git a/Subsurface/Items/CharacterInventory.cs b/Subsurface/Items/CharacterInventory.cs index e924accb7..966ec7802 100644 --- a/Subsurface/Items/CharacterInventory.cs +++ b/Subsurface/Items/CharacterInventory.cs @@ -13,16 +13,54 @@ namespace Subsurface class CharacterInventory : Inventory { + private static Texture2D icons; + private Character character; private static LimbSlot[] limbSlots = new LimbSlot[] { - LimbSlot.Head, LimbSlot.Torso, LimbSlot.LeftHand, LimbSlot.RightHand, LimbSlot.Legs, + LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any }; + private Vector2[] slotPositions; + public CharacterInventory(int capacity, Character character) : base(capacity) { this.character = character; + + if (icons == null) icons = Game1.textureLoader.FromFile("Content/UI/inventoryIcons.png"); + + slotPositions = new Vector2[limbSlots.Length]; + + + int rectWidth = 40, rectHeight = 40; + int spacing = 10; + for (int i = 0; i < slotPositions.Length; i++) + { + switch (i) + { + //head, torso, legs + case 0: + case 1: + case 2: + slotPositions[i] = new Vector2( + spacing, + Game1.GraphicsHeight - (spacing + rectHeight) * (3 - i)); + break; + //lefthand, righthand + case 3: + case 4: + slotPositions[i] = new Vector2( + spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 3), + Game1.GraphicsHeight - (spacing + rectHeight)); + break; + default: + slotPositions[i] = new Vector2( + spacing * (4 + (i - 5)) + rectWidth * (3 + (i - 5)), + Game1.GraphicsHeight - (spacing + rectHeight)); + break; + } + } } protected override void DropItem(Item item) @@ -181,47 +219,38 @@ namespace Subsurface doubleClickedItem = null; int rectWidth = 40, rectHeight = 40; - - int spacing = 10; - Rectangle slotRect = new Rectangle(0, 0, rectWidth, rectHeight); Rectangle draggingItemSlot = slotRect; for (int i = 0; i < capacity; i++) { - int x, y; - switch (i) - { - //head - case 0: - //legs - case 4: - x = spacing * 2 + rectWidth; - y = Game1.GraphicsHeight - (spacing + rectHeight) * ((i == 0) ? 3 : 1); - break; - //lefthand - case 2: - //torso - case 1: - //righthand - case 3: - x = spacing; - if (i == 1) x += (spacing + rectWidth); - if (i == 3) x += (spacing + rectWidth) * 2; - y = Game1.GraphicsHeight - (spacing + rectHeight) * 2; - break; - default: - x = spacing * (4 + (i - 5)) + rectWidth * (3 + (i - 5)); - y = Game1.GraphicsHeight - (spacing + rectHeight); - break; - } + slotRect.X = (int)slotPositions[i].X; + slotRect.Y = (int)slotPositions[i].Y; + + if (i==1) //head + { + spriteBatch.Draw(icons, new Vector2(slotRect.Center.X, slotRect.Center.Y), + new Rectangle(0,0,56,128), Color.White*0.7f, 0.0f, + new Vector2(28.0f, 64.0f), Vector2.One, + SpriteEffects.None, 0.1f); + } + else if (i==3 || i==4) + { + spriteBatch.Draw(icons, new Vector2(slotRect.Center.X, slotRect.Center.Y), + new Rectangle(92, 41*(4-i), 36, 40), Color.White * 0.7f, 0.0f, + new Vector2(18.0f, 20.0f), Vector2.One, + SpriteEffects.None, 0.1f); + } + } + + for (int i = 0; i < capacity; i++) + { + slotRect.X = (int)slotPositions[i].X; + slotRect.Y = (int)slotPositions[i].Y; - slotRect.X = x; - slotRect.Y = y; UpdateSlot(spriteBatch, slotRect, i, items[i], false); if (draggingItem!=null && draggingItem == items[i]) draggingItemSlot = slotRect; - } if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition)) diff --git a/Subsurface/Items/Components/Power/PowerTransfer.cs b/Subsurface/Items/Components/Power/PowerTransfer.cs index 238780802..961ef0a0a 100644 --- a/Subsurface/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Items/Components/Power/PowerTransfer.cs @@ -141,9 +141,9 @@ namespace Subsurface.Items.Components { base.ReceiveSignal(signal, connection, sender, power); - if (connection.Name=="signal") + if (connection.Name == "signal") { - connection.SendSignal(signal, item, 0.0f); + connection.SendSignal(signal, sender, 0.0f); } } diff --git a/Subsurface/Items/Components/Signal/Connection.cs b/Subsurface/Items/Components/Signal/Connection.cs index 695da00ed..efd2536a4 100644 --- a/Subsurface/Items/Components/Signal/Connection.cs +++ b/Subsurface/Items/Components/Signal/Connection.cs @@ -143,6 +143,7 @@ namespace Subsurface.Items.Components Connection recipient = Wires[i].OtherConnection(this); if (recipient == null) continue; + if (recipient.item == this.item || recipient.item == sender) continue; foreach (ItemComponent ic in recipient.item.components) { diff --git a/Subsurface/Items/Components/Signal/Wire.cs b/Subsurface/Items/Components/Signal/Wire.cs index c50649956..5cb2bb011 100644 --- a/Subsurface/Items/Components/Signal/Wire.cs +++ b/Subsurface/Items/Components/Signal/Wire.cs @@ -89,11 +89,22 @@ namespace Subsurface.Items.Components if (connections[0] != null && connections[1] != null) { - item.Drop(null, false); + //List prevNodes = new List(Nodes); + + + foreach (ItemComponent ic in item.components) + { + if (ic == this) continue; + ic.Drop(null); + } + if (item.container != null) item.container.RemoveContained(this.item); + + item.body.Enabled = false; isActive = false; + //Nodes = prevNodes; CleanNodes(); } @@ -114,6 +125,13 @@ namespace Subsurface.Items.Components isActive = false; } + public override void Drop(Character dropper) + { + ClearConnections(); + + isActive = false; + } + public override void Update(float deltaTime, Camera cam) { if (Nodes.Count == 0) return; diff --git a/Subsurface/Items/Item.cs b/Subsurface/Items/Item.cs index 23c0b003c..6c7c91fff 100644 --- a/Subsurface/Items/Item.cs +++ b/Subsurface/Items/Item.cs @@ -714,7 +714,7 @@ namespace Subsurface if (Vector2.Distance(position, item.SimPosition) > item.prefab.PickDistance) continue; dist = Vector2.Distance(pickPosition, item.SimPosition); - if ((closest == null || dist < closestDist) && Submarine.CheckVisibility(position, item.SimPosition)==null) + if ((closest == null || dist < closestDist)) { closest = item; closestDist = dist; diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index d51d48407..a45191f9c 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -404,6 +404,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest Designer diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index a4567604d..92cc73001 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ