Fixed entity linking not working
This commit is contained in:
@@ -127,18 +127,36 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!prefab.IsLinkable) return;
|
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);
|
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
|
||||||
foreach (MapEntity entity in mapEntityList)
|
if (lClick)
|
||||||
{
|
{
|
||||||
if (entity == this || !entity.IsHighlighted) continue;
|
foreach (MapEntity entity in mapEntityList)
|
||||||
if (linkedTo.Contains(entity)) continue;
|
{
|
||||||
if (!entity.IsMouseOn(position)) continue;
|
if (entity == this || !entity.IsHighlighted) continue;
|
||||||
|
if (linkedTo.Contains(entity)) continue;
|
||||||
|
if (!entity.IsMouseOn(position)) continue;
|
||||||
|
|
||||||
linkedTo.Add(entity);
|
linkedTo.Add(entity);
|
||||||
if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -56,7 +57,38 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return decal;
|
return decal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateEditing(Camera cam)
|
||||||
|
{
|
||||||
|
if (!PlayerInput.KeyDown(Keys.Space)) return;
|
||||||
|
bool lClick = PlayerInput.LeftButtonClicked();
|
||||||
|
bool rClick = PlayerInput.RightButtonClicked();
|
||||||
|
if (!lClick && !rClick) return;
|
||||||
|
|
||||||
|
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
|
||||||
|
if (lClick)
|
||||||
|
{
|
||||||
|
foreach (MapEntity entity in mapEntityList)
|
||||||
|
{
|
||||||
|
if (entity == this || !entity.IsHighlighted) continue;
|
||||||
|
if (!entity.IsMouseOn(position)) continue;
|
||||||
|
|
||||||
|
if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (MapEntity entity in mapEntityList)
|
||||||
|
{
|
||||||
|
if (entity == this || !entity.IsHighlighted) continue;
|
||||||
|
if (!entity.IsMouseOn(position)) continue;
|
||||||
|
|
||||||
|
if (entity.linkedTo != null && entity.linkedTo.Contains(this)) entity.linkedTo.Remove(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
partial void UpdateProjSpecific(float deltaTime, Camera cam)
|
partial void UpdateProjSpecific(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
if (EditWater)
|
if (EditWater)
|
||||||
|
|||||||
@@ -59,13 +59,19 @@ namespace Barotrauma
|
|||||||
get;
|
get;
|
||||||
protected set;
|
protected set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serialize(false, false)]
|
[Serialize(false, false)]
|
||||||
public virtual bool IsLinkable
|
public bool Linkable //TODO: make this property's name consistent
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool IsLinkable
|
||||||
|
{
|
||||||
|
get { return Linkable; }
|
||||||
|
private set { Linkable = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public MapEntityCategory Category
|
public MapEntityCategory Category
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user