Resizing structures/items in editor
This commit is contained in:
@@ -286,7 +286,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Item(Rectangle newRect, ItemPrefab itemPrefab, Submarine submarine)
|
public Item(Rectangle newRect, ItemPrefab itemPrefab, Submarine submarine)
|
||||||
: base(submarine)
|
: base(itemPrefab, submarine)
|
||||||
{
|
{
|
||||||
prefab = itemPrefab;
|
prefab = itemPrefab;
|
||||||
|
|
||||||
@@ -1219,7 +1219,7 @@ namespace Barotrauma
|
|||||||
element.Add(new XAttribute("name", prefab.Name),
|
element.Add(new XAttribute("name", prefab.Name),
|
||||||
new XAttribute("ID", ID));
|
new XAttribute("ID", ID));
|
||||||
|
|
||||||
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
|
if (ResizeHorizontal || ResizeVertical)
|
||||||
{
|
{
|
||||||
element.Add(new XAttribute("rect",
|
element.Add(new XAttribute("rect",
|
||||||
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ namespace Barotrauma
|
|||||||
//private Sound waterSound;
|
//private Sound waterSound;
|
||||||
|
|
||||||
//a value between 0.0f-1.0f (0.0 = closed, 1.0f = open)
|
//a value between 0.0f-1.0f (0.0 = closed, 1.0f = open)
|
||||||
float open;
|
private float open;
|
||||||
|
|
||||||
//the force of the water flow which is exerted on physics bodies
|
//the force of the water flow which is exerted on physics bodies
|
||||||
Vector2 flowForce;
|
private Vector2 flowForce;
|
||||||
|
|
||||||
Hull flowTargetHull;
|
private Hull flowTargetHull;
|
||||||
|
|
||||||
float higherSurface;
|
private float higherSurface;
|
||||||
float lowerSurface;
|
private float lowerSurface;
|
||||||
|
|
||||||
|
|
||||||
public float Open
|
public float Open
|
||||||
@@ -39,11 +39,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Door ConnectedDoor;
|
public Door ConnectedDoor;
|
||||||
|
|
||||||
//public Vector2 FlowForce
|
|
||||||
//{
|
|
||||||
// get { return flowForce*soundVolume; }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public Vector2 LerpedFlowForce
|
public Vector2 LerpedFlowForce
|
||||||
{
|
{
|
||||||
get { return lerpedFlowForce; }
|
get { return lerpedFlowForce; }
|
||||||
@@ -64,6 +59,20 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Rectangle Rect
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.Rect;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Rect = value;
|
||||||
|
|
||||||
|
FindHulls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Gap(MapEntityPrefab prefab, Rectangle rectangle)
|
public Gap(MapEntityPrefab prefab, Rectangle rectangle)
|
||||||
: this (rectangle, Submarine.Loaded)
|
: this (rectangle, Submarine.Loaded)
|
||||||
{ }
|
{ }
|
||||||
@@ -73,7 +82,7 @@ namespace Barotrauma
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine)
|
public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine)
|
||||||
: base (submarine)
|
: base (MapEntityPrefab.list.Find(m=> m.Name == "Gap"), submarine)
|
||||||
{
|
{
|
||||||
rect = newRect;
|
rect = newRect;
|
||||||
linkedTo = new ObservableCollection<MapEntity>();
|
linkedTo = new ObservableCollection<MapEntity>();
|
||||||
@@ -169,34 +178,21 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height), clr * 0.5f, true);
|
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height), clr * 0.5f, true);
|
||||||
|
|
||||||
if (isHorizontal)
|
for (int i = 0; i < linkedTo.Count; i++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < linkedTo.Count; i++ )
|
Vector2 dir = isHorizontal ?
|
||||||
{
|
new Vector2(Math.Sign(linkedTo[i].Rect.Center.X - rect.Center.X), 0.0f)
|
||||||
if (linkedTo[i].Rect.Center.X > rect.Center.X)
|
: new Vector2(0.0f, Math.Sign((linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f) - (rect.Y - rect.Height / 2.0f)));
|
||||||
{
|
|
||||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.Right, -WorldRect.Y, 10, rect.Height), Color.Green * 0.3f, true);
|
Vector2 arrowPos = new Vector2(WorldRect.Center.X, -(WorldRect.Y - WorldRect.Height / 2));
|
||||||
}
|
arrowPos += new Vector2(dir.X * (WorldRect.Width / 2 + 10), dir.Y * (WorldRect.Height / 2 + 10));
|
||||||
else
|
|
||||||
{
|
GUI.Arrow.Draw(sb,
|
||||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X - 10, -WorldRect.Y, 10, rect.Height), Color.Green * 0.3f, true);
|
arrowPos,
|
||||||
}
|
clr * 0.8f,
|
||||||
}
|
GUI.Arrow.Origin, MathUtils.VectorToAngle(dir) + MathHelper.PiOver2,
|
||||||
}
|
isHorizontal ? new Vector2(rect.Height / 16.0f, 1.0f) : new Vector2(rect.Width / 16.0f, 1.0f));
|
||||||
else
|
}
|
||||||
{
|
|
||||||
for (int i = 0; i < linkedTo.Count; i++)
|
|
||||||
{
|
|
||||||
if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f > rect.Y-rect.Height/2.0f)
|
|
||||||
{
|
|
||||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y - 10, rect.Width, 10), Color.Green * 0.3f, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y + rect.Height, rect.Width, 10), Color.Green * 0.3f, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSelected)
|
if (isSelected)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,6 +74,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Rectangle Rect
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.Rect;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Rect = value;
|
||||||
|
|
||||||
|
Item.UpdateHulls();
|
||||||
|
Gap.UpdateHulls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool IsLinkable
|
public override bool IsLinkable
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
@@ -151,13 +166,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Hull(MapEntityPrefab prefab, Rectangle rectangle)
|
public Hull(MapEntityPrefab prefab, Rectangle rectangle)
|
||||||
: this (rectangle, Submarine.Loaded)
|
: this (prefab, rectangle, Submarine.Loaded)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hull(Rectangle rectangle, Submarine submarine)
|
public Hull(MapEntityPrefab prefab, Rectangle rectangle, Submarine submarine)
|
||||||
: base (submarine)
|
: base (prefab, submarine)
|
||||||
{
|
{
|
||||||
rect = rectangle;
|
rect = rectangle;
|
||||||
|
|
||||||
@@ -691,7 +706,7 @@ namespace Barotrauma
|
|||||||
int.Parse(element.Attribute("height").Value));
|
int.Parse(element.Attribute("height").Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
Hull h = new Hull(rect, submarine);
|
Hull h = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), rect, submarine);
|
||||||
|
|
||||||
h.volume = ToolBox.GetAttributeFloat(element, "pressure", 0.0f);
|
h.volume = ToolBox.GetAttributeFloat(element, "pressure", 0.0f);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ namespace Barotrauma
|
|||||||
protected static Vector2 selectionSize = Vector2.Zero;
|
protected static Vector2 selectionSize = Vector2.Zero;
|
||||||
|
|
||||||
protected static Vector2 startMovingPos = Vector2.Zero;
|
protected static Vector2 startMovingPos = Vector2.Zero;
|
||||||
|
|
||||||
|
private MapEntityPrefab prefab;
|
||||||
|
|
||||||
protected List<ushort> linkedToID;
|
protected List<ushort> linkedToID;
|
||||||
|
|
||||||
//observable collection because some entities may need to be notified when the collection is modified
|
//observable collection because some entities may need to be notified when the collection is modified
|
||||||
@@ -66,6 +68,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//the position and dimensions of the entity
|
//the position and dimensions of the entity
|
||||||
protected Rectangle rect;
|
protected Rectangle rect;
|
||||||
|
|
||||||
|
private static bool resizing;
|
||||||
|
private int resizeDirX, resizeDirY;
|
||||||
|
|
||||||
public virtual Rectangle Rect {
|
public virtual Rectangle Rect {
|
||||||
get { return rect; }
|
get { return rect; }
|
||||||
@@ -139,12 +144,24 @@ namespace Barotrauma
|
|||||||
set { isSelected = value; }
|
set { isSelected = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool ResizeHorizontal
|
||||||
|
{
|
||||||
|
get { return prefab == null ? false : prefab.ResizeHorizontal; }
|
||||||
|
}
|
||||||
|
protected bool ResizeVertical
|
||||||
|
{
|
||||||
|
get { return prefab == null ? false : prefab.ResizeVertical; }
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string Name
|
public virtual string Name
|
||||||
{
|
{
|
||||||
get { return ""; }
|
get { return ""; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapEntity(Submarine submarine) : base(submarine) { }
|
public MapEntity(MapEntityPrefab prefab, Submarine submarine) : base(submarine)
|
||||||
|
{
|
||||||
|
this.prefab = prefab;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Move(Vector2 amount)
|
public virtual void Move(Vector2 amount)
|
||||||
{
|
{
|
||||||
@@ -232,6 +249,12 @@ namespace Barotrauma
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void UpdateSelecting(Camera cam)
|
public static void UpdateSelecting(Camera cam)
|
||||||
{
|
{
|
||||||
|
if (resizing)
|
||||||
|
{
|
||||||
|
if (selectedList.Count == 0) resizing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (MapEntity e in mapEntityList)
|
foreach (MapEntity e in mapEntityList)
|
||||||
{
|
{
|
||||||
e.isHighlighted = false;
|
e.isHighlighted = false;
|
||||||
@@ -245,7 +268,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow) return;
|
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow) return;
|
||||||
|
|
||||||
if (MapEntityPrefab.Selected != null)
|
if (MapEntityPrefab.Selected != null)
|
||||||
{
|
{
|
||||||
selectionPos = Vector2.Zero;
|
selectionPos = Vector2.Zero;
|
||||||
@@ -412,6 +435,11 @@ namespace Barotrauma
|
|||||||
if (selectedList.Count == 1)
|
if (selectedList.Count == 1)
|
||||||
{
|
{
|
||||||
selectedList[0].DrawEditing(spriteBatch, cam);
|
selectedList[0].DrawEditing(spriteBatch, cam);
|
||||||
|
|
||||||
|
if (selectedList[0].ResizeHorizontal || selectedList[0].ResizeVertical)
|
||||||
|
{
|
||||||
|
selectedList[0].DrawResizing(spriteBatch, cam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -443,6 +471,89 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam) {}
|
public virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam) {}
|
||||||
|
|
||||||
|
private void DrawResizing(SpriteBatch spriteBatch, Camera cam)
|
||||||
|
{
|
||||||
|
isHighlighted = true;
|
||||||
|
|
||||||
|
int startX = ResizeHorizontal ? -1 : 0;
|
||||||
|
int StartY = ResizeVertical ? -1 : 0;
|
||||||
|
|
||||||
|
for (int x = startX; x < 2; x += 2)
|
||||||
|
{
|
||||||
|
for (int y = StartY; y < 2; y += 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
Vector2 handlePos = cam.WorldToScreen(Position + new Vector2(x * (rect.Width * 0.5f + 5), y * (rect.Height * 0.5f + 5)));
|
||||||
|
|
||||||
|
bool highlighted = Vector2.Distance(PlayerInput.MousePosition, handlePos)<5.0f;
|
||||||
|
|
||||||
|
GUI.DrawRectangle(spriteBatch, handlePos - new Vector2(3.0f, 3.0f), new Vector2(6.0f, 6.0f), Color.White * (highlighted ? 1.0f : 0.6f), true);
|
||||||
|
|
||||||
|
if (highlighted)
|
||||||
|
{
|
||||||
|
if (PlayerInput.LeftButtonDown())
|
||||||
|
{
|
||||||
|
selectionPos = Vector2.Zero;
|
||||||
|
resizeDirX = x;
|
||||||
|
resizeDirY = y;
|
||||||
|
resizing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resizing)
|
||||||
|
{
|
||||||
|
|
||||||
|
Vector2 placePosition = new Vector2(rect.X, rect.Y);
|
||||||
|
Vector2 placeSize = new Vector2(rect.Width, rect.Height);
|
||||||
|
|
||||||
|
Vector2 mousePos = Submarine.MouseToWorldGrid(cam);
|
||||||
|
|
||||||
|
if (resizeDirX >0)
|
||||||
|
{
|
||||||
|
mousePos.X = Math.Max(mousePos.X, rect.X + Submarine.GridSize.X);
|
||||||
|
placeSize.X = mousePos.X - placePosition.X;
|
||||||
|
}
|
||||||
|
else if (resizeDirX <0)
|
||||||
|
{
|
||||||
|
mousePos.X = Math.Min(mousePos.X, rect.Right - Submarine.GridSize.X);
|
||||||
|
|
||||||
|
placeSize.X = (placePosition.X + placeSize.X)-mousePos.X;
|
||||||
|
placePosition.X = mousePos.X;
|
||||||
|
}
|
||||||
|
if (resizeDirY < 0)
|
||||||
|
{
|
||||||
|
mousePos.Y = Math.Min(mousePos.Y, rect.Y - Submarine.GridSize.Y);
|
||||||
|
placeSize.Y = placePosition.Y-mousePos.Y;
|
||||||
|
}
|
||||||
|
else if (resizeDirY > 0)
|
||||||
|
{
|
||||||
|
mousePos.Y = Math.Max(mousePos.Y, rect.Y - rect.Height + Submarine.GridSize.X);
|
||||||
|
|
||||||
|
placeSize.Y = mousePos.Y - (rect.Y - rect.Height);
|
||||||
|
placePosition.Y = mousePos.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int)placePosition.X != rect.X || (int)placePosition.Y != rect.Y || (int)placeSize.X != rect.Width || (int)placeSize.Y != rect.Height)
|
||||||
|
{
|
||||||
|
Rect = new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PlayerInput.LeftButtonHeld())
|
||||||
|
{
|
||||||
|
resizing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (resizeHorizontal) placeSize.X = position.X - placePosition.X;
|
||||||
|
//if (resizeVertical) placeSize.Y = placePosition.Y - position.Y;
|
||||||
|
|
||||||
|
//Rectangle newRect = Submarine.AbsRect(placePosition, placeSize);
|
||||||
|
//newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
|
||||||
|
//newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static List<MapEntity> FindMapEntities(Vector2 pos)
|
public static List<MapEntity> FindMapEntities(Vector2 pos)
|
||||||
{
|
{
|
||||||
List<MapEntity> foundEntities = new List<MapEntity>();
|
List<MapEntity> foundEntities = new List<MapEntity>();
|
||||||
@@ -518,13 +629,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
mapEntityList[i].OnMapLoaded();
|
mapEntityList[i].OnMapLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//mapEntityList.Sort((x, y) =>
|
|
||||||
//{
|
|
||||||
// return x.Name.CompareTo(y.Name);
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Structure(Rectangle rectangle, StructurePrefab sp, Submarine submarine)
|
public Structure(Rectangle rectangle, StructurePrefab sp, Submarine submarine)
|
||||||
: base(submarine)
|
: base(sp, submarine)
|
||||||
{
|
{
|
||||||
if (rectangle.Width == 0 || rectangle.Height == 0) return;
|
if (rectangle.Width == 0 || rectangle.Height == 0) return;
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WayPoint(Rectangle newRect, Submarine submarine)
|
public WayPoint(Rectangle newRect, Submarine submarine)
|
||||||
: base (submarine)
|
: base (null, submarine)
|
||||||
{
|
{
|
||||||
rect = newRect;
|
rect = newRect;
|
||||||
linkedTo = new ObservableCollection<MapEntity>();
|
linkedTo = new ObservableCollection<MapEntity>();
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
v0.3.4.0
|
||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Multiplayer:
|
||||||
|
- missing submarine files can be downloaded from the server host
|
||||||
|
- player syncing bugfixes (aiming is visible to other players, smoother movement in water)
|
||||||
|
- creature syncing bugfixes (less teleporting around)
|
||||||
|
- fixed the server lobby displaying wrong numbers of votes at the client's side
|
||||||
|
- fixed the server list displaying 16/16 players as 0/16
|
||||||
|
- saving server settings
|
||||||
|
|
||||||
|
Other:
|
||||||
|
- skyholder artifacts consume oxygen
|
||||||
|
- thermal artifacts catch fire even if they're not being held
|
||||||
|
- placed items/structures can be resized in the editor
|
||||||
|
- items in the inventory can be swapped between slots by dragging them on top of each other
|
||||||
|
- slower underwater scooters
|
||||||
|
- fixed pressure building up in enclosed rooms full of water, even if there were no hull breaches
|
||||||
|
- an indicator which shows the direction of the sub when spectating
|
||||||
|
- fixed crashing when loading a submarine with no hulls
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
v0.3.3.1
|
v0.3.3.1
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user