Fixed object pool unlimited mode.

This commit is contained in:
Harrison Deng 2020-07-11 11:45:03 -05:00
parent 326d97bd64
commit 72925842b7

View File

@ -24,7 +24,7 @@ namespace SlatedGameToolkit.Framework.Utilities.Collections.Pooling
}
public void CreateAmount(int amount) {
if (Size >= 0 && Count + amount >= Size) throw new FrameworkUsageException(string.Format("Object pool surpassed set size of {0}", Size));
if (Size > 0 && Count + amount >= Size) throw new FrameworkUsageException(string.Format("Object pool surpassed set size of {0}", Size));
for (int i = 0; i < amount; i++) {
pool.Add(creator());
}
@ -40,7 +40,7 @@ namespace SlatedGameToolkit.Framework.Utilities.Collections.Pooling
}
public void Release(Poolable poolable) {
if (Size >= 0 && Count + 1 >= Size) throw new FrameworkUsageException(string.Format("Object pool surpassed set size of {0}", Size));
if (Size > 0 && Count + 1 >= Size) throw new FrameworkUsageException(string.Format("Object pool surpassed set size of {0}", Size));
poolable.Reset();
pool.Add(poolable);
}