-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #604 from misternebula/dev
0.26.3
- Loading branch information
Showing
9 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Mirror; | ||
using QSB.Player; | ||
using QSB.Utility; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace QSB; | ||
internal class Ghostbuster : MonoBehaviour, IAddComponentOnStart | ||
{ | ||
private const int UpdateInterval = 60; | ||
|
||
private int _updateCount; | ||
|
||
public void Update() | ||
{ | ||
if (!QSBCore.IsInMultiplayer) | ||
{ | ||
return; | ||
} | ||
|
||
if (!QSBCore.IsHost) | ||
{ | ||
return; | ||
} | ||
|
||
if (_updateCount != UpdateInterval) | ||
{ | ||
_updateCount++; | ||
return; | ||
} | ||
else | ||
{ | ||
_updateCount = 0; | ||
} | ||
|
||
var _ghostPlayers = new List<PlayerInfo>(); | ||
|
||
foreach (var player in QSBPlayerManager.PlayerList) | ||
{ | ||
var isGhost = false; | ||
|
||
var networkIdentity = player.TransformSync.netIdentity; | ||
|
||
if (networkIdentity.connectionToClient == null) | ||
{ | ||
isGhost = true; | ||
} | ||
else if (!NetworkServer.connections.ContainsValue(networkIdentity.connectionToClient)) | ||
{ | ||
isGhost = true; | ||
} | ||
|
||
if (isGhost) | ||
{ | ||
// WE GOT ONE!!!!!! | ||
_ghostPlayers.Add(player); | ||
} | ||
} | ||
|
||
foreach (var item in _ghostPlayers) | ||
{ | ||
DebugLog.ToConsole($"Deleting playerId:{item.PlayerId} - It's a ghooOoOoOooost! (hopefully)", OWML.Common.MessageType.Info); | ||
NetworkServer.DestroyPlayerForConnection(item.TransformSync.netIdentity.connectionToClient); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters