Skip to content

Commit 3e2af96

Browse files
committed
fix: reverting replacement of Dispose() to Destroy()
1 parent db2bcaf commit 3e2af96

File tree

11 files changed

+58
-56
lines changed

11 files changed

+58
-56
lines changed

Prowl.Editor/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private static int Run(CliOpenOptions options)
119119
else if (Hotkeys.IsHotkeyDown("SaveScene", new() { Key = Key.S, Ctrl = true }))
120120
EditorGuiManager.SaveScene();
121121

122-
Application.isPlaying = PlayMode.Current == PlayMode.Mode.Playing;
122+
Application.IsPlaying = PlayMode.Current == PlayMode.Mode.Playing;
123123

124124

125125
try

Prowl.Players/Prowl.Desktop/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class Program
1212
public static int Main(string[] args)
1313
{
1414

15-
Application.isPlaying = true;
15+
Application.IsPlaying = true;
1616
Application.DataPath = Data.FullName;
1717

1818

Prowl.Runtime/Application.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace Prowl.Runtime;
1212

1313
public static class Application
1414
{
15-
public static bool isRunning;
16-
public static bool isPlaying = false;
17-
public static bool isEditor { get; private set; }
15+
public static bool IsRunning { get; private set; }
16+
public static bool IsPlaying { get; set; }
17+
public static bool IsEditor { get; private set; }
1818

1919
public static string? DataPath = null;
2020

@@ -25,24 +25,24 @@ public static class Application
2525
public static event Action Render;
2626
public static event Action Quitting;
2727

28-
private static readonly TimeData AppTime = new();
28+
private static readonly TimeData s_appTime = new();
2929

30-
private static readonly GraphicsBackend[] preferredWindowsBackends = // Covers Windows/UWP
30+
private static readonly GraphicsBackend[] s_preferredWindowsBackends = // Covers Windows/UWP
3131
[
3232
GraphicsBackend.Vulkan,
3333
GraphicsBackend.OpenGL,
3434
GraphicsBackend.Direct3D11,
3535
GraphicsBackend.OpenGLES,
3636
];
3737

38-
private static readonly GraphicsBackend[] preferredUnixBackends = // Cover Unix-like (Linux, FreeBSD, OpenBSD)
38+
private static readonly GraphicsBackend[] s_preferredUnixBackends = // Cover Unix-like (Linux, FreeBSD, OpenBSD)
3939
[
4040
GraphicsBackend.Vulkan,
4141
GraphicsBackend.OpenGL,
4242
GraphicsBackend.OpenGLES,
4343
];
4444

45-
private static readonly GraphicsBackend[] preferredMacBackends = // Covers MacOS/Apple
45+
private static readonly GraphicsBackend[] s_preferredMacBackends = // Covers macOS/Apple
4646
[
4747
GraphicsBackend.Metal,
4848
GraphicsBackend.OpenGL,
@@ -53,20 +53,20 @@ public static GraphicsBackend GetBackend()
5353
{
5454
if (RuntimeUtils.IsWindows())
5555
{
56-
return preferredWindowsBackends[0];
56+
return s_preferredWindowsBackends[0];
5757
}
5858
else if (RuntimeUtils.IsMac())
5959
{
60-
return preferredMacBackends[0];
60+
return s_preferredMacBackends[0];
6161
}
6262

63-
return preferredUnixBackends[0];
63+
return s_preferredUnixBackends[0];
6464
}
6565

6666
public static void Run(string title, int width, int height, IAssetProvider assetProvider, bool editor)
6767
{
6868
AssetProvider = assetProvider;
69-
isEditor = editor;
69+
IsEditor = editor;
7070

7171
Debug.Log("Initializing...");
7272

@@ -76,10 +76,10 @@ public static void Run(string title, int width, int height, IAssetProvider asset
7676

7777
Screen.Closing += AppClose;
7878

79-
isRunning = true;
80-
isPlaying = true; // Base application is not the editor, isplaying is always true
79+
IsRunning = true;
80+
IsPlaying = true; // Base application is not the editor, IsPlaying is always true
8181

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

8585
static void AppInitialize()
@@ -88,7 +88,7 @@ static void AppInitialize()
8888
SceneManager.Initialize();
8989
AudioSystem.Initialize();
9090

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

9393
AssemblyManager.Initialize();
9494

@@ -103,9 +103,9 @@ static void AppUpdate()
103103
{
104104
AudioSystem.UpdatePool();
105105

106-
AppTime.Update();
106+
s_appTime.Update();
107107

108-
Time.TimeStack.Push(AppTime);
108+
Time.TimeStack.Push(s_appTime);
109109

110110
Update.Invoke();
111111
Render.Invoke();
@@ -120,7 +120,7 @@ static void AppUpdate()
120120

121121
static void AppClose()
122122
{
123-
isRunning = false;
123+
IsRunning = false;
124124
Quitting.Invoke();
125125
Graphics.Dispose();
126126
Physics.Dispose();

Prowl.Runtime/AssetRef.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public AssetRef(Guid id)
139139
/// the specified alias.
140140
/// </summary>
141141
/// <param name="id"></param>
142+
/// <param name="fileId"></param>
142143
public AssetRef(Guid id, ushort fileId)
143144
{
144145
instance = null;
@@ -152,8 +153,8 @@ public AssetRef(Guid id, ushort fileId)
152153
public AssetRef(T? res)
153154
{
154155
instance = res;
155-
assetID = res != null ? res.AssetID : Guid.Empty;
156-
fileID = res != null ? res.FileID : (ushort)0;
156+
assetID = res?.AssetID ?? Guid.Empty;
157+
fileID = res?.FileID ?? 0;
157158
}
158159

159160
public object? GetInstance()

Prowl.Runtime/Audio/AudioSystem.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public static class AudioSystem
1818

1919
private static readonly List<ActiveAudio> _active = [];
2020
private static readonly List<ActiveAudio> _pool = [];
21-
private static AudioListener _listener;
21+
private static AudioListener? s_listener;
2222

23-
public static AudioListener Listener => _listener;
23+
public static AudioListener Listener => s_listener;
2424

2525
public static AudioEngine Engine => _engine;
2626

@@ -75,17 +75,17 @@ public static void UpdatePool()
7575

7676
public static void RegisterListener(AudioListener audioListener)
7777
{
78-
if (_listener != null)
78+
if (s_listener != null)
7979
{
8080
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.");
8181
return;
8282
}
83-
_listener = audioListener;
83+
s_listener = audioListener;
8484
}
8585

8686
public static void UnregisterListener(AudioListener audioListener)
8787
{
88-
_listener = null;
88+
s_listener = null;
8989
}
9090

9191
public static AudioBuffer GetAudioBuffer(AudioClip clip)

Prowl.Runtime/Color.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ public struct Color
1313

1414
public float grayscale => 0.299f * r + 0.587f * g + 0.114f * b;
1515

16-
public static Color black => new Color(0f, 0f, 0f, 1f);
16+
public static Color black => new(0f, 0f, 0f, 1f);
1717

18-
public static Color blue => new Color(0f, 0f, 1f, 1f);
18+
public static Color blue => new(0f, 0f, 1f, 1f);
1919

20-
public static Color clear => new Color(0f, 0f, 0f, 0f);
20+
public static Color clear => new(0f, 0f, 0f, 0f);
2121

22-
public static Color cyan => new Color(0f, 1f, 1f, 1f);
22+
public static Color cyan => new(0f, 1f, 1f, 1f);
2323

24-
public static Color gray => new Color(0.5f, 0.5f, 0.5f, 1f);
24+
public static Color gray => new(0.5f, 0.5f, 0.5f, 1f);
2525

26-
public static Color green => new Color(0f, 1f, 0f, 1f);
26+
public static Color green => new(0f, 1f, 0f, 1f);
2727

28-
public static Color grey => new Color(0.5f, 0.5f, 0.5f, 1f);
28+
public static Color grey => new(0.5f, 0.5f, 0.5f, 1f);
2929

30-
public static Color magenta => new Color(1f, 0f, 1f, 1f);
30+
public static Color magenta => new(1f, 0f, 1f, 1f);
3131

32-
public static Color red => new Color(1f, 0f, 0f, 1f);
32+
public static Color red => new(1f, 0f, 0f, 1f);
3333

34-
public static Color white => new Color(1f, 1f, 1f, 1f);
34+
public static Color white => new(1f, 1f, 1f, 1f);
3535

36-
public static Color yellow => new Color(1f, 0.9215f, 0.0156f, 1f);
36+
public static Color yellow => new(1f, 0.9215f, 0.0156f, 1f);
3737

3838
public float this[int index]
3939
{
@@ -121,7 +121,7 @@ public static Color FromHSV(float h, float s, float v, float a = 1)
121121
float t = v * (1 - s * (1 - f));
122122

123123
// build our rgb color
124-
Color color = new Color(0, 0, 0, a);
124+
Color color = new(0, 0, 0, a);
125125

126126
switch (i)
127127
{
@@ -165,27 +165,27 @@ public static Color FromHSV(float h, float s, float v, float a = 1)
165165
return color;
166166
}
167167

168-
public static Color operator +(Color a, Color b) => new Color(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a);
168+
public static Color operator +(Color a, Color b) => new(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a);
169169

170-
public static Color operator /(Color a, float b) => new Color(a.r / b, a.g / b, a.b / b, a.a / b);
170+
public static Color operator /(Color a, float b) => new(a.r / b, a.g / b, a.b / b, a.a / b);
171171

172-
public static bool operator ==(Color lhs, Color rhs) => lhs == rhs;
172+
public static bool operator ==(Color lhs, Color rhs) => lhs.Equals(rhs);
173173

174-
public static implicit operator Vector4(Color c) => new Vector4(c.r, c.g, c.b, c.a);
175-
public static implicit operator System.Numerics.Vector4(Color c) => new System.Numerics.Vector4(c.r, c.g, c.b, c.a);
174+
public static implicit operator Vector4(Color c) => new(c.r, c.g, c.b, c.a);
175+
public static implicit operator System.Numerics.Vector4(Color c) => new(c.r, c.g, c.b, c.a);
176176

177-
public static implicit operator Color(Vector4 v) => new Color((float)v.x, (float)v.y, (float)v.z, (float)v.w);
178-
public static implicit operator Color(System.Numerics.Vector4 v) => new Color(v.X, v.Y, v.Z, v.W);
177+
public static implicit operator Color(Vector4 v) => new((float)v.x, (float)v.y, (float)v.z, (float)v.w);
178+
public static implicit operator Color(System.Numerics.Vector4 v) => new(v.X, v.Y, v.Z, v.W);
179179

180-
public static bool operator !=(Color lhs, Color rhs) => lhs != rhs;
180+
public static bool operator !=(Color lhs, Color rhs) => !lhs.Equals(rhs);
181181

182-
public static Color operator *(Color a, Color b) => new Color(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a);
182+
public static Color operator *(Color a, Color b) => new(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a);
183183

184-
public static Color operator *(Color a, float b) => new Color(a.r * b, a.g * b, a.b * b, a.a * b);
184+
public static Color operator *(Color a, float b) => new(a.r * b, a.g * b, a.b * b, a.a * b);
185185

186-
public static Color operator *(float b, Color a) => new Color(a.r * b, a.g * b, a.b * b, a.a * b);
186+
public static Color operator *(float b, Color a) => new(a.r * b, a.g * b, a.b * b, a.a * b);
187187

188-
public static Color operator -(Color a, Color b) => new Color(a.r - b.r, a.g - b.g, a.b - b.b, a.a - b.a);
188+
public static Color operator -(Color a, Color b) => new(a.r - b.r, a.g - b.g, a.b - b.b, a.a - b.a);
189189

190190
public override bool Equals(object? other)
191191
{

Prowl.Runtime/EngineObject.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public static EngineObject Instantiate(EngineObject obj, bool keepAssetID = fals
130130
/// Force the object to dispose immediately
131131
/// You are advised to not use this! Use Destroy() Instead.
132132
/// </summary>
133+
/// TODO: FIXME: replacing GameObject and EngineObject calls crashes the app
133134
[Obsolete("You are advised to not use this! Use Destroy() Instead.")]
134135
public void Dispose()
135136
{

Prowl.Runtime/GameObject/MonoBehaviour.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ internal void Do(Action action)
154154

155155
try
156156
{
157-
if (Application.isPlaying || always)
157+
if (Application.IsPlaying || always)
158158
action();
159159
}
160160
catch (Exception e)

Prowl.Runtime/Physics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class PhysicsSetting : ScriptableSingleton<PhysicsSetting>
3636

3737
public static class Physics
3838
{
39-
public static bool IsReady => isInitialized && Application.isPlaying;
39+
public static bool IsReady => isInitialized && Application.IsPlaying;
4040

4141
public static Simulation? Sim { get; private set; }
4242
public static BufferPool? Pool { get; private set; }

Prowl.Runtime/SceneManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static void Update()
113113
if (_gameObjects[i].enabledInHierarchy)
114114
_gameObjects[i].PreUpdate();
115115

116-
if (Application.isPlaying)
116+
if (Application.IsPlaying)
117117
Physics.Update();
118118

119119
ForeachComponent((x) =>

0 commit comments

Comments
 (0)