diff --git a/CHANGELOG.md b/CHANGELOG.md index 08d8a25..0fb500a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.12.1] - 2024-10-25 + +**Fixed**: +- The endless loop when calling *RngService.Range()* +- The endless loop *GameObjectPool* when spawning new entities + ## [0.12.0] - 2024-10-22 - Added IRngData to PoolService to suppprt read only data structure and allow abtract injection of data into other objects @@ -51,13 +57,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.7.1] - 2023-07-28 -**Fixed**: -- Compilation errors in various test files and the PoolService class have been fixed. - **Changed**: - Tests have been moved to proper folders, and the package number has been updated. - An unused namespace import has been removed from the InstallerTest class. +**Fixed**: +- Compilation errors in various test files and the PoolService class have been fixed. + ## [0.7.0] - 2023-07-28 - Introduced a code review process using GitHub Actions workflow. diff --git a/Runtime/ObjectPool.cs b/Runtime/ObjectPool.cs index 7bd548c..b099bb5 100644 --- a/Runtime/ObjectPool.cs +++ b/Runtime/ObjectPool.cs @@ -344,7 +344,7 @@ public class GameObjectPool : ObjectPoolBase /// If true then when the object is despawned back to the pool will be parented to the same as the sample entity /// parent transform /// - public bool DespawnToSampleParent { get; set; } + public bool DespawnToSampleParent { get; set; } = true; public GameObjectPool(uint initSize, GameObject sampleEntity) : base(initSize, sampleEntity, Instantiator) { @@ -375,7 +375,7 @@ public static GameObject Instantiator(GameObject entityRef) protected override GameObject SpawnEntity() { - var entity = SpawnEntity(); + var entity = base.SpawnEntity(); entity.SetActive(true); @@ -403,7 +403,7 @@ public class GameObjectPool : ObjectPoolBase where T : Behaviour /// If true then when the object is despawned back to the pool will be parented to the same as the sample entity /// parent transform /// - public bool DespawnToSampleParent { get; set; } + public bool DespawnToSampleParent { get; set; } = true; public GameObjectPool(uint initSize, T sampleEntity) : base(initSize, sampleEntity, Instantiator) { @@ -442,14 +442,17 @@ protected override T SpawnEntity() { T entity = null; - do + while(entity == null) { - entity = SpawnEntity(); + entity = base.SpawnEntity(); + + if(entity.gameObject == null) + { + SpawnedEntities.Remove(entity); + + entity = null; + } } - // ReSharper disable once ConditionIsAlwaysTrueOrFalse - // Need to do while loop and check as parent objects could have destroyed the entity/gameobject before it could - // be properly disposed by pool service - while (entity == null || entity.gameObject == null); entity.gameObject.SetActive(true); diff --git a/Runtime/RngService.cs b/Runtime/RngService.cs index 003bac9..a7eecbb 100644 --- a/Runtime/RngService.cs +++ b/Runtime/RngService.cs @@ -205,8 +205,8 @@ public static int[] Restore(int count, int seed) /// public static int Range(int min, int max, int[] rndState, bool maxInclusive) { - var floatMin = min; - var floatMax = max; + floatP floatMin = min; + floatP floatMax = max; return Range(floatMin, floatMax, rndState, maxInclusive); } diff --git a/package.json b/package.json index b3945fe..46872a9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.gamelovers.services", "displayName": "Services", "author": "Miguel Tomas", - "version": "0.12.0", + "version": "0.12.1", "unity": "2022.4", "license": "MIT", "description": "The purpose of this package is to provide a set of services to ease the development of a basic game architecture",