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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user