Added a method for changing a client's controlled character. Clients now get back control if their character is revived via the debug console.

+ It's possible to give clients control of monsters, which should add some new gameplay possibilitie. ;)
This commit is contained in:
Joonas Rikkonen
2017-06-10 15:07:10 +03:00
parent 8886409d56
commit 9b0d7c1020
6 changed files with 151 additions and 46 deletions
+32 -2
View File
@@ -1,5 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -1945,6 +1944,37 @@ namespace Barotrauma.Networking
return true;
}
public void SetClientCharacter(Client client, Character newCharacter)
{
if (client == null) return;
//the client's previous character is no longer a remote player
if (client.Character != null)
{
client.Character.IsRemotePlayer = false;
}
if (newCharacter == null)
{
if (client.Character != null) //removing control of the current character
{
newCharacter.IsRemotePlayer = false;
CreateEntityEvent(client.Character, new object[] { NetEntityEvent.Type.Control, null });
client.Character = null;
}
}
else if (client.Character != newCharacter) //taking control of a new character
{
newCharacter.ResetNetState();
newCharacter.LastNetworkUpdateID = client.Character.LastNetworkUpdateID;
newCharacter.IsRemotePlayer = true;
client.Character = newCharacter;
CreateEntityEvent(newCharacter, new object[] { NetEntityEvent.Type.Control, client });
}
}
private void UpdateCharacterInfo(NetIncomingMessage message, Client sender)
{
Gender gender = Gender.Male;