Progress
This commit is contained in:
@@ -148,16 +148,17 @@ namespace Barotrauma
|
|||||||
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *
|
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *
|
||||||
viewMatrix;
|
viewMatrix;
|
||||||
|
|
||||||
prevPosition = position;
|
|
||||||
prevZoom = zoom;
|
|
||||||
|
|
||||||
|
|
||||||
Sound.CameraPos = new Vector3(WorldViewCenter.X, WorldViewCenter.Y, 0.0f);
|
Sound.CameraPos = new Vector3(WorldViewCenter.X, WorldViewCenter.Y, 0.0f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveCamera(float deltaTime)
|
public void MoveCamera(float deltaTime)
|
||||||
{
|
{
|
||||||
|
prevPosition = position;
|
||||||
|
prevZoom = zoom;
|
||||||
|
|
||||||
float moveSpeed = 20.0f/zoom;
|
float moveSpeed = 20.0f/zoom;
|
||||||
|
|
||||||
Vector2 moveCam = Vector2.Zero;
|
Vector2 moveCam = Vector2.Zero;
|
||||||
@@ -210,6 +211,7 @@ namespace Barotrauma
|
|||||||
public Vector2 Position
|
public Vector2 Position
|
||||||
{
|
{
|
||||||
get { return position; }
|
get { return position; }
|
||||||
|
set { position = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 ScreenToWorld(Vector2 coords)
|
public Vector2 ScreenToWorld(Vector2 coords)
|
||||||
|
|||||||
@@ -54,15 +54,19 @@ namespace Barotrauma
|
|||||||
(pathSteering.CurrentPath.NextNode == null || pathSteering.CurrentPath.Unreachable)))
|
(pathSteering.CurrentPath.NextNode == null || pathSteering.CurrentPath.Unreachable)))
|
||||||
{
|
{
|
||||||
//steer away from edges of the hull
|
//steer away from edges of the hull
|
||||||
if (character.Position.X < character.AnimController.CurrentHull.Rect.X + WallAvoidDistance)
|
if (character.AnimController.CurrentHull!=null)
|
||||||
{
|
{
|
||||||
pathSteering.SteeringManual(deltaTime, Vector2.UnitX);
|
if (character.Position.X < character.AnimController.CurrentHull.Rect.X + WallAvoidDistance)
|
||||||
}
|
{
|
||||||
else if (character.Position.X > character.AnimController.CurrentHull.Rect.Right - WallAvoidDistance)
|
pathSteering.SteeringManual(deltaTime, Vector2.UnitX);
|
||||||
{
|
}
|
||||||
pathSteering.SteeringManual(deltaTime, -Vector2.UnitX);
|
else if (character.Position.X > character.AnimController.CurrentHull.Rect.Right - WallAvoidDistance)
|
||||||
|
{
|
||||||
|
pathSteering.SteeringManual(deltaTime, -Vector2.UnitX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
character.AIController.SteeringManager.SteeringWander(1.0f);
|
character.AIController.SteeringManager.SteeringWander(1.0f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ namespace Barotrauma
|
|||||||
case NetworkEventType.KillCharacter:
|
case NetworkEventType.KillCharacter:
|
||||||
return true;
|
return true;
|
||||||
case NetworkEventType.ImportantEntityUpdate:
|
case NetworkEventType.ImportantEntityUpdate:
|
||||||
int i = 0;
|
|
||||||
//foreach (Limb limb in AnimController.Limbs)
|
//foreach (Limb limb in AnimController.Limbs)
|
||||||
//{
|
//{
|
||||||
//if (RefLimb.ignoreCollisions) continue;
|
//if (RefLimb.ignoreCollisions) continue;
|
||||||
|
|||||||
@@ -152,7 +152,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Hull CurrentHull
|
public Hull CurrentHull
|
||||||
{
|
{
|
||||||
get { return currentHull;}
|
get { return currentHull; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == currentHull) return;
|
||||||
|
|
||||||
|
currentHull = value;
|
||||||
|
foreach (Limb limb in Limbs)
|
||||||
|
{
|
||||||
|
limb.body.Submarine = currentHull == null ? null : Submarine.Loaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IgnorePlatforms
|
public bool IgnorePlatforms
|
||||||
@@ -534,7 +544,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (newHull == currentHull) return;
|
if (newHull == currentHull) return;
|
||||||
|
|
||||||
currentHull = newHull;
|
CurrentHull = newHull;
|
||||||
|
|
||||||
|
|
||||||
UpdateCollisionCategories();
|
UpdateCollisionCategories();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,19 +273,19 @@ namespace Barotrauma
|
|||||||
get { return AnimController.RefLimb.SimPosition; }
|
get { return AnimController.RefLimb.SimPosition; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 Position
|
public override Vector2 Position
|
||||||
{
|
{
|
||||||
get { return ConvertUnits.ToDisplayUnits(AnimController.RefLimb.SimPosition); }
|
get { return AnimController.RefLimb.Position; }
|
||||||
}
|
}
|
||||||
|
|
||||||
static Character()
|
static Character()
|
||||||
{
|
{
|
||||||
DeathMsg[(int)CauseOfDeath.Damage] = "succumbed to your injuries";
|
DeathMsg[(int)CauseOfDeath.Damage] = "succumbed to your injuries";
|
||||||
DeathMsg[(int)CauseOfDeath.Bloodloss] = "bled out";
|
DeathMsg[(int)CauseOfDeath.Bloodloss] = "bled out";
|
||||||
DeathMsg[(int)CauseOfDeath.Drowning] = "drowned";
|
DeathMsg[(int)CauseOfDeath.Drowning] = "drowned";
|
||||||
DeathMsg[(int)CauseOfDeath.Suffocation] = "suffocated";
|
DeathMsg[(int)CauseOfDeath.Suffocation] = "suffocated";
|
||||||
DeathMsg[(int)CauseOfDeath.Pressure] = "been crushed by water pressure";
|
DeathMsg[(int)CauseOfDeath.Pressure] = "been crushed by water pressure";
|
||||||
DeathMsg[(int)CauseOfDeath.Burn] = "burnt to death";
|
DeathMsg[(int)CauseOfDeath.Burn] = "burnt to death";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Character Create(string file, Vector2 position)
|
public static Character Create(string file, Vector2 position)
|
||||||
@@ -334,6 +334,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
|
protected Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
|
||||||
|
: base(null)
|
||||||
{
|
{
|
||||||
|
|
||||||
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
|
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
|
||||||
@@ -522,7 +523,7 @@ namespace Barotrauma
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = new Item(itemPrefab, Position);
|
Item item = new Item(itemPrefab, Position, null);
|
||||||
|
|
||||||
if (info.Job.EquipSpawnItem[i])
|
if (info.Job.EquipSpawnItem[i])
|
||||||
{
|
{
|
||||||
@@ -754,12 +755,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (moveCam)
|
if (moveCam)
|
||||||
{
|
{
|
||||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
cam.TargetPos = WorldPosition;
|
||||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
if (AnimController.CurrentHull != null) cursorPosition -= Submarine.Loaded.Position;
|
||||||
|
|
||||||
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
|
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
|
||||||
|
|
||||||
if (Vector2.Distance(AnimController.Limbs[0].SimPosition, mouseSimPos)>1.0f)
|
if (Vector2.Distance(AnimController.Limbs[0].SimPosition, mouseSimPos)>1.0f)
|
||||||
{
|
{
|
||||||
Body body = Submarine.PickBody(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
Body body = Submarine.PickBody(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||||
@@ -877,9 +881,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
|
||||||
|
Submarine = AnimController.CurrentHull == null ? null : Submarine.Loaded;
|
||||||
|
|
||||||
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
||||||
|
|
||||||
AnimController.SimplePhysicsEnabled = (Character.controlled != this && Vector2.Distance(cam.WorldViewCenter, Position) > 5000.0f);
|
AnimController.SimplePhysicsEnabled = (Character.controlled != this && Vector2.Distance(cam.WorldViewCenter, WorldPosition) > 5000.0f);
|
||||||
|
|
||||||
if (isDead) return;
|
if (isDead) return;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
|||||||
} while (tries < 10);
|
} while (tries < 10);
|
||||||
|
|
||||||
|
|
||||||
item = new Item(itemPrefab, position);
|
item = new Item(itemPrefab, position, null);
|
||||||
item.MoveWithLevel = true;
|
item.MoveWithLevel = true;
|
||||||
item.body.FarseerBody.GravityScale = 0.5f;
|
item.body.FarseerBody.GravityScale = 0.5f;
|
||||||
//item.MoveWithLevel = true;
|
//item.MoveWithLevel = true;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Barotrauma
|
|||||||
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
||||||
Rand.Range(cargoRoom.Rect.Y - cargoRoom.Rect.Height + 20.0f, cargoRoom.Rect.Y));
|
Rand.Range(cargoRoom.Rect.Y - cargoRoom.Rect.Height + 20.0f, cargoRoom.Rect.Y));
|
||||||
|
|
||||||
new Item(prefab as ItemPrefab, position);
|
new Item(prefab as ItemPrefab, position, wp.Submarine);
|
||||||
}
|
}
|
||||||
|
|
||||||
purchasedItems.Clear();
|
purchasedItems.Clear();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Barotrauma.Items.Components
|
|||||||
linkedGap = e as Gap;
|
linkedGap = e as Gap;
|
||||||
if (linkedGap != null) return linkedGap;
|
if (linkedGap != null) return linkedGap;
|
||||||
}
|
}
|
||||||
linkedGap = new Gap(item.Rect);
|
linkedGap = new Gap(item.Rect, Item.Submarine);
|
||||||
linkedGap.Open = openState;
|
linkedGap.Open = openState;
|
||||||
item.linkedTo.Add(linkedGap);
|
item.linkedTo.Add(linkedGap);
|
||||||
return linkedGap;
|
return linkedGap;
|
||||||
|
|||||||
@@ -255,13 +255,14 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public Item(ItemPrefab itemPrefab, Vector2 position)
|
public Item(ItemPrefab itemPrefab, Vector2 position, Submarine submarine)
|
||||||
: this(new Rectangle((int)position.X, (int)position.Y, (int)itemPrefab.sprite.size.X, (int)itemPrefab.sprite.size.Y), itemPrefab)
|
: this(new Rectangle((int)position.X, (int)position.Y, (int)itemPrefab.sprite.size.X, (int)itemPrefab.sprite.size.Y), itemPrefab, submarine)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item(Rectangle newRect, ItemPrefab itemPrefab)
|
public Item(Rectangle newRect, ItemPrefab itemPrefab, Submarine submarine)
|
||||||
|
: base(submarine)
|
||||||
{
|
{
|
||||||
prefab = itemPrefab;
|
prefab = itemPrefab;
|
||||||
|
|
||||||
@@ -409,6 +410,10 @@ namespace Barotrauma
|
|||||||
public virtual Hull FindHull()
|
public virtual Hull FindHull()
|
||||||
{
|
{
|
||||||
CurrentHull = Hull.FindHull((body == null) ? Position : ConvertUnits.ToDisplayUnits(body.SimPosition), CurrentHull);
|
CurrentHull = Hull.FindHull((body == null) ? Position : ConvertUnits.ToDisplayUnits(body.SimPosition), CurrentHull);
|
||||||
|
if (body!=null)
|
||||||
|
{
|
||||||
|
body.Submarine = CurrentHull == null ? null : Submarine.Loaded;
|
||||||
|
}
|
||||||
return CurrentHull;
|
return CurrentHull;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,7 +603,16 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (body == null)
|
if (body == null)
|
||||||
{
|
{
|
||||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
|
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
|
||||||
|
{
|
||||||
|
|
||||||
|
prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X+rect.Width/2, -DrawPosition.Y-rect.Height/2), new Vector2(rect.Width, rect.Height), color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prefab.sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (body.Enabled)
|
else if (body.Enabled)
|
||||||
{
|
{
|
||||||
@@ -615,7 +629,7 @@ namespace Barotrauma
|
|||||||
depth = holdable.Picker.AnimController.GetLimb(LimbType.LeftArm).sprite.Depth - 0.000001f;
|
depth = holdable.Picker.AnimController.GetLimb(LimbType.LeftArm).sprite.Depth - 0.000001f;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.Draw(spriteBatch, prefab.sprite, color, depth);
|
body.Draw(spriteBatch, prefab.sprite, color, depth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1159,7 +1173,7 @@ namespace Barotrauma
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Load(XElement element)
|
public static void Load(XElement element, Submarine submarine)
|
||||||
{
|
{
|
||||||
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
||||||
string[] rectValues = rectString.Split(',');
|
string[] rectValues = rectString.Split(',');
|
||||||
@@ -1195,7 +1209,8 @@ namespace Barotrauma
|
|||||||
rect.Height = (int)ip.Size.Y;
|
rect.Height = (int)ip.Size.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = new Item(rect, ip);
|
Item item = new Item(rect, ip, submarine);
|
||||||
|
item.Submarine = submarine;
|
||||||
item.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
item.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
|
|
||||||
item.linkedToID = new List<ushort>();
|
item.linkedToID = new List<ushort>();
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (PlayerInput.LeftButtonClicked())
|
if (PlayerInput.LeftButtonClicked())
|
||||||
{
|
{
|
||||||
new Item(new Rectangle((int)position.X, (int)position.Y, (int)sprite.size.X, (int)sprite.size.Y), this);
|
new Item(new Rectangle((int)position.X, (int)position.Y, (int)sprite.size.X, (int)sprite.size.Y), this, Submarine.Loaded);
|
||||||
//constructor.Invoke(lobject);
|
//constructor.Invoke(lobject);
|
||||||
|
|
||||||
placePosition = Vector2.Zero;
|
placePosition = Vector2.Zero;
|
||||||
@@ -112,7 +112,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
|
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
|
||||||
{
|
{
|
||||||
new Item(new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y), this);
|
new Item(new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y), this, Submarine.Loaded);
|
||||||
placePosition = Vector2.Zero;
|
placePosition = Vector2.Zero;
|
||||||
//selected = null;
|
//selected = null;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var itemInfo = spawnQueue.Dequeue();
|
var itemInfo = spawnQueue.Dequeue();
|
||||||
|
|
||||||
new Item(itemInfo.First, itemInfo.Second);
|
//!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
new Item(itemInfo.First, itemInfo.Second, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,13 +46,36 @@ namespace Barotrauma
|
|||||||
get { return Vector2.Zero; }
|
get { return Vector2.Zero; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual Vector2 Position
|
||||||
|
{
|
||||||
|
get { return Vector2.Zero; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 WorldPosition
|
||||||
|
{
|
||||||
|
get { return Submarine == null ? Position : Submarine.Position + Position; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 DrawPosition
|
||||||
|
{
|
||||||
|
get { return Submarine == null ? Position : Submarine.DrawPosition + Position; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Submarine Submarine
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
protected set;
|
||||||
|
}
|
||||||
|
|
||||||
public AITarget AiTarget
|
public AITarget AiTarget
|
||||||
{
|
{
|
||||||
get { return aiTarget; }
|
get { return aiTarget; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity()
|
public Entity(Submarine submarine)
|
||||||
{
|
{
|
||||||
|
this.Submarine = submarine;
|
||||||
|
|
||||||
//give an unique ID
|
//give an unique ID
|
||||||
bool IDfound;
|
bool IDfound;
|
||||||
id = 1;//Rand.Int(int.MaxValue);
|
id = 1;//Rand.Int(int.MaxValue);
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ namespace Barotrauma
|
|||||||
get { return flowTargetHull; }
|
get { return flowTargetHull; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gap(Rectangle newRect)
|
public Gap(Rectangle newRect, Submarine submarine)
|
||||||
: this(newRect, (newRect.Width < newRect.Height))
|
: this(newRect, newRect.Width < newRect.Height, submarine)
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
public Gap(Rectangle newRect, bool isHorizontal)
|
public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine)
|
||||||
|
: base (submarine)
|
||||||
{
|
{
|
||||||
rect = newRect;
|
rect = newRect;
|
||||||
linkedTo = new ObservableCollection<MapEntity>();
|
linkedTo = new ObservableCollection<MapEntity>();
|
||||||
@@ -564,7 +564,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void Load(XElement element)
|
public static void Load(XElement element, Submarine submarine)
|
||||||
{
|
{
|
||||||
Rectangle rect = new Rectangle(
|
Rectangle rect = new Rectangle(
|
||||||
int.Parse(element.Attribute("x").Value),
|
int.Parse(element.Attribute("x").Value),
|
||||||
@@ -572,7 +572,7 @@ namespace Barotrauma
|
|||||||
int.Parse(element.Attribute("width").Value),
|
int.Parse(element.Attribute("width").Value),
|
||||||
int.Parse(element.Attribute("height").Value));
|
int.Parse(element.Attribute("height").Value));
|
||||||
|
|
||||||
Gap g = new Gap(rect);
|
Gap g = new Gap(rect, submarine);
|
||||||
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
|
|
||||||
g.linkedToID = new List<ushort>();
|
g.linkedToID = new List<ushort>();
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ namespace Barotrauma
|
|||||||
get { return fireSources; }
|
get { return fireSources; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hull(Rectangle rectangle)
|
public Hull(Rectangle rectangle, Submarine submarine)
|
||||||
|
: base (submarine)
|
||||||
{
|
{
|
||||||
rect = rectangle;
|
rect = rectangle;
|
||||||
|
|
||||||
@@ -376,12 +377,13 @@ namespace Barotrauma
|
|||||||
if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return;
|
if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return;
|
||||||
|
|
||||||
//calculate where the surface should be based on the water volume
|
//calculate where the surface should be based on the water volume
|
||||||
float top = rect.Y;
|
float top = rect.Y+Submarine.Position.Y;
|
||||||
float bottom = rect.Y - rect.Height;
|
float bottom = top - rect.Height;
|
||||||
float surfaceY = bottom + Volume / rect.Width;
|
float surfaceY = bottom + Volume / rect.Width;
|
||||||
|
|
||||||
//interpolate the position of the rendered surface towards the "target surface"
|
//interpolate the position of the rendered surface towards the "target surface"
|
||||||
surface = surface + (surfaceY - surface) / 10.0f;
|
surface = surface + ((surfaceY - Submarine.Position.Y) - surface) / 10.0f;
|
||||||
|
float drawSurface = surface + Submarine.Position.Y;
|
||||||
|
|
||||||
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||||
|
|
||||||
@@ -393,15 +395,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector3[] corners = new Vector3[4];
|
Vector3[] corners = new Vector3[4];
|
||||||
|
|
||||||
corners[0] = new Vector3(rect.X, top, 0.0f);
|
corners[0] = new Vector3(rect.X, rect.Y, 0.0f);
|
||||||
corners[1] = new Vector3(rect.X + rect.Width, top, 0.0f);
|
corners[1] = new Vector3(rect.X + rect.Width, rect.Y, 0.0f);
|
||||||
|
|
||||||
corners[2] = new Vector3(corners[1].X, bottom, 0.0f);
|
corners[2] = new Vector3(corners[1].X, rect.Y-rect.Height, 0.0f);
|
||||||
corners[3] = new Vector3(corners[0].X, bottom, 0.0f);
|
corners[3] = new Vector3(corners[0].X, corners[2].Y, 0.0f);
|
||||||
|
|
||||||
Vector2[] uvCoords = new Vector2[4];
|
Vector2[] uvCoords = new Vector2[4];
|
||||||
for (int i = 0; i < 4; i++ )
|
for (int i = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
|
corners[i] += new Vector3(Submarine.Loaded.Position, 0.0f);
|
||||||
uvCoords[i] = Vector2.Transform(new Vector2(corners[i].X, -corners[i].Y), transform);
|
uvCoords[i] = Vector2.Transform(new Vector2(corners[i].X, -corners[i].Y), transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,8 +421,8 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = rect.X;
|
float x = rect.X+Submarine.Position.X;
|
||||||
int start = (int)Math.Floor((float)(cam.WorldView.X - x) / WaveWidth);
|
int start = (int)Math.Floor((cam.WorldView.X - x) / WaveWidth);
|
||||||
start = Math.Max(start, 0);
|
start = Math.Max(start, 0);
|
||||||
|
|
||||||
int end = (waveY.Length - 1)
|
int end = (waveY.Length - 1)
|
||||||
@@ -435,7 +438,7 @@ namespace Barotrauma
|
|||||||
Vector3[] corners = new Vector3[4];
|
Vector3[] corners = new Vector3[4];
|
||||||
|
|
||||||
corners[0] = new Vector3(x, top, 0.0f);
|
corners[0] = new Vector3(x, top, 0.0f);
|
||||||
corners[3] = new Vector3(corners[0].X, surface + waveY[i], 0.0f);
|
corners[3] = new Vector3(corners[0].X, drawSurface + waveY[i], 0.0f);
|
||||||
|
|
||||||
//skip adjacent "water rects" if the surface of the water is roughly at the same position
|
//skip adjacent "water rects" if the surface of the water is roughly at the same position
|
||||||
int width = WaveWidth;
|
int width = WaveWidth;
|
||||||
@@ -446,7 +449,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
corners[1] = new Vector3(x + width, top, 0.0f);
|
corners[1] = new Vector3(x + width, top, 0.0f);
|
||||||
corners[2] = new Vector3(corners[1].X, surface + waveY[i+1], 0.0f);
|
corners[2] = new Vector3(corners[1].X, drawSurface + waveY[i + 1], 0.0f);
|
||||||
|
|
||||||
Vector2[] uvCoords = new Vector2[4];
|
Vector2[] uvCoords = new Vector2[4];
|
||||||
for (int n = 0; n < 4; n++)
|
for (int n = 0; n < 4; n++)
|
||||||
@@ -527,7 +530,7 @@ namespace Barotrauma
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Load(XElement element)
|
public static void Load(XElement element, Submarine submarine)
|
||||||
{
|
{
|
||||||
Rectangle rect = new Rectangle(
|
Rectangle rect = new Rectangle(
|
||||||
int.Parse(element.Attribute("x").Value),
|
int.Parse(element.Attribute("x").Value),
|
||||||
@@ -535,7 +538,7 @@ namespace Barotrauma
|
|||||||
int.Parse(element.Attribute("width").Value),
|
int.Parse(element.Attribute("width").Value),
|
||||||
int.Parse(element.Attribute("height").Value));
|
int.Parse(element.Attribute("height").Value));
|
||||||
|
|
||||||
Hull h = new Hull(rect);
|
Hull h = new Hull(rect, submarine);
|
||||||
|
|
||||||
h.volume = ToolBox.GetAttributeFloat(element, "pressure", 0.0f);
|
h.volume = ToolBox.GetAttributeFloat(element, "pressure", 0.0f);
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ namespace Barotrauma
|
|||||||
for (int i = 0; i <3 ; i++ )
|
for (int i = 0; i <3 ; i++ )
|
||||||
{
|
{
|
||||||
Vector2 position = pathCells[Rand.Range((int)(pathCells.Count * 0.5f), pathCells.Count - 2, false)].Center;
|
Vector2 position = pathCells[Rand.Range((int)(pathCells.Count * 0.5f), pathCells.Count - 2, false)].Center;
|
||||||
WayPoint wayPoint = new WayPoint(new Rectangle((int)position.X, (int)position.Y, 10, 10));
|
WayPoint wayPoint = new WayPoint(new Rectangle((int)position.X, (int)position.Y, 10, 10), null);
|
||||||
wayPoint.MoveWithLevel = true;
|
wayPoint.MoveWithLevel = true;
|
||||||
wayPoint.SpawnType = SpawnType.Enemy;
|
wayPoint.SpawnType = SpawnType.Enemy;
|
||||||
}
|
}
|
||||||
@@ -454,7 +454,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (placeWaypoints)
|
if (placeWaypoints)
|
||||||
{
|
{
|
||||||
WayPoint newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, (int)(borders.Height + shaftHeight), 10, 10));
|
WayPoint newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, (int)(borders.Height + shaftHeight), 10, 10), null);
|
||||||
newWaypoint.MoveWithLevel = true;
|
newWaypoint.MoveWithLevel = true;
|
||||||
|
|
||||||
WayPoint prevWaypoint = newWaypoint;
|
WayPoint prevWaypoint = newWaypoint;
|
||||||
@@ -471,7 +471,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
if (i >= pathCells.Count) break;
|
if (i >= pathCells.Count) break;
|
||||||
|
|
||||||
newWaypoint = new WayPoint(new Rectangle((int)pathCells[i].Center.X, (int)pathCells[i].Center.Y, 10, 10));
|
newWaypoint = new WayPoint(new Rectangle((int)pathCells[i].Center.X, (int)pathCells[i].Center.Y, 10, 10), null);
|
||||||
newWaypoint.MoveWithLevel = true;
|
newWaypoint.MoveWithLevel = true;
|
||||||
if (prevWaypoint != null)
|
if (prevWaypoint != null)
|
||||||
{
|
{
|
||||||
@@ -481,7 +481,7 @@ namespace Barotrauma
|
|||||||
prevWaypoint = newWaypoint;
|
prevWaypoint = newWaypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
newWaypoint = new WayPoint(new Rectangle((int)pathCells[pathCells.Count - 1].Center.X, (int)(borders.Height + shaftHeight), 10, 10));
|
newWaypoint = new WayPoint(new Rectangle((int)pathCells[pathCells.Count - 1].Center.X, (int)(borders.Height + shaftHeight), 10, 10), null);
|
||||||
newWaypoint.MoveWithLevel = true;
|
newWaypoint.MoveWithLevel = true;
|
||||||
|
|
||||||
prevWaypoint.linkedTo.Add(newWaypoint);
|
prevWaypoint.linkedTo.Add(newWaypoint);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace Barotrauma
|
|||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Vector2 Position
|
public override Vector2 Position
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -139,6 +139,8 @@ namespace Barotrauma
|
|||||||
get { return ""; }
|
get { return ""; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapEntity(Submarine submarine) : base(submarine) { }
|
||||||
|
|
||||||
public virtual void Move(Vector2 amount)
|
public virtual void Move(Vector2 amount)
|
||||||
{
|
{
|
||||||
rect.X += (int)amount.X;
|
rect.X += (int)amount.X;
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ namespace Barotrauma
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Structure(Rectangle rectangle, StructurePrefab sp)
|
public Structure(Rectangle rectangle, StructurePrefab sp, Submarine submarine)
|
||||||
|
: base(submarine)
|
||||||
{
|
{
|
||||||
if (rectangle.Width == 0 || rectangle.Height == 0) return;
|
if (rectangle.Width == 0 || rectangle.Height == 0) return;
|
||||||
|
|
||||||
@@ -291,24 +292,25 @@ namespace Barotrauma
|
|||||||
Color color = (isHighlighted) ? Color.Green : Color.White;
|
Color color = (isHighlighted) ? Color.Green : Color.White;
|
||||||
if (isSelected && editing) color = Color.Red;
|
if (isSelected && editing) color = Color.Red;
|
||||||
|
|
||||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), Vector2.Zero, color);
|
Vector2 drawPos = Submarine == null ? new Vector2(rect.X, -rect.Y) : new Vector2(rect.X + Submarine.DrawPosition.X, -(rect.Y + Submarine.DrawPosition.Y));
|
||||||
|
|
||||||
|
prefab.sprite.DrawTiled(spriteBatch, drawPos, new Vector2(rect.Width, rect.Height), Vector2.Zero, color);
|
||||||
|
|
||||||
foreach (WallSection s in sections)
|
foreach (WallSection s in sections)
|
||||||
{
|
{
|
||||||
if (s.isHighLighted)
|
if (s.isHighLighted)
|
||||||
{
|
{
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Rectangle((int)s.rect.X, (int)-s.rect.Y, (int)s.rect.Width, (int)s.rect.Height),
|
drawPos, new Vector2(rect.Width, rect.Height),
|
||||||
new Color((s.damage / prefab.MaxHealth), 1.0f - (s.damage / prefab.MaxHealth), 0.0f, 1.0f), true);
|
new Color((s.damage / prefab.MaxHealth), 1.0f - (s.damage / prefab.MaxHealth), 0.0f, 1.0f), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s.isHighLighted = false;
|
s.isHighLighted = false;
|
||||||
|
|
||||||
if (s.damage < 0.01f) continue;
|
if (s.damage < 0.01f) continue;
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Rectangle((int)s.rect.X, (int)-s.rect.Y, (int)s.rect.Width, (int)s.rect.Height),
|
drawPos, new Vector2(rect.Width, rect.Height),
|
||||||
Color.Black * (s.damage / prefab.MaxHealth), true);
|
Color.Black * (s.damage / prefab.MaxHealth), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +476,7 @@ namespace Barotrauma
|
|||||||
gapRect.Y += 10;
|
gapRect.Y += 10;
|
||||||
gapRect.Width += 20;
|
gapRect.Width += 20;
|
||||||
gapRect.Height += 20;
|
gapRect.Height += 20;
|
||||||
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal);
|
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,7 +592,7 @@ namespace Barotrauma
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Load(XElement element)
|
public static void Load(XElement element, Submarine submarine)
|
||||||
{
|
{
|
||||||
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
||||||
string[] rectValues = rectString.Split(',');
|
string[] rectValues = rectString.Split(',');
|
||||||
@@ -609,7 +611,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (ep.Name == name)
|
if (ep.Name == name)
|
||||||
{
|
{
|
||||||
s = new Structure(rect, (StructurePrefab)ep);
|
s = new Structure(rect, (StructurePrefab)ep, submarine);
|
||||||
|
s.Submarine = submarine;
|
||||||
s.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
s.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
|
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
|
||||||
{
|
{
|
||||||
new Structure(newRect, this);
|
new Structure(newRect, this, Submarine.Loaded);
|
||||||
selected = null;
|
selected = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace Barotrauma
|
|||||||
private string filePath;
|
private string filePath;
|
||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
|
private Vector2 prevPosition;
|
||||||
|
|
||||||
private float lastNetworkUpdate;
|
private float lastNetworkUpdate;
|
||||||
|
|
||||||
@@ -94,13 +95,17 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Vector2 Position
|
||||||
|
|
||||||
public Vector2 Position
|
|
||||||
{
|
{
|
||||||
get { return subBody.Position; }
|
get { return subBody.Position; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new Vector2 DrawPosition
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 Speed
|
public Vector2 Speed
|
||||||
{
|
{
|
||||||
get { return subBody==null ? Vector2.Zero : subBody.Speed; }
|
get { return subBody==null ? Vector2.Zero : subBody.Speed; }
|
||||||
@@ -129,7 +134,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//constructors & generation ----------------------------------------------------
|
//constructors & generation ----------------------------------------------------
|
||||||
|
|
||||||
public Submarine(string filePath, string hash = "")
|
public Submarine(string filePath, string hash = "") : base(null)
|
||||||
{
|
{
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
try
|
try
|
||||||
@@ -180,6 +185,12 @@ namespace Barotrauma
|
|||||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
|
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Submarine.Loaded!=null)
|
||||||
|
{
|
||||||
|
Submarine.Loaded.DrawPosition = Physics.Interpolate(Submarine.Loaded.prevPosition, Submarine.Loaded.Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (loaded == null) return;
|
if (loaded == null) return;
|
||||||
|
|
||||||
//foreach (HullBody hb in loaded.hullBodies)
|
//foreach (HullBody hb in loaded.hullBodies)
|
||||||
@@ -373,6 +384,12 @@ namespace Barotrauma
|
|||||||
if (subBody != null) subBody.ApplyForce(force);
|
if (subBody != null) subBody.ApplyForce(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetPrevTransform(Vector2 position, Camera cam = null)
|
||||||
|
{
|
||||||
|
if (cam != null) cam.Position += prevPosition - position;
|
||||||
|
prevPosition = position;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetPosition(Vector2 position)
|
public void SetPosition(Vector2 position)
|
||||||
{
|
{
|
||||||
if (!MathUtils.IsValid(position)) return;
|
if (!MathUtils.IsValid(position)) return;
|
||||||
@@ -618,7 +635,7 @@ namespace Barotrauma
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
MethodInfo loadMethod = t.GetMethod("Load");
|
MethodInfo loadMethod = t.GetMethod("Load");
|
||||||
loadMethod.Invoke(t, new object[] { element });
|
loadMethod.Invoke(t, new object[] { element, this });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace Barotrauma
|
|||||||
basicEffect.Texture = texture;
|
basicEffect.Texture = texture;
|
||||||
|
|
||||||
basicEffect.View = Matrix.Identity;
|
basicEffect.View = Matrix.Identity;
|
||||||
basicEffect.World = cam.ShaderTransform
|
basicEffect.World = transform
|
||||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||||
|
|
||||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||||
|
|||||||
@@ -63,7 +63,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WayPoint(Rectangle newRect)
|
public WayPoint(Vector2 position, SpawnType spawnType, Submarine submarine, Gap gap = null)
|
||||||
|
: this(new Rectangle((int)position.X-3, (int)position.Y+3, 6, 6), submarine)
|
||||||
|
{
|
||||||
|
this.spawnType = spawnType;
|
||||||
|
ConnectedGap = gap;
|
||||||
|
}
|
||||||
|
public WayPoint(Rectangle newRect, Submarine submarine)
|
||||||
|
: base (submarine)
|
||||||
{
|
{
|
||||||
rect = newRect;
|
rect = newRect;
|
||||||
linkedTo = new ObservableCollection<MapEntity>();
|
linkedTo = new ObservableCollection<MapEntity>();
|
||||||
@@ -73,14 +80,6 @@ namespace Barotrauma
|
|||||||
WayPointList.Add(this);
|
WayPointList.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WayPoint(Vector2 position, SpawnType spawnType, Gap gap = null)
|
|
||||||
:this(new Rectangle((int)position.X-3, (int)position.Y+3, 6, 6))
|
|
||||||
{
|
|
||||||
this.spawnType = spawnType;
|
|
||||||
ConnectedGap = gap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back=true)
|
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back=true)
|
||||||
{
|
{
|
||||||
if (!editing && !GameMain.DebugDraw) return;
|
if (!editing && !GameMain.DebugDraw) return;
|
||||||
@@ -228,13 +227,13 @@ namespace Barotrauma
|
|||||||
if (hull.Rect.Width<minDist*3.0f)
|
if (hull.Rect.Width<minDist*3.0f)
|
||||||
{
|
{
|
||||||
var wayPoint = new WayPoint(
|
var wayPoint = new WayPoint(
|
||||||
new Vector2(hull.Rect.X + hull.Rect.Width / 2.0f, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path);
|
new Vector2(hull.Rect.X + hull.Rect.Width / 2.0f, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (float x = hull.Rect.X + minDist; x <= hull.Rect.X + hull.Rect.Width - minDist; x += minDist)
|
for (float x = hull.Rect.X + minDist; x <= hull.Rect.X + hull.Rect.Width - minDist; x += minDist)
|
||||||
{
|
{
|
||||||
var wayPoint = new WayPoint(new Vector2(x, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path);
|
var wayPoint = new WayPoint(new Vector2(x, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
||||||
|
|
||||||
if (prevWaypoint != null) wayPoint.ConnectTo(prevWaypoint);
|
if (prevWaypoint != null) wayPoint.ConnectTo(prevWaypoint);
|
||||||
|
|
||||||
@@ -257,11 +256,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
stairPoints[0] = new WayPoint(
|
stairPoints[0] = new WayPoint(
|
||||||
new Vector2(stairs.Rect.X - 50.0f,
|
new Vector2(stairs.Rect.X - 50.0f,
|
||||||
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? 80 : stairs.Rect.Height) + heightFromFloor), SpawnType.Path);
|
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? 80 : stairs.Rect.Height) + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
||||||
|
|
||||||
stairPoints[1] = new WayPoint(
|
stairPoints[1] = new WayPoint(
|
||||||
new Vector2(stairs.Rect.Right + 50.0f,
|
new Vector2(stairs.Rect.Right + 50.0f,
|
||||||
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? stairs.Rect.Height : 80) + heightFromFloor), SpawnType.Path);
|
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? stairs.Rect.Height : 80) + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++ )
|
for (int i = 0; i < 2; i++ )
|
||||||
{
|
{
|
||||||
@@ -281,7 +280,7 @@ namespace Barotrauma
|
|||||||
if (!gap.isHorizontal) continue;
|
if (!gap.isHorizontal) continue;
|
||||||
|
|
||||||
var wayPoint = new WayPoint(
|
var wayPoint = new WayPoint(
|
||||||
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height + heightFromFloor), SpawnType.Path, gap);
|
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded, gap);
|
||||||
|
|
||||||
for (int dir = -1; dir <= 1; dir += 2)
|
for (int dir = -1; dir <= 1; dir += 2)
|
||||||
{
|
{
|
||||||
@@ -442,14 +441,14 @@ namespace Barotrauma
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Load(XElement element)
|
public static void Load(XElement element, Submarine submarine)
|
||||||
{
|
{
|
||||||
Rectangle rect = new Rectangle(
|
Rectangle rect = new Rectangle(
|
||||||
int.Parse(element.Attribute("x").Value),
|
int.Parse(element.Attribute("x").Value),
|
||||||
int.Parse(element.Attribute("y").Value),
|
int.Parse(element.Attribute("y").Value),
|
||||||
(int)Submarine.GridSize.X, (int)Submarine.GridSize.Y);
|
(int)Submarine.GridSize.X, (int)Submarine.GridSize.Y);
|
||||||
|
|
||||||
WayPoint w = new WayPoint(rect);
|
WayPoint w = new WayPoint(rect, submarine);
|
||||||
|
|
||||||
w.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
w.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||||
w.spawnType = (SpawnType)Enum.Parse(typeof(SpawnType),
|
w.spawnType = (SpawnType)Enum.Parse(typeof(SpawnType),
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Vector2 DrawPosition
|
public Vector2 DrawPosition
|
||||||
{
|
{
|
||||||
get { return drawPosition; }
|
get { return Submarine == null ? drawPosition : drawPosition + Submarine.DrawPosition; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public float DrawRotation
|
public float DrawRotation
|
||||||
@@ -96,6 +96,8 @@ namespace Barotrauma
|
|||||||
get { return drawRotation; }
|
get { return drawRotation; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Submarine Submarine;
|
||||||
|
|
||||||
public float Dir
|
public float Dir
|
||||||
{
|
{
|
||||||
get { return dir; }
|
get { return dir; }
|
||||||
@@ -313,7 +315,7 @@ namespace Barotrauma
|
|||||||
color = Color.Blue;
|
color = Color.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprite.Draw(spriteBatch, new Vector2(drawPosition.X, -drawPosition.Y), color, -drawRotation, 1.0f, spriteEffect, depth);
|
sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, -drawRotation, 1.0f, spriteEffect, depth);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace Barotrauma
|
|||||||
Sounds.SoundManager.LowPassHFGain = 1.0f;
|
Sounds.SoundManager.LowPassHFGain = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rendc;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows the game to run logic such as updating the world,
|
/// Allows the game to run logic such as updating the world,
|
||||||
/// checking for collisions, gathering input, and playing audio.
|
/// checking for collisions, gathering input, and playing audio.
|
||||||
@@ -94,12 +96,14 @@ namespace Barotrauma
|
|||||||
|
|
||||||
StatusEffect.UpdateAll((float)deltaTime);
|
StatusEffect.UpdateAll((float)deltaTime);
|
||||||
|
|
||||||
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 4);
|
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 6);
|
||||||
//Physics.accumulator = Physics.step;
|
//Physics.accumulator = Physics.step;
|
||||||
while (Physics.accumulator >= Physics.step)
|
while (Physics.accumulator >= Physics.step)
|
||||||
{
|
{
|
||||||
cam.MoveCamera((float)Physics.step);
|
cam.MoveCamera((float)Physics.step);
|
||||||
|
|
||||||
|
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position, cam);
|
||||||
|
|
||||||
foreach (PhysicsBody pb in PhysicsBody.list)
|
foreach (PhysicsBody pb in PhysicsBody.list)
|
||||||
{
|
{
|
||||||
pb.SetPrevTransform(pb.SimPosition, pb.Rotation);
|
pb.SetPrevTransform(pb.SimPosition, pb.Rotation);
|
||||||
@@ -229,7 +233,7 @@ namespace Barotrauma
|
|||||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||||
BlendState.AlphaBlend,
|
BlendState.AlphaBlend,
|
||||||
null, null, null, null,
|
null, null, null, null,
|
||||||
Matrix.CreateTranslation(new Vector3(Submarine.Loaded.Position.X, -Submarine.Loaded.Position.Y, 0.0f))*cam.Transform);
|
cam.Transform);
|
||||||
|
|
||||||
Submarine.DrawBack(spriteBatch);
|
Submarine.DrawBack(spriteBatch);
|
||||||
|
|
||||||
@@ -315,7 +319,7 @@ namespace Barotrauma
|
|||||||
hull.Render(graphics, cam);
|
hull.Render(graphics, cam);
|
||||||
}
|
}
|
||||||
|
|
||||||
Hull.renderer.Render(graphics, cam, renderTargetAir,Cam.ShaderTransform);
|
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
|
||||||
|
|
||||||
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
|
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
|
||||||
{
|
{
|
||||||
@@ -330,7 +334,7 @@ namespace Barotrauma
|
|||||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||||
BlendState.AlphaBlend, SamplerState.LinearWrap,
|
BlendState.AlphaBlend, SamplerState.LinearWrap,
|
||||||
null, null, null,
|
null, null, null,
|
||||||
Matrix.CreateTranslation(new Vector3(Submarine.Loaded.Position.X, -Submarine.Loaded.Position.Y, 0.0f))*cam.Transform);
|
cam.Transform);
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch);
|
foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch);
|
||||||
|
|
||||||
|
|||||||
@@ -216,8 +216,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Vector2 startOffset, Color color)
|
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Vector2 startOffset, Color color)
|
||||||
{
|
{
|
||||||
pos.X = (int)pos.X;
|
//pos.X = (int)pos.X;
|
||||||
pos.Y = (int)pos.Y;
|
//pos.Y = (int)pos.Y;
|
||||||
|
|
||||||
//how many times the texture needs to be drawn on the x-axis
|
//how many times the texture needs to be drawn on the x-axis
|
||||||
int xTiles = (int)Math.Ceiling((targetSize.X+startOffset.X) / sourceRect.Width);
|
int xTiles = (int)Math.Ceiling((targetSize.X+startOffset.X) / sourceRect.Width);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user