This commit is contained in:
Regalis
2015-12-04 01:37:30 +02:00
parent c064c5eb50
commit 242af12f14
25 changed files with 200 additions and 109 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ namespace Barotrauma.Items.Components
linkedGap = e as Gap;
if (linkedGap != null) return linkedGap;
}
linkedGap = new Gap(item.Rect);
linkedGap = new Gap(item.Rect, Item.Submarine);
linkedGap.Open = openState;
item.linkedTo.Add(linkedGap);
return linkedGap;
+23 -8
View File
@@ -255,13 +255,14 @@ namespace Barotrauma
//}
public Item(ItemPrefab itemPrefab, Vector2 position)
: this(new Rectangle((int)position.X, (int)position.Y, (int)itemPrefab.sprite.size.X, (int)itemPrefab.sprite.size.Y), itemPrefab)
public Item(ItemPrefab itemPrefab, Vector2 position, Submarine submarine)
: this(new Rectangle((int)position.X, (int)position.Y, (int)itemPrefab.sprite.size.X, (int)itemPrefab.sprite.size.Y), itemPrefab, submarine)
{
}
public Item(Rectangle newRect, ItemPrefab itemPrefab)
public Item(Rectangle newRect, ItemPrefab itemPrefab, Submarine submarine)
: base(submarine)
{
prefab = itemPrefab;
@@ -409,6 +410,10 @@ namespace Barotrauma
public virtual Hull FindHull()
{
CurrentHull = Hull.FindHull((body == null) ? Position : ConvertUnits.ToDisplayUnits(body.SimPosition), CurrentHull);
if (body!=null)
{
body.Submarine = CurrentHull == null ? null : Submarine.Loaded;
}
return CurrentHull;
}
@@ -598,7 +603,16 @@ namespace Barotrauma
{
if (body == null)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X+rect.Width/2, -DrawPosition.Y-rect.Height/2), new Vector2(rect.Width, rect.Height), color);
}
else
{
prefab.sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color);
}
}
else if (body.Enabled)
{
@@ -615,7 +629,7 @@ namespace Barotrauma
depth = holdable.Picker.AnimController.GetLimb(LimbType.LeftArm).sprite.Depth - 0.000001f;
}
body.Draw(spriteBatch, prefab.sprite, color, depth);
body.Draw(spriteBatch, prefab.sprite, color, depth);
}
else
{
@@ -1159,8 +1173,8 @@ namespace Barotrauma
return element;
}
public static void Load(XElement element)
{
public static void Load(XElement element, Submarine submarine)
{
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
string[] rectValues = rectString.Split(',');
Rectangle rect = Rectangle.Empty;
@@ -1195,7 +1209,8 @@ namespace Barotrauma
rect.Height = (int)ip.Size.Y;
}
Item item = new Item(rect, ip);
Item item = new Item(rect, ip, submarine);
item.Submarine = submarine;
item.ID = (ushort)int.Parse(element.Attribute("ID").Value);
item.linkedToID = new List<ushort>();
+2 -2
View File
@@ -83,7 +83,7 @@ namespace Barotrauma
{
if (PlayerInput.LeftButtonClicked())
{
new Item(new Rectangle((int)position.X, (int)position.Y, (int)sprite.size.X, (int)sprite.size.Y), this);
new Item(new Rectangle((int)position.X, (int)position.Y, (int)sprite.size.X, (int)sprite.size.Y), this, Submarine.Loaded);
//constructor.Invoke(lobject);
placePosition = Vector2.Zero;
@@ -112,7 +112,7 @@ namespace Barotrauma
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
{
new Item(new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y), this);
new Item(new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y), this, Submarine.Loaded);
placePosition = Vector2.Zero;
//selected = null;
return;
+2 -1
View File
@@ -30,7 +30,8 @@ namespace Barotrauma
{
var itemInfo = spawnQueue.Dequeue();
new Item(itemInfo.First, itemInfo.Second);
//!!!!!!!!!!!!!!!!!!!!!!
new Item(itemInfo.First, itemInfo.Second, null);
}
}
}