quantum-space-buddies/QSB/PoolSync/CustomNomaiRemoteCameraStreaming.cs

63 lines
1.6 KiB
C#
Raw Normal View History

2022-03-03 03:46:33 +00:00
namespace QSB.PoolSync;
2023-07-28 18:30:57 +00:00
public class CustomNomaiRemoteCameraStreaming : SectoredMonoBehaviour
2021-03-06 23:59:44 +00:00
{
2022-03-03 03:46:33 +00:00
private CustomNomaiRemoteCameraPlatform _remoteCameraPlatform;
private StreamingGroup _streamingGroup;
private NomaiRemoteCameraStreaming _oldStreaming;
private bool _hasLoadedAssets;
2021-03-06 23:59:44 +00:00
2022-03-03 03:46:33 +00:00
public override void Awake()
{
base.Awake();
_oldStreaming = GetComponent<NomaiRemoteCameraStreaming>();
SetSector(_oldStreaming.GetSector());
}
2021-03-06 23:59:44 +00:00
2022-03-03 03:46:33 +00:00
private void Start()
{
_remoteCameraPlatform = _oldStreaming._remoteCameraPlatform.GetComponent<CustomNomaiRemoteCameraPlatform>();
enabled = false;
}
2022-03-03 03:46:33 +00:00
private void FixedUpdate()
{
var stone = _remoteCameraPlatform.GetSocketedStone();
if (stone == null)
{
2022-03-03 03:46:33 +00:00
if (_hasLoadedAssets)
2021-03-06 23:59:44 +00:00
{
2022-03-03 03:46:33 +00:00
_hasLoadedAssets = false;
_streamingGroup.ReleaseRequiredAssets();
_streamingGroup.ReleaseGeneralAssets();
_streamingGroup = null;
}
2022-03-03 03:46:33 +00:00
}
else
{
if (!_hasLoadedAssets)
{
2022-03-03 03:46:33 +00:00
_hasLoadedAssets = true;
_streamingGroup = StreamingGroup.GetStreamingGroup(NomaiRemoteCameraStreaming.NomaiRemoteCameraPlatformIDToSceneName(stone.GetRemoteCameraID()));
_streamingGroup.RequestRequiredAssets();
_streamingGroup.RequestGeneralAssets();
2021-03-06 23:59:44 +00:00
}
}
2022-03-03 03:46:33 +00:00
}
2021-03-06 23:59:44 +00:00
2022-03-03 03:46:33 +00:00
public override void OnSectorOccupantAdded(SectorDetector sectorDetector)
{
if (sectorDetector.GetOccupantType() == DynamicOccupant.Player && StreamingManager.isStreamingEnabled)
2021-03-06 23:59:44 +00:00
{
2022-03-03 03:46:33 +00:00
enabled = true;
2021-03-06 23:59:44 +00:00
}
2022-03-03 03:46:33 +00:00
}
2021-03-06 23:59:44 +00:00
2022-03-03 03:46:33 +00:00
public override void OnSectorOccupantRemoved(SectorDetector sectorDetector)
{
if (sectorDetector.GetOccupantType() == DynamicOccupant.Player)
2021-03-06 23:59:44 +00:00
{
2022-03-03 03:46:33 +00:00
enabled = false;
2021-03-06 23:59:44 +00:00
}
}
}