(776291eb7) Create linked gaps when the door is selected. Move the gaps with the doors.
This commit is contained in:
@@ -451,7 +451,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void UpdateEditing(Camera cam)
|
public override void UpdateEditing(Camera cam)
|
||||||
{
|
{
|
||||||
if (editingHUD == null || editingHUD.UserData as Item != this)
|
if (editingHUD == null || editingHUD.UserData == null)
|
||||||
{
|
{
|
||||||
editingHUD = CreateEditingHUD(Screen.Selected != GameMain.SubEditorScreen);
|
editingHUD = CreateEditingHUD(Screen.Selected != GameMain.SubEditorScreen);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace Barotrauma
|
|||||||
center.Y -= center.Y % Submarine.GridSize.Y;
|
center.Y -= center.Y % Submarine.GridSize.Y;
|
||||||
|
|
||||||
MapEntity.SelectedList.Clear();
|
MapEntity.SelectedList.Clear();
|
||||||
MapEntity.SelectedList.AddRange(assemblyEntities);
|
assemblyEntities.ForEach(e => MapEntity.AddSelection(e));
|
||||||
|
|
||||||
foreach (MapEntity mapEntity in assemblyEntities)
|
foreach (MapEntity mapEntity in assemblyEntities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -367,14 +367,19 @@ namespace Barotrauma
|
|||||||
foreach (MapEntity e in newSelection)
|
foreach (MapEntity e in newSelection)
|
||||||
{
|
{
|
||||||
if (selectedList.Contains(e))
|
if (selectedList.Contains(e))
|
||||||
selectedList.Remove(e);
|
{
|
||||||
|
RemoveSelection(e);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
selectedList.Add(e);
|
{
|
||||||
|
AddSelection(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selectedList = newSelection;
|
selectedList.Clear();
|
||||||
|
newSelection.ForEach(e => AddSelection(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
//select wire if both items it's connected to are selected
|
//select wire if both items it's connected to are selected
|
||||||
@@ -457,9 +462,13 @@ namespace Barotrauma
|
|||||||
PlayerInput.KeyDown(Keys.RightControl))
|
PlayerInput.KeyDown(Keys.RightControl))
|
||||||
{
|
{
|
||||||
if (selectedList.Contains(entity))
|
if (selectedList.Contains(entity))
|
||||||
selectedList.Remove(entity);
|
{
|
||||||
|
RemoveSelection(entity);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
selectedList.Add(entity);
|
{
|
||||||
|
AddSelection(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -469,6 +478,45 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddSelection(MapEntity entity)
|
||||||
|
{
|
||||||
|
if (selectedList.Contains(entity)) { return; }
|
||||||
|
selectedList.Add(entity);
|
||||||
|
if (entity is Item i)
|
||||||
|
{
|
||||||
|
var door = i.GetComponent<Door>();
|
||||||
|
if (door != null)
|
||||||
|
{
|
||||||
|
var gap = door.LinkedGap;
|
||||||
|
if (gap != null)
|
||||||
|
{
|
||||||
|
door.RefreshLinkedGap();
|
||||||
|
if (!selectedList.Contains(gap))
|
||||||
|
{
|
||||||
|
selectedList.Add(gap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveSelection(MapEntity entity)
|
||||||
|
{
|
||||||
|
selectedList.Remove(entity);
|
||||||
|
if (entity is Item i)
|
||||||
|
{
|
||||||
|
var door = i.GetComponent<Door>();
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
@@ -533,8 +581,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<MapEntity> FilteredSelectedList { get; private set; } = new List<MapEntity>();
|
||||||
|
|
||||||
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)
|
||||||
@@ -552,13 +603,18 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedList.Count == 0) return;
|
if (selectedList.Count == 0) return;
|
||||||
|
foreach (var e in selectedList)
|
||||||
if (selectedList.Count == 1)
|
|
||||||
{
|
{
|
||||||
selectedList[0].UpdateEditing(cam);
|
if (e is Gap) { continue; }
|
||||||
if (selectedList[0].ResizeHorizontal || selectedList[0].ResizeVertical)
|
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 +678,10 @@ namespace Barotrauma
|
|||||||
selectedList.Clear();
|
selectedList.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void SelectEntity(MapEntity entity)
|
public static void SelectEntity(MapEntity entity)
|
||||||
{
|
{
|
||||||
DeselectAll();
|
DeselectAll();
|
||||||
|
AddSelection(entity);
|
||||||
selectedList.Add(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2109,10 +2109,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void AddToGUIUpdateList()
|
public override void AddToGUIUpdateList()
|
||||||
{
|
{
|
||||||
if (MapEntity.SelectedList.Count == 1)
|
MapEntity.FilteredSelectedList.FirstOrDefault()?.AddToGUIUpdateList();
|
||||||
{
|
|
||||||
MapEntity.SelectedList[0].AddToGUIUpdateList();
|
|
||||||
}
|
|
||||||
if (MapEntity.HighlightedListBox != null)
|
if (MapEntity.HighlightedListBox != null)
|
||||||
{
|
{
|
||||||
MapEntity.HighlightedListBox.AddToGUIUpdateList();
|
MapEntity.HighlightedListBox.AddToGUIUpdateList();
|
||||||
@@ -2293,9 +2290,9 @@ namespace Barotrauma
|
|||||||
dummyCharacter.SelectedConstruction = null;
|
dummyCharacter.SelectedConstruction = null;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
else if (MapEntity.SelectedList.Count == 1)
|
else if (MapEntity.FilteredSelectedList.Count == 1)
|
||||||
{
|
{
|
||||||
(MapEntity.SelectedList[0] as Item)?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
(MapEntity.FilteredSelectedList[0] as Item)?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterHUD.Update((float)deltaTime, dummyCharacter, cam);
|
CharacterHUD.Update((float)deltaTime, dummyCharacter, cam);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace Barotrauma.Items.Components
|
|||||||
private float openState;
|
private float openState;
|
||||||
private Sprite doorSprite, weldedSprite, brokenSprite;
|
private Sprite doorSprite, weldedSprite, brokenSprite;
|
||||||
private bool scaleBrokenSprite, fadeBrokenSprite;
|
private bool scaleBrokenSprite, fadeBrokenSprite;
|
||||||
private bool createdNewGap;
|
|
||||||
private bool autoOrientGap;
|
private bool autoOrientGap;
|
||||||
|
|
||||||
private bool isStuck;
|
private bool isStuck;
|
||||||
@@ -87,17 +86,19 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (linkedGap != null) return linkedGap;
|
if (linkedGap == null)
|
||||||
|
|
||||||
foreach (MapEntity e in item.linkedTo)
|
|
||||||
{
|
{
|
||||||
linkedGap = e as Gap;
|
GetLinkedGap();
|
||||||
if (linkedGap != null)
|
|
||||||
{
|
|
||||||
linkedGap.PassAmbientLight = Window != Rectangle.Empty;
|
|
||||||
return linkedGap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return linkedGap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetLinkedGap()
|
||||||
|
{
|
||||||
|
linkedGap = item.linkedTo.FirstOrDefault(e => e is Gap) as Gap;
|
||||||
|
if (linkedGap == null)
|
||||||
|
{
|
||||||
Rectangle rect = item.Rect;
|
Rectangle rect = item.Rect;
|
||||||
if (IsHorizontal)
|
if (IsHorizontal)
|
||||||
{
|
{
|
||||||
@@ -109,17 +110,13 @@ namespace Barotrauma.Items.Components
|
|||||||
rect.X -= 5;
|
rect.X -= 5;
|
||||||
rect.Width += 10;
|
rect.Width += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
linkedGap = new Gap(rect, !IsHorizontal, Item.Submarine)
|
linkedGap = new Gap(rect, !IsHorizontal, Item.Submarine)
|
||||||
{
|
{
|
||||||
Submarine = item.Submarine,
|
Submarine = item.Submarine
|
||||||
PassAmbientLight = Window != Rectangle.Empty,
|
|
||||||
Open = openState
|
|
||||||
};
|
};
|
||||||
item.linkedTo.Add(linkedGap);
|
item.linkedTo.Add(linkedGap);
|
||||||
createdNewGap = true;
|
|
||||||
return linkedGap;
|
|
||||||
}
|
}
|
||||||
|
RefreshLinkedGap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsHorizontal { get; private set; }
|
public bool IsHorizontal { get; private set; }
|
||||||
@@ -370,12 +367,20 @@ namespace Barotrauma.Items.Components
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMapLoaded()
|
public void RefreshLinkedGap()
|
||||||
{
|
{
|
||||||
LinkedGap.ConnectedDoor = this;
|
LinkedGap.ConnectedDoor = this;
|
||||||
|
if (autoOrientGap)
|
||||||
|
{
|
||||||
|
LinkedGap.AutoOrient();
|
||||||
|
}
|
||||||
LinkedGap.Open = openState;
|
LinkedGap.Open = openState;
|
||||||
if (createdNewGap && autoOrientGap) linkedGap.AutoOrient();
|
LinkedGap.PassAmbientLight = Window != Rectangle.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnMapLoaded()
|
||||||
|
{
|
||||||
|
RefreshLinkedGap();
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
Vector2[] corners = GetConvexHullCorners(Rectangle.Empty);
|
Vector2[] corners = GetConvexHullCorners(Rectangle.Empty);
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace Barotrauma
|
|||||||
if (Screen.Selected == GameMain.SubEditorScreen)
|
if (Screen.Selected == GameMain.SubEditorScreen)
|
||||||
{
|
{
|
||||||
MapEntity.SelectedList.Clear();
|
MapEntity.SelectedList.Clear();
|
||||||
MapEntity.SelectedList.AddRange(entities);
|
entities.ForEach(e => MapEntity.AddSelection(e));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return entities;
|
return entities;
|
||||||
|
|||||||
Reference in New Issue
Block a user