Merge branch 'master' of bitbucket.org:Regalis11/barotrauma

This commit is contained in:
Sebastian Broberg
2016-03-03 20:18:35 +01:00
111 changed files with 1720 additions and 1204 deletions

View File

@@ -116,11 +116,13 @@ namespace Barotrauma
if (!fireSources[i].CheckOverLap(fireSources[j])) continue;
fireSources[j].position.X = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
float leftEdge = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
fireSources[j].size.X =
Math.Max(fireSources[i].position.X + fireSources[i].size.X, fireSources[j].position.X + fireSources[j].size.X)
- fireSources[j].position.X;
- leftEdge;
fireSources[j].position.X = leftEdge;
fireSources[i].Remove();
}
@@ -140,7 +142,7 @@ namespace Barotrauma
public void Update(float deltaTime)
{
float count = Rand.Range(0.0f, (float)Math.Sqrt(size.X)/3.0f);
float count = Rand.Range(0.0f, size.X/50.0f);
if (fireSoundBasic != null)
{
@@ -173,10 +175,10 @@ namespace Barotrauma
spawnPos, speed, 0.0f, hull);
if (particle == null) continue;
if (Rand.Int(20) == 1) particle.OnChangeHull = OnChangeHull;
particle.Size *= MathHelper.Clamp(size.X/100.0f * Math.Max(hull.Oxygen/hull.FullVolume, 0.4f), 0.5f, 4.0f);
particle.Size *= MathHelper.Clamp(size.X/60.0f * Math.Max(hull.Oxygen/hull.FullVolume, 0.4f), 0.5f, 3.0f);
if (size.X < 100.0f) continue;
@@ -218,7 +220,7 @@ namespace Barotrauma
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X-100.0f && pos.X < fs.position.X+fs.size.X+100.0f)!=null) return;
new FireSource(new Vector2(pos.X, particleHull.Rect.Y-particleHull.Rect.Height + 5.0f));
new FireSource(new Vector2(pos.X, particleHull.WorldRect.Y-particleHull.Rect.Height + 5.0f));
}
private void DamageCharacters(float deltaTime)

View File

@@ -20,15 +20,15 @@ namespace Barotrauma
//private Sound waterSound;
//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
Vector2 flowForce;
private Vector2 flowForce;
Hull flowTargetHull;
private Hull flowTargetHull;
float higherSurface;
float lowerSurface;
private float higherSurface;
private float lowerSurface;
public float Open
@@ -39,11 +39,6 @@ namespace Barotrauma
public Door ConnectedDoor;
//public Vector2 FlowForce
//{
// get { return flowForce*soundVolume; }
//}
public Vector2 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)
: this (rectangle, Submarine.Loaded)
{ }
@@ -73,7 +82,7 @@ namespace Barotrauma
{ }
public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine)
: base (submarine)
: base (MapEntityPrefab.list.Find(m=> m.Name == "Gap"), submarine)
{
rect = newRect;
linkedTo = new ObservableCollection<MapEntity>();
@@ -154,9 +163,12 @@ namespace Barotrauma
if (GameMain.DebugDraw)
{
Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Height/ 2.0f));
GUI.DrawLine(sb, center, center + flowForce/10.0f, Color.Red);
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + lerpedFlowForce / 10.0f + Vector2.One * 5.0f, Color.Orange);
GUI.DrawLine(sb, center, center + new Vector2(flowForce.X, -flowForce.Y)/10.0f, Color.Red);
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + new Vector2(lerpedFlowForce.X, -lerpedFlowForce.Y) / 10.0f + Vector2.One * 5.0f, Color.Orange);
}
if (!editing || !ShowGaps) return;
@@ -166,34 +178,21 @@ namespace Barotrauma
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++ )
{
if (linkedTo[i].Rect.Center.X > rect.Center.X)
{
GUI.DrawRectangle(sb, new Rectangle(WorldRect.Right, -WorldRect.Y, 10, rect.Height), Color.Green * 0.3f, true);
}
else
{
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X - 10, -WorldRect.Y, 10, rect.Height), Color.Green * 0.3f, true);
}
}
}
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);
}
}
}
Vector2 dir = isHorizontal ?
new Vector2(Math.Sign(linkedTo[i].Rect.Center.X - rect.Center.X), 0.0f)
: new Vector2(0.0f, Math.Sign((linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f) - (rect.Y - rect.Height / 2.0f)));
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));
GUI.Arrow.Draw(sb,
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));
}
if (isSelected)
{
@@ -288,6 +287,25 @@ namespace Barotrauma
}
}
if (flowTargetHull != null && lerpedFlowForce != Vector2.Zero)
{
foreach (Character character in Character.CharacterList)
{
if (character.AnimController.CurrentHull != flowTargetHull) continue;
foreach (Limb limb in character.AnimController.Limbs)
{
if (!limb.inWater) continue;
float dist = Vector2.Distance(limb.WorldPosition, WorldPosition);
if (dist > lerpedFlowForce.Length()) continue;
limb.body.ApplyForce(lerpedFlowForce / dist/10.0f);
}
}
}
}
@@ -444,7 +462,7 @@ namespace Barotrauma
if (open > 0.0f)
{
if (hull1.Volume>hull1.FullVolume && hull2.Volume>hull2.FullVolume)
if (hull1.Volume > hull1.FullVolume - Hull.MaxCompress && hull2.Volume > hull2.FullVolume - Hull.MaxCompress)
{
float avgLethality = (hull1.LethalPressure + hull2.LethalPressure) / 2.0f;
hull1.LethalPressure = avgLethality;
@@ -497,21 +515,31 @@ namespace Barotrauma
lowerSurface = rect.Y;
if (hull1.Volume < hull1.FullVolume - Hull.MaxCompress &&
hull1.Surface > -rect.Y)
hull1.Surface < rect.Y)
{
float vel = (rect.Y + hull1.Surface) * 0.03f;
if (rect.X > hull1.Rect.X + hull1.Rect.Width / 2.0f)
{
float vel = ((rect.Y - rect.Height / 2) - (hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1])) * 0.1f;
hull1.WaveVel[hull1.WaveY.Length - 1] += vel;
hull1.WaveVel[hull1.WaveY.Length - 2] += vel;
}
else
{
float vel = ((rect.Y - rect.Height / 2) - (hull1.Surface + hull1.WaveY[0])) * 0.1f;
hull1.WaveVel[0] += vel;
hull1.WaveVel[1] += vel;
}
}
else
{
hull1.LethalPressure += (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth) ? 100.0f * deltaTime : 10.0f * deltaTime;
}
}
else
{
@@ -523,7 +551,12 @@ namespace Barotrauma
{
flowForce = new Vector2(0.0f, delta);
}
if (hull1.Volume >= hull1.FullVolume - Hull.MaxCompress)
{
hull1.LethalPressure += (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth) ? 100.0f * deltaTime : 10.0f * deltaTime;
}
}
}
private void UpdateOxygen()

View File

@@ -12,7 +12,7 @@ using Lidgren.Network;
namespace Barotrauma
{
class Hull : MapEntity
class Hull : MapEntity, IPropertyObject
{
public static List<Hull> hullList = new List<Hull>();
private static EntityGrid entityGrid;
@@ -20,7 +20,7 @@ namespace Barotrauma
public static bool ShowHulls = true;
public static bool EditWater, EditFire;
public static WaterRenderer renderer;
private List<FireSource> fireSources;
@@ -37,7 +37,11 @@ namespace Barotrauma
//how much excess water the room can contain (= more than the volume of the room)
public const float MaxCompress = 10000f;
public readonly Dictionary<string, PropertyDescriptor> properties;
public readonly Dictionary<string, ObjectProperty> properties;
public Dictionary<string, ObjectProperty> ObjectProperties
{
get { return properties; }
}
private float lethalPressure;
@@ -71,6 +75,21 @@ namespace Barotrauma
}
}
public override Rectangle Rect
{
get
{
return base.Rect;
}
set
{
base.Rect = value;
Item.UpdateHulls();
Gap.UpdateHulls();
}
}
public override bool IsLinkable
{
get { return true; }
@@ -148,13 +167,13 @@ namespace Barotrauma
}
public Hull(MapEntityPrefab prefab, Rectangle rectangle)
: this (rectangle, Submarine.Loaded)
: this (prefab, rectangle, Submarine.Loaded)
{
}
public Hull(Rectangle rectangle, Submarine submarine)
: base (submarine)
public Hull(MapEntityPrefab prefab, Rectangle rectangle, Submarine submarine)
: base (prefab, submarine)
{
rect = rectangle;
@@ -162,9 +181,7 @@ namespace Barotrauma
fireSources = new List<FireSource>();
properties = TypeDescriptor.GetProperties(GetType())
.Cast<PropertyDescriptor>()
.ToDictionary(pr => pr.Name);
properties = ObjectProperty.GetProperties(this);
int arraySize = (rectangle.Width / WaveWidth + 1);
waveY = new float[arraySize];
@@ -434,11 +451,6 @@ namespace Barotrauma
update = false;
}
}
else
{
LethalPressure += ( Submarine.Loaded!=null && Submarine.Loaded.AtDamageDepth) ? 100.0f*deltaTime : 10.0f * deltaTime;
}
}
public void HandleItems(float deltaTime, Item body)
@@ -720,7 +732,7 @@ namespace Barotrauma
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);

View File

@@ -2,6 +2,7 @@
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
namespace Barotrauma
{
@@ -25,20 +26,20 @@ namespace Barotrauma
get { return waterTexture; }
}
public WaterRenderer(GraphicsDevice graphicsDevice)
public WaterRenderer(GraphicsDevice graphicsDevice, ContentManager content)
{
#if WINDOWS
byte[] bytecode = File.ReadAllBytes("Content/watershader.mgfx");
waterEffect = content.Load<Effect>("watershader");
#endif
#if LINUX
byte[] bytecode = File.ReadAllBytes("Content/watershader_opengl.mgfx");
#endif
waterEffect = new Effect(graphicsDevice, bytecode);
waterEffect = content.Load<Effect>("watershader_opengl");
#endif
waterTexture = TextureLoader.FromFile("Content/waterbump.png");
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
#if WINDOWS
//waterEffect.Parameters["xTexture"].SetValue(waterTexture);
#endif

View File

@@ -23,7 +23,9 @@ namespace Barotrauma
protected static Vector2 selectionSize = Vector2.Zero;
protected static Vector2 startMovingPos = Vector2.Zero;
private MapEntityPrefab prefab;
protected List<ushort> linkedToID;
//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
protected Rectangle rect;
private static bool resizing;
private int resizeDirX, resizeDirY;
public virtual Rectangle Rect {
get { return rect; }
@@ -139,12 +144,24 @@ namespace Barotrauma
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
{
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)
{
@@ -232,6 +249,12 @@ namespace Barotrauma
/// </summary>
public static void UpdateSelecting(Camera cam)
{
if (resizing)
{
if (selectedList.Count == 0) resizing = false;
return;
}
foreach (MapEntity e in mapEntityList)
{
e.isHighlighted = false;
@@ -245,7 +268,7 @@ namespace Barotrauma
}
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow) return;
if (MapEntityPrefab.Selected != null)
{
selectionPos = Vector2.Zero;
@@ -412,6 +435,11 @@ namespace Barotrauma
if (selectedList.Count == 1)
{
selectedList[0].DrawEditing(spriteBatch, cam);
if (selectedList[0].ResizeHorizontal || selectedList[0].ResizeVertical)
{
selectedList[0].DrawResizing(spriteBatch, cam);
}
}
else
{
@@ -443,6 +471,89 @@ namespace Barotrauma
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)
{
List<MapEntity> foundEntities = new List<MapEntity>();
@@ -518,13 +629,6 @@ namespace Barotrauma
{
mapEntityList[i].OnMapLoaded();
}
//mapEntityList.Sort((x, y) =>
//{
// return x.Name.CompareTo(y.Name);
//});
}

View File

@@ -142,7 +142,7 @@ namespace Barotrauma
}
public Structure(Rectangle rectangle, StructurePrefab sp, Submarine submarine)
: base(submarine)
: base(sp, submarine)
{
if (rectangle.Width == 0 || rectangle.Height == 0) return;

View File

@@ -511,17 +511,17 @@ namespace Barotrauma
return true;
}
public static bool SaveCurrent(string fileName)
public static bool SaveCurrent(string filePath)
{
if (loaded==null)
{
loaded = new Submarine(fileName);
loaded = new Submarine(filePath);
// return;
}
loaded.filePath = SavePath + System.IO.Path.DirectorySeparatorChar + fileName;
loaded.filePath = filePath;
return loaded.SaveAs(SavePath+System.IO.Path.DirectorySeparatorChar+fileName);
return loaded.SaveAs(filePath);
}
public void CheckForErrors()
@@ -590,7 +590,7 @@ namespace Barotrauma
{
try
{
filePaths.AddRange(Directory.GetDirectories(subDirectory));
filePaths.AddRange(Directory.GetFiles(subDirectory).ToList());
}
catch (Exception e)
{
@@ -604,6 +604,8 @@ namespace Barotrauma
//Map savedMap = new Map(mapPath);
SavedSubmarines.Add(new Submarine(path));
}
if (GameMain.NetLobbyScreen!=null) GameMain.NetLobbyScreen.UpdateSubList();
}
private XDocument OpenDoc(string file)
@@ -629,12 +631,16 @@ namespace Barotrauma
if (extension == ".sub")
{
Stream stream = SaveUtil.DecompressFiletoStream(file);
if (stream == null)
Stream stream = null;
try
{
DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed!");
return null;
stream = SaveUtil.DecompressFiletoStream(file);
}
catch (Exception e)
{
DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed!", e);
return null;
}
try
{
@@ -713,37 +719,42 @@ namespace Barotrauma
}
}
Vector2 topLeft = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
Vector2 bottomRight = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
foreach (Hull hull in Hull.hullList)
Vector2 center = Vector2.Zero;
if (Hull.hullList.Any())
{
if (hull.Rect.X < topLeft.X) topLeft.X = hull.Rect.X;
if (hull.Rect.Y > topLeft.Y) topLeft.Y = hull.Rect.Y;
if (hull.Rect.Right > bottomRight.X) bottomRight.X = hull.Rect.Right;
if (hull.Rect.Y - hull.Rect.Height < bottomRight.Y) bottomRight.Y = hull.Rect.Y - hull.Rect.Height;
}
Vector2 center = (topLeft + bottomRight) / 2.0f;
center.X -= center.X % GridSize.X;
center.Y -= center.Y % GridSize.Y;
foreach (Item item in Item.ItemList)
{
var wire = item.GetComponent<Items.Components.Wire>();
if (wire == null) continue;
for (int i = 0; i < wire.Nodes.Count; i++)
Vector2 topLeft = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
Vector2 bottomRight = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
foreach (Hull hull in Hull.hullList)
{
wire.Nodes[i] -= center;
}
}
if (hull.Rect.X < topLeft.X) topLeft.X = hull.Rect.X;
if (hull.Rect.Y > topLeft.Y) topLeft.Y = hull.Rect.Y;
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].Submarine == null) continue;
if (hull.Rect.Right > bottomRight.X) bottomRight.X = hull.Rect.Right;
if (hull.Rect.Y - hull.Rect.Height < bottomRight.Y) bottomRight.Y = hull.Rect.Y - hull.Rect.Height;
}
center = (topLeft + bottomRight) / 2.0f;
center.X -= center.X % GridSize.X;
center.Y -= center.Y % GridSize.Y;
foreach (Item item in Item.ItemList)
{
var wire = item.GetComponent<Items.Components.Wire>();
if (wire == null) continue;
for (int i = 0; i < wire.Nodes.Count; i++)
{
wire.Nodes[i] -= center;
}
}
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].Submarine == null) continue;
MapEntity.mapEntityList[i].Move(-center);
MapEntity.mapEntityList[i].Move(-center);
}
}
subBody = new SubmarineBody(this);

View File

@@ -226,25 +226,32 @@ namespace Barotrauma
if (dist > 1000.0f)
{
Vector2 moveAmount = ConvertUnits.ToSimUnits((Vector2)targetPosition) - body.Position;
Vector2 displayerMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
Vector2 displayMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
body.SetTransform(body.Position + moveAmount, 0.0f);
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayerMoveAmount;
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayMoveAmount;
GameMain.GameScreen.Cam.Position += displayerMoveAmount;
GameMain.GameScreen.Cam.UpdateTransform();
GameMain.GameScreen.Cam.Position += displayMoveAmount;
if (GameMain.GameScreen.Cam.TargetPos!=Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += displayMoveAmount;
GameMain.GameScreen.Cam.UpdateTransform(false);
submarine.SetPrevTransform(submarine.Position);
submarine.UpdateTransform();
targetPosition = null;
}
else if (dist > 50.0f)
{
Vector2 moveAmount = Vector2.Normalize((Vector2)targetPosition - Position);
moveAmount *= ConvertUnits.ToSimUnits(Math.Min(dist, 100.0f));
Vector2 displayerMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
Vector2 displayMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
body.SetTransform(body.Position + moveAmount * deltaTime, 0.0f);
GameMain.GameScreen.Cam.Position += displayerMoveAmount * deltaTime;
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayerMoveAmount;
GameMain.GameScreen.Cam.Position += displayMoveAmount * deltaTime;
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += displayMoveAmount;
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayMoveAmount;
//GameMain.GameScreen.Cam.UpdateTransform(false);
}
else
{

View File

@@ -96,7 +96,7 @@ namespace Barotrauma
}
public WayPoint(Rectangle newRect, Submarine submarine)
: base (submarine)
: base (null, submarine)
{
rect = newRect;
linkedTo = new ObservableCollection<MapEntity>();