public delegate T CreateNewObjectGame(Game1 game);
and would like to use it in the following method:
public ResourcePool(int allocation, ValidateObject objectCheck, CreateNewObjectGame objectCreate, bool isWrappable) { this.isWrappable = isWrappable; this.objectCheck = objectCheck; numberOfInvalidObjects = allocation; objects = new T[allocation]; for (int i = 0; i < allocation; ++i) { T t = objectCreate(); objects = t; } }
The problem is that objectCreate() require game to be passed into the method but this is already the case with this:
poolItem = new ResourcePool<Item>(200, Item.IsValid, Item.Instance(this), true);
The 'this' refers to the Game1 class being passed into the delegate. So how can I then access the class when calling objectCreate without having to pass in the class again via another argument?