Fixed wire drop/connect bugs, fixed powertransfer signal StackOverflowException, inventory icons
This commit is contained in:
BIN
Subsurface/Content/UI/inventoryIcons.png
Normal file
BIN
Subsurface/Content/UI/inventoryIcons.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -89,11 +89,22 @@ namespace Subsurface.Items.Components
|
||||
|
||||
if (connections[0] != null && connections[1] != null)
|
||||
{
|
||||
item.Drop(null, false);
|
||||
//List<Vector2> prevNodes = new List<Vector2>(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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -404,6 +404,9 @@
|
||||
<Content Include="Content\UI\caret.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\UI\inventoryIcons.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\UI\style.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
Reference in New Issue
Block a user