Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 1.34.2 #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TrickSaber/GlobalTrickManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void OnTrickEndRequested(TrickAction trickAction)
if (_config.SlowmoDuringThrow && !_isMultiplayer &&
!IsTrickInState(trickAction, TrickState.Started) && _slowmoApplied)
{
if(_applySlowmoCoroutine!=null)SharedCoroutineStarter.instance.StopCoroutine(_applySlowmoCoroutine);
if(_applySlowmoCoroutine!=null) SharedCoroutineStarter.instance.StopCoroutine(_applySlowmoCoroutine);
_endSlowmoCoroutine = SharedCoroutineStarter.instance.StartCoroutine(EndSlowmoSmooth());
_slowmoApplied = false;
}
Expand Down
2 changes: 1 addition & 1 deletion TrickSaber/InputHandling/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private InputManager(PluginConfig config, SiraLog logger)
_trickInputHandler = new TrickInputHandler();
}

public void Init(SaberType type, VRControllersInputManager vrControllersInputManager)
public void Init(SaberType type)
{
OVRInput.Controller oculusController;
XRNode node;
Expand Down
2 changes: 1 addition & 1 deletion TrickSaber/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using SiraUtil.Zenject;
using TrickSaber.Configuration;
using TrickSaber.Installers;
using Zenject;
using IPALogger = IPA.Logging.Logger;

namespace TrickSaber
{
[Plugin(RuntimeOptions.DynamicInit)]
public class Plugin
{

[Init]
public Plugin(IPALogger logger, Config conf, Zenjector zenjector)
{
Expand Down
2 changes: 1 addition & 1 deletion TrickSaber/SaberTrickManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async void Init(GlobalTrickManager globalTrickManager)

_movementController.Init(_vrController, this);

_inputManager.Init(_saber.saberType, _vrController.GetField<VRControllersInputManager, VRController>("_vrControllersInputManager"));
_inputManager.Init(_saber.saberType);
_inputManager.TrickActivated += OnTrickActivated;
_inputManager.TrickDeactivated += OnTrickDeactivated;

Expand Down
58 changes: 58 additions & 0 deletions TrickSaber/SharedCoroutineStarter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using UnityEngine;

namespace TrickSaber
{
// Mostly a copy-paste of PersistentSingleton<T> from game version < 1.31.0.
internal class SharedCoroutineStarter : MonoBehaviour
{
private static SharedCoroutineStarter? _instance;
private static object _lock = new object();
private static bool _applicationIsQuitting;

public static SharedCoroutineStarter? instance
{
get
{
if (_applicationIsQuitting)
{
Debug.LogWarning("[Singleton] Instance '" + nameof(SharedCoroutineStarter) + "' already destroyed on application quit. Won't create again - returning null.");
return null;
}

lock (_lock)
{
if (_instance == null)
{
_instance = FindObjectOfType<SharedCoroutineStarter>();

if (FindObjectsOfType<SharedCoroutineStarter>().Length > 1)
{
Debug.LogError("[Singleton] Something went really wrong - there should never be more than 1 singleton! Reopening the scene might fix it.");
return _instance;
}

if (_instance == null)
{
GameObject obj = new GameObject();
_instance = obj.AddComponent<SharedCoroutineStarter>();
obj.name = nameof(SharedCoroutineStarter);
DontDestroyOnLoad(obj);
}
}

return _instance;
}
}
}

protected void OnEnable()
{
DontDestroyOnLoad(this);
}

protected virtual void OnDestroy()
{
_applicationIsQuitting = true;
}
}
}
3 changes: 3 additions & 0 deletions TrickSaber/TrickSaber.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BGLib.UnityExtension">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.UnityExtension.dll</HintPath>
</Reference>
<Reference Include="BSML">
<HintPath>$(BeatSaberDir)\Plugins\BSML.dll</HintPath>
<Private>False</Private>
Expand Down
2 changes: 1 addition & 1 deletion TrickSaber/UI/SettingsUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private void ShowFlow()

public void Dispose()
{
if (MenuButtons.IsSingletonAvailable && BSMLParser.IsSingletonAvailable)
if (MenuButtons.instance != null && BSMLParser.instance != null)
{
MenuButtons.instance.UnregisterButton(_menuButton);
}
Expand Down