Cargo spawns at the floor of the cargo room, item configs are fetched from the prefab instead of reloading the config files every time when placing an item
This commit is contained in:
@@ -69,12 +69,14 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
//Vector2 position = new Vector2(
|
||||
// Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20, false),
|
||||
// cargoRoom.Rect.Y - cargoRoom.Rect.Height + 10.0f);
|
||||
Vector2 position = new Vector2(
|
||||
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
|
||||
cargoRoom.Rect.Y - cargoRoom.Rect.Height + 16.0f);
|
||||
|
||||
var item = new Item(itemPrefab, cargoSpawnPos.Position + Rand.Vector(10.0f, false), cargoRoom.Submarine);
|
||||
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
|
||||
item.FindHull();
|
||||
|
||||
|
||||
items.Add(item);
|
||||
|
||||
if (parent != null) parent.Combine(item);
|
||||
|
||||
@@ -325,20 +325,9 @@ namespace Barotrauma
|
||||
|
||||
condition = 100.0f;
|
||||
|
||||
XElement element = ToolBox.TryLoadXml(Prefab.ConfigFile).Root;
|
||||
XElement element = prefab.ConfigElement;
|
||||
if (element == null) return;
|
||||
|
||||
if (ToolBox.GetAttributeString(element, "name", "") != Name)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (ToolBox.GetAttributeString(subElement, "name", "") != Name) continue;
|
||||
|
||||
element = subElement;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
properties = ObjectProperty.InitProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
|
||||
@@ -52,6 +52,12 @@ namespace Barotrauma
|
||||
get { return configFile; }
|
||||
}
|
||||
|
||||
public XElement ConfigElement
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public List<DeconstructItem> DeconstructItems
|
||||
{
|
||||
get;
|
||||
@@ -203,6 +209,7 @@ namespace Barotrauma
|
||||
public ItemPrefab (XElement element, string filePath)
|
||||
{
|
||||
configFile = filePath;
|
||||
ConfigElement = element;
|
||||
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!");
|
||||
|
||||
Reference in New Issue
Block a user