Readded traitors
This commit is contained in:
@@ -183,7 +183,7 @@
|
|||||||
<Compile Include="Source\GameSession\HireManager.cs" />
|
<Compile Include="Source\GameSession\HireManager.cs" />
|
||||||
<Compile Include="Source\Characters\Animation\HumanoidAnimController.cs" />
|
<Compile Include="Source\Characters\Animation\HumanoidAnimController.cs" />
|
||||||
<Compile Include="Source\GameSession\GameModes\SinglePlayerMode.cs" />
|
<Compile Include="Source\GameSession\GameModes\SinglePlayerMode.cs" />
|
||||||
<Compile Include="Source\GameSession\GameModes\TraitorMode.cs" />
|
<Compile Include="Source\GameSession\GameModes\TraitorManager.cs" />
|
||||||
<Compile Include="Source\GUI\ComponentStyle.cs" />
|
<Compile Include="Source\GUI\ComponentStyle.cs" />
|
||||||
<Compile Include="Source\GUI\GUIImage.cs" />
|
<Compile Include="Source\GUI\GUIImage.cs" />
|
||||||
<Compile Include="Source\GUI\GUIMessageBox.cs" />
|
<Compile Include="Source\GUI\GUIMessageBox.cs" />
|
||||||
|
|||||||
+13
-5
@@ -5,8 +5,18 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
class TraitorManager
|
class TraitorManager
|
||||||
{
|
{
|
||||||
private Character traitorCharacter, targetCharacter;
|
public Character TraitorCharacter
|
||||||
|
{
|
||||||
|
get { return traitorCharacter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Character TargetCharacter
|
||||||
|
{
|
||||||
|
get { return targetCharacter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private Character traitorCharacter, targetCharacter;
|
||||||
|
|
||||||
public TraitorManager(GameServer server)
|
public TraitorManager(GameServer server)
|
||||||
{
|
{
|
||||||
Start(server);
|
Start(server);
|
||||||
@@ -19,8 +29,8 @@ namespace Barotrauma
|
|||||||
List<Character> characters = new List<Character>();
|
List<Character> characters = new List<Character>();
|
||||||
foreach (Client client in server.ConnectedClients)
|
foreach (Client client in server.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (!client.inGame || client.Character==null) continue;
|
if (client.Character != null)
|
||||||
characters.Add(client.Character);
|
characters.Add(client.Character);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.Character!= null) characters.Add(server.Character);
|
if (server.Character!= null) characters.Add(server.Character);
|
||||||
@@ -52,8 +62,6 @@ namespace Barotrauma
|
|||||||
CreateStartPopUp(traitorCharacter.Name);
|
CreateStartPopUp(traitorCharacter.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.NewTraitor(traitorCharacter, targetCharacter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateStartPopUp(string targetName)
|
public static void CreateStartPopUp(string targetName)
|
||||||
@@ -589,6 +589,9 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
bool respawnAllowed = inc.ReadBoolean();
|
bool respawnAllowed = inc.ReadBoolean();
|
||||||
bool loadSecondSub = inc.ReadBoolean();
|
bool loadSecondSub = inc.ReadBoolean();
|
||||||
|
|
||||||
|
bool isTraitor = inc.ReadBoolean();
|
||||||
|
string traitorTargetName = isTraitor ? inc.ReadString() : null;
|
||||||
|
|
||||||
GameModePreset gameMode = GameModePreset.list.Find(gm => gm.Name == modeName);
|
GameModePreset gameMode = GameModePreset.list.Find(gm => gm.Name == modeName);
|
||||||
|
|
||||||
@@ -615,16 +618,10 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.SelectedShuttle);
|
if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.SelectedShuttle);
|
||||||
|
|
||||||
//int characterCount = inc.ReadByte();
|
if (isTraitor)
|
||||||
//for (int i = 0; i < characterCount; i++)
|
{
|
||||||
//{
|
TraitorManager.CreateStartPopUp(traitorTargetName);
|
||||||
// var character = Character.ReadSpawnData(inc);
|
}
|
||||||
// if (inc.ReadBoolean())
|
|
||||||
// {
|
|
||||||
// myCharacter = character;
|
|
||||||
// Character.Controlled = character;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
gameStarted = true;
|
gameStarted = true;
|
||||||
|
|
||||||
@@ -678,7 +675,6 @@ namespace Barotrauma.Networking
|
|||||||
List<Submarine> submarines = new List<Submarine>();
|
List<Submarine> submarines = new List<Submarine>();
|
||||||
for (int i = 0; i < subListCount; i++)
|
for (int i = 0; i < subListCount; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
string subName = inc.ReadString();
|
string subName = inc.ReadString();
|
||||||
string subHash = inc.ReadString();
|
string subHash = inc.ReadString();
|
||||||
|
|
||||||
|
|||||||
@@ -1025,6 +1025,18 @@ namespace Barotrauma.Networking
|
|||||||
Entity.Spawner.AddToSpawnedList(c);
|
Entity.Spawner.AddToSpawnedList(c);
|
||||||
Entity.Spawner.AddToSpawnedList(c.SpawnItems);
|
Entity.Spawner.AddToSpawnedList(c.SpawnItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TraitorManager = null;
|
||||||
|
if (TraitorsEnabled == YesNoMaybe.Yes ||
|
||||||
|
(TraitorsEnabled == YesNoMaybe.Maybe && Rand.Range(0.0f, 1.0f) < 0.5f))
|
||||||
|
{
|
||||||
|
TraitorManager = new TraitorManager(this);
|
||||||
|
|
||||||
|
if (TraitorManager.TraitorCharacter!=null && TraitorManager.TargetCharacter != null)
|
||||||
|
{
|
||||||
|
Log(TraitorManager.TraitorCharacter.Name + " is the traitor and the target is " + TraitorManager.TargetCharacter.Name, Color.Cyan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset, connectedClients);
|
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset, connectedClients);
|
||||||
//var startMessage = CreateStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset);
|
//var startMessage = CreateStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset);
|
||||||
@@ -1080,6 +1092,19 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
msg.Write(AllowRespawn && missionAllowRespawn);
|
msg.Write(AllowRespawn && missionAllowRespawn);
|
||||||
msg.Write(Submarine.MainSubs[1] != null); //loadSecondSub
|
msg.Write(Submarine.MainSubs[1] != null); //loadSecondSub
|
||||||
|
|
||||||
|
if (TraitorManager != null &&
|
||||||
|
TraitorManager.TraitorCharacter != null &&
|
||||||
|
TraitorManager.TargetCharacter != null &&
|
||||||
|
TraitorManager.TraitorCharacter == client.Character)
|
||||||
|
{
|
||||||
|
msg.Write(true);
|
||||||
|
msg.Write(TraitorManager.TargetCharacter.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.Write(false);
|
||||||
|
}
|
||||||
|
|
||||||
server.SendMessage(msg, client.Connection, NetDeliveryMethod.ReliableUnordered);
|
server.SendMessage(msg, client.Connection, NetDeliveryMethod.ReliableUnordered);
|
||||||
}
|
}
|
||||||
@@ -1263,19 +1288,6 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NewTraitor(Character traitor, Character target)
|
|
||||||
{
|
|
||||||
Log(traitor.Name + " is the traitor and the target is " + target.Name, Color.Cyan);
|
|
||||||
|
|
||||||
Client traitorClient = null;
|
|
||||||
foreach (Client c in connectedClients)
|
|
||||||
{
|
|
||||||
if (c.Character != traitor) continue;
|
|
||||||
traitorClient = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add the message to the chatbox and pass it to all clients who can receive it
|
/// Add the message to the chatbox and pass it to all clients who can receive it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user