Fixed server end cinematic, bugfix in submarine position syncing, CharacterIgnoreDistance bugfix, readded crew button to multiplayer, searching a path out of the sub
This commit is contained in:
@@ -62,10 +62,26 @@ namespace Barotrauma
|
||||
|
||||
if (target!=null) character.AIController.SelectTarget(target.AiTarget);
|
||||
|
||||
character.AIController.SteeringManager.SteeringSeek(
|
||||
target != null ? target.SimPosition : targetPos);
|
||||
|
||||
Vector2 currTargetPos = target != null ? target.SimPosition : targetPos;
|
||||
Vector2 currTargetPos = Vector2.Zero;
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
currTargetPos = targetPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
currTargetPos = target.SimPosition;
|
||||
|
||||
//if character is outside the sub and target isn't, transform the position
|
||||
if (character.Submarine == null && target.Submarine != null)
|
||||
{
|
||||
currTargetPos += target.Submarine.SimPosition;
|
||||
}
|
||||
}
|
||||
|
||||
character.AIController.SteeringManager.SteeringSeek(currTargetPos);
|
||||
|
||||
if (Vector2.Distance(currTargetPos, character.SimPosition) < 1.0f)
|
||||
{
|
||||
character.AnimController.TargetDir = currTargetPos.X > character.SimPosition.X ? Direction.Right : Direction.Left;
|
||||
|
||||
@@ -100,12 +100,22 @@ namespace Barotrauma
|
||||
PathNode startNode = null;
|
||||
foreach (PathNode node in nodes)
|
||||
{
|
||||
float dist = System.Math.Abs(start.X-node.Position.X)+
|
||||
System.Math.Abs(start.Y - node.Position.Y)*10.0f +
|
||||
Vector2.Distance(end,node.Position)/2.0f;
|
||||
Vector2 nodePos = node.Position;
|
||||
|
||||
//if node waypoint is one of submarine waypoints outside the sub, transform position
|
||||
if (node.Waypoint != null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull == null)
|
||||
{
|
||||
nodePos -= node.Waypoint.Submarine.Position;
|
||||
}
|
||||
|
||||
float dist = System.Math.Abs(start.X-nodePos.X)+
|
||||
System.Math.Abs(start.Y - nodePos.Y)*10.0f +
|
||||
Vector2.Distance(end,nodePos)/2.0f;
|
||||
|
||||
if (dist<closestDist || startNode==null)
|
||||
{
|
||||
if (insideSubmarine && Submarine.CheckVisibility(start, node.Position) != null) continue;
|
||||
//if searching for a path inside the sub, make sure the waypoint is visible
|
||||
if (insideSubmarine && node.Waypoint.CurrentHull != null && Submarine.CheckVisibility(start, node.Waypoint.SimPosition) != null) continue;
|
||||
|
||||
closestDist = dist;
|
||||
startNode = node;
|
||||
@@ -122,10 +132,19 @@ namespace Barotrauma
|
||||
PathNode endNode = null;
|
||||
foreach (PathNode node in nodes)
|
||||
{
|
||||
float dist = Vector2.Distance(end, node.Position);
|
||||
Vector2 nodePos = node.Position;
|
||||
|
||||
//if node waypoint is one of submarine waypoints outside the sub, transform position
|
||||
if (node.Waypoint!=null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull==null)
|
||||
{
|
||||
nodePos -= node.Waypoint.Submarine.Position;
|
||||
}
|
||||
|
||||
float dist = Vector2.Distance(end, nodePos);
|
||||
if (dist < closestDist || endNode == null)
|
||||
{
|
||||
if (insideSubmarine && Submarine.CheckVisibility(end, node.Waypoint.SimPosition) != null) continue;
|
||||
//if searching for a path inside the sub, make sure the waypoint is visible
|
||||
if (insideSubmarine && node.Waypoint.CurrentHull!=null && Submarine.CheckVisibility(end, node.Waypoint.SimPosition) != null) continue;
|
||||
|
||||
closestDist = dist;
|
||||
endNode = node;
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Barotrauma
|
||||
//{
|
||||
//if (RefLimb.ignoreCollisions) continue;
|
||||
|
||||
if ((AnimController.RefLimb.SimPosition - Submarine.Loaded.SimPosition).Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
//if ((AnimController.RefLimb.SimPosition - Submarine.Loaded.SimPosition).Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
|
||||
message.Write(AnimController.RefLimb.SimPosition.X);
|
||||
message.Write(AnimController.RefLimb.SimPosition.Y);
|
||||
@@ -94,15 +94,15 @@ namespace Barotrauma
|
||||
aiController.FillNetworkData(message);
|
||||
return true;
|
||||
case NetworkEventType.EntityUpdate:
|
||||
if (Submarine == null)
|
||||
{
|
||||
if ((AnimController.RefLimb.SimPosition - Submarine.Loaded.SimPosition).Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
//if (Submarine == null)
|
||||
//{
|
||||
// if ((AnimController.RefLimb.SimPosition - Submarine.Loaded.SimPosition).Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AnimController.RefLimb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (AnimController.RefLimb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||
//}
|
||||
|
||||
|
||||
message.Write(AnimController.TargetDir == Direction.Right);
|
||||
|
||||
@@ -11,9 +11,11 @@ namespace Barotrauma
|
||||
|
||||
private Character monster;
|
||||
|
||||
private Vector2 radarPosition;
|
||||
|
||||
public override Vector2 RadarPosition
|
||||
{
|
||||
get { return monster.Position; }
|
||||
get { return radarPosition; }
|
||||
}
|
||||
|
||||
public MonsterMission(XElement element)
|
||||
@@ -27,6 +29,7 @@ namespace Barotrauma
|
||||
Vector2 position = level.PositionsOfInterest[Rand.Int(level.PositionsOfInterest.Count, false)];
|
||||
|
||||
monster = Character.Create(monsterFile, position);
|
||||
radarPosition = monster.Position;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
@@ -34,6 +37,8 @@ namespace Barotrauma
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
if (monster.Enabled) radarPosition = monster.Position;
|
||||
|
||||
if (!monster.IsDead) return;
|
||||
ShowMessage(state);
|
||||
state = 1;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -225,7 +226,7 @@ namespace Barotrauma
|
||||
AddCharacter(character);
|
||||
}
|
||||
|
||||
if (characters.Count > 0) SelectCharacter(null, characters[0]);
|
||||
if (characters.Any()) listBox.Select(0);// SelectCharacter(null, characters[0]);
|
||||
}
|
||||
|
||||
public void EndShift()
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Barotrauma
|
||||
{
|
||||
isRunning = false;
|
||||
|
||||
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam);
|
||||
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, 5.0f);
|
||||
|
||||
SoundPlayer.OverrideMusicType = CrewManager.characters.Any(c => !c.IsDead) ? "endshift" : "crewdead";
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Barotrauma
|
||||
get { return Vector2.Zero; }
|
||||
}
|
||||
|
||||
public Vector2 WorldPosition
|
||||
public virtual Vector2 WorldPosition
|
||||
{
|
||||
get { return Submarine == null ? Position : Submarine.Position + Position; }
|
||||
}
|
||||
|
||||
@@ -170,15 +170,14 @@ namespace Barotrauma
|
||||
InsertToList();
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
public static void GenerateEntityGrid()
|
||||
{
|
||||
|
||||
if (entityGrid == null)
|
||||
entityGrid = new EntityGrid(Submarine.Borders, 200.0f);
|
||||
|
||||
foreach (Hull hull in hullList)
|
||||
{
|
||||
entityGrid = new EntityGrid(Submarine.Borders, 200.0f);
|
||||
entityGrid.InsertEntity(hull);
|
||||
}
|
||||
|
||||
entityGrid.InsertEntity(this);
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 position)
|
||||
|
||||
@@ -499,13 +499,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mapEntityList.Count; i++)
|
||||
{
|
||||
if (mapEntityList[i].Submarine != null) mapEntityList[i].Move(Submarine.HiddenSubPosition);
|
||||
}
|
||||
|
||||
for (int i = 0; i<mapEntityList.Count; i++)
|
||||
{
|
||||
MapEntity e = mapEntityList[i];
|
||||
|
||||
e.OnMapLoaded();
|
||||
|
||||
if (e.Submarine != null) e.Move(Submarine.HiddenSubPosition);
|
||||
mapEntityList[i].OnMapLoaded();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -105,6 +105,14 @@ namespace Barotrauma
|
||||
get { return subBody==null ? Vector2.Zero : subBody.Position - HiddenSubPosition; }
|
||||
}
|
||||
|
||||
public override Vector2 WorldPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConvertUnits.ToDisplayUnits(subBody.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AtEndPosition
|
||||
{
|
||||
get
|
||||
@@ -136,7 +144,7 @@ namespace Barotrauma
|
||||
return ConvertUnits.ToSimUnits(Position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Vector2 Velocity
|
||||
{
|
||||
get { return subBody==null ? Vector2.Zero : subBody.Velocity; }
|
||||
@@ -661,6 +669,8 @@ namespace Barotrauma
|
||||
|
||||
loaded = this;
|
||||
|
||||
Hull.GenerateEntityGrid();
|
||||
|
||||
MapEntity.MapLoaded();
|
||||
|
||||
WayPoint.GenerateSubWaypoints();
|
||||
|
||||
@@ -212,20 +212,27 @@ namespace Barotrauma
|
||||
{
|
||||
if (targetPosition != null && targetPosition != Position)
|
||||
{
|
||||
Vector2 targetSimPos = ConvertUnits.ToSimUnits((Vector2)targetPosition);
|
||||
//Vector2 targetSimPos = ConvertUnits.ToSimUnits((Vector2)targetPosition);
|
||||
|
||||
float dist = Vector2.Distance((Vector2)targetPosition, Position);
|
||||
System.Diagnostics.Debug.WriteLine(targetPosition + " -> " + Position + " - " + dist);
|
||||
if (dist > 1000.0f)
|
||||
{
|
||||
body.SetTransform(targetSimPos, 0.0f);
|
||||
body.SetTransform(ConvertUnits.ToSimUnits((Vector2)targetPosition), 0.0f);
|
||||
|
||||
GameMain.GameScreen.Cam.Position = submarine.Position + Submarine.HiddenSubPosition;
|
||||
targetPosition = null;
|
||||
}
|
||||
else if (dist > 50.0f)
|
||||
{
|
||||
Vector2 moveAmount = Vector2.Normalize(targetSimPos - body.Position);
|
||||
moveAmount *= Math.Min(dist, 100.0f);
|
||||
Vector2 moveAmount = Vector2.Normalize((Vector2)targetPosition - Position);
|
||||
moveAmount *= ConvertUnits.ToSimUnits(Math.Min(dist, 100.0f));
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("moveamount: "+moveAmount);
|
||||
|
||||
body.SetTransform(body.Position + moveAmount * deltaTime, 0.0f);
|
||||
|
||||
//GameMain.GameScreen.Cam.Position += ConvertUnits.ToDisplayUnits(moveAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -15,8 +15,10 @@ namespace Barotrauma
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private float duration;
|
||||
|
||||
public TransitionCinematic(Submarine submarine, Camera cam)
|
||||
public TransitionCinematic(Submarine submarine, Camera cam, float duration)
|
||||
{
|
||||
Vector2 targetPos = submarine.Position;
|
||||
|
||||
@@ -29,6 +31,8 @@ namespace Barotrauma
|
||||
targetPos = Level.Loaded.StartPosition + Vector2.UnitY * 500.0f;
|
||||
}
|
||||
|
||||
this.duration = duration;
|
||||
|
||||
Running = true;
|
||||
CoroutineManager.StartCoroutine(UpdateTransitionCinematic(submarine, cam, targetPos));
|
||||
}
|
||||
@@ -46,7 +50,6 @@ namespace Barotrauma
|
||||
Level.Loaded.ShaftBodies[1].Enabled = false;
|
||||
|
||||
cam.TargetPos = Vector2.Zero;
|
||||
float duration = 5.0f;
|
||||
float timer = 0.0f;
|
||||
|
||||
while (timer < duration)
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace Barotrauma
|
||||
|
||||
InsertToList();
|
||||
WayPointList.Add(this);
|
||||
|
||||
currentHull = Hull.FindHull(WorldPosition);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back=true)
|
||||
@@ -472,7 +474,7 @@ namespace Barotrauma
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
currentHull = Hull.FindHull(WorldPosition);
|
||||
currentHull = Hull.FindHull(WorldPosition, currentHull);
|
||||
}
|
||||
|
||||
public override XElement Save(XDocument doc)
|
||||
|
||||
@@ -596,27 +596,51 @@ namespace Barotrauma.Networking
|
||||
Character.Controlled = null;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
|
||||
float endPreviewLength = 10.0f;
|
||||
|
||||
DateTime endTime = DateTime.Now + new TimeSpan(0,0,0,0,(int)(1000.0f*endPreviewLength));
|
||||
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
|
||||
float secondsLeft = endPreviewLength;
|
||||
|
||||
do
|
||||
{
|
||||
secondsLeft = (float)(endTime - DateTime.Now).TotalSeconds;
|
||||
secondsLeft -= CoroutineManager.DeltaTime;
|
||||
|
||||
float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
|
||||
Vector2 offset = (new Vector2(
|
||||
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
//float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
|
||||
//Vector2 offset = (new Vector2(
|
||||
// (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
// (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.DrawPosition + offset * 0.8f;
|
||||
//GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f;
|
||||
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
} while (secondsLeft > 0.0f);
|
||||
|
||||
//float endPreviewLength = 10.0f;
|
||||
|
||||
//DateTime endTime = DateTime.Now + new TimeSpan(0,0,0,0,(int)(1000.0f*endPreviewLength));
|
||||
//float secondsLeft = endPreviewLength;
|
||||
|
||||
//do
|
||||
//{
|
||||
// secondsLeft = (float)(endTime - DateTime.Now).TotalSeconds;
|
||||
|
||||
// float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
|
||||
// Vector2 offset = (new Vector2(
|
||||
// (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
// (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
// GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.DrawPosition + offset * 0.8f;
|
||||
// //Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
// messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
|
||||
// yield return CoroutineStatus.Running;
|
||||
//} while (secondsLeft > 0.0f);
|
||||
|
||||
messageBox.Close(null,null);
|
||||
|
||||
Submarine.Unload();
|
||||
|
||||
@@ -288,7 +288,9 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (!(c is AICharacter) || c.IsDead) continue;
|
||||
|
||||
if (c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue;
|
||||
Vector2 diff = Submarine.Loaded.WorldPosition - c.WorldPosition;
|
||||
|
||||
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
||||
|
||||
new NetworkEvent(NetworkEventType.EntityUpdate, c.ID, false);
|
||||
}
|
||||
@@ -318,7 +320,12 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (c.IsDead) continue;
|
||||
|
||||
if (c is AICharacter && c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue;
|
||||
if (c is AICharacter)
|
||||
{
|
||||
Vector2 diff = c.WorldPosition - Submarine.Loaded.WorldPosition;
|
||||
|
||||
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
||||
}
|
||||
|
||||
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, c.ID, false);
|
||||
}
|
||||
@@ -870,19 +877,20 @@ namespace Barotrauma.Networking
|
||||
|
||||
float endPreviewLength = 10.0f;
|
||||
|
||||
DateTime endTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, (int)(1000.0f * endPreviewLength));
|
||||
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
|
||||
float secondsLeft = endPreviewLength;
|
||||
|
||||
do
|
||||
{
|
||||
secondsLeft = (float)(endTime - DateTime.Now).TotalSeconds;
|
||||
secondsLeft -= CoroutineManager.DeltaTime;
|
||||
|
||||
float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
|
||||
Vector2 offset = (new Vector2(
|
||||
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
//float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
|
||||
//Vector2 offset = (new Vector2(
|
||||
// (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
// (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f;
|
||||
//GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f;
|
||||
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
|
||||
|
||||
@@ -206,6 +206,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
inGameHUD.Update(deltaTime);
|
||||
|
||||
GameMain.GameSession.CrewManager.Update(deltaTime);
|
||||
|
||||
//if (crewFrameOpen) crewFrame.Update(deltaTime);
|
||||
|
||||
if (Character.Controlled == null || Character.Controlled.IsDead)
|
||||
@@ -233,6 +235,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (!gameStarted || Screen.Selected != GameMain.GameScreen) return;
|
||||
|
||||
GameMain.GameSession.CrewManager.Draw(spriteBatch);
|
||||
|
||||
inGameHUD.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user