diff --git a/Prowl.Editor/Program.cs b/Prowl.Editor/Program.cs
index 9ecfcaaba..dc14a181f 100644
--- a/Prowl.Editor/Program.cs
+++ b/Prowl.Editor/Program.cs
@@ -119,7 +119,7 @@ private static int Run(CliOpenOptions options)
else if (Hotkeys.IsHotkeyDown("SaveScene", new() { Key = Key.S, Ctrl = true }))
EditorGuiManager.SaveScene();
- Application.isPlaying = PlayMode.Current == PlayMode.Mode.Playing;
+ Application.IsPlaying = PlayMode.Current == PlayMode.Mode.Playing;
try
diff --git a/Prowl.Players/Prowl.Desktop/Program.cs b/Prowl.Players/Prowl.Desktop/Program.cs
index 6d234b016..cdc3c82e2 100644
--- a/Prowl.Players/Prowl.Desktop/Program.cs
+++ b/Prowl.Players/Prowl.Desktop/Program.cs
@@ -12,7 +12,7 @@ internal class Program
public static int Main(string[] args)
{
- Application.isPlaying = true;
+ Application.IsPlaying = true;
Application.DataPath = Data.FullName;
diff --git a/Prowl.Runtime/Application.cs b/Prowl.Runtime/Application.cs
index 3cf1fc95a..3a3858edb 100644
--- a/Prowl.Runtime/Application.cs
+++ b/Prowl.Runtime/Application.cs
@@ -12,9 +12,9 @@ namespace Prowl.Runtime;
public static class Application
{
- public static bool isRunning;
- public static bool isPlaying = false;
- public static bool isEditor { get; private set; }
+ public static bool IsRunning { get; private set; }
+ public static bool IsPlaying { get; set; }
+ public static bool IsEditor { get; private set; }
public static string? DataPath = null;
@@ -25,9 +25,9 @@ public static class Application
public static event Action Render;
public static event Action Quitting;
- private static readonly TimeData AppTime = new();
+ private static readonly TimeData s_appTime = new();
- private static readonly GraphicsBackend[] preferredWindowsBackends = // Covers Windows/UWP
+ private static readonly GraphicsBackend[] s_preferredWindowsBackends = // Covers Windows/UWP
[
GraphicsBackend.Vulkan,
GraphicsBackend.OpenGL,
@@ -35,14 +35,14 @@ public static class Application
GraphicsBackend.OpenGLES,
];
- private static readonly GraphicsBackend[] preferredUnixBackends = // Cover Unix-like (Linux, FreeBSD, OpenBSD)
+ private static readonly GraphicsBackend[] s_preferredUnixBackends = // Cover Unix-like (Linux, FreeBSD, OpenBSD)
[
GraphicsBackend.Vulkan,
GraphicsBackend.OpenGL,
GraphicsBackend.OpenGLES,
];
- private static readonly GraphicsBackend[] preferredMacBackends = // Covers MacOS/Apple
+ private static readonly GraphicsBackend[] s_preferredMacBackends = // Covers macOS/Apple
[
GraphicsBackend.Metal,
GraphicsBackend.OpenGL,
@@ -53,20 +53,20 @@ public static GraphicsBackend GetBackend()
{
if (RuntimeUtils.IsWindows())
{
- return preferredWindowsBackends[0];
+ return s_preferredWindowsBackends[0];
}
else if (RuntimeUtils.IsMac())
{
- return preferredMacBackends[0];
+ return s_preferredMacBackends[0];
}
- return preferredUnixBackends[0];
+ return s_preferredUnixBackends[0];
}
public static void Run(string title, int width, int height, IAssetProvider assetProvider, bool editor)
{
AssetProvider = assetProvider;
- isEditor = editor;
+ IsEditor = editor;
Debug.Log("Initializing...");
@@ -76,10 +76,10 @@ 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
+ IsRunning = 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()
@@ -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();
@@ -103,9 +103,9 @@ static void AppUpdate()
{
AudioSystem.UpdatePool();
- AppTime.Update();
+ s_appTime.Update();
- Time.TimeStack.Push(AppTime);
+ Time.TimeStack.Push(s_appTime);
Update.Invoke();
Render.Invoke();
@@ -120,7 +120,7 @@ static void AppUpdate()
static void AppClose()
{
- isRunning = false;
+ IsRunning = false;
Quitting.Invoke();
Graphics.Dispose();
Physics.Dispose();
diff --git a/Prowl.Runtime/AssetRef.cs b/Prowl.Runtime/AssetRef.cs
index e54f1b516..d29090bbf 100644
--- a/Prowl.Runtime/AssetRef.cs
+++ b/Prowl.Runtime/AssetRef.cs
@@ -139,6 +139,7 @@ public AssetRef(Guid id)
/// the specified alias.
///
///
+ ///
public AssetRef(Guid id, ushort fileId)
{
instance = null;
@@ -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()
diff --git a/Prowl.Runtime/Audio/AudioSystem.cs b/Prowl.Runtime/Audio/AudioSystem.cs
index 24c1d867a..e37482059 100644
--- a/Prowl.Runtime/Audio/AudioSystem.cs
+++ b/Prowl.Runtime/Audio/AudioSystem.cs
@@ -18,9 +18,9 @@ public static class AudioSystem
private static readonly List _active = [];
private static readonly List _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;
@@ -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)
diff --git a/Prowl.Runtime/Color.cs b/Prowl.Runtime/Color.cs
index 533911ed4..b35142c9c 100644
--- a/Prowl.Runtime/Color.cs
+++ b/Prowl.Runtime/Color.cs
@@ -13,27 +13,27 @@ public struct Color
public float grayscale => 0.299f * r + 0.587f * g + 0.114f * b;
- public static Color black => new Color(0f, 0f, 0f, 1f);
+ public static Color black => new(0f, 0f, 0f, 1f);
- public static Color blue => new Color(0f, 0f, 1f, 1f);
+ public static Color blue => new(0f, 0f, 1f, 1f);
- public static Color clear => new Color(0f, 0f, 0f, 0f);
+ public static Color clear => new(0f, 0f, 0f, 0f);
- public static Color cyan => new Color(0f, 1f, 1f, 1f);
+ public static Color cyan => new(0f, 1f, 1f, 1f);
- public static Color gray => new Color(0.5f, 0.5f, 0.5f, 1f);
+ public static Color gray => new(0.5f, 0.5f, 0.5f, 1f);
- public static Color green => new Color(0f, 1f, 0f, 1f);
+ public static Color green => new(0f, 1f, 0f, 1f);
- public static Color grey => new Color(0.5f, 0.5f, 0.5f, 1f);
+ public static Color grey => new(0.5f, 0.5f, 0.5f, 1f);
- public static Color magenta => new Color(1f, 0f, 1f, 1f);
+ public static Color magenta => new(1f, 0f, 1f, 1f);
- public static Color red => new Color(1f, 0f, 0f, 1f);
+ public static Color red => new(1f, 0f, 0f, 1f);
- public static Color white => new Color(1f, 1f, 1f, 1f);
+ public static Color white => new(1f, 1f, 1f, 1f);
- public static Color yellow => new Color(1f, 0.9215f, 0.0156f, 1f);
+ public static Color yellow => new(1f, 0.9215f, 0.0156f, 1f);
public float this[int index]
{
@@ -121,7 +121,7 @@ public static Color FromHSV(float h, float s, float v, float a = 1)
float t = v * (1 - s * (1 - f));
// build our rgb color
- Color color = new Color(0, 0, 0, a);
+ Color color = new(0, 0, 0, a);
switch (i)
{
@@ -165,27 +165,27 @@ public static Color FromHSV(float h, float s, float v, float a = 1)
return color;
}
- 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);
+ 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);
- public static Color operator /(Color a, float b) => new Color(a.r / b, a.g / b, a.b / b, a.a / b);
+ public static Color operator /(Color a, float b) => new(a.r / b, a.g / b, a.b / b, a.a / b);
- public static bool operator ==(Color lhs, Color rhs) => lhs == rhs;
+ public static bool operator ==(Color lhs, Color rhs) => lhs.Equals(rhs);
- public static implicit operator Vector4(Color c) => new Vector4(c.r, c.g, c.b, c.a);
- public static implicit operator System.Numerics.Vector4(Color c) => new System.Numerics.Vector4(c.r, c.g, c.b, c.a);
+ public static implicit operator Vector4(Color c) => new(c.r, c.g, c.b, c.a);
+ public static implicit operator System.Numerics.Vector4(Color c) => new(c.r, c.g, c.b, c.a);
- public static implicit operator Color(Vector4 v) => new Color((float)v.x, (float)v.y, (float)v.z, (float)v.w);
- public static implicit operator Color(System.Numerics.Vector4 v) => new Color(v.X, v.Y, v.Z, v.W);
+ public static implicit operator Color(Vector4 v) => new((float)v.x, (float)v.y, (float)v.z, (float)v.w);
+ public static implicit operator Color(System.Numerics.Vector4 v) => new(v.X, v.Y, v.Z, v.W);
- public static bool operator !=(Color lhs, Color rhs) => lhs != rhs;
+ public static bool operator !=(Color lhs, Color rhs) => !lhs.Equals(rhs);
- 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);
+ 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);
- public static Color operator *(Color a, float b) => new Color(a.r * b, a.g * b, a.b * b, a.a * b);
+ public static Color operator *(Color a, float b) => new(a.r * b, a.g * b, a.b * b, a.a * b);
- public static Color operator *(float b, Color a) => new Color(a.r * b, a.g * b, a.b * b, a.a * b);
+ public static Color operator *(float b, Color a) => new(a.r * b, a.g * b, a.b * b, a.a * b);
- 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);
+ 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);
public override bool Equals(object? other)
{
diff --git a/Prowl.Runtime/EngineObject.cs b/Prowl.Runtime/EngineObject.cs
index 8866113ff..c135b12eb 100644
--- a/Prowl.Runtime/EngineObject.cs
+++ b/Prowl.Runtime/EngineObject.cs
@@ -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.
///
+ /// TODO: FIXME: replacing GameObject and EngineObject calls crashes the app
[Obsolete("You are advised to not use this! Use Destroy() Instead.")]
public void Dispose()
{
diff --git a/Prowl.Runtime/GameObject/MonoBehaviour.cs b/Prowl.Runtime/GameObject/MonoBehaviour.cs
index 5f482d167..13623ddb0 100644
--- a/Prowl.Runtime/GameObject/MonoBehaviour.cs
+++ b/Prowl.Runtime/GameObject/MonoBehaviour.cs
@@ -154,7 +154,7 @@ internal void Do(Action action)
try
{
- if (Application.isPlaying || always)
+ if (Application.IsPlaying || always)
action();
}
catch (Exception e)
diff --git a/Prowl.Runtime/Physics.cs b/Prowl.Runtime/Physics.cs
index c227d62cd..88e230a81 100644
--- a/Prowl.Runtime/Physics.cs
+++ b/Prowl.Runtime/Physics.cs
@@ -36,7 +36,7 @@ public class PhysicsSetting : ScriptableSingleton
public static class Physics
{
- public static bool IsReady => isInitialized && Application.isPlaying;
+ public static bool IsReady => isInitialized && Application.IsPlaying;
public static Simulation? Sim { get; private set; }
public static BufferPool? Pool { get; private set; }
diff --git a/Prowl.Runtime/SceneManager.cs b/Prowl.Runtime/SceneManager.cs
index b6d14cd83..3deb07fad 100644
--- a/Prowl.Runtime/SceneManager.cs
+++ b/Prowl.Runtime/SceneManager.cs
@@ -113,7 +113,7 @@ public static void Update()
if (_gameObjects[i].enabledInHierarchy)
_gameObjects[i].PreUpdate();
- if (Application.isPlaying)
+ if (Application.IsPlaying)
Physics.Update();
ForeachComponent((x) =>
diff --git a/Prowl.Runtime/Utils/ScriptableSingleton.cs b/Prowl.Runtime/Utils/ScriptableSingleton.cs
index b99abcc67..461f28998 100644
--- a/Prowl.Runtime/Utils/ScriptableSingleton.cs
+++ b/Prowl.Runtime/Utils/ScriptableSingleton.cs
@@ -72,14 +72,14 @@ protected string GetFilePath(string? dataPath)
ArgumentNullException.ThrowIfNull(dataPath);
// Persistent across sessions for a single project
- if (Application.isEditor == false)
+ if (Application.IsEditor == false)
throw new InvalidOperationException("Editor Settings are only available in the editor");
directory = Path.Combine(dataPath, "ProjectSettings", "Editor");
break;
case FilePathAttribute.Location.EditorPreference:
// Persistent across all projects
// TODO: !Application.isRunning is just a hack to allow CLI operations that do not depend on the editor
- if (!Application.isRunning || Application.isEditor == false)
+ if (!Application.IsRunning || Application.IsEditor == false)
throw new InvalidOperationException("Preferences are only available in the editor");
directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Prowl", "Editor");
break;