(c224aa4f4) Refresh the size of the linked gap when a door's scale is changed
This commit is contained in:
@@ -170,14 +170,14 @@ namespace Barotrauma.Items.Components
|
|||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Door(Item item, XElement element)
|
public Door(Item item, XElement element)
|
||||||
: base(item, element)
|
: base(item, element)
|
||||||
{
|
{
|
||||||
IsHorizontal = element.GetAttributeBool("horizontal", false);
|
IsHorizontal = element.GetAttributeBool("horizontal", false);
|
||||||
canBePicked = element.GetAttributeBool("canbepicked", false);
|
canBePicked = element.GetAttributeBool("canbepicked", false);
|
||||||
autoOrientGap = element.GetAttributeBool("autoorientgap", false);
|
autoOrientGap = element.GetAttributeBool("autoorientgap", false);
|
||||||
|
|
||||||
foreach (XElement subElement in element.Elements())
|
foreach (XElement subElement in element.Elements())
|
||||||
{
|
{
|
||||||
string texturePath = subElement.GetAttributeString("texture", "");
|
string texturePath = subElement.GetAttributeString("texture", "");
|
||||||
@@ -401,6 +401,18 @@ namespace Barotrauma.Items.Components
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnScaleChanged()
|
||||||
|
{
|
||||||
|
#if CLIENT
|
||||||
|
UpdateConvexHulls();
|
||||||
|
#endif
|
||||||
|
if (linkedGap != null)
|
||||||
|
{
|
||||||
|
RefreshLinkedGap();
|
||||||
|
linkedGap.Rect = item.Rect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void RemoveComponentSpecific()
|
protected override void RemoveComponentSpecific()
|
||||||
{
|
{
|
||||||
base.RemoveComponentSpecific();
|
base.RemoveComponentSpecific();
|
||||||
|
|||||||
@@ -693,6 +693,8 @@ namespace Barotrauma.Items.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnItemLoaded() { }
|
public virtual void OnItemLoaded() { }
|
||||||
|
|
||||||
|
public virtual void OnScaleChanged() { }
|
||||||
|
|
||||||
// TODO: Consider using generics, interfaces, or inheritance instead of reflection -> would be easier to debug when something changes/goes wrong.
|
// TODO: Consider using generics, interfaces, or inheritance instead of reflection -> would be easier to debug when something changes/goes wrong.
|
||||||
// For example, currently we can edit the constructors but they will fail in runtime because the parameters are not changed here.
|
// For example, currently we can edit the constructors but they will fail in runtime because the parameters are not changed here.
|
||||||
// It's also painful to find where the constructors are used, because the references exist only at runtime.
|
// It's also painful to find where the constructors are used, because the references exist only at runtime.
|
||||||
|
|||||||
@@ -217,6 +217,14 @@ namespace Barotrauma
|
|||||||
int newHeight = ResizeVertical ? rect.Height : (int)(defaultRect.Height * relativeScale);
|
int newHeight = ResizeVertical ? rect.Height : (int)(defaultRect.Height * relativeScale);
|
||||||
Rect = new Rectangle(rect.X, rect.Y, newWidth, newHeight);
|
Rect = new Rectangle(rect.X, rect.Y, newWidth, newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (components != null)
|
||||||
|
{
|
||||||
|
foreach (ItemComponent component in components)
|
||||||
|
{
|
||||||
|
component.OnScaleChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,20 +207,22 @@ namespace Barotrauma
|
|||||||
//clone links between the entities
|
//clone links between the entities
|
||||||
for (int i = 0; i < clones.Count; i++)
|
for (int i = 0; i < clones.Count; i++)
|
||||||
{
|
{
|
||||||
if (entitiesToClone[i].linkedTo == null) continue;
|
if (entitiesToClone[i].linkedTo == null) { continue; }
|
||||||
foreach (MapEntity linked in entitiesToClone[i].linkedTo)
|
foreach (MapEntity linked in entitiesToClone[i].linkedTo)
|
||||||
{
|
{
|
||||||
if (!entitiesToClone.Contains(linked)) continue;
|
if (!entitiesToClone.Contains(linked)) { continue; }
|
||||||
|
|
||||||
clones[i].linkedTo.Add(clones[entitiesToClone.IndexOf(linked)]);
|
clones[i].linkedTo.Add(clones[entitiesToClone.IndexOf(linked)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//connect clone wires to the clone items
|
//connect clone wires to the clone items and refresh links between doors and gaps
|
||||||
for (int i = 0; i < clones.Count; i++)
|
for (int i = 0; i < clones.Count; i++)
|
||||||
{
|
{
|
||||||
var cloneItem = clones[i] as Item;
|
var cloneItem = clones[i] as Item;
|
||||||
if (cloneItem == null) continue;
|
if (cloneItem == null) { continue; }
|
||||||
|
|
||||||
|
var door = cloneItem.GetComponent<Door>();
|
||||||
|
if (door != null) { door.RefreshLinkedGap(); }
|
||||||
|
|
||||||
var cloneWire = cloneItem.GetComponent<Wire>();
|
var cloneWire = cloneItem.GetComponent<Wire>();
|
||||||
if (cloneWire == null) continue;
|
if (cloneWire == null) continue;
|
||||||
@@ -231,7 +233,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
for (int n = 0; n < 2; n++)
|
for (int n = 0; n < 2; n++)
|
||||||
{
|
{
|
||||||
if (originalWire.Connections[n] == null) continue;
|
if (originalWire.Connections[n] == null) { continue; }
|
||||||
|
|
||||||
var connectedItem = originalWire.Connections[n].Item;
|
var connectedItem = originalWire.Connections[n].Item;
|
||||||
if (connectedItem == null) continue;
|
if (connectedItem == null) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user