@@ -8,47 +8,47 @@ namespace ToolBox.Pools
88 [ System . Serializable ]
99 public class Pool
1010 {
11- [ SerializeField , AssetsOnly , ValueDropdown ( nameof ( GetPoolables ) ) ] private Poolable prefab = null ;
12- [ SerializeField ] private int startCount = 0 ;
13- [ SerializeField , SceneObjectsOnly ] private Transform holder = null ;
14- [ SerializeField ] private GameObjectReactor objectInitializator = null ;
11+ [ SerializeField , AssetsOnly , ValueDropdown ( nameof ( GetPoolables ) ) ] private Poolable _prefab = null ;
12+ [ SerializeField ] private int _startCount = 0 ;
13+ [ SerializeField , SceneObjectsOnly ] private Transform _holder = null ;
14+ [ SerializeField ] private GameObjectReactor _objectInitializator = null ;
1515
16- private int currentCount = 0 ;
17- private Queue < Poolable > entities = null ;
16+ private int _currentCount = 0 ;
17+ private Queue < Poolable > _entities = null ;
1818
1919 public Pool ( Poolable prefab , int startCount , Transform holder , GameObjectReactor objectInitializator )
2020 {
21- this . prefab = prefab ;
22- this . startCount = startCount ;
23- this . holder = holder ;
24- this . objectInitializator = objectInitializator ;
21+ _prefab = prefab ;
22+ _startCount = startCount ;
23+ _holder = holder ;
24+ _objectInitializator = objectInitializator ;
2525 }
2626
2727 private IEnumerable < Poolable > GetPoolables ( ) =>
2828 Resources . FindObjectsOfTypeAll < Poolable > ( ) ;
2929
3030 public void Fill ( )
3131 {
32- entities = new Queue < Poolable > ( startCount ) ;
33- currentCount = startCount ;
32+ _entities = new Queue < Poolable > ( _startCount ) ;
33+ _currentCount = _startCount ;
3434
35- Poolable original = Object . Instantiate ( prefab , holder ) ;
35+ Poolable original = Object . Instantiate ( _prefab , _holder ) ;
3636
37- if ( objectInitializator != null )
38- objectInitializator . SendReaction ( original . gameObject ) ;
37+ if ( _objectInitializator != null )
38+ _objectInitializator . SendReaction ( original . gameObject ) ;
3939
4040 AddToPool ( original ) ;
4141
42- for ( int i = 0 ; i < startCount - 1 ; i ++ )
42+ for ( int i = 0 ; i < _startCount - 1 ; i ++ )
4343 {
44- Poolable entity = Object . Instantiate ( original , holder ) ;
44+ Poolable entity = Object . Instantiate ( original , _holder ) ;
4545 AddToPool ( entity ) ;
4646 }
4747
4848 void AddToPool ( Poolable newEntity )
4949 {
5050 newEntity . SetPool ( this ) ;
51- entities . Enqueue ( newEntity ) ;
51+ _entities . Enqueue ( newEntity ) ;
5252 newEntity . gameObject . SetActive ( false ) ;
5353 }
5454 }
@@ -110,36 +110,36 @@ public void ReturnEntity(Poolable entity)
110110 if ( entity . Pool != this )
111111 return ;
112112
113- entities . Enqueue ( entity ) ;
114- currentCount ++ ;
113+ _entities . Enqueue ( entity ) ;
114+ _currentCount ++ ;
115115
116- entity . transform . SetParent ( holder , false ) ;
116+ entity . transform . SetParent ( _holder , false ) ;
117117 entity . gameObject . SetActive ( false ) ;
118118 }
119119
120120 private Poolable TakeEntity ( )
121121 {
122122 Poolable entity ;
123123
124- if ( currentCount == 0 )
124+ if ( _currentCount == 0 )
125125 {
126- entity = Object . Instantiate ( prefab , holder ) ;
126+ entity = Object . Instantiate ( _prefab , _holder ) ;
127127 entity . SetPool ( this ) ;
128128
129129 return entity ;
130130 }
131131
132- entity = entities . Dequeue ( ) ;
132+ entity = _entities . Dequeue ( ) ;
133133
134134 if ( entity == null )
135135 {
136- entity = Object . Instantiate ( prefab , holder ) ;
136+ entity = Object . Instantiate ( _prefab , _holder ) ;
137137 entity . SetPool ( this ) ;
138- currentCount ++ ;
138+ _currentCount ++ ;
139139 }
140140
141141 entity . gameObject . SetActive ( true ) ;
142- currentCount -- ;
142+ _currentCount -- ;
143143
144144 return entity ;
145145 }
0 commit comments