Skip to content

Commit

Permalink
🚧 Move Stash Extensions to another file
Browse files Browse the repository at this point in the history
  • Loading branch information
olegmrzv committed Nov 22, 2022
1 parent 0c9022c commit 6cdbb33
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
18 changes: 0 additions & 18 deletions Core/Stash.cs
Expand Up @@ -281,22 +281,4 @@ public sealed class Stash<T> : Stash where T : struct, IComponent {
}
}

public static class StashExtensions {
public static Stash<T> AsDisposable<T>(this Stash<T> stash) where T : struct, IComponent, IDisposable {
#if MORPEH_DEBUG
if (stash == null || stash.components == null) {
throw new Exception($"[MORPEH] You are trying mark AsDisposable null or disposed stash");
}
#endif

if (stash.componentDispose != null) {
return stash;
}

void ComponentDispose(ref T c) => c.Dispose();
stash.componentDispose = ComponentDispose;

return stash;
}
}
}
28 changes: 28 additions & 0 deletions Core/StashExtensions.cs
@@ -0,0 +1,28 @@
#if UNITY_EDITOR
#define MORPEH_DEBUG
#endif
#if !MORPEH_DEBUG
#define MORPEH_DEBUG_DISABLED
#endif

namespace Scellecs.Morpeh {
using System;
public static class StashExtensions {
public static Stash<T> AsDisposable<T>(this Stash<T> stash) where T : struct, IComponent, IDisposable {
#if MORPEH_DEBUG
if (stash == null || stash.components == null) {
throw new Exception($"[MORPEH] You are trying mark AsDisposable null or disposed stash");
}
#endif

if (stash.componentDispose != null) {
return stash;
}

void ComponentDispose(ref T c) => c.Dispose();
stash.componentDispose = ComponentDispose;

return stash;
}
}
}
11 changes: 11 additions & 0 deletions Core/StashExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6cdbb33

Please sign in to comment.