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

65 lines
1.6 KiB
C#
Raw Normal View History

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