Mathijs-Bakker / Extenject

Dependency Injection Framework for Unity Game Engine
MIT License
512 stars 95 forks source link

Now MemoryPool.Spawn methods are virtual #69

Closed KurbanismailovZaur closed 1 month ago

KurbanismailovZaur commented 1 year ago

Added virtual keyword to all MonoMemoryPool.Spawn methods with parameters. This allows you to redefine the names of the parameters of the Spawn method, which is very convenient.

Before change:

public TValue Spawn(TParam1 param)

image

As you can see the parameter name is param. This is not very convenient, because there can be a lot of parameters and you don't remember everything.

After change:

public virtual TValue Spawn(TParam1 param)

Override the Spawn method on the pool to specify parameter names.

public class Pool : MonoMemoryPool<float, Enemy>
{
    public override Enemy Spawn(float speed) => base.Spawn(speed);
}

Now you can use the Spawn method with friendly parameter names. image

I think this is a very simple and cool change.

Mathijs-Bakker commented 1 year ago

Thanx!

I think this is a very simple and cool change.

Simple can be great too!

I do think that we need to notify users of this possibility in the Memory Pools docs before merging your PR. Maybe add an (Overriding Spawn Method with Parameter names?) section with an example on this .