Items/structures can be copied by holding ctrl in the editor

This commit is contained in:
Regalis
2016-11-11 17:37:03 +02:00
parent 96cedd67f1
commit e6b2919877
4 changed files with 70 additions and 22 deletions
+22
View File
@@ -413,6 +413,28 @@ namespace Barotrauma
ItemList.Add(this);
}
public override MapEntity Clone()
{
Item clone = new Item(rect, prefab, Submarine);
foreach (KeyValuePair<string, ObjectProperty> property in properties)
{
if (!property.Value.Attributes.OfType<Editable>().Any()) continue;
clone.properties[property.Key].TrySetValue(property.Value.GetValue());
}
if (ContainedItems!=null)
{
foreach (Item containedItem in ContainedItems)
{
var containedClone = containedItem.Clone();
clone.ownInventory.TryPutItem(containedItem);
}
}
return clone;
}
public T GetComponent<T>()
{
foreach (ItemComponent ic in components)