(5b697f37f) Link the door and the gap even more strictly. It shouldn't be possible to destroy or move the other without moving the other. Fixes #1528.
This commit is contained in:
@@ -483,6 +483,26 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (selectedList.Contains(entity)) { return; }
|
if (selectedList.Contains(entity)) { return; }
|
||||||
selectedList.Add(entity);
|
selectedList.Add(entity);
|
||||||
|
HandleDoorGapLinks(entity,
|
||||||
|
onGapFound: (door, gap) =>
|
||||||
|
{
|
||||||
|
door.RefreshLinkedGap();
|
||||||
|
if (!selectedList.Contains(gap))
|
||||||
|
{
|
||||||
|
selectedList.Add(gap);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDoorFound: (door, gap) =>
|
||||||
|
{
|
||||||
|
if (!selectedList.Contains(door.Item))
|
||||||
|
{
|
||||||
|
selectedList.Add(door.Item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleDoorGapLinks(MapEntity entity, Action<Door, Gap> onGapFound, Action<Door, Gap> onDoorFound)
|
||||||
|
{
|
||||||
if (entity is Item i)
|
if (entity is Item i)
|
||||||
{
|
{
|
||||||
var door = i.GetComponent<Door>();
|
var door = i.GetComponent<Door>();
|
||||||
@@ -491,31 +511,26 @@ namespace Barotrauma
|
|||||||
var gap = door.LinkedGap;
|
var gap = door.LinkedGap;
|
||||||
if (gap != null)
|
if (gap != null)
|
||||||
{
|
{
|
||||||
door.RefreshLinkedGap();
|
onGapFound(door, gap);
|
||||||
if (!selectedList.Contains(gap))
|
|
||||||
{
|
|
||||||
selectedList.Add(gap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (entity is Gap gap)
|
||||||
|
{
|
||||||
|
var door = gap.ConnectedDoor;
|
||||||
|
if (door != null)
|
||||||
|
{
|
||||||
|
onDoorFound(door, gap);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveSelection(MapEntity entity)
|
public static void RemoveSelection(MapEntity entity)
|
||||||
{
|
{
|
||||||
selectedList.Remove(entity);
|
selectedList.Remove(entity);
|
||||||
if (entity is Item i)
|
HandleDoorGapLinks(entity,
|
||||||
{
|
onGapFound: (door, gap) => selectedList.Remove(gap),
|
||||||
var door = i.GetComponent<Door>();
|
onDoorFound: (door, gap) => selectedList.Remove(door.Item));
|
||||||
if (door != null)
|
|
||||||
{
|
|
||||||
var gap = door.LinkedGap;
|
|
||||||
if (gap != null)
|
|
||||||
{
|
|
||||||
selectedList.Remove(gap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static partial void UpdateAllProjSpecific(float deltaTime)
|
static partial void UpdateAllProjSpecific(float deltaTime)
|
||||||
@@ -585,12 +600,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void UpdateEditor(Camera cam)
|
public static void UpdateEditor(Camera cam)
|
||||||
{
|
{
|
||||||
FilteredSelectedList.Clear();
|
|
||||||
if (highlightedListBox != null) highlightedListBox.UpdateManually((float)Timing.Step);
|
if (highlightedListBox != null) highlightedListBox.UpdateManually((float)Timing.Step);
|
||||||
|
|
||||||
if (editingHUD != null)
|
if (editingHUD != null)
|
||||||
{
|
{
|
||||||
if (selectedList.Count == 0 || editingHUD.UserData != selectedList[0])
|
if (FilteredSelectedList.Count == 0 || editingHUD.UserData != FilteredSelectedList[0])
|
||||||
{
|
{
|
||||||
foreach (GUIComponent component in editingHUD.Children)
|
foreach (GUIComponent component in editingHUD.Children)
|
||||||
{
|
{
|
||||||
@@ -601,7 +615,7 @@ namespace Barotrauma
|
|||||||
editingHUD = null;
|
editingHUD = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FilteredSelectedList.Clear();
|
||||||
if (selectedList.Count == 0) return;
|
if (selectedList.Count == 0) return;
|
||||||
foreach (var e in selectedList)
|
foreach (var e in selectedList)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user