mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
Merge pull request #376 from misternebula/fix-satellite-projector-rendertexture
add new rendertexture
This commit is contained in:
commit
6b7ce21726
@ -10,6 +10,14 @@ namespace QSB.SatelliteSync.Patches
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(SatelliteSnapshotController), nameof(SatelliteSnapshotController.Awake))]
|
||||
public static void CreateNewRenderTexture(SatelliteSnapshotController __instance)
|
||||
{
|
||||
__instance._snapshotTexture = SatelliteProjectorManager.Instance.SatelliteCameraSnapshot;
|
||||
__instance._satelliteCamera.targetTexture = __instance._snapshotTexture;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(SatelliteSnapshotController), nameof(SatelliteSnapshotController.OnPressInteract))]
|
||||
public static bool UseProjector()
|
||||
|
@ -9,15 +9,44 @@ namespace QSB.SatelliteSync
|
||||
public static SatelliteProjectorManager Instance { get; private set; }
|
||||
|
||||
public SatelliteSnapshotController Projector { get; private set; }
|
||||
public RenderTexture SatelliteCameraSnapshot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_satelliteCameraSnapshot == null)
|
||||
{
|
||||
_satelliteCameraSnapshot = new RenderTexture(512, 512, 16)
|
||||
{
|
||||
name = "SatelliteCameraSnapshot",
|
||||
hideFlags = HideFlags.HideAndDontSave
|
||||
};
|
||||
_satelliteCameraSnapshot.Create();
|
||||
}
|
||||
|
||||
return _satelliteCameraSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
private static RenderTexture _satelliteCameraSnapshot;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Instance = this;
|
||||
QSBSceneManager.OnUniverseSceneLoaded += OnSceneLoaded;
|
||||
QSBNetworkManager.Instance.OnClientConnected += OnConnected;
|
||||
}
|
||||
|
||||
public void OnDestroy() => QSBSceneManager.OnUniverseSceneLoaded -= OnSceneLoaded;
|
||||
|
||||
public void OnConnected()
|
||||
{
|
||||
if (QSBSceneManager.CurrentScene == OWScene.SolarSystem)
|
||||
{
|
||||
Projector._snapshotTexture = SatelliteCameraSnapshot;
|
||||
Projector._satelliteCamera.targetTexture = Projector._snapshotTexture;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene oldScene, OWScene newScene)
|
||||
{
|
||||
if (newScene == OWScene.SolarSystem)
|
||||
@ -25,6 +54,9 @@ namespace QSB.SatelliteSync
|
||||
Projector = QSBWorldSync.GetUnityObjects<SatelliteSnapshotController>().First();
|
||||
Projector._loopingSource.spatialBlend = 1f;
|
||||
Projector._oneShotSource.spatialBlend = 1f;
|
||||
|
||||
Projector._snapshotTexture = SatelliteCameraSnapshot;
|
||||
Projector._satelliteCamera.targetTexture = Projector._snapshotTexture;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user