public static Obstacle CreateNew(Layer layer) { if (string.IsNullOrEmpty(mContentManagerName)) { throw new System.Exception("You must first initialize the factory to use it."); } Obstacle instance = null; instance = new Obstacle(mContentManagerName, false); instance.AddToManagers(layer); if (mScreenListReference != null) { mScreenListReference.Add(instance); } if (EntitySpawned != null) { EntitySpawned(instance); } return instance; }
/// <summary> /// Makes the argument objectToMakeUnused marked as unused. This method is generated to be used /// by generated code. Use Destroy instead when writing custom code so that your code will behave /// the same whether your Entity is pooled or not. /// </summary> public static void MakeUnused(Obstacle objectToMakeUnused) { MakeUnused(objectToMakeUnused, true); }
private static void FactoryInitialize() { const int numberToPreAllocate = 20; for (int i = 0; i < numberToPreAllocate; i++) { Obstacle instance = new Obstacle(mContentManagerName, false); mPool.AddToPool(instance); } }
/// <summary> /// Makes the argument objectToMakeUnused marked as unused. This method is generated to be used /// by generated code. Use Destroy instead when writing custom code so that your code will behave /// the same whether your Entity is pooled or not. /// </summary> public static void MakeUnused(Obstacle objectToMakeUnused, bool callDestroy) { objectToMakeUnused.Destroy(); }