mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-19 12:40:56 +00:00
commit
6a40c9b399
66
QSB/Ghostbuster.cs
Normal file
66
QSB/Ghostbuster.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -220,7 +220,7 @@ internal class MultiplayerHUDManager : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
private void OnRemovePlayer(PlayerInfo player)
|
||||
{
|
||||
Destroy(player.HUDBox.gameObject);
|
||||
Destroy(player.HUDBox?.gameObject);
|
||||
}
|
||||
|
||||
private PlanetTrigger CreateTrigger(string parentPath, HUDIcon icon)
|
||||
|
@ -49,10 +49,16 @@ internal class VolumePatches : QSBPatch
|
||||
public static bool PreventRemotePlayerEnter(object __instance, GameObject hitObj)
|
||||
{
|
||||
DebugLog.DebugWrite($"{__instance} funny prevent enter {hitObj}");
|
||||
// this is a dogshit fix to a bug where this would ApplyShock to remote players,
|
||||
// which would actually apply the shock affects to the entire planet / sector
|
||||
//
|
||||
// TODO: also do this with remote probes
|
||||
return hitObj.name is not ("REMOTE_PlayerDetector" or "REMOTE_CameraDetector");
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(VanishVolume), nameof(VanishVolume.OnTriggerEnter))]
|
||||
public static bool PreventRemotePlayerEnter(object __instance, Collider hitCollider)
|
||||
{
|
||||
DebugLog.DebugWrite($"{__instance} funny prevent enter {hitCollider}");
|
||||
// TODO: also do this with remote probes
|
||||
return hitCollider.name is not ("REMOTE_PlayerDetector" or "REMOTE_CameraDetector");
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class PlayerTransformSync : SectoredTransformSync
|
||||
var player = new PlayerInfo(this);
|
||||
QSBPlayerManager.PlayerList.SafeAdd(player);
|
||||
base.OnStartClient();
|
||||
QSBPlayerManager.OnAddPlayer?.Invoke(Player);
|
||||
QSBPlayerManager.OnAddPlayer?.SafeInvoke(Player);
|
||||
DebugLog.DebugWrite($"Create Player : {Player}", MessageType.Info);
|
||||
|
||||
JoinLeaveSingularity.Create(Player, true);
|
||||
@ -50,7 +50,7 @@ public class PlayerTransformSync : SectoredTransformSync
|
||||
|
||||
// TODO : Maybe move this to a leave event...? Would ensure everything could finish up before removing the player
|
||||
QSBPatch.Remote = true;
|
||||
QSBPlayerManager.OnRemovePlayer?.Invoke(Player);
|
||||
QSBPlayerManager.OnRemovePlayer?.SafeInvoke(Player);
|
||||
QSBPatch.Remote = false;
|
||||
base.OnStopClient();
|
||||
Player.HudMarker?.Remove();
|
||||
|
@ -16,7 +16,7 @@
|
||||
</Target>
|
||||
|
||||
<Target Name="weave qsb" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="MirrorWeaver "$(TargetPath)"" WorkingDirectory="..\MirrorWeaver\bin\$(Configuration)\" />
|
||||
<Exec Command=".\MirrorWeaver "$(TargetPath)"" WorkingDirectory="..\MirrorWeaver\bin\$(Configuration)\" />
|
||||
</Target>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -226,7 +226,7 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart
|
||||
{
|
||||
var player = new PlayerInfo(QSBPlayerManager.LocalPlayer.TransformSync);
|
||||
QSBPlayerManager.PlayerList.SafeAdd(player);
|
||||
QSBPlayerManager.OnAddPlayer?.Invoke(player);
|
||||
QSBPlayerManager.OnAddPlayer?.SafeInvoke(player);
|
||||
DebugLog.DebugWrite($"CREATING FAKE PLAYER : {player}", MessageType.Info);
|
||||
|
||||
JoinLeaveSingularity.Create(player, true);
|
||||
|
@ -159,6 +159,12 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
{
|
||||
WriteLine(1, $" - {item}");
|
||||
}
|
||||
|
||||
WriteLine(1, $"Sectors :");
|
||||
foreach (var sector in PlayerTransformSync.LocalInstance.SectorDetector.SectorList)
|
||||
{
|
||||
WriteLine(1, $"- {sector.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -196,12 +202,6 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
WriteLine(2, $" - Ref. Sector : {(referenceSector == null ? "NULL" : referenceSector.Name)}", referenceSector == null ? Color.red : Color.white);
|
||||
WriteLine(2, $" - Ref. Transform : {(referenceTransform == null ? "NULL" : referenceTransform.name)}", referenceTransform == null ? Color.red : Color.white);
|
||||
|
||||
WriteLine(2, $"Sectors :");
|
||||
foreach (var sector in PlayerTransformSync.LocalInstance.SectorDetector.SectorList)
|
||||
{
|
||||
WriteLine(2, $"- {sector.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Mirror;
|
||||
using OWML.Common;
|
||||
using QSB.Player;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -40,10 +41,10 @@ public static class Extensions
|
||||
|
||||
public static uint GetPlayerId(this NetworkConnectionToClient conn)
|
||||
{
|
||||
if (!conn.identity)
|
||||
if (conn.identity == null)
|
||||
{
|
||||
// wtf
|
||||
DebugLog.ToConsole($"Error - GetPlayerId on {conn} has no identity\n{Environment.StackTrace}", MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - GetPlayerId on {conn} has no identity.", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
"body": "- Disable *all* other mods. (Can heavily affect performance)\n- Make sure you are not running any other network-intensive applications."
|
||||
},
|
||||
"uniqueName": "Raicuparta.QuantumSpaceBuddies",
|
||||
"version": "0.26.1",
|
||||
"version": "0.26.3",
|
||||
"owmlVersion": "2.9.0",
|
||||
"dependencies": [ "_nebula.MenuFramework", "JohnCorby.VanillaFix" ],
|
||||
"pathsToPreserve": [ "debugsettings.json" ],
|
||||
|
Loading…
x
Reference in New Issue
Block a user