- host can respawn
- respawn info texts - camera clamped to the the upper edge of the level - fixed submarinebody being generated from all walls (and not just the ones belonging to that specific sub)
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
<item name="Wrench"/>
|
<item name="Wrench"/>
|
||||||
</fixrequirement>
|
</fixrequirement>
|
||||||
|
|
||||||
<Engine minvoltage="0.5" powerconsumption="500.0" maxforce="500" canbeselected = "true">
|
<Engine minvoltage="0.5" powerconsumption="500.0" maxforce="300" canbeselected = "true">
|
||||||
<StatusEffect type="InWater" target="This" condition="-2.0"/>
|
<StatusEffect type="InWater" target="This" condition="-2.0"/>
|
||||||
<GuiFrame rect="0,0,350,160" alignment="Center" color="0.0,0.0,0.0,0.6"/>
|
<GuiFrame rect="0,0,350,160" alignment="Center" color="0.0,0.0,0.0,0.6"/>
|
||||||
<sound file="engine.ogg" type="OnActive" range="3000.0" volume="CurrentVolume" loop="true"/>
|
<sound file="engine.ogg" type="OnActive" range="3000.0" volume="CurrentVolume" loop="true"/>
|
||||||
|
|||||||
@@ -125,17 +125,11 @@ namespace Barotrauma
|
|||||||
public void Translate(Vector2 amount)
|
public void Translate(Vector2 amount)
|
||||||
{
|
{
|
||||||
position += amount;
|
position += amount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTransform(bool interpolate = true, bool clampPos = false)
|
public void UpdateTransform(bool interpolate = true, bool clampPos = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (clampPos && Level.Loaded != null)
|
|
||||||
{
|
|
||||||
position.Y -= Math.Max(worldView.Y - Level.Loaded.Size.Y, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 interpolatedPosition = interpolate ? Physics.Interpolate(prevPosition, position) : position;
|
Vector2 interpolatedPosition = interpolate ? Physics.Interpolate(prevPosition, position) : position;
|
||||||
|
|
||||||
float interpolatedZoom = interpolate ? Physics.Interpolate(prevZoom, zoom) : zoom;
|
float interpolatedZoom = interpolate ? Physics.Interpolate(prevZoom, zoom) : zoom;
|
||||||
@@ -143,6 +137,13 @@ namespace Barotrauma
|
|||||||
worldView.X = (int)(interpolatedPosition.X - worldView.Width / 2.0);
|
worldView.X = (int)(interpolatedPosition.X - worldView.Width / 2.0);
|
||||||
worldView.Y = (int)(interpolatedPosition.Y + worldView.Height / 2.0);
|
worldView.Y = (int)(interpolatedPosition.Y + worldView.Height / 2.0);
|
||||||
|
|
||||||
|
|
||||||
|
if (Level.Loaded != null && clampPos)
|
||||||
|
{
|
||||||
|
position.Y -= Math.Max(worldView.Y - Level.Loaded.Size.Y, 0.0f);
|
||||||
|
interpolatedPosition.Y -= Math.Max(worldView.Y - Level.Loaded.Size.Y, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
transform = Matrix.CreateTranslation(
|
transform = Matrix.CreateTranslation(
|
||||||
new Vector3(-interpolatedPosition.X, interpolatedPosition.Y, 0)) *
|
new Vector3(-interpolatedPosition.X, interpolatedPosition.Y, 0)) *
|
||||||
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *
|
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *
|
||||||
@@ -221,9 +222,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
shakeTargetPosition = Rand.Vector(Shake);
|
shakeTargetPosition = Rand.Vector(Shake);
|
||||||
shakePosition = Vector2.Lerp(shakePosition, shakeTargetPosition, 0.5f);
|
shakePosition = Vector2.Lerp(shakePosition, shakeTargetPosition, 0.5f);
|
||||||
Shake = MathHelper.Lerp(Shake, 0.0f, deltaTime*2.0f);
|
Shake = MathHelper.Lerp(Shake, 0.0f, deltaTime * 2.0f);
|
||||||
|
|
||||||
Translate(moveCam+shakePosition);
|
Translate(moveCam + shakePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 Position
|
public Vector2 Position
|
||||||
|
|||||||
@@ -105,9 +105,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (currentPath == null) return Vector2.Zero;
|
if (currentPath == null) return Vector2.Zero;
|
||||||
|
|
||||||
if (currentPath.CurrentIndex == currentPath.Nodes.Count)
|
if (currentPath.Finished)
|
||||||
{
|
{
|
||||||
|
|
||||||
Vector2 pos2 = host.SimPosition;
|
Vector2 pos2 = host.SimPosition;
|
||||||
if (character != null && character.Submarine == null && CurrentPath.Nodes.Last().Submarine != null)
|
if (character != null && character.Submarine == null && CurrentPath.Nodes.Last().Submarine != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Finished
|
||||||
|
{
|
||||||
|
get { return currentIndex >= nodes.Count; }
|
||||||
|
}
|
||||||
|
|
||||||
public void SkipToNextNode()
|
public void SkipToNextNode()
|
||||||
{
|
{
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
|
|||||||
@@ -444,28 +444,31 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (connection.Name=="toggle")
|
if (connection.Name=="toggle")
|
||||||
{
|
{
|
||||||
SetState(!isOpen, false);
|
SetState(!isOpen, false, true);
|
||||||
}
|
}
|
||||||
else if (connection.Name == "set_state")
|
else if (connection.Name == "set_state")
|
||||||
{
|
{
|
||||||
SetState(signal != "0", false);
|
SetState(signal != "0", false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
item.NewComponentEvent(this, false, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetState(bool state, bool isNetWorkMessage)
|
public void SetState(bool open, bool isNetworkMessage, bool sendNetworkMessage = false)
|
||||||
{
|
{
|
||||||
if (GameMain.Client != null && !isNetWorkMessage) return;
|
if (GameMain.Client != null && !isNetworkMessage) return;
|
||||||
|
|
||||||
if (isStuck || isOpen == state) return;
|
if (isStuck || isOpen == open) return;
|
||||||
|
|
||||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||||
|
|
||||||
isOpen = state;
|
isOpen = open;
|
||||||
|
|
||||||
//opening a partially stuck door makes it less stuck
|
//opening a partially stuck door makes it less stuck
|
||||||
if (isOpen) stuck = MathHelper.Clamp(stuck - 30.0f, 0.0f, 100.0f);
|
if (isOpen) stuck = MathHelper.Clamp(stuck - 30.0f, 0.0f, 100.0f);
|
||||||
|
|
||||||
|
if (sendNetworkMessage)
|
||||||
|
{
|
||||||
|
item.NewComponentEvent(this, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
class Level
|
class Level
|
||||||
{
|
{
|
||||||
|
public const float ShaftHeight = 1000.0f;
|
||||||
|
|
||||||
public static Level Loaded
|
public static Level Loaded
|
||||||
{
|
{
|
||||||
get { return loaded; }
|
get { return loaded; }
|
||||||
@@ -56,7 +58,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private WrappingWall[,] wrappingWalls;
|
private WrappingWall[,] wrappingWalls;
|
||||||
|
|
||||||
private float shaftHeight;
|
//private float shaftHeight;
|
||||||
|
|
||||||
//List<Body> bodies;
|
//List<Body> bodies;
|
||||||
private List<VoronoiCell> cells;
|
private List<VoronoiCell> cells;
|
||||||
@@ -513,7 +515,7 @@ namespace Barotrauma
|
|||||||
ShaftBodies = new Body[2];
|
ShaftBodies = new Body[2];
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 200.0f, 10.0f, 5.0f);
|
ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 200.0f, ConvertUnits.ToSimUnits(ShaftHeight), 5.0f);
|
||||||
ShaftBodies[i].BodyType = BodyType.Static;
|
ShaftBodies[i].BodyType = BodyType.Static;
|
||||||
ShaftBodies[i].CollisionCategories = Physics.CollisionLevel;
|
ShaftBodies[i].CollisionCategories = Physics.CollisionLevel;
|
||||||
|
|
||||||
@@ -585,7 +587,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
List<WayPoint> wayPoints = new List<WayPoint>();
|
List<WayPoint> wayPoints = new List<WayPoint>();
|
||||||
|
|
||||||
var newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, (int)(borders.Height + shaftHeight), 10, 10), null);
|
var newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, borders.Height, 10, 10), null);
|
||||||
newWaypoint.MoveWithLevel = true;
|
newWaypoint.MoveWithLevel = true;
|
||||||
wayPoints.Add(newWaypoint);
|
wayPoints.Add(newWaypoint);
|
||||||
|
|
||||||
@@ -625,7 +627,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), null);
|
newWaypoint = new WayPoint(new Rectangle((int)pathCells[pathCells.Count - 1].Center.X, borders.Height, 10, 10), null);
|
||||||
newWaypoint.MoveWithLevel = true;
|
newWaypoint.MoveWithLevel = true;
|
||||||
wayPoints.Add(newWaypoint);
|
wayPoints.Add(newWaypoint);
|
||||||
|
|
||||||
|
|||||||
@@ -319,9 +319,11 @@ namespace Barotrauma.RuinGeneration
|
|||||||
(int)((wall.B.X - wall.A.X) + radius*2.0f),
|
(int)((wall.B.X - wall.A.X) + radius*2.0f),
|
||||||
(int)((wall.B.Y - wall.A.Y) + radius*2.0f));
|
(int)((wall.B.Y - wall.A.Y) + radius*2.0f));
|
||||||
|
|
||||||
|
//cut a section off from both ends of a horizontal wall to get nicer looking corners
|
||||||
if (wall.A.Y == wall.B.Y)
|
if (wall.A.Y == wall.B.Y)
|
||||||
{
|
{
|
||||||
rect.Inflate(-32, 0);
|
rect.Inflate(-32, 0);
|
||||||
|
if (rect.Width < Submarine.GridSize.X) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var structure = new Structure(rect, structurePrefab.Prefab as StructurePrefab, null);
|
var structure = new Structure(rect, structurePrefab.Prefab as StructurePrefab, null);
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (Structure wall in Structure.WallList)
|
foreach (Structure wall in Structure.WallList)
|
||||||
{
|
{
|
||||||
|
if (wall.Submarine != submarine) continue;
|
||||||
|
|
||||||
Rectangle rect = wall.Rect;
|
Rectangle rect = wall.Rect;
|
||||||
FixtureFactory.AttachRectangle(
|
FixtureFactory.AttachRectangle(
|
||||||
ConvertUnits.ToSimUnits(rect.Width),
|
ConvertUnits.ToSimUnits(rect.Width),
|
||||||
@@ -241,7 +243,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
ForceTranslate(moveAmount);
|
ForceTranslate(moveAmount);
|
||||||
|
|
||||||
if (submarine == Submarine.MainSub) GameMain.GameScreen.Cam.UpdateTransform(false);
|
if ((Character.Controlled != null && Character.Controlled.Submarine == submarine) ||
|
||||||
|
(Character.Controlled == null && Submarine.GetClosest(GameMain.GameScreen.Cam.WorldViewCenter) == submarine))
|
||||||
|
{
|
||||||
|
GameMain.GameScreen.Cam.UpdateTransform(false);
|
||||||
|
}
|
||||||
|
|
||||||
submarine.SetPrevTransform(submarine.Position);
|
submarine.SetPrevTransform(submarine.Position);
|
||||||
submarine.UpdateTransform();
|
submarine.UpdateTransform();
|
||||||
@@ -296,7 +302,7 @@ namespace Barotrauma
|
|||||||
if (Character.Controlled != null) Character.Controlled.CursorPosition += amount;
|
if (Character.Controlled != null) Character.Controlled.CursorPosition += amount;
|
||||||
|
|
||||||
if ((Character.Controlled != null && Character.Controlled.Submarine == submarine) ||
|
if ((Character.Controlled != null && Character.Controlled.Submarine == submarine) ||
|
||||||
Submarine.GetClosest(GameMain.GameScreen.Cam.WorldViewCenter) == submarine)
|
(Character.Controlled == null && Submarine.GetClosest(GameMain.GameScreen.Cam.WorldViewCenter) == submarine))
|
||||||
{
|
{
|
||||||
GameMain.GameScreen.Cam.Position += amount;
|
GameMain.GameScreen.Cam.Position += amount;
|
||||||
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += amount;
|
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += amount;
|
||||||
|
|||||||
@@ -413,6 +413,11 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
reliableChannel.Update(deltaTime);
|
reliableChannel.Update(deltaTime);
|
||||||
|
|
||||||
|
if (gameStarted && respawnManager != null)
|
||||||
|
{
|
||||||
|
respawnManager.Update(deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
if (updateTimer > DateTime.Now) return;
|
if (updateTimer > DateTime.Now) return;
|
||||||
|
|
||||||
if (myCharacter != null)
|
if (myCharacter != null)
|
||||||
@@ -730,6 +735,8 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||||
GameMain.LightManager.LosEnabled = false;
|
GameMain.LightManager.LosEnabled = false;
|
||||||
|
|
||||||
|
respawnManager = null;
|
||||||
|
|
||||||
float endPreviewLength = 10.0f;
|
float endPreviewLength = 10.0f;
|
||||||
|
|
||||||
if (Screen.Selected == GameMain.GameScreen)
|
if (Screen.Selected == GameMain.GameScreen)
|
||||||
@@ -779,11 +786,6 @@ namespace Barotrauma.Networking
|
|||||||
if (fileStreamReceiver != null &&
|
if (fileStreamReceiver != null &&
|
||||||
(fileStreamReceiver.Status == FileTransferStatus.Receiving || fileStreamReceiver.Status == FileTransferStatus.NotStarted))
|
(fileStreamReceiver.Status == FileTransferStatus.Receiving || fileStreamReceiver.Status == FileTransferStatus.NotStarted))
|
||||||
{
|
{
|
||||||
//Vector2 pos = Screen.Selected == GameMain.NetLobbyScreen ?
|
|
||||||
// new Vector2(GameMain.NetLobbyScreen.SubList.Rect.X, GameMain.NetLobbyScreen.SubList.Rect.Bottom+5) : new Vector2(GameMain.GraphicsWidth / 2 - 200, 10);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 pos = new Vector2(GameMain.GraphicsWidth / 2 - 130, GameMain.NetLobbyScreen.InfoFrame.Rect.Y / 2 - 15);
|
Vector2 pos = new Vector2(GameMain.GraphicsWidth / 2 - 130, GameMain.NetLobbyScreen.InfoFrame.Rect.Y / 2 - 15);
|
||||||
|
|
||||||
GUI.DrawString(spriteBatch,
|
GUI.DrawString(spriteBatch,
|
||||||
@@ -804,6 +806,16 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (respawnManager != null && respawnManager.CurrentState == RespawnManager.State.Waiting &&
|
||||||
|
myCharacter != null && myCharacter.IsDead)
|
||||||
|
{
|
||||||
|
GUI.DrawString(spriteBatch,
|
||||||
|
new Vector2(GameMain.GraphicsWidth - 300.0f, 20),
|
||||||
|
"Respawning in " + (int)respawnManager.RespawnTimer + " s",
|
||||||
|
Color.White, null, 0, GUI.SmallFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!GameMain.DebugDraw) return;
|
if (!GameMain.DebugDraw) return;
|
||||||
|
|
||||||
int width = 200, height = 300;
|
int width = 200, height = 300;
|
||||||
|
|||||||
@@ -851,6 +851,10 @@ namespace Barotrauma.Networking
|
|||||||
existingEvents = new List<NetworkEvent>(NetworkEvent.Events);
|
existingEvents = new List<NetworkEvent>(NetworkEvent.Events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
|
||||||
|
sender.inGame = true;
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1102,6 +1106,8 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||||
GameMain.LightManager.LosEnabled = false;
|
GameMain.LightManager.LosEnabled = false;
|
||||||
|
|
||||||
|
respawnManager = null;
|
||||||
|
|
||||||
gameStarted = false;
|
gameStarted = false;
|
||||||
|
|
||||||
if (connectedClients.Count > 0)
|
if (connectedClients.Count > 0)
|
||||||
@@ -1144,7 +1150,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RespawnClients()
|
public void SendRespawnManagerMsg()
|
||||||
{
|
{
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
NetOutgoingMessage msg = server.CreateMessage();
|
||||||
respawnManager.WriteNetworkEvent(msg);
|
respawnManager.WriteNetworkEvent(msg);
|
||||||
@@ -1342,6 +1348,14 @@ namespace Barotrauma.Networking
|
|||||||
log.LogFrame.Draw(spriteBatch);
|
log.LogFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (respawnManager != null && respawnManager.CurrentState == RespawnManager.State.Waiting && respawnManager.CountdownStarted)
|
||||||
|
{
|
||||||
|
GUI.DrawString(spriteBatch,
|
||||||
|
new Vector2(GameMain.GraphicsWidth - 500.0f, 20),
|
||||||
|
"Respawning in " + (int)respawnManager.RespawnTimer + " s",
|
||||||
|
Color.White, null, 0, GUI.SmallFont);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ShowNetStats) return;
|
if (!ShowNetStats) return;
|
||||||
|
|
||||||
int width = 200, height = 300;
|
int width = 200, height = 300;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
const float RespawnInterval = 20.0f;
|
const float RespawnInterval = 20.0f;
|
||||||
|
|
||||||
enum State
|
public enum State
|
||||||
{
|
{
|
||||||
Waiting,
|
Waiting,
|
||||||
Transporting,
|
Transporting,
|
||||||
@@ -31,6 +31,22 @@ namespace Barotrauma.Networking
|
|||||||
private Steering shuttleSteering;
|
private Steering shuttleSteering;
|
||||||
private List<Door> shuttleDoors;
|
private List<Door> shuttleDoors;
|
||||||
|
|
||||||
|
public float RespawnTimer
|
||||||
|
{
|
||||||
|
get { return respawnTimer; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CountdownStarted
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public State CurrentState
|
||||||
|
{
|
||||||
|
get { return state; }
|
||||||
|
}
|
||||||
|
|
||||||
private float respawnTimer, shuttleReturnTimer;
|
private float respawnTimer, shuttleReturnTimer;
|
||||||
|
|
||||||
public RespawnManager(NetworkMember server)
|
public RespawnManager(NetworkMember server)
|
||||||
@@ -85,42 +101,49 @@ namespace Barotrauma.Networking
|
|||||||
private void UpdateWaiting(float deltaTime)
|
private void UpdateWaiting(float deltaTime)
|
||||||
{
|
{
|
||||||
var server = networkMember as GameServer;
|
var server = networkMember as GameServer;
|
||||||
if (server == null) return;
|
if (server == null)
|
||||||
|
{
|
||||||
|
if (CountdownStarted)
|
||||||
|
{
|
||||||
|
respawnTimer = Math.Max(0.0f, respawnTimer - deltaTime);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
respawnShuttle.Velocity = Vector2.Zero;
|
respawnShuttle.Velocity = Vector2.Zero;
|
||||||
|
|
||||||
shuttleSteering.AutoPilot = false;
|
shuttleSteering.AutoPilot = false;
|
||||||
shuttleSteering.MaintainPos = false;
|
shuttleSteering.MaintainPos = false;
|
||||||
|
|
||||||
if (GetClientsToRespawn().Count < MinCharactersToRespawn) return;
|
int characterToRespawnCount = GetClientsToRespawn().Count;
|
||||||
|
if (server.Character != null && server.Character.IsDead) characterToRespawnCount++;
|
||||||
|
|
||||||
if (respawnTimer % 10.0f < 5.0f && (respawnTimer - deltaTime) % 10.0f > 5.0f)
|
CountdownStarted = characterToRespawnCount >= MinCharactersToRespawn;
|
||||||
{
|
|
||||||
string time = respawnTimer <= 60.0f ?
|
|
||||||
(int)respawnTimer + " seconds" :
|
|
||||||
(int)Math.Floor(respawnTimer / 60.0f) + " minutes";
|
|
||||||
|
|
||||||
server.SendChatMessage("Transportation shuttle dispatching in " + time, ChatMessageType.Server);
|
if (!CountdownStarted) return;
|
||||||
}
|
|
||||||
|
|
||||||
respawnTimer -= deltaTime;
|
respawnTimer -= deltaTime;
|
||||||
if (respawnTimer <= 0.0f)
|
if (respawnTimer <= 0.0f)
|
||||||
{
|
{
|
||||||
Respawn();
|
|
||||||
|
|
||||||
respawnTimer = RespawnInterval;
|
respawnTimer = RespawnInterval;
|
||||||
state = State.Transporting;
|
|
||||||
|
Respawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTransporting(float deltaTime)
|
private void UpdateTransporting(float deltaTime)
|
||||||
{
|
{
|
||||||
|
var server = networkMember as GameServer;
|
||||||
|
if (server == null) return;
|
||||||
|
|
||||||
if (Character.CharacterList.Any(c => c.Submarine == respawnShuttle && !c.IsDead)) return;
|
if (Character.CharacterList.Any(c => c.Submarine == respawnShuttle && !c.IsDead)) return;
|
||||||
|
|
||||||
shuttleReturnTimer += deltaTime;
|
shuttleReturnTimer += deltaTime;
|
||||||
if (shuttleReturnTimer > 10.0f)
|
if (shuttleReturnTimer > 10.0f)
|
||||||
{
|
{
|
||||||
state = State.Returning;
|
state = State.Returning;
|
||||||
|
|
||||||
|
server.SendRespawnManagerMsg();
|
||||||
shuttleReturnTimer = 0.0f;
|
shuttleReturnTimer = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,14 +157,31 @@ namespace Barotrauma.Networking
|
|||||||
shuttleSteering.AutoPilot = true;
|
shuttleSteering.AutoPilot = true;
|
||||||
shuttleSteering.MaintainPos = false;
|
shuttleSteering.MaintainPos = false;
|
||||||
|
|
||||||
shuttleDoors.ForEach(s => s.IsOpen = false);
|
foreach (Door door in shuttleDoors)
|
||||||
|
{
|
||||||
|
if (door.IsOpen) door.SetState(false, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (shuttleSteering.SteeringPath != null && shuttleSteering.SteeringPath.CurrentIndex == shuttleSteering.SteeringPath.Nodes.Count-1)
|
var server = networkMember as GameServer;
|
||||||
|
if (server == null) return;
|
||||||
|
|
||||||
|
//shuttle has returned if the path has been traversed or the shuttle is close enough to the exit
|
||||||
|
if (shuttleSteering.SteeringPath != null && shuttleSteering.SteeringPath.Finished
|
||||||
|
|| (respawnShuttle.WorldPosition.Y + respawnShuttle.Borders.Y > Level.Loaded.StartPosition.Y - Level.ShaftHeight &&
|
||||||
|
Math.Abs(Level.Loaded.StartPosition.X - respawnShuttle.WorldPosition.X) < 1000.0f))
|
||||||
{
|
{
|
||||||
CoroutineManager.StartCoroutine(
|
CoroutineManager.StartCoroutine(
|
||||||
ForceShuttleToPos(new Vector2(Level.Loaded.StartPosition.X, Level.Loaded.Size.Y + 1000.0f), 100.0f));
|
ForceShuttleToPos(new Vector2(Level.Loaded.StartPosition.X, Level.Loaded.Size.Y + 1000.0f), 100.0f));
|
||||||
|
|
||||||
|
if (GameMain.GameSession != null && GameMain.GameSession.Map != null)
|
||||||
|
{
|
||||||
|
string msg = "The transportation shuttle has returned to " + GameMain.GameSession.Map.SelectedLocation;
|
||||||
|
|
||||||
|
server.SendChatMessage(ChatMessage.Create("", msg, ChatMessageType.Server, null), server.ConnectedClients);
|
||||||
|
}
|
||||||
|
|
||||||
state = State.Waiting;
|
state = State.Waiting;
|
||||||
|
server.SendRespawnManagerMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
shuttleReturnTimer = 0.0f;
|
shuttleReturnTimer = 0.0f;
|
||||||
@@ -153,13 +193,15 @@ namespace Barotrauma.Networking
|
|||||||
var server = networkMember as GameServer;
|
var server = networkMember as GameServer;
|
||||||
if (server == null) return;
|
if (server == null) return;
|
||||||
|
|
||||||
|
state = State.Transporting;
|
||||||
|
|
||||||
ResetShuttlePos();
|
ResetShuttlePos();
|
||||||
|
|
||||||
server.SendChatMessage("Transportation shuttle dispatched");
|
server.SendChatMessage(ChatMessage.Create("", "Transportation shuttle dispatched", ChatMessageType.Server, null), server.ConnectedClients);
|
||||||
|
|
||||||
server.RespawnClients();
|
server.SendRespawnManagerMsg();
|
||||||
|
|
||||||
CoroutineManager.StartCoroutine(ForceShuttleToPos(Level.Loaded.StartPosition, 100.0f));
|
CoroutineManager.StartCoroutine(ForceShuttleToPos(Level.Loaded.StartPosition - Vector2.UnitY * Level.ShaftHeight, 100.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed)
|
private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed)
|
||||||
@@ -171,15 +213,18 @@ namespace Barotrauma.Networking
|
|||||||
Vector2 displayVel = Vector2.Normalize(position - respawnShuttle.WorldPosition) * speed;
|
Vector2 displayVel = Vector2.Normalize(position - respawnShuttle.WorldPosition) * speed;
|
||||||
respawnShuttle.SubBody.Body.LinearVelocity = ConvertUnits.ToSimUnits(displayVel);
|
respawnShuttle.SubBody.Body.LinearVelocity = ConvertUnits.ToSimUnits(displayVel);
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
|
if (respawnShuttle.SubBody == null) yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBodies[0]);
|
respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBodies[0]);
|
||||||
|
|
||||||
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetShuttlePos()
|
private void ResetShuttlePos()
|
||||||
{
|
{
|
||||||
respawnShuttle.SetPosition(new Vector2(Level.Loaded.StartPosition.X, Level.Loaded.Size.Y + 1000.0f));
|
respawnShuttle.SetPosition(new Vector2(Level.Loaded.StartPosition.X, Level.Loaded.Size.Y + respawnShuttle.Borders.Height));
|
||||||
|
|
||||||
respawnShuttle.Velocity = Vector2.Zero;
|
respawnShuttle.Velocity = Vector2.Zero;
|
||||||
}
|
}
|
||||||
@@ -187,40 +232,81 @@ namespace Barotrauma.Networking
|
|||||||
public void WriteNetworkEvent(NetOutgoingMessage msg)
|
public void WriteNetworkEvent(NetOutgoingMessage msg)
|
||||||
{
|
{
|
||||||
var server = networkMember as GameServer;
|
var server = networkMember as GameServer;
|
||||||
var clients = GetClientsToRespawn();
|
|
||||||
|
|
||||||
msg.Write((byte)PacketTypes.Respawn);
|
msg.Write((byte)PacketTypes.Respawn);
|
||||||
|
|
||||||
var waypoints = WayPoint.SelectCrewSpawnPoints(clients.Select(c => c.characterInfo).ToList(), respawnShuttle);
|
msg.WriteRangedInteger(0, Enum.GetNames(typeof(State)).Length, (int)state);
|
||||||
|
|
||||||
msg.Write((byte)clients.Count);
|
switch (state)
|
||||||
for (int i = 0; i < clients.Count; i++)
|
|
||||||
{
|
{
|
||||||
msg.Write((byte)clients[i].ID);
|
case State.Transporting:
|
||||||
clients[i].Character = Character.Create(clients[i].characterInfo, waypoints[i].WorldPosition, true, false);
|
var clients = GetClientsToRespawn();
|
||||||
clients[i].Character.GiveJobItems(waypoints[i]);
|
|
||||||
|
|
||||||
GameMain.GameSession.CrewManager.characters.Add(clients[i].Character);
|
List<CharacterInfo> characterInfos = clients.Select(c => c.characterInfo).ToList();
|
||||||
|
if (server.Character != null && server.Character.IsDead) characterInfos.Add(server.CharacterInfo);
|
||||||
|
|
||||||
server.WriteCharacterData(msg, clients[i].Character.Name, clients[i].Character);
|
var waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, respawnShuttle);
|
||||||
|
|
||||||
|
msg.Write((byte)characterInfos.Count);
|
||||||
|
for (int i = 0; i < characterInfos.Count; i++)
|
||||||
|
{
|
||||||
|
var character = Character.Create(characterInfos[i], waypoints[i].WorldPosition, true, false);
|
||||||
|
|
||||||
|
if (i < clients.Count)
|
||||||
|
{
|
||||||
|
msg.Write((byte)clients[i].ID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.Write((byte)0);
|
||||||
|
server.Character = character;
|
||||||
|
Character.Controlled = character;
|
||||||
|
}
|
||||||
|
|
||||||
|
character.GiveJobItems(waypoints[i]);
|
||||||
|
|
||||||
|
GameMain.GameSession.CrewManager.characters.Add(character);
|
||||||
|
|
||||||
|
server.WriteCharacterData(msg, character.Name, character);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case State.Waiting:
|
||||||
|
msg.Write(respawnTimer);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadNetworkEvent(NetIncomingMessage inc)
|
public void ReadNetworkEvent(NetIncomingMessage inc)
|
||||||
{
|
{
|
||||||
ResetShuttlePos();
|
state = (State)inc.ReadRangedInteger(0, Enum.GetNames(typeof(State)).Length);
|
||||||
|
|
||||||
var client = networkMember as GameClient;
|
switch (state)
|
||||||
|
|
||||||
int clientCount = inc.ReadByte();
|
|
||||||
for (int i = 0; i<clientCount; i++)
|
|
||||||
{
|
{
|
||||||
byte clientId = inc.ReadByte();
|
case State.Transporting:
|
||||||
|
CountdownStarted = false;
|
||||||
|
ResetShuttlePos();
|
||||||
|
|
||||||
client.ReadCharacterData(inc, clientId == client.ID);
|
var client = networkMember as GameClient;
|
||||||
|
|
||||||
|
int clientCount = inc.ReadByte();
|
||||||
|
for (int i = 0; i < clientCount; i++)
|
||||||
|
{
|
||||||
|
byte clientId = inc.ReadByte();
|
||||||
|
|
||||||
|
client.ReadCharacterData(inc, clientId == client.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
CoroutineManager.StartCoroutine(ForceShuttleToPos(Level.Loaded.StartPosition - Vector2.UnitY * Level.ShaftHeight, 100.0f));
|
||||||
|
break;
|
||||||
|
case State.Waiting:
|
||||||
|
CountdownStarted = true;
|
||||||
|
respawnTimer = inc.ReadSingle();
|
||||||
|
break;
|
||||||
|
case State.Returning:
|
||||||
|
CountdownStarted = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoroutineManager.StartCoroutine(ForceShuttleToPos(Level.Loaded.StartPosition, 100.0f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
cam.UpdateTransform(true, true);
|
cam.UpdateTransform(true, !GameMain.DebugDraw);
|
||||||
|
|
||||||
DrawMap(graphics, spriteBatch);
|
DrawMap(graphics, spriteBatch);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user