Skip to content

Commit

Permalink
fix: reverting replacement of Dispose() to Destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
brmassa committed Sep 18, 2024
1 parent 4c695f1 commit 100488f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Prowl.Runtime/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static class Application
GraphicsBackend.OpenGLES,
];

private static readonly GraphicsBackend[] s_preferredMacBackends = // Covers MacOS/Apple
private static readonly GraphicsBackend[] s_preferredMacBackends = // Covers macOS/Apple
[
GraphicsBackend.Metal,
GraphicsBackend.OpenGL,
Expand Down Expand Up @@ -77,9 +77,9 @@ public static void Run(string title, int width, int height, IAssetProvider asset
Screen.Closing += AppClose;

IsRunning = true;
IsPlaying = true; // Base application is not the editor, isplaying is always true
IsPlaying = true; // Base application is not the editor, IsPlaying is always true

Screen.Start($"{title} - {GetBackend()}", new Vector2Int(width, height), new Vector2Int(100, 100), WindowState.Normal);
Screen.Start($"{title} - {GetBackend()}", new Vector2Int(width, height), new Vector2Int(100, 100));
}

static void AppInitialize()
Expand All @@ -88,7 +88,7 @@ static void AppInitialize()
SceneManager.Initialize();
AudioSystem.Initialize();

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

AssemblyManager.Initialize();

Expand Down Expand Up @@ -120,8 +120,8 @@ static void AppUpdate()

static void AppClose()
{
isRunning = false;
Quitting?.Invoke();
IsRunning = false;
Quitting.Invoke();
Graphics.Dispose();
Physics.Dispose();
AudioSystem.Dispose();
Expand Down
5 changes: 3 additions & 2 deletions Prowl.Runtime/AssetRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public AssetRef(Guid id)
/// the specified alias.
/// </summary>
/// <param name="id"></param>
/// <param name="fileId"></param>
public AssetRef(Guid id, ushort fileId)
{
instance = null;
Expand All @@ -152,8 +153,8 @@ public AssetRef(Guid id, ushort fileId)
public AssetRef(T? res)
{
instance = res;
assetID = res != null ? res.AssetID : Guid.Empty;
fileID = res != null ? res.FileID : (ushort)0;
assetID = res?.AssetID ?? Guid.Empty;
fileID = res?.FileID ?? 0;
}

public object? GetInstance()
Expand Down
10 changes: 5 additions & 5 deletions Prowl.Runtime/Audio/AudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static class AudioSystem

private static readonly List<ActiveAudio> _active = [];
private static readonly List<ActiveAudio> _pool = [];
private static AudioListener _listener;
private static AudioListener? s_listener;

public static AudioListener Listener => _listener;
public static AudioListener Listener => s_listener;

public static AudioEngine Engine => _engine;

Expand Down Expand Up @@ -75,17 +75,17 @@ public static void UpdatePool()

public static void RegisterListener(AudioListener audioListener)
{
if (_listener != null)
if (s_listener != null)
{
Debug.LogWarning("Audio listener already registered, only the first in the scene will work as intended! Please destroy that one first before instantiating a new Listener.");
return;
}
_listener = audioListener;
s_listener = audioListener;
}

public static void UnregisterListener(AudioListener audioListener)
{
_listener = null;
s_listener = null;
}

public static AudioBuffer GetAudioBuffer(AudioClip clip)
Expand Down
1 change: 1 addition & 0 deletions Prowl.Runtime/EngineObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public static EngineObject Instantiate(EngineObject obj, bool keepAssetID = fals
/// Force the object to dispose immediately
/// You are advised to not use this! Use Destroy() Instead.
/// </summary>
/// TODO: FIXME: replacing GameObject and EngineObject calls crashes the app
[Obsolete("You are advised to not use this! Use Destroy() Instead.")]
public void Dispose()
{
Expand Down

0 comments on commit 100488f

Please sign in to comment.