Fire extinguisher, burnt limbs, spectating improvements, option to disable spectating, jumpsuits for engi & mech, fireproof items, stuff

This commit is contained in:
Regalis
2015-11-18 20:02:45 +02:00
parent 7b6d92bb27
commit 9b08201972
36 changed files with 429 additions and 85 deletions
+12 -5
View File
@@ -207,12 +207,16 @@ namespace Barotrauma.Networking
{
myID = inc.ReadInt32();
gameStarted = inc.ReadBoolean();
if (gameStarted && Screen.Selected != GameMain.GameScreen)
{
new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start.");
}
bool hasCharacter = inc.ReadBoolean();
bool allowSpectating = inc.ReadBoolean();
if (gameStarted && Screen.Selected != GameMain.GameScreen)
{
new GUIMessageBox("Please wait",
(allowSpectating) ?
"A round is already running, but you can spectate the game while waiting for a new one to start." :
"A round is already running and the admin has disabled spectating. You will have to wait for a new round to start.");
}
if (gameStarted && !hasCharacter && myCharacter!=null)
{
@@ -221,6 +225,7 @@ namespace Barotrauma.Networking
new GUIMessageBox("Connection timed out", "You were disconnected for too long and your Character was deleted. Please wait for another round to start.");
}
GameMain.NetLobbyScreen.ClearPlayers();
//add the names of other connected clients to the lobby screen
@@ -686,6 +691,8 @@ namespace Barotrauma.Networking
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
if (button != null) button.Enabled = false;
return false;
}
+43 -3
View File
@@ -362,6 +362,7 @@ namespace Barotrauma.Networking
outmsg.Write(sender.ID);
outmsg.Write(gameStarted);
outmsg.Write(gameStarted && sender.Character!=null);
outmsg.Write(allowSpectating);
//notify the client about other clients already logged in
outmsg.Write((characterInfo == null) ? ConnectedClients.Count - 1 : ConnectedClients.Count);
@@ -461,12 +462,13 @@ namespace Barotrauma.Networking
Voting.RegisterVote(inc, ConnectedClients);
break;
case (byte)PacketTypes.SpectateRequest:
if (gameStarted)
if (gameStarted && allowSpectating)
{
var startMessage = CreateStartMessage(roundStartSeed, Submarine.Loaded, GameMain.GameSession.gameMode.Preset);
server.SendMessage(startMessage, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered);
dataSender.Spectating = true;
CoroutineManager.StartCoroutine(SyncSpectator(dataSender));
}
break;
}
@@ -605,11 +607,14 @@ namespace Barotrauma.Networking
}
private void SendNetworkEvents()
private void SendNetworkEvents(List<Client> recipients = null)
{
if (NetworkEvent.Events.Count == 0) return;
List<Client> recipients = ConnectedClients.FindAll(c => c.Character != null || c.Spectating);
if (recipients == null)
{
recipients = ConnectedClients.FindAll(c => c.Character != null || c.Spectating);
}
if (recipients.Count == 0) return;
@@ -635,6 +640,41 @@ namespace Barotrauma.Networking
NetworkEvent.Events.Clear();
}
private IEnumerable<object> SyncSpectator(Client sender)
{
yield return new WaitForSeconds(3.0f);
var existingEvents = NetworkEvent.Events;
NetworkEvent.Events.Clear();
foreach (Hull hull in Hull.hullList)
{
if (!hull.FireSources.Any() && hull.Volume < 0.01f) continue;
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, hull.ID, false);
}
SendNetworkEvents(new List<Client>() { sender });
foreach (Character c in Character.CharacterList)
{
new NetworkEvent(NetworkEventType.EntityUpdate, c.ID, false);
if (c.Inventory != null) new NetworkEvent(NetworkEventType.InventoryUpdate, c.ID, false);
if (c.IsDead) new NetworkEvent(NetworkEventType.KillCharacter, c.ID, false);
}
SendNetworkEvents(new List<Client>() { sender });
foreach (Item item in Item.ItemList)
{
if (item.body == null || item.body.Enabled == false) continue;
new NetworkEvent(NetworkEventType.DropItem, item.ID, false);
}
SendNetworkEvents(new List<Client>() { sender });
yield return CoroutineStatus.Success;
}
public bool StartGameClicked(GUIButton button, object obj)
{
@@ -34,6 +34,8 @@ namespace Barotrauma.Networking
private bool autoRestart;
private bool allowSpectating = true;
public bool AutoRestart
{
get { return (ConnectedClients.Count == 0) ? false : autoRestart; }
@@ -65,6 +67,11 @@ namespace Barotrauma.Networking
get { return banList; }
}
public bool AllowSpectating
{
get { return allowSpectating; }
}
private void CreateSettingsFrame()
{
settingsFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f);
@@ -94,6 +101,13 @@ namespace Barotrauma.Networking
selectionTick.UserData = (SelectionMode)i;
}
var allowSpecBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Allow spectating", Alignment.Left, innerFrame);
allowSpecBox.Selected = true;
allowSpecBox.OnSelected = ToggleAllowSpectating;
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
closeButton.OnClicked = ToggleSettingsFrame;
}
@@ -144,6 +158,12 @@ namespace Barotrauma.Networking
return true;
}
private bool ToggleAllowSpectating(GUITickBox tickBox)
{
allowSpectating = tickBox.Selected;
return true;
}
public bool ToggleSettingsFrame(GUIButton button, object obj)
{
if (settingsFrame==null)