craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 325 forks source link

add ability to configure layerdepth for autotriggered particleeffects #756

Closed codymanix closed 2 years ago

codymanix commented 2 years ago

Hi! I needed the ability to define the layerdepth also for autotriggered particleeffects so I've added this little feature, it was just a few lines and seems to work very well.

This is the first time I contribute something to any OS project, so please be lenient if I did something wrong.

lithiumtoast commented 2 years ago

Hey @codymanix, thanks for the PR.

Could you add a float layerDepth = 1 parameter to the other Trigger method and use it within that method? I'm not sure why it's a value of 1 in the existing code, but I rather keep it the same behaviour as it was before for now.

codymanix commented 2 years ago

Which other Trigger method do you mean? The only literal "1" I can find in ParticleEmitter.cs is the one in the call to Release(line.Origin + offset, **1**), but it doesn't relate to the layerDepth but instead it is the argument for numToRelease:

       public void Trigger(LineSegment line)
        {
            var numToRelease = _random.Next(Parameters.Quantity);
            var lineVector = line.ToVector();

            for (var i = 0; i < numToRelease; i++)
            {
                var offset = lineVector * _random.NextSingle();
                Release(line.Origin + offset, **1**);
            }
        }

        private void Release(Vector2 position, int numToRelease, float layerDepth = 0)

The layerDepth parameter I added did not change the default value, which was 0.

lithiumtoast commented 2 years ago

Ah shoot, yes, there is no third parameter on that line. I thought the 1 was for the third parameter. What I mean is to add layerDepth parameter for the other Trigger method and pass it along when calling Release.

codymanix commented 2 years ago

you mean additionally to the Trigger(Vector2 position, float layerDepth = 0) method add layerDepth to public void Trigger(LineSegment line) also?

lithiumtoast commented 2 years ago

Yes, for symmtery and completion.

codymanix commented 2 years ago

Ok I completed the overloads now and pushed again.

I also saw, that some constructor arguments for ParticleEffect are not used (autoTrigger, autoTriggerDelay). Can I delete them?

      public ParticleEffect(string name = null, bool autoTrigger = true, float autoTriggerDelay = 0f)
        {
            Name = name;
            Emitters = new List<ParticleEmitter>();
        }
lithiumtoast commented 2 years ago

yes

codymanix commented 2 years ago

done.

codymanix commented 2 years ago

for some reason the build failed. can one try to rerun the build?

Run dotnet nuget push "./**/*.nupkg" --source "MyGet" --skip-duplicate --api-key $MYGET_ACCESS_TOKEN
Specify --help for a list of available options and commands.
error: Missing value for option 'api-key'
lithiumtoast commented 2 years ago

That's expected; there is something wrong with pushing NuGet packages for a pull request.