Namespace StansAssets.Foundation.Patterns
Classes
CollectionPool<TCollection, TItem>
Generic collections pool implementation.
ComponentPool<T>
Component pool. Provided prefab instance will be used as a source for component entities.
DefaultPool<T>
Simplified default ObjectPool<T> implementation.
DictionaryPool<TKey, TValue>
Dictionary
Pool.
EventBus
Basic implementation of the IEventBus.
ListPool<T>
List
pool.
MonoSingleton<T>
Singleton pattern implementation. Can be used with classes extended from a MonoBehaviour. Once instance is found or created, game object will be marked as DontDestroyOnLoad.
ObjectPool<T>
Generic object pool implementation.
PrefabPool
Simplified prefab implementation.
ServiceLocator
The Service Locator patter. This pattern gives you a simple way to decouple dependencies. There are a lot props and cons about this patters but it's up to you to decide, if this pattern fits your project. Few articles we think it worth reading before using this pattern.
Singleton<T>
Singleton pattern implementation.
StaticBus<T>
This is the simplest an fastest implementation for the event bus pattern. Since this is static bus DO NOT USE it when you making a package, Since it may conflict with user project.
It only make sense to use it inside the project you maintain and own.
Structs
ObjectPool<T>.PooledObject
A Pooled object wraps a reference to an instance that will be returned to the pool when the Pooled object is disposed. The purpose is to automate the return of references so that they do not need to be returned manually. A PooledObject can be used like so:
MyClass myInstance;
using(myPool.Get(out myInstance)) // When leaving the scope myInstance will be returned to the pool.
{
// Do something with myInstance
}
Interfaces
IEvent
Interface represents and even distributed via IEventBus
IEventBus
An interface for the event bus pattern.
IReadOnlyEventBus
Interface allows to subscribe and unsubscribe from event bus events. But hides and ability to dispatch an event.
IReadOnlyServiceLocator
The read only interfaces for the IServiceLocator pattern. Should be used if you would only like to retrieve services, without giving and ability to register new ones.
IServiceLocator
The Service Locator patter. This pattern gives you a simple way to decouple dependencies. There are a lot props and cons about this patters but it's up to you to decide, if this pattern fits your project. Few articles we think it worth reading before using this pattern.