Fixed entity linking not working
This commit is contained in:
@@ -127,18 +127,36 @@ namespace Barotrauma
|
||||
|
||||
if (!prefab.IsLinkable) return;
|
||||
|
||||
if (!PlayerInput.LeftButtonClicked() || !PlayerInput.KeyDown(Keys.Space)) return;
|
||||
if (!PlayerInput.KeyDown(Keys.Space)) return;
|
||||
bool lClick = PlayerInput.LeftButtonClicked();
|
||||
bool rClick = PlayerInput.RightButtonClicked();
|
||||
if (!lClick && !rClick) return;
|
||||
|
||||
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
|
||||
foreach (MapEntity entity in mapEntityList)
|
||||
if (lClick)
|
||||
{
|
||||
if (entity == this || !entity.IsHighlighted) continue;
|
||||
if (linkedTo.Contains(entity)) continue;
|
||||
if (!entity.IsMouseOn(position)) continue;
|
||||
foreach (MapEntity entity in mapEntityList)
|
||||
{
|
||||
if (entity == this || !entity.IsHighlighted) continue;
|
||||
if (linkedTo.Contains(entity)) continue;
|
||||
if (!entity.IsMouseOn(position)) continue;
|
||||
|
||||
linkedTo.Add(entity);
|
||||
if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this);
|
||||
linkedTo.Add(entity);
|
||||
if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (MapEntity entity in mapEntityList)
|
||||
{
|
||||
if (entity == this || !entity.IsHighlighted) continue;
|
||||
if (!linkedTo.Contains(entity)) continue;
|
||||
if (!entity.IsMouseOn(position)) continue;
|
||||
|
||||
linkedTo.Remove(entity);
|
||||
if (entity.linkedTo != null && entity.linkedTo.Contains(this)) entity.linkedTo.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user