Skip to content

Bogenbai/Entitas-Flux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Entitas Flux

Entitas Flux is a fork of the great and terrible Entitas Framework.
I created it to add features missing from the original Entitas that I believe should be there, and to support newer Unity versions.
Don’t expect major changes or a big redesign like Entitas Redux. Updates will (or will not) come slowly and only when I need a feature.

CI Release

Features

Atomic components

Components that have a single field are generated with a single property, which simplifies access to the value:

[Game] public class CurrentHealth : IComponent { public float Value; }
// access:
entity.CurrentHealth
// instead of:
entity.currentHealth.Value

Watched attribute

This attribute simplifies deferred reactivity.
When component X is marked with the [Watched] attribute and its value is changed (via ReplaceX(...)/AddX(...)/RemoveX(), the entity receives an XChanged marker component.
These markers live for one frame: they notify systems during that frame and are then removed so the logic doesn’t repeat on the next frame.

[Game, Watched] public class Wallet : IComponent { public Dictionary<CurrencyTypeId, int> Value; }
// entity.ReplaceWallet(newValue);
// will cause entity.isWalletChanged to be `true`

It will also generate a GameWatchedCleanupSystems feature that removes all those Changed component on cleanup. You should put it in your systems order, usually it fits well right before GameCleanupSystems.

Friendly Component Dropdown

In the original Entitas adding components via inspector is a pain because there’s no search bar. Entitas Flux has one.

📸 Show large screenshot
My screenshot

Safe component removal

Sometimes you just remove component X if it exists on the entity. Without extra ifs or matcher checks, call SafeRemoveX():

entity.SafeRemoveBoxCollider2D();
entity.SafeRemoveCollider2D();

Under the hood it does this:

if (hasBoxCollider2D) 
    RemoveComponent(GameComponentsLookup.BoxCollider2D);

Defines

ENTITAS_DISABLE_REACTIVITY - partially disables Entitas' default reactivity. Gives small performance boost. ENTITAS_HIDE_STANDARD_MEMBERS - hides standard generated component members that start with a lowercase letter in atomic components.

More features coming soon (or not)

How to use

If you start fresh

Just create new repo using THIS as a template.

If you already have Entitas in the project

If you already have Entitas project and you want to switch to this fork, then:

  1. Go to Releases and download the Entitas-Flux-vX.X.X archive. This archive contains framework DLLs.
  2. Replace the corresponding DLLs in the Entitas and Jenny folders. The DLLs in the archive are organized by folder, so it’s easier to see which DLL goes where.
    But just in case, here’s where everything should go:
// Jenny/Jenny/Plugins/Entitas:   
Entitas.CodeGeneration.Plugins.dll   
Entitas.Roslyn.CodeGeneration.Plugins.dll   
Entitas.VisualDebugging.CodeGeneration.Plugins.dll   
// Assets/Entitas/Entitas:   
Entitas.CodeGeneration.Attributes.dll   
Entitas.dll   
Entitas.Unity.dll   
Entitas.VisualDebugging.Unity.dll   
// Assets/Entitas/Entitas/Editor:   
Entitas.Migration.dll   
Entitas.Migration.Unity.Editor.dll   
Entitas.Unity.Editor.dll   
Entitas.VisualDebugging.Unity.Editor.dll   
  1. Update your JennyRoslyn.properties with DataProviders and Generators Entitas Flux provides (JennyRoslyn.properties example)
  2. Hope it works :)

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An Entitas fork that brings a bunch of cool features

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages