diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 51285f3..ac1dbff 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,8 +1,8 @@
- $(DefineConstants);DEBUG;GHOST_EDITOR;MHP_ENABLE_SAFETY_CHECKS;
+ $(DefineConstants);DEBUG;GHOST_EDITOR;
$(DefineConstants);GHOST_EDITOR;MHP_ENABLE_SAFETY_CHECKS;
-
\ No newline at end of file
+
diff --git a/src/Runtime/Ghost.Core/Ghost.Core.csproj b/src/Runtime/Ghost.Core/Ghost.Core.csproj
index ac8de7b..7ac3b08 100644
--- a/src/Runtime/Ghost.Core/Ghost.Core.csproj
+++ b/src/Runtime/Ghost.Core/Ghost.Core.csproj
@@ -12,9 +12,13 @@
- $(DefineConstants);MHP_ENABLE_STACKTRACE
+ $(DefineConstants);MHP_ENABLE_SAFETY_CHECKS;MHP_ENABLE_STACKTRACE
-
+
+
+ $(DefineConstants);MHP_ENABLE_SAFETY_CHECKS
+
+
diff --git a/src/Runtime/Ghost.Core/Graphics/ShaderPropertyRegistry.cs b/src/Runtime/Ghost.Core/Graphics/ShaderPropertyRegistry.cs
index 6596c4f..a25eb19 100644
--- a/src/Runtime/Ghost.Core/Graphics/ShaderPropertyRegistry.cs
+++ b/src/Runtime/Ghost.Core/Graphics/ShaderPropertyRegistry.cs
@@ -33,7 +33,7 @@ public readonly struct ShaderPropertyFieldInfo
}
}
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
public struct ShaderPropertyInfo
{
public string ShaderName
@@ -71,4 +71,4 @@ public static class ShaderPropertiesRegistry
return s_nameToCode.TryGetValue(name, out info);
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/Runtime/Ghost.Core/Result.cs b/src/Runtime/Ghost.Core/Result.cs
index aa05003..68ee806 100644
--- a/src/Runtime/Ghost.Core/Result.cs
+++ b/src/Runtime/Ghost.Core/Result.cs
@@ -114,7 +114,7 @@ public readonly struct Result
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (IsFailure)
{
throw new InvalidOperationException($"Cannot access Value when Result is a failure. {_message}");
@@ -176,7 +176,7 @@ public readonly struct Result
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (IsFailure)
{
throw new InvalidOperationException($"Cannot access Value when Result is a failure. Error: {_error}");
@@ -235,7 +235,7 @@ public readonly ref struct RefResult
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (IsFailure)
{
throw new InvalidOperationException($"Cannot access Value when Result is a failure. Error: {_error}");
diff --git a/src/Runtime/Ghost.Entities/Archetype.cs b/src/Runtime/Ghost.Entities/Archetype.cs
index ccd9c67..8bd0538 100644
--- a/src/Runtime/Ghost.Entities/Archetype.cs
+++ b/src/Runtime/Ghost.Entities/Archetype.cs
@@ -116,7 +116,7 @@ internal unsafe struct Chunk : IDisposable
internal int _count;
internal readonly int _capacity;
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
// For debugging purpose
internal int _worldID;
internal int _archetypeID;
@@ -363,7 +363,7 @@ internal unsafe struct Archetype : IDisposable
// Need to allocate a new chunk
var newChunk = new Chunk(Chunk.CHUNK_BUFFER_SIZE, _entityCapacity, _layouts.Count, world.Version);
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
newChunk._worldID = _worldID;
newChunk._archetypeID = _id;
#endif
diff --git a/src/Runtime/Ghost.Entities/Component.cs b/src/Runtime/Ghost.Entities/Component.cs
index e6afff3..e5c264e 100644
--- a/src/Runtime/Ghost.Entities/Component.cs
+++ b/src/Runtime/Ghost.Entities/Component.cs
@@ -44,7 +44,7 @@ internal static class ComponentRegistry
private static readonly Dictionary s_typeHandleToID = new();
private static readonly Dictionary s_nameToRuntimeID = new();
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
internal static readonly Dictionary s_runtimeIDToType = new();
#endif
@@ -83,7 +83,7 @@ internal static class ComponentRegistry
s_typeHandleToID[typeHandle] = newID;
s_nameToRuntimeID[stableName] = newID;
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
s_runtimeIDToType[newID.Value] = typeof(T);
#endif
diff --git a/src/Runtime/Ghost.Entities/ManagedComponent.cs b/src/Runtime/Ghost.Entities/ManagedComponent.cs
index 9947f1b..103e5c9 100644
--- a/src/Runtime/Ghost.Entities/ManagedComponent.cs
+++ b/src/Runtime/Ghost.Entities/ManagedComponent.cs
@@ -38,7 +38,7 @@ internal static class ManagedComponentRegistry
private static readonly List s_registeredComponents = new();
private static readonly Dictionary s_typeHandleToID = new();
private static readonly Dictionary s_nameToRuntimeID = new();
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
internal static readonly Dictionary s_runtimeIDToType = new();
#endif
@@ -66,7 +66,7 @@ internal static class ManagedComponentRegistry
s_typeHandleToID[typeHandle] = newID;
s_nameToRuntimeID[stableName] = newID;
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
s_runtimeIDToType[newID.Value] = typeof(T);
#endif
diff --git a/src/Runtime/Ghost.Entities/World.cs b/src/Runtime/Ghost.Entities/World.cs
index 20a9bf6..4349ce7 100644
--- a/src/Runtime/Ghost.Entities/World.cs
+++ b/src/Runtime/Ghost.Entities/World.cs
@@ -49,7 +49,7 @@ public partial class World
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static World GetWorldUncheck(Identifier id)
{
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (id.Value < 0 || id.Value >= s_worlds.Count)
{
throw new ArgumentOutOfRangeException(nameof(id), "World ID is out of range.");
diff --git a/src/Runtime/Ghost.Graphics.D3D12/D3D12DescriptorHeap.cs b/src/Runtime/Ghost.Graphics.D3D12/D3D12DescriptorHeap.cs
index 23c67b0..60deaa3 100644
--- a/src/Runtime/Ghost.Graphics.D3D12/D3D12DescriptorHeap.cs
+++ b/src/Runtime/Ghost.Graphics.D3D12/D3D12DescriptorHeap.cs
@@ -147,10 +147,10 @@ internal unsafe class D3D12DescriptorHeap : IDisposable
{
for (var index = baseIndex; index < baseIndex + count; index++)
{
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (!_allocatedDescriptors.IsSet(index))
{
- Debug.WriteLine("Error: Attempted to release an un-allocated descriptor");
+ Logger.Debug("Error: Attempted to release an un-allocated descriptor");
}
#endif
diff --git a/src/Runtime/Ghost.Graphics.D3D12/D3D12ResourceDatabase.cs b/src/Runtime/Ghost.Graphics.D3D12/D3D12ResourceDatabase.cs
index 069d922..7d6df4b 100644
--- a/src/Runtime/Ghost.Graphics.D3D12/D3D12ResourceDatabase.cs
+++ b/src/Runtime/Ghost.Graphics.D3D12/D3D12ResourceDatabase.cs
@@ -109,7 +109,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
private UnsafeSlotMap _resources;
private UnsafeHashMap> _samplers;
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
private readonly Dictionary, string> _resourceName;
#endif
@@ -129,7 +129,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
_resources = new UnsafeSlotMap(64, AllocationHandle.Persistent, AllocationOption.Clear);
_samplers = new UnsafeHashMap>(32, AllocationHandle.Persistent);
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
_resourceName = new Dictionary, string>(64);
#endif
@@ -162,7 +162,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
var id = _resources.Add(new ResourceRecord(pResource, initialBarrierData, viewGroup, desc), out var generation);
var handle = new Handle(id, generation);
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (!string.IsNullOrEmpty(name))
{
pResource->SetName(name);
@@ -191,7 +191,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
var id = _resources.Add(new ResourceRecord(allocation, initialBarrierData, resourceDescriptor, desc), out var generation);
var handle = new Handle(id, generation);
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (!string.IsNullOrEmpty(name))
{
allocation->SetName(name);
@@ -293,7 +293,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
{
Logger.DebugAssert(!_disposed);
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
if (_resourceName.TryGetValue(handle, out var name))
{
return name;
@@ -316,7 +316,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
_releaseQueue.Enqueue(entry);
_resources.Remove(handle.ID, handle.Generation);
-#if DEBUG || GHOST_EDITOR
+#if GHOST_EDITOR
_resourceName.Remove(handle, out _);
#endif
}