Merge pull request #269 from misternebula/pool-fixes

Pool fixes
This commit is contained in:
_nebula 2021-03-29 00:04:07 +01:00 committed by GitHub
commit a2e8419cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 96 additions and 50 deletions

View File

@ -19,18 +19,6 @@ namespace QSB.ItemSync
QSBWorldSync.Init<QSBWarpCoreItem, WarpCoreItem>();
QSBWorldSync.Init<QSBNomaiConversationStoneSocket, NomaiConversationStoneSocket>();
QSBWorldSync.Init<QSBNomaiConversationStone, NomaiConversationStone>();
foreach (var streaming in Resources.FindObjectsOfTypeAll<NomaiRemoteCameraStreaming>())
{
streaming.gameObject.AddComponent<CustomNomaiRemoteCameraStreaming>();
}
foreach (var camera in Resources.FindObjectsOfTypeAll<NomaiRemoteCamera>())
{
camera.gameObject.AddComponent<CustomNomaiRemoteCamera>();
}
foreach (var platform in Resources.FindObjectsOfTypeAll<NomaiRemoteCameraPlatform>())
{
platform.gameObject.AddComponent<CustomNomaiRemoteCameraPlatform>();
}
}
public static IQSBOWItem GetObject(OWItem unityObject)

View File

@ -18,15 +18,6 @@ namespace QSB.ItemSync.Patches
QSBCore.HarmonyHelper.AddPrefix<ItemTool>("StartUnsocketItem", typeof(ItemPatches), nameof(ItemTool_StartUnsocketItem));
QSBCore.HarmonyHelper.AddPrefix<ItemTool>("CompleteUnsocketItem", typeof(ItemPatches), nameof(ItemTool_CompleteUnsocketItem));
QSBCore.HarmonyHelper.AddPrefix<ItemTool>("DropItem", typeof(ItemPatches), nameof(ItemTool_DropItem));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("Update", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("OnSocketableRemoved", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("OnSocketableDonePlacing", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("OnPedestalContact", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("FixedUpdate", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnSectorOccupantAdded", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnSectorOccupantRemoved", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnEntry", typeof(ItemPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnExit", typeof(ItemPatches), nameof(ReturnFalse));
}
public override void DoUnpatches()
@ -36,19 +27,8 @@ namespace QSB.ItemSync.Patches
QSBCore.HarmonyHelper.Unpatch<ItemTool>("StartUnsocketItem");
QSBCore.HarmonyHelper.Unpatch<ItemTool>("CompleteUnsocketItem");
QSBCore.HarmonyHelper.Unpatch<ItemTool>("DropItem");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("Update");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("OnSocketableRemoved");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("OnSocketableDonePlacing");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("OnPedestalContact");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("FixedUpdate");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnSectorOccupantAdded");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnSectorOccupantRemoved");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnEntry");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnExit");
}
public static bool ReturnFalse() => false;
public static bool ItemTool_MoveItemToCarrySocket(OWItem item)
{
var itemId = QSBWorldSync.GetIdFromTypeSubset(ItemManager.GetObject(item));

View File

@ -7,6 +7,7 @@ using QSB.GeyserSync.Patches;
using QSB.ItemSync.Patches;
using QSB.LogSync.Patches;
using QSB.OrbSync.Patches;
using QSB.PoolSync.Patches;
using QSB.QuantumSync.Patches;
using QSB.StatueSync.Patches;
using QSB.TimeSync.Patches;
@ -43,7 +44,8 @@ namespace QSB.Patches
new QuantumPatches(),
new ItemPatches(),
new StatuePatches(),
new GeyserPatches()
new GeyserPatches(),
new PoolPatches()
};
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);

View File

@ -1,5 +1,6 @@
using QSB.Events;
using QSB.ItemSync;
using QSB.PoolSync;
using QSB.Utility;
namespace QSB.Player.Events

View File

@ -1,6 +1,6 @@
using UnityEngine;
namespace QSB.ItemSync
namespace QSB.PoolSync
{
internal class CustomNomaiRemoteCamera : MonoBehaviour
{

View File

@ -8,7 +8,7 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace QSB.ItemSync
namespace QSB.PoolSync
{
internal class CustomNomaiRemoteCameraPlatform : NomaiShared
{
@ -92,6 +92,7 @@ namespace QSB.ItemSync
_hologramGroup.SetActive(false);
UpdateRendererFade();
_transitionStone.SetActive(false);
_hologramGroup.transform.SetParent(null);
}
private void Start()
@ -258,7 +259,7 @@ namespace QSB.ItemSync
return;
}
UpdatePoolRenderer();
_slavePlatform._poolT = target;
_slavePlatform._poolT = _poolT;
_slavePlatform.UpdatePoolRenderer();
}
@ -338,11 +339,6 @@ namespace QSB.ItemSync
DebugLog.ToConsole($"Error - Gameobject for {item.Key.PlayerId} in _playerToHologram is null!", MessageType.Error);
continue;
}
if (!item.Value.activeInHierarchy)
{
DebugLog.ToConsole($"Error - Gameobject for {item.Key.PlayerId} is inactive!", MessageType.Error);
continue;
}
var hologram = item.Value.transform.GetChild(0);
hologram.position = TransformPoint(item.Key.Body.transform.position, this, _slavePlatform);
hologram.rotation = TransformRotation(item.Key.Body.transform.rotation, this, _slavePlatform);
@ -362,6 +358,10 @@ namespace QSB.ItemSync
private void OnSocketableRemoved(OWItem socketable)
{
if (_wasLocalInBounds)
{
QSBEventManager.FireEvent(EventNames.QSBExitPlatform, CustomPlatformList.IndexOf(this));
}
if (_slavePlatform == null)
{
return;
@ -400,7 +400,7 @@ namespace QSB.ItemSync
{
Debug.LogError("Shared stone with Remote Camera ID: " + _sharedStone.GetRemoteCameraID() + " has no registered camera platform!");
}
if (_slavePlatform == this || !_slavePlatform.gameObject.activeInHierarchy)
if (_slavePlatform == this || !_slavePlatform.gameObject.activeSelf)
{
_sharedStone = null;
_slavePlatform = null;
@ -564,6 +564,7 @@ namespace QSB.ItemSync
private void OnLeaveBounds()
{
DisconnectCamera();
QSBEventManager.FireEvent(EventNames.QSBExitPlatform, CustomPlatformList.IndexOf(this));
if (_anyoneStillOnPlatform)
{
return;
@ -633,7 +634,7 @@ namespace QSB.ItemSync
return;
}
var hologram = _playerToHologram.First(x => x.Key == player).Value;
if (hologram.activeInHierarchy)
if (hologram.activeSelf)
{
OnRemotePlayerExit(id);
}
@ -646,6 +647,9 @@ namespace QSB.ItemSync
{
return;
}
_hologramGroup.SetActive(true);
var player = QSBPlayerManager.GetPlayer(playerId);
if (_playerToHologram.ContainsKey(player))
{
@ -673,7 +677,6 @@ namespace QSB.ItemSync
_playerToHologram.Add(player, hologramCopy.gameObject);
_hologramGroup.SetActive(true);
hologramCopy.gameObject.SetActive(true);
}
@ -686,10 +689,14 @@ namespace QSB.ItemSync
var player = QSBPlayerManager.GetPlayer(playerId);
if (!_playerToHologram.ContainsKey(player))
{
DebugLog.ToConsole($"Error - Trying to remove remote player {playerId} that isn't in _playerToHologram!", MessageType.Error);
return;
}
_playerToHologram[player].SetActive(false);
if (!_platformActive)
{
_hologramGroup.SetActive(false);
}
}
public enum CameraState

View File

@ -1,6 +1,6 @@
using OWML.Utils;
namespace QSB.ItemSync
namespace QSB.PoolSync
{
internal class CustomNomaiRemoteCameraStreaming : SectoredMonoBehaviour
{

View File

@ -0,0 +1,39 @@
using QSB.Patches;
namespace QSB.PoolSync.Patches
{
internal class PoolPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
public override void DoPatches()
{
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("Awake", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("Update", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("OnSocketableRemoved", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("OnSocketableDonePlacing", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraPlatform>("OnPedestalContact", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("FixedUpdate", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnSectorOccupantAdded", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnSectorOccupantRemoved", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnEntry", typeof(PoolPatches), nameof(ReturnFalse));
QSBCore.HarmonyHelper.AddPrefix<NomaiRemoteCameraStreaming>("OnExit", typeof(PoolPatches), nameof(ReturnFalse));
}
public override void DoUnpatches()
{
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("Awake");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("Update");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("OnSocketableRemoved");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("OnSocketableDonePlacing");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraPlatform>("OnPedestalContact");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("FixedUpdate");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnSectorOccupantAdded");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnSectorOccupantRemoved");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnEntry");
QSBCore.HarmonyHelper.Unpatch<NomaiRemoteCameraStreaming>("OnExit");
}
public static bool ReturnFalse() => false;
}
}

View File

@ -0,0 +1,24 @@
using QSB.WorldSync;
using UnityEngine;
namespace QSB.PoolSync
{
class PoolManager : WorldObjectManager
{
protected override void RebuildWorldObjects(OWScene scene)
{
foreach (var streaming in Resources.FindObjectsOfTypeAll<NomaiRemoteCameraStreaming>())
{
streaming.gameObject.AddComponent<CustomNomaiRemoteCameraStreaming>();
}
foreach (var camera in Resources.FindObjectsOfTypeAll<NomaiRemoteCamera>())
{
camera.gameObject.AddComponent<CustomNomaiRemoteCamera>();
}
foreach (var platform in Resources.FindObjectsOfTypeAll<NomaiRemoteCameraPlatform>())
{
platform.gameObject.AddComponent<CustomNomaiRemoteCameraPlatform>();
}
}
}
}

View File

@ -134,8 +134,8 @@
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
<Compile Include="Instruments\InstrumentsManager.cs" />
<Compile Include="ItemSync\CustomNomaiRemoteCameraPlatform.cs" />
<Compile Include="ItemSync\CustomNomaiRemoteCameraStreaming.cs" />
<Compile Include="PoolSync\CustomNomaiRemoteCameraPlatform.cs" />
<Compile Include="PoolSync\CustomNomaiRemoteCameraStreaming.cs" />
<Compile Include="ItemSync\Events\DropItemEvent.cs" />
<Compile Include="ItemSync\Events\DropItemMessage.cs" />
<Compile Include="ItemSync\Events\MoveToCarryEvent.cs" />
@ -144,7 +144,7 @@
<Compile Include="ItemSync\ItemManager.cs" />
<Compile Include="ItemSync\Patches\ItemPatches.cs" />
<Compile Include="ItemSync\SocketEventType.cs" />
<Compile Include="ItemSync\CustomNomaiRemoteCamera.cs" />
<Compile Include="PoolSync\CustomNomaiRemoteCamera.cs" />
<Compile Include="ItemSync\WorldObjects\IQSBOWItem.cs" />
<Compile Include="ItemSync\WorldObjects\IQSBOWItemSocket.cs" />
<Compile Include="ItemSync\WorldObjects\QSBNomaiConversationStone.cs" />
@ -177,6 +177,8 @@
<Compile Include="Player\PlayerEntanglementWatcher.cs" />
<Compile Include="Player\PlayerMapMarker.cs" />
<Compile Include="Player\PlayerSyncObject.cs" />
<Compile Include="PoolSync\Patches\PoolPatches.cs" />
<Compile Include="PoolSync\PoolManager.cs" />
<Compile Include="QSBInputManager.cs" />
<Compile Include="QSBNetworkLobby.cs" />
<Compile Include="Patches\QSBPatch.cs" />

View File

@ -8,6 +8,7 @@ using QSB.ItemSync;
using QSB.OrbSync;
using QSB.Patches;
using QSB.Player;
using QSB.PoolSync;
using QSB.QuantumSync;
using QSB.QuantumSync.WorldObjects;
using QSB.SectorSync;
@ -104,6 +105,7 @@ namespace QSB
gameObject.AddComponent<PlayerEntanglementWatcher>();
gameObject.AddComponent<ItemManager>();
gameObject.AddComponent<StatueManager>();
gameObject.AddComponent<PoolManager>();
DebugBoxManager.Init();

View File

@ -7,6 +7,7 @@ using QSB.Instruments;
using QSB.ItemSync;
using QSB.Patches;
using QSB.Player;
using QSB.PoolSync;
using QSB.TimeSync;
using QSB.TransformSync;
using QSB.Utility;

View File

@ -4,6 +4,6 @@
"name": "Quantum Space Buddies",
"description": "Adds online multiplayer to the game.",
"uniqueName": "Raicuparta.QuantumSpaceBuddies",
"version": "0.9.0",
"version": "0.9.1",
"owmlVersion": "1.1.8"
}