Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Ability to use multiple plugins of the same type. #2917

Closed
T1mL3arn opened this issue Sep 23, 2023 · 3 comments · Fixed by #2952
Closed

[Feature request] Ability to use multiple plugins of the same type. #2917

T1mL3arn opened this issue Sep 23, 2023 · 3 comments · Fixed by #2952

Comments

@T1mL3arn
Copy link
Contributor

Right now PluginFrontEnd disallows to use more than one plugin with the same type.

if (FlxStringUtil.sameClassName(Plugin, plugin))
{
return Plugin;
}
}

My personal use case: tween managers for different types of objects to separately control what can tween and what cannot. Flixel allows to manage tweens in a separate way with FlxTweenManager, but I cannot use such manager twice with a plugin frontend. So I have to use it maybe in a state and add the manager to the state as a usual flixel object. Sometimes it is fine. But for me more preferable way would be like that:

// MyGame.hx

menuTweens = FlxG.plugins.add(new FlxTweenManager());
gameTweens = FlxG.plugins.add(new FlxTweenManager());

// any other game state *.hx

MyGame.gameTweens.tween(someSprite, ...);

// game was paused

MyGame.gameTweens.active = false;

Workaround to bypass type check

class MakeFlixelHappyTweenManager extends FlxTweenManager {}
gameTweens = FlxG.plugins.add(new MakeFlixelHappyTweenManager());

// or 

FlxG.plugins.list.push(gameTweens = new FlxTweenManager());
@Geokureli
Copy link
Member

// MyGame.hx

menuTweens = FlxG.plugins.add(new FlxTweenManager());
gameTweens = FlxG.plugins.add(new FlxTweenManager());

// any other game state *.hx

MyGame.gameTweens.tween(someSprite, ...);

// game was paused

MyGame.gameTweens.active = false;

what happens if you try this, is there an error thrown?

@T1mL3arn
Copy link
Contributor Author

what happens if you try this, is there an error thrown?

No errors. Plugin frontend disallows to use multiple FlxTweenManager instances, so newly created tween managers (when they are used with "preferable" way) won't be in FlxG.plugins and won't be updated by Flixel thus any tweens added to menuTweens or gameTweens just do nothing.

Right now I extend FlxTweenManager so I can use more than one manager as a plugin.

@Geokureli
Copy link
Member

Geokureli commented Nov 1, 2023

I added a PR that deprecates add for addIfUniqueType and adds the transitionary method: addPlugin which allows for multiple plugins of the same type. Eventually, add will take the place of addPlugin but only after enough time has passed where people can react to each step of this change. We may need to remove add in the next breaking version, since people are less likely to skip over major versions. later on we can add it back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants