(ded4a3e0a) v0.9.0.7

This commit is contained in:
Joonas Rikkonen
2019-06-25 16:00:44 +03:00
parent e5ae622c77
commit 4a51db77b5
1777 changed files with 421528 additions and 917 deletions
@@ -367,14 +367,19 @@ namespace Barotrauma
foreach (MapEntity e in newSelection)
{
if (selectedList.Contains(e))
selectedList.Remove(e);
{
RemoveSelection(e);
}
else
selectedList.Add(e);
{
AddSelection(e);
}
}
}
else
{
selectedList = newSelection;
selectedList.Clear();
newSelection.ForEach(e => AddSelection(e));
}
//select wire if both items it's connected to are selected
@@ -457,9 +462,13 @@ namespace Barotrauma
PlayerInput.KeyDown(Keys.RightControl))
{
if (selectedList.Contains(entity))
selectedList.Remove(entity);
{
RemoveSelection(entity);
}
else
selectedList.Add(entity);
{
AddSelection(entity);
}
}
else
{
@@ -469,6 +478,60 @@ namespace Barotrauma
return true;
};
}
public static void AddSelection(MapEntity entity)
{
if (selectedList.Contains(entity)) { return; }
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)
{
var door = i.GetComponent<Door>();
if (door != null)
{
var gap = door.LinkedGap;
if (gap != null)
{
onGapFound(door, gap);
}
}
}
else if (entity is Gap gap)
{
var door = gap.ConnectedDoor;
if (door != null)
{
onDoorFound(door, gap);
}
}
}
public static void RemoveSelection(MapEntity entity)
{
selectedList.Remove(entity);
HandleDoorGapLinks(entity,
onGapFound: (door, gap) => selectedList.Remove(gap),
onDoorFound: (door, gap) => selectedList.Remove(door.Item));
}
static partial void UpdateAllProjSpecific(float deltaTime)
{
@@ -533,13 +596,15 @@ namespace Barotrauma
}
}
public static List<MapEntity> FilteredSelectedList { get; private set; } = new List<MapEntity>();
public static void UpdateEditor(Camera cam)
{
if (highlightedListBox != null) highlightedListBox.UpdateManually((float)Timing.Step);
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)
{
@@ -550,15 +615,20 @@ namespace Barotrauma
editingHUD = null;
}
}
FilteredSelectedList.Clear();
if (selectedList.Count == 0) return;
if (selectedList.Count == 1)
foreach (var e in selectedList)
{
selectedList[0].UpdateEditing(cam);
if (selectedList[0].ResizeHorizontal || selectedList[0].ResizeVertical)
if (e is Gap) { continue; }
FilteredSelectedList.Add(e);
}
var first = FilteredSelectedList.FirstOrDefault();
if (first != null)
{
first.UpdateEditing(cam);
if (first.ResizeHorizontal || first.ResizeVertical)
{
selectedList[0].UpdateResizing(cam);
first.UpdateResizing(cam);
}
}
@@ -622,12 +692,10 @@ namespace Barotrauma
selectedList.Clear();
}
public static void SelectEntity(MapEntity entity)
{
DeselectAll();
selectedList.Add(entity);
AddSelection(entity);
}
/// <summary>