question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No more chainable APIs?

See original GitHub issue

I am in the process of upgrading my project to a newer version of Entitas and I noticed that 0.37.0 is generating void for the component methods, which means I can no longer chain Entity creation, ie, something like below no longer works;

context.ReplaceMoveInput(movement).IsDeleteOnExit(true);

Or for a specific entity,

e.AddTurnBased(i + 1, config.turnDelay)
 .IsAIMove(true)
 .AddFoodDamager(dmg)
 .AddSmoothMove(config.turnDelay)
 .AddAudioAttackSource(Audio.scavengers_enemy1, Audio.scavengers_enemy2);

Is there a replacement or new best practice for this functionality? Having a fluent style API was really nice for quickly setting up entities.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sschmidcommented, Jun 19, 2017

Hey @JamesMcMahon,

sorry for removing this, but the good thing is, if you’re preferring a different output from the code generator you can easily customize this by adding and using a custom generator.

All current generators can be found here: https://github.com/sschmid/Entitas-CSharp/tree/develop/Addons/Entitas.CodeGeneration.Plugins/Entitas.CodeGeneration.Plugins/Plugins/CodeGenerators

You can create a new class and get inspired (aka copy paste) by existing generators. Put all your custom generators into an Editor folder and you will be able to select them in the Entitas Prefs Window.

You could for example change the ComponentEntityGenerator and create a custom one that return the entity.

https://github.com/sschmid/Entitas-CSharp/blob/develop/Addons/Entitas.CodeGeneration.Plugins/Entitas.CodeGeneration.Plugins/Plugins/CodeGenerators/ComponentEntityGenerator.cs#L20-L43

    public ${ContextName}Entity Add${ComponentName}(${memberArgs}) {
        var index = ${Index};
        var component = CreateComponent<${ComponentType}>(index);
${memberAssignment}
        AddComponent(index, component);

        return this;
    }

Hope that helps

1reaction
nbreum15commented, May 31, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fluent APIs Using Method Chaining in JavaScript
Methods that stop the chain. They can return any final value. You cannot chain more methods to this value. An example. Let's code...
Read more >
When to Build Fluent APIs
Fluent API - No Longer Set. Fluent programming interfaces use method chaining and domain-specific language to mimic declarative programming ...
Read more >
LeaVerou/chainvas: Make APIs suck less
A tiny, modular library that can add chaining to any API that isn't naturally chainable, like the Canvas API, the DOM and more....
Read more >
Fluent APIs And Method Chaining - Modern Web
Rather, Method Chaining should be used, perhaps more appropriately, as a means of implementing Fluent APIs which allow for writing more concise expressions....
Read more >
Solved: API chaining
If I have a scenario where one api proxy needs to call another API, what is the best way to do it? I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found