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:
@@ -27,7 +27,7 @@ namespace Barotrauma
|
||||
{
|
||||
base.Update(cam, deltaTime);
|
||||
|
||||
if (!Enabled) return;
|
||||
if (!Enabled || IsRemotePlayer) return;
|
||||
|
||||
float dist = Vector2.DistanceSquared(cam.WorldViewCenter, WorldPosition);
|
||||
if (dist > 8000.0f * 8000.0f)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Barotrauma
|
||||
public Hull PreviousHull = null;
|
||||
public Hull CurrentHull = null;
|
||||
|
||||
public readonly bool IsRemotePlayer;
|
||||
public bool IsRemotePlayer;
|
||||
|
||||
private CharacterInventory inventory;
|
||||
|
||||
@@ -810,7 +810,7 @@ namespace Barotrauma
|
||||
ViewTarget = null;
|
||||
if (!AllowInput) return;
|
||||
|
||||
if (!(this is AICharacter) || controlled == this)
|
||||
if (!(this is AICharacter) || controlled == this || IsRemotePlayer)
|
||||
{
|
||||
Vector2 targetMovement = GetTargetMovement();
|
||||
|
||||
@@ -1289,7 +1289,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Character c in CharacterList)
|
||||
{
|
||||
if (!(c is AICharacter)) continue;
|
||||
if (!(c is AICharacter) && !c.IsRemotePlayer) continue;
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
@@ -1432,7 +1432,7 @@ namespace Barotrauma
|
||||
selectedConstruction = null;
|
||||
}
|
||||
|
||||
if (controlled != this && !(this is AICharacter))
|
||||
if (controlled != this && (!(this is AICharacter) || IsRemotePlayer))
|
||||
{
|
||||
if (!LockHands)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Barotrauma
|
||||
private bool networkUpdateSent;
|
||||
|
||||
public bool isSynced = false;
|
||||
|
||||
|
||||
public List<CharacterStateInfo> MemState
|
||||
{
|
||||
get { return memState; }
|
||||
@@ -93,6 +93,16 @@ namespace Barotrauma
|
||||
get { return memLocalState; }
|
||||
}
|
||||
|
||||
public void ResetNetState()
|
||||
{
|
||||
memInput.Clear();
|
||||
memState.Clear();
|
||||
memLocalState.Clear();
|
||||
|
||||
LastNetworkUpdateID = 0;
|
||||
LastProcessedID = 0;
|
||||
}
|
||||
|
||||
private void UpdateNetInput()
|
||||
{
|
||||
if (this != Character.Controlled)
|
||||
@@ -112,7 +122,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GameMain.Server != null && !(this is AICharacter))
|
||||
else if (GameMain.Server != null && (!(this is AICharacter) || IsRemotePlayer))
|
||||
{
|
||||
if (!AllowInput)
|
||||
{
|
||||
@@ -387,17 +397,24 @@ namespace Barotrauma
|
||||
|
||||
if (extraData != null)
|
||||
{
|
||||
|
||||
switch ((NetEntityEvent.Type)extraData[0])
|
||||
{
|
||||
case NetEntityEvent.Type.InventoryState:
|
||||
msg.Write(true);
|
||||
msg.WriteRangedInteger(0, 2, 0);
|
||||
inventory.ClientWrite(msg, extraData);
|
||||
break;
|
||||
case NetEntityEvent.Type.Control:
|
||||
msg.WriteRangedInteger(0, 2, 1);
|
||||
Client owner = ((Client)extraData[1]);
|
||||
msg.Write(owner == null ? (byte)0 : owner.ID);
|
||||
break;
|
||||
case NetEntityEvent.Type.Status:
|
||||
msg.Write(false);
|
||||
msg.WriteRangedInteger(0, 2, 2);
|
||||
WriteStatus(msg);
|
||||
break;
|
||||
}
|
||||
msg.WritePadBits();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -573,15 +590,36 @@ namespace Barotrauma
|
||||
|
||||
break;
|
||||
case ServerNetObject.ENTITY_EVENT:
|
||||
bool isInventoryUpdate = msg.ReadBoolean();
|
||||
|
||||
int eventType = msg.ReadRangedInteger(0, 2);
|
||||
switch (eventType)
|
||||
{
|
||||
case 0:
|
||||
inventory.ClientRead(type, msg, sendingTime);
|
||||
break;
|
||||
case 1:
|
||||
byte ownerID = msg.ReadByte();
|
||||
ResetNetState();
|
||||
if (ownerID == GameMain.Client.ID)
|
||||
{
|
||||
if (controlled != null)
|
||||
{
|
||||
LastNetworkUpdateID = controlled.LastNetworkUpdateID;
|
||||
}
|
||||
|
||||
if (isInventoryUpdate)
|
||||
{
|
||||
inventory.ClientRead(type, msg, sendingTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadStatus(msg);
|
||||
controlled = this;
|
||||
IsRemotePlayer = false;
|
||||
GameMain.Client.Character = this;
|
||||
}
|
||||
else if (controlled == this)
|
||||
{
|
||||
controlled = null;
|
||||
IsRemotePlayer = ownerID > 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ReadStatus(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user