(9f1c10ee0) Update the ladder and gap reference if the waypoint is moved around in the editor. TODO: stairs.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Barotrauma.Items.Components;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -48,6 +51,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
iconSize = (int)(iconSize * 1.5f);
|
iconSize = (int)(iconSize * 1.5f);
|
||||||
}
|
}
|
||||||
|
if (Stairs != null)
|
||||||
|
{
|
||||||
|
iconSize = (int)(iconSize * 1.5f);
|
||||||
|
}
|
||||||
|
|
||||||
spriteBatch.Draw(iconTexture,
|
spriteBatch.Draw(iconTexture,
|
||||||
new Rectangle((int)(drawPos.X - iconSize / 2), (int)(drawPos.Y - iconSize / 2), iconSize, iconSize),
|
new Rectangle((int)(drawPos.X - iconSize / 2), (int)(drawPos.Y - iconSize / 2), iconSize, iconSize),
|
||||||
@@ -90,10 +97,49 @@ namespace Barotrauma
|
|||||||
editingHUD = CreateEditingHUD();
|
editingHUD = CreateEditingHUD();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerInput.LeftButtonClicked())
|
if (IsSelected && PlayerInput.LeftButtonClicked())
|
||||||
{
|
{
|
||||||
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
|
||||||
|
// Update gaps, ladders, and stairs
|
||||||
|
UpdateLinkedEntity(position, Gap.GapList, gap => ConnectedGap = gap, gap =>
|
||||||
|
{
|
||||||
|
if (ConnectedGap == gap)
|
||||||
|
{
|
||||||
|
ConnectedGap = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
UpdateLinkedEntity(position, Item.ItemList, i =>
|
||||||
|
{
|
||||||
|
var ladder = i?.GetComponent<Ladder>();
|
||||||
|
if (ladder != null)
|
||||||
|
{
|
||||||
|
Ladders = ladder;
|
||||||
|
}
|
||||||
|
}, i =>
|
||||||
|
{
|
||||||
|
var ladder = i?.GetComponent<Ladder>();
|
||||||
|
if (ladder != null)
|
||||||
|
{
|
||||||
|
if (Ladders == ladder)
|
||||||
|
{
|
||||||
|
Ladders = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, inflate: 5);
|
||||||
|
// TODO: Cannot check the rectangle, since the rectangle is not rotated -> Need to use the collider.
|
||||||
|
//var stairList = mapEntityList.Where(me => me is Structure s && s.StairDirection != Direction.None).Select(me => me as Structure);
|
||||||
|
//UpdateLinkedEntity(position, stairList, s =>
|
||||||
|
//{
|
||||||
|
// Stairs = s;
|
||||||
|
//}, s =>
|
||||||
|
//{
|
||||||
|
// if (Stairs == s)
|
||||||
|
// {
|
||||||
|
// Stairs = null;
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
foreach (MapEntity e in mapEntityList)
|
foreach (MapEntity e in mapEntityList)
|
||||||
{
|
{
|
||||||
if (e.GetType() != typeof(WayPoint)) continue;
|
if (e.GetType() != typeof(WayPoint)) continue;
|
||||||
@@ -107,6 +153,23 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateLinkedEntity<T>(Vector2 worldPos, IEnumerable<T> list, Action<T> match, Action<T> noMatch, int inflate = 0) where T : MapEntity
|
||||||
|
{
|
||||||
|
foreach (var entity in list)
|
||||||
|
{
|
||||||
|
var rect = entity.WorldRect;
|
||||||
|
rect.Inflate(inflate, inflate);
|
||||||
|
if (Submarine.RectContains(rect, worldPos))
|
||||||
|
{
|
||||||
|
match(entity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
noMatch(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool ChangeSpawnType(GUIButton button, object obj)
|
private bool ChangeSpawnType(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
GUITextBlock spawnTypeText = button.Parent.GetChildByUserData("spawntypetext") as GUITextBlock;
|
GUITextBlock spawnTypeText = button.Parent.GetChildByUserData("spawntypetext") as GUITextBlock;
|
||||||
|
|||||||
Reference in New Issue
Block a user