Skip to content

Commit f43d4ab

Browse files
Merge pull request #20 from CoderGamester/develop
Release 0.12.2
2 parents 4dc526a + 92edd6b commit f43d4ab

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.12.2] - 2024-11-02
8+
9+
**Fixed**:
10+
- Fixed an inssue where *IPoolEntityObject<T>.Init()* wouldn't be called when spawning entities
11+
712
## [0.12.1] - 2024-10-25
813

914
**Fixed**:

Runtime/ObjectPool.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@ protected ObjectPoolBase(uint initSize, T sampleEntity, Func<T, T> instantiator)
164164

165165
for (var i = 0; i < initSize; i++)
166166
{
167-
var entity = instantiator.Invoke(SampleEntity);
168-
var poolEntity = entity as IPoolEntityObject<T>;
169-
170-
poolEntity?.Init(this);
171-
_stack.Push(entity);
167+
_stack.Push(CallInstantiator());
172168
}
173169
}
174170

@@ -274,7 +270,7 @@ protected virtual T SpawnEntity()
274270

275271
do
276272
{
277-
entity = _stack.Count == 0 ? _instantiator.Invoke(SampleEntity) : _stack.Pop();
273+
entity = _stack.Count == 0 ? CallInstantiator() : _stack.Pop();
278274
}
279275
// Need to do while loop and check as parent objects could have destroyed the entity/gameobject before it could
280276
// be properly disposed by pool service
@@ -287,6 +283,16 @@ protected virtual T SpawnEntity()
287283

288284
protected virtual void PostDespawnEntity(T entity) { }
289285

286+
protected T CallInstantiator()
287+
{
288+
var entity = _instantiator.Invoke(SampleEntity);
289+
var poolEntity = entity as IPoolEntityObject<T>;
290+
291+
poolEntity?.Init(this);
292+
293+
return entity;
294+
}
295+
290296
protected void CallOnSpawned(T entity)
291297
{
292298
var poolEntity = entity as IPoolEntitySpawn;

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "com.gamelovers.services",
33
"displayName": "Services",
44
"author": "Miguel Tomas",
5-
"version": "0.12.1",
6-
"unity": "2022.4",
5+
"version": "0.12.2",
6+
"unity": "2022.3",
77
"license": "MIT",
88
"description": "The purpose of this package is to provide a set of services to ease the development of a basic game architecture",
99
"type": "library",
1010
"hideInEditor": false,
1111
"dependencies": {
12-
"com.gamelovers.dataextensions": "0.6.0"
12+
"com.gamelovers.dataextensions": "0.6.2"
1313
}
1414
}

0 commit comments

Comments
 (0)