1 /** 2 * This System provider always returns the same instance of the component. The system 3 * is passed to the provider at initialisation. 4 */ 5 module ashd.fsm.systemInstanceProvider; 6 7 8 import ashd.core.system : System; 9 import ashd.fsm.ISystemProvider: ISystemProvider; 10 11 12 public class SystemInstanceProvider(T): ISystemProvider 13 { 14 private 15 { 16 T mInstance; 17 int mSystemPriority; 18 } 19 20 /** 21 * Constructor 22 * 23 * @param instance The instance to return whenever a System is requested. 24 */ 25 public this ( T instance_a ) 26 { 27 mInstance = instance_a; 28 } 29 30 /** 31 * Used to request a component from this provider 32 * 33 * @return The instance of the System 34 */ 35 protected Object createDynamicInstance( ClassInfo type_a ){ return mInstance; } 36 37 38 @property 39 { 40 /** 41 * Used to compare this provider with others. Any provider that returns the same component 42 * instance will be regarded as equivalent. 43 * 44 * @return The instance 45 */ 46 public hash_t identifier() 47 { 48 return mInstance.toHash(); 49 } 50 51 /** 52 * The priority at which the System should be added to the Engine 53 */ 54 public int priority() { return mSystemPriority; } 55 public void priority( int value_a ) { mSystemPriority = value_a; } 56 57 } 58 }