File tree Expand file tree Collapse file tree 6 files changed +26
-5
lines changed Expand file tree Collapse file tree 6 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -87,5 +87,7 @@ public bool Release(RefItem item)
8787 availibleItems . Enqueue ( item ) ;
8888 return true ;
8989 }
90+
91+ public override bool HasDependencyOn ( RefComponent refComponent ) => refComponent == this ;
9092 }
9193}
Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ private void OnValidate()
2828 pools . RemoveAt ( i ) ;
2929 continue ;
3030 }
31+
32+ if ( poolComp . HasDependencyOn ( this ) )
33+ {
34+ pools . RemoveAt ( i ) ;
35+ Debug . LogWarning ( "[RefPoolerGroup] Detected cyclic dependency: Removing item" ) ;
36+ continue ;
37+ }
3138 }
3239 }
3340
@@ -84,5 +91,15 @@ public override RefItem Get()
8491 }
8592 return selectedPool . Get ( ) ;
8693 }
94+
95+ public override bool HasDependencyOn ( RefComponent refComponent )
96+ {
97+ foreach ( var pool in pools )
98+ {
99+ if ( pool == refComponent ) return true ;
100+ return pool . HasDependencyOn ( refComponent ) ;
101+ }
102+ return false ;
103+ }
87104 }
88105}
Original file line number Diff line number Diff line change @@ -45,6 +45,6 @@ private void ApplyAsset(RefPooler pooler)
4545 pooler . ReuseObjects = reuseObjects ;
4646 }
4747
48- public override bool IsContainedIn ( RefResource resource ) => resource == this ;
48+ public override bool HasDependencyOn ( RefResource resource ) => resource == this ;
4949 }
5050}
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ private void OnValidate()
3737 continue ;
3838 }
3939
40- if ( poolRes . IsContainedIn ( this ) )
40+ if ( poolRes . HasDependencyOn ( this ) )
4141 {
4242 pools . RemoveAt ( i ) ;
4343 Debug . LogWarning ( "[PoolGroupAsset] Cyclic dependency detected, removing!" ) ;
@@ -82,12 +82,12 @@ public override RefComponent CreateComponent()
8282 return groupComponent ;
8383 }
8484
85- public override bool IsContainedIn ( RefResource resource )
85+ public override bool HasDependencyOn ( RefResource resource )
8686 {
8787 foreach ( var poolAsset in pools )
8888 {
8989 if ( poolAsset == resource ) return true ;
90- if ( poolAsset . IsContainedIn ( resource ) )
90+ if ( poolAsset . HasDependencyOn ( resource ) )
9191 {
9292 return true ;
9393 }
Original file line number Diff line number Diff line change @@ -6,5 +6,7 @@ public abstract class RefComponent : MonoBehaviour
66 {
77 public abstract void Prepare ( ) ;
88 public abstract RefItem Get ( ) ;
9+
10+ public abstract bool HasDependencyOn ( RefComponent refComponent ) ;
911 }
1012}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ public abstract class RefResource : ScriptableObject
77 public abstract void Prepare ( ) ;
88 public abstract RefItem Get ( ) ;
99
10- public abstract bool IsContainedIn ( RefResource resource ) ;
1110 public abstract RefComponent CreateComponent ( ) ;
11+ public abstract bool HasDependencyOn ( RefResource resource ) ;
1212 }
1313}
You can’t perform that action at this time.
0 commit comments