Giter VIP home page Giter VIP logo

entitas-redux's Introduction

EntitasRedux Continous Deployment Entitas Redux on Discord GitHub issues License: MIT Twitter Follow

Buy Me a Coffee at ko-fi.com

Entitas Redux

About

Entitas Redux is a reworked version of Entitas with a sole focus on Unity. For more background on this project, see here for more information.

Requirements

  • Min Unity Version: 2019.4
  • Scripting Runtime: .Net 4.X
  • .Net Core Runtime: 3.1.X
  • MSBuild: MSBuild is required for the Roslyn parsing Genesis Requires. There are a few ways to ensure this is installed and I would recommend restarting your PC after performing any of these steps (see here for MS docs on installation).
    • MSBuild is installed along with Visual Studio, so having VS installed accomplishes this requirement.
    • Installing the .Net Core SDK v3.1 will ensure MSBuild is installed.
    • Installing the Visual Studio Build Tools here will ensure MSBuild is available.

Installing Entitas Redux and Getting Started

For instructions on installing Entitas Redux and how to get up and running, see here on the wiki.

Support

If this is useful to you and/or you’d like to see future development and more tools in the future, please consider supporting it either by contributing to the Github projects (submitting bug reports or features and/or creating pull requests) or by buying me coffee using any of the links below. Every little bit helps!

ko-fi

Contributing

For information on how to contribute and code style guidelines, please visit here.

entitas-redux's People

Contributors

jeffcampbellmakesgames avatar jessetg avatar jzapdot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

entitas-redux's Issues

[FEATURE REQUEST] Investigate interface code generated by Event system for improvements

Is your feature request related to a problem? Please describe.
When documenting usage of the [Event] attribute recently I noticed that the listener interface method could be clearer.

Example Event Component

using System;
using JCMG.EntitasRedux;
using UnityEngine;
using EventType = JCMG.EntitasRedux.EventType;

namespace ExampleContent.VisualDebugging
{
	[Serializable]
	[VisualDebug]
	[Event(EventTarget.Self, EventType.Added)]
	[Event(EventTarget.Self, EventType.Removed)]
	public class Vector3Component : IComponent
	{
		public Vector3 vector3;
	}
}

Example Listener Interfaces Generated

public interface IVector3Listener
{
    // This interface method could be clearer about what is happening
    void OnVector3(VisualDebugEntity entity, UnityEngine.Vector3 vector3);
}

public interface IVector3RemovedListener
{
    // This interface method is clear and doesn't need to change.
    void OnVector3Removed(VisualDebugEntity entity);
}

Describe the solution you'd like
I'd like to change the generated interface for the Added event to be something more like OnVector3Added and add a bit of XML documentation on the interface method to reflect that this interface method will be invoked when the component is added, updated, or replaced.

public interface IVector3Listener
{
    /// <summary>
    /// Invoked when the <see cref="ExampleContent.VisualDebugging.Vector3Component"/> on an entity is added, updated,
    /// or replaced. 
    /// </summary>
    /// <param name="entity">The entity on which the component change took place</param>
    void OnVector3Added(VisualDebugEntity entity, UnityEngine.Vector3 vector3);
}

[DISCUSS] Update code generation to use Roslyn over Reflection

Is your feature request related to a problem? Please describe.

Several folks have asked me recently about why EntitasRedux uses reflection-based code generation versus Roslyn like the Entitas Asset Store version does. In short:

  • I have more familiarity with reflection over Roslyn, particularly for code-generation and this made forking Entitas originally easier to do.
  • The open-source version of Entitas is reflection-based and it would have been a significant effort undertaken to refactor this to be Roslyn based at the same time as the forking effort.
  • Previously I had written a Roslyn-based code generator and was unhappy with the amount of effort it took to construct code using Roslyn syntax, though analysis takes significantly less. In hindsight, I would have been better off using it for code-analysis only and used more traditional text templating for the code-generation itself.

Reflection-based code analysis for data providers has a few disadvantages related to Roslyn-based code-analysis.

  • Can only inspect code in compiled assemblies; compiler errors will prevent discovery of new code changes.
  • Requires extra work to discover members/objects based on access modifiers, i.e. public versus private.

Roslyn on the other hand has disadvantages of it's own for Unity, though several have become less relevant over time as Unity has changed.

  • Generally folks are less familiar with Roslyn versus reflection, smaller knowledgeable userbase
  • The ability to use Roslyn in Unity directly has been hampered with the older compiler (mcs) and 3.5 Net version. This has been largely mitigated as Unity has made several upgrades and now in 2019 and later the default compiler is Roslyn and the .Net version is 4.6 equivalent.
  • Requires a bit more complex setup to be able to discover all csharp source files, add references to assemblies, in order to inspect code. It also can't as far as I know inspect code directly in assemblies as its parsing ability is limited to source files.

Describe the solution you'd like
I'd like for EntitasRedux to be able to gain the same or similar features as its Roslyn-powered equivalent, and potentially share some of those same capabilities with Genesis as well so that other developers can use Roslyn-based code analysis easily in Unity for other purposes unrelated to EntitasRedux.

I'd like to hear more from others with regards to their experience using the open-source reflection-based Entitas or EntitasRedux frameworks and how that contrasts with their experience using the Roslyn-based closed-source Entitas. In general, I'd also like to hear more about developers experience with Roslyn and any other pro/cons between reflection and Roslyn that I don't have listed above.

[RESEARCH] Investigate concrete support for other Unity callbacks for Entities

Is your feature request related to a problem? Please describe.

There are many GameObject/MonoBehaviour oriented callbacks that would be useful for interacting with an Entity. This includes callbacks for collision (OnCollisionEnter/2D for example, the IPointer interface methods, triggers, etc...). As of right now, the best way to utilize these would be to create one or more MonoBehaviour derived classes with an EntityLink component (with entity linked) to gain access to the entity for the relevant logic. If limited to one or more components this seems fine, but if there is a lot of complex logic in a single callback class it could become a bit unwieldy and if split up into multiple Monobehavior derived classes there is more overhead for traditional Unity components.

Describe the solution you'd like
Ideally, an Entity could have one or more abstract, mechanics-focused systems local to itself that would all be executed off of a single Monobehaviour component. Due to Unity's GameObject hierarchy and how certain callbacks like collisions and triggers message up the hierarchy, the MonoBehavior component executing these abstract systems should be separate from EntityLink and placeable by a developer so they can customize how their prefab/GameObject is setup.

This would not include FixedUpdate, Update and LateUpdate as those are first-class citizens of Systems already.

Implementation Tasks

  • Identify all desired Unity callbacks and define interfaces for them as EntitasRedux abstract systems. These should remain stateless and only have knowledge of the relevant context and entities.
  • Design and implement code-generation process for associating Unity callback systems with zero or more contexts and generating components per Unity callback.
  • Design and implement editor workflows for using new Unity callback components, particularly how to setup both scene objects/prefabs.

[FEATURE REQUEST] Collect AutoGenerated Cleanup Systems into single System per Context

Problem
I use quite a few [Cleanup] components. These generate cleanup systems for me (e.g. DestroyGameEntitiesWithMyComponentSystem), which is great; however, I then have to remember to add each of them to my game.

Solution
I'd prefer that an additional AutoGeneratedGameCleanupSystems system be created that compiles all of the automatically generated cleanup systems into a single system that I can add to my game.

Alternatives
I can do this manually and maintain separate autogenerated cleanup features, but that still involves manually maintaining the systems contained in there. It would provide a layer of abstraction, but doesn't alleviate the maintenance hassle.

Vanilla Entitas provides only a single systems that lumps together all of the cleanups per context. I do prefer the ability to pick and choose that's supported by having the individual systems, but usually (read: programmer speak for always) I'm just going to want to use all of them.

[QUESTION] How to setup a new assembly definition asset without loosing access to the generated code?

I'm using Unity 2020.3.13f1 want to setup an assembly definition asset to pass it as a reference to the Play/Edit mode tests.

  • Install .Net Core 3.1
  • Create a new project
  • Project Settings => Player => Change the API compability level to .NET 4.x (for PC, Android and HTML)
  • Install the packages via openupm add com.jeffcampbellmakesgames.entitasredux
  • Create a folder right next to the Assets folder and name it Genesis.CLI
  • Project Settings => Genesis => Set this folder as the Genesis installation folder by selecting it

image

  • Click the button "Update Genesis CLI"
  • Click the button "Install or Update All Plugins"
  • Create new GenesisSettings inside Assets/Sources via context menu => Create => JCMG => Genesis => GenesisSettings

image

  • Open the GenesisSettings.asset in the inspector
  • Click the button "Auto Import"
  • Change the output directory to Assets/Sources/Generated
  • Click the button "Generate"
  • Create a new component Assets/Sources/Features/AComponent.cs with the content
using JCMG.EntitasRedux;

namespace Sources.Features
{
    [Game]
    public sealed class AComponent : IComponent { }
}

image

  • Generate the code again

Everything should be fine for now. You can find a stable version in this temporary reproduction repository branch

https://github.com/matthiashermsen/er-namespace-reproduction

Since I want to setup unit tests I have to create the assembly definition asset. To ensure all the code is picked up I created it here Asset/Sources/Sources.asmdef with this setup

image

Compile errors come up

image

I tried to generate the code again but unfortunately the errors remain. I pushed the broken version on this branch

https://github.com/matthiashermsen/er-namespace-reproduction/tree/broken

I would like to know how to solve this problem

  • Is there a way the Play/Edit mode test assembly definitions don't require the sources assembly definition?
  • Are there any configurations for ER / Genesis?
  • Is it not possible to use namespaces with Genesis when using the built in Unity test framework?

[FEATURE REQUEST] Create error log or stop playmode if Refactor Mode is still enabled

Is your feature request related to a problem? Please describe.
When Refactor Mode is enabled, most code relying on EntitasRedux will fail as component members will not be assigned (as they are compiled out). It's not always obvious when Refactor Mode is on and it can lead to developers troubleshooting bugs that don't exist.

Describe the solution you'd like
There should be a clear and obvious error when Refactor Mode is enabled and Play-Mode starts, or Play-Mode should be stopped with a bug full-screen warning of some sort that it needs to be turned off first.

[Docs] Create guide on how to reference entities

Is your feature request related to a problem? Please describe.
A topic that often comes up on Discord is how to reference Entities in other places like components or systems. This page here on the original wiki covers some areas. I'd like to create a similar page that covers some of the commonly recommended practices with example code provided:

  • Storing reference to an Entity ID in a component
  • Use a an EntityIndex to be able to search for zero or more entities based on other data.

[FEATURE REQUEST] Create API for copying one entity to another

Is your feature request related to a problem? Please describe.
I'd like to have an easy way to copy all of the components on an entity over to another entity. This previously existed, but used reflection at runtime to shallow-copy each member's value. In vanilla Entitas, that implementation is here.

Describe the solution you'd like
I'd like for this new CopyTo method to take advantage of the newer component copy methods to copy all components from one entity of a particular context type to another. In this way, it will potentially support deep-copying of components from one entity to another.

[FEATURE REQUEST] Update minimum Unity project version to latest 2019.4 LTS patch

Is your feature request related to a problem? Please describe.
I'd like for EntitasRedux to support an LTS version of Unity as the minimum version as it ensures it will be stable and receiving bug fixes on that Unity version for 2 years. After those 2 years have passed I would bump the minimum LTS version of Unity that EntitasRedux supports to the 2020 version.

Describe the solution you'd like
Open the Unity project on the latest 2019.4 LTS patch version, ensure there are not any compiler errors and that all unit tests pass, project builds. If this all looks good, check in updates, merge to develop, and update readme to reflect new minimum version.

[FEATURE REQUEST] Ensure support exists for Experimental PlayMode Options

Is your feature request related to a problem? Please describe.
There are several newer options in Unity for disabling reloading the app domain and/or reloading the scene when entering playmode. These greatly speed up iteration time in the editor. I'd like to be able to make sure that EntitasRedux supports working with these options, particularly as there are several static classes used for contexts and other areas.

image

Describe the solution you'd like
It should be possible for a developer to activate these options without errors or other issues being caused by EntitasRedux. This may require setting up an editor-only handler to flush or reset any static state after exiting playmode back to edit mode.

[v2] Port v1 EntitasRedux.VisualDebugging.Editor.Plugins plugins to use Genesis v2

Is your feature request related to a problem? Please describe.
For EntitasRedux v2, all content from the EntitasRedux.VisualDebugging.Editor.Plugins AssemblyDefinition should be ported to be implemented in the external Plugins solution under the EntitasRedux.VisualDebuggingPlugins project. This work is being implemented on the feat/v2 branch and any PRs should target that branch.

[BUG] Attributes Event & CleanUp generates one unnecessary system

Describe the bug
When using the attributes Event and CleanUp for one component, an unnecessary system will be created. This system will destroy all entities with the listener component attached.

Unity Version:
Unity 2019.4.12f1

To Reproduce

  1. Create a new component with at least one context and attributes Event(Self) & CleanUp(DestroyEntity)
  2. generate Code
  3. two cleanup systems were created

Expected behavior
It should only create one cleanup system for the cleanup attribute and not a cleanup system for the event listener component.

[BUG] Entitas Redux installation link on wiki page is broken

Describe the bug
The main README file shows the correct git installation urls

https://github.com/jeffcampbellmakesgames/entitas-redux#install-via-git-url

but the wiki page has a broken url for the Entitas Redux package

https://github.com/jeffcampbellmakesgames/Entitas-Redux/wiki/Installation#install-via-git-url

There is missing a hyphen between "entitasredux".

Expected behavior
Instead of

"com.jeffcampbellmakesgames.entitasredux" : "https://github.com/jeffcampbellmakesgames/entitasredux.git#release/stable"

I would expect this

"com.jeffcampbellmakesgames.entitasredux" : "https://github.com/jeffcampbellmakesgames/entitas-redux.git#release/stable"

Additional context
Suggestion:

  • Fix the wiki page
  • Remove the installation guide from the main README file
  • Refer to the wiki page in the main README file

[FEATURE REQUEST] Rename `has` bool property on entities, context to `Has`

Is your feature request related to a problem? Please describe.
I recently noticed the code style was off for the hasX bool property on entities, contexts when it should reflect HasX to match the intended modern C# code style.

Describe the solution you'd like
This property should be renamed in code-gen and updated in example content, unit tests.

[BUG] Component name collision on code generation

Describe the bug

Two Components belonging to the same Context with the same short name, but different fully-qualified type names will result in a compilation error post-code generation since the Entity, Matcher, and ComponentsLookup member names for both will be the same.

To Reproduce

  1. Create two components with the same name, one in a global namespace and one in a custom namespace.
using JCMG.EntitasRedux;
using UnityEngine;

namespace ExampleContent
{
	public class FooComponent : IComponent
	{
	}
}

public class FooComponent : IComponent
	{
	}
  1. Run code generation.

  2. Compiler errors will occur.

Expected behavior
A warning/exception should be issued prior to code-generation and halts the code-gen process.

Screenshots

image

[FEATURE REQUEST] Modify CopyComponentTo code-gen for better copying

Is your feature request related to a problem? Please describe.
Currently the entity API CopyComponentTo performs a shallow copy of a component where a template instance's members's vales are assigned to a new component instance's members. This results in reference types being assigned directly, thus maintaining the reference instance of the same member between two different component instances. This includes members that are collections where the instance of the collection is assigned to both component instances. There is not currently an option that enables for deep copying a reference type member and/or copying the contents of a list to a new component collection member rather than assigning the collection itself.

Describe the solution you'd like
Ideally, the outcome of a reference type member on a component being copied should be:

  • By default pass the member by reference.
    • For member types derived from MonoBehaviour or ScriptableObject (really anything from UnityEngine.Object) the intent is more likely to assign by ref since they usually don't have a default constructor or straightforward way to copy over all the instance data.
    • For member types that are plain-old CSharp objects, work from the developer is needed to copy over all required data on the component to a new instance, particularly where they could also contain Unity object member types.
  • When a member reference type implements ICloneable, rather than assign the ref value directly call the Clone method on assignment to create a new separate instance of that ref type. By implementing ICloneable on a type used as a member on a component, in effect that will result in CopyComponentTo deep-copying the ref instance to a new one.
  • When a member type is a collection:
    • If its an IList, IReadOnlyList, iterate over the list item in a for loop and assign/copy each member using these same default/ICloneable, collection rules.
    • If its not an IList, IReadOnlyList, iterate over the collection in a foreach loop and assign/copy each member using these same default/ICloneable, collection rules.

Describe alternatives you've considered
I'd like to avoid heavy usage of runtime reflection as much as possible to reduce down on the performance hit this operation should take (especially since it has the capacity to be used in bulk for many entities from blueprints). Any reflection that takes place should either be small or cached for reuse.

Tasks

  • Implement ICloneable on several example ref type components
  • Add ICloneable code-generation logic for CopyComponentTo method code-generator
  • Add List code-generation logic for CopyComponentTo method code-generator
  • Add Array code-generation logic for CopyComponentTo method code-generator
  • Add Dictionary code-generation logic for CopyComponentTo method code-generator
  • Add unit tests for TypeExtensions to validate functionality
  • Add unit tests for CopyComponentTo method to validate functionality
  • Update documentation

[RESEARCH] Investigate alternative object cloning libraries for copying components, blueprints

Is your feature request related to a problem? Please describe.

I'd like for copying components, blueprints to be simpler and easier for developer to solve without needing to implement ICloneable for custom reference types to determine how a deep clone should occur (or at least make that optional for potential performance improvements).

Describe the solution you'd like

There are some third-party libraries I could add as a dependency to simplify deep clones of component members, but they would likely need:

  • Potentially may not compile for Unity and/or need additional work to be able to compile for Unity.
  • May not work on specific platforms with constrained resources and functionality like WebGL.
  • Constraints or filtering added to be able to handle/exclude native Unity ref types derived from UnityEngine.Object like MonoBehavior, ScriptableObject, Texture2D, etc...

Describe alternatives you've considered
I'd rather not duplicate the efforts at writing another homebrew deep-cloning solution for C# if reasonable alternative exist that are either maintained or that I could fork and maintain for Unity/C#.

Additional context
This is something worthwhile to look into, but nothing I would hold up the blueprints feature for on a release. On second thought I would like to add this to blueprints on the first release if possible because it would remove many of the cloning edge cases a developer would need to take into account and simplify the implementation.

[FEATURE REQUEST] Verify Unity 2020.2 compatibility/support

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Unity 2020.2 has just been released; please verify that everything is working as expected for this TECH release version.

Describe the solution you'd like
A clear and concise description of what you want to happen.

There should not be any compiler errors, warnings, or breaks in functionality when using EntitasRedux on this version.

[FEATURE REQUEST] Add preprocessing symbol #if #endif on content's of generated code

Is your feature request related to a problem? Please describe.
A workflow was recently described on an easier way to refactor existing code that is also touched by auto-generated code. Rather than need to hand-modify auto-generated code where it had been changed, instead it was easier to:

  • Surround the internal implementation of auto-generated code with a pre-processor symbol
  • Set the preprocessor symbol when refactoring changes are needed (so that the internal implementation is compiled out)
  • Refactor as needed and regenerate code.
  • Unset the scripting symbol.

Describe the solution you'd like

  • All internal implementations of auto-generated code should be surrounded with an #if !ENTITAS_REDUX_UNSET, #endif block.
  • It would be helpful to have a menu item for setting/removing this as a scripting symbol in Unity so that a developer doesn't need to hand-modify the Scripting Symbols in the PlayerSettings.
  • The implementation of auto-generated code should only be compiled out IF the scripting symbol is present.

[FEATURE REQUEST] Add wiki page on how to setup a complete repository

Is your feature request related to a problem? Please describe.
Currently there is a Hello World wiki page covering the basics. It would be nice to have a guide covering a complete setup e.g. for "teams" working with Git and automated tests.

Describe the solution you'd like
It would be nice to have a wiki page covering the following parts:

  • Prerequisites
  • How to setup the Git repository
  • How to setup the .gitignore file
  • How to setup the Unity project for that repository
  • How to setup Entitas-Redux for that Unity project
  • Simple code example
  • How to setup the tests

Describe alternatives you've considered
Entitas experts might create more complex examples e.g. how to create a "Pong" with Entitas-Redux.

[v2] Port v1 EntitasRedux.Editor.Plugins plugins to use Genesis v2

Is your feature request related to a problem? Please describe.
For EntitasRedux v2, the following groups of plugins from the EntitasRedux.Editor.Plugins AssemblyDefinition should be ported to be implemented in the external Plugins solution under the EntitasRedux.CorePlugins project. This work is being implemented on the feat/v2 branch and any PRs should target that branch.

  • Cleanup
  • Component
  • Configs
  • Context
  • Data
  • Drawers
  • Entity
  • EntityIndex
  • Events
  • Extensions

[BUG] Build compile error for missing Contexts.SharedInstance member

Describe the bug
A recent feature adding experimental playmode support accidentally compiles out the Contexts.SharedInstance member when not in the editor. This causes a compile error when building a player as that member is no longer available.

Unity Version:

  • Unity 2019.4.11f1

To Reproduce

  • Attempt to build an empty project with any EntitasRedux generated content on v1.3.3
  • Compiler error occurs for missing Contexts.SharedInstance member

Expected behavior
This Contexts.SharedInstance member should be available in runtime code and should not be contained in a ifdef UNITY_EDITOR block.

[Docs] Document best practices for Entitas Redux

Is your feature request related to a problem? Please describe.
It would be good to provide newcomers to either an ECS framework or Entitas Redux with a collection of best practices to better inform how to utilize these approaches or framework in their project.

[FEATURE REQUEST] Create release checklist

Is your feature request related to a problem? Please describe.
When making a release, I usually pick up on the fly which steps to go through based on previous experience. Sometimes I forget a step or tag a release incorrectly such that UPM doesn't pick it up.

Describe the solution you'd like
I'd like to formalize a release checklist on the wiki to make it easier to remember the steps to go through in the proper order to make a release.

[v2] Port v1 EntitasRedux.Blueprints.Editor.Plugins plugins to use Genesis v2

Is your feature request related to a problem? Please describe.
For EntitasRedux v2, all content from the EntitasRedux.Blueprints.Editor.Plugins AssemblyDefinition should be ported to be implemented in the external Plugins solution under the EntitasRedux.BlueprintPlugins project. This work is being implemented on the feat/v2 branch and any PRs should target that branch.

[FEATURE REQUEST] Create and document process for estimating baseline performance for different platforms

Is your feature request related to a problem? Please describe.

I'd like to get a better understanding of the strengths and limitations of EntitasRedux performance-wise to better advise users and test any changes/improvements. There are a suite of performance tests setup as a a unit test in the editor (only run manually as it takes several seconds to complete), but these are only helpful insofar as the player or build environment is comparable to the Editor, which for many platforms such as iOS, Android they are not.

Describe the solution you'd like

Unity has a performance testing framework that seems like it would be well-suited to this task, providing more metrics and a dedicated editor window to view the results (both when run on editor and in a player/build). See here for more info.

[FEATURE REQUEST] Scriptable Systems and Features

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

There are advantages in Unity to being able to create systems as ScriptableObjects, but there is a lack of parity between POCO objects and systems that cause disadvantages and require workarounds. There are also architectural considerations with using ScriptableObject systems that differ from POCO systems:

Advantages

  • Dependencies for a system can be easily assigned or injected to a given system through serialized fields in the Inspector.
  • Systems can easily be configured in the Unity Editor with relation to other systems by capturing them in the relevant list for a given feature. This includes adding, removing, or reordering systems in the collection. This is significant as it gives more ability for non-engineers to modify system behavior directly.

Disadvantages

  • Systems written as ScriptableObjects don't have a constructor equivalent like a POCO that can be used as a pre-initialization step.
  • ScriptableObjects require more care in the editor to ensure that any locally initialized fields not intended to be serialized are cleaned up between Editor play sessions, usually by using the `[NonSerialized] attribute.
  • ScriptableObjects can't be as easily disposed in code as POCO objects can be; depending on how a ScriptableObject is referenced
  • There is not any native framework support directly for ScriptableObject systems, which results in each developer needing to write their own support for using them.

Describe the solution you'd like
A clear and concise description of what you want to happen.

  • A developer should be able to write systems as ScriptableObjects using an EntitasRedux-provided base type.
    • An overridable initialization method should be available that provides a IContexts interface.
  • A developer should be able to create features in the Unity Editor as a scriptable object and:
    • Assign a custom name for the feature
    • Add, Remove, and Reorder systems for that feature.
    • Assign a default Contexts instance to use, but be able to pass a Contexts in code if desired.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

One option that might bring POCOs up to parity with ScriptableObjects for being able to manipulate them in the editor would be to provide a base system C# type and use the [SerializeReference] attribute to be able to polymorphic serialize derived system instance types in a list or array. This opens the door to more of the same features, advantages as ScriptableObjects, but not all.

Additional context
Add any other context or screenshots about the feature request here.

Tasks

  • Implementation
  • Tests
  • Documentation

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • My code is well-commented, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

[FEATURE REQUEST] Add create C# script file templates for systems

Is your feature request related to a problem? Please describe.

It would be helpful for users to be able to create new components, indexes, or system scripts from the Unity Editor as a template.

Describe the solution you'd like
The user should be able to right-click in the Project window and select EntitasRedux->Script Type to create a template version of that script.

An example of this type of functionality can be found here.

[RESEARCH] Investigate Blueprints and determine best course of action

Is your feature request related to a problem? Please describe.

Blueprints are a feature intended to make it easier to configure Entities in the Unity Editor much like you would a prefab, but are currently too problematic for a variety of reasons to include with the main library of EntitasRedux. There is value in being able to configure Entities in the Unity Editor directly without code or with a minimum of configuration/decoration.

Describe the solution you'd like

Ideally, for a user they would be able to add some sort of component for an Entity of a given context to a GameObject and add/remove/modify components at will. When playing, using this component on an object should automatically create the Entity and add the user-configured components.

Implementation Tasks

Blueprint Entity

  • A MonoBehaviour component should be code-generated per context that enables adding or removing components specific to that context.
  • A ScriptableObject should be code-generated per context that enables adding or removing components specific to that context.
  • A custom inspector should be created to enable adding and removing components specific to that context
  • Documentation should be added to the Wiki for using this version of blueprints

[FEATURE REQUEST] API for adding, replacing components should be extended

Is your feature request related to a problem? Please describe.

Currently, the API for modifying components on an Entity involves passing all of the properties of that component into a method either adding that component or replacing an existing component.

image

This works alright for components with one or two fields, but after several fields this can be a bit exhausting, particularly if you only want to modify one or two fields.

Describe the solution you'd like

Ideally, there should be a way to be able to modify a subset of a component's fields without needing to call either Add or Replace with the superset of all of that component's fields AND still have the appropriate Events be called for Adding, Replacing, or Removing a component and work with component pooling. There are a couple of options to look into:

  • The property for a non-flag component is currently get-only. This could be changed to include a setter.
  • Add and Replace component method overloads could be added that accept a component value.

For all of these options, their internal implementation would obey the same logic rules for events, pooling and require additional unit tests to verify that.

Describe alternatives you've considered
It is possible right now to get an existing component and modify one or two fields directly on it without calling Entity methods for Replacing, but this can only be done in this context and it does not trigger events for the entity's component being updated.

[BUG] Indexes are not generated

Describe the bug
Attributes [EntityIndex] and [PrimaryEntityIndex] do not generate additional code for getting entities from context.

Unity Version:
Unity 2020.3.0f1

To Reproduce

  1. Create new Unity 2020.3.0f1 project
  2. Update manifest.json with:
    "com.jeffcampbellmakesgames.genesis": "https://github.com/jeffcampbellmakesgames/genesis.git#release/stable",
    "com.jeffcampbellmakesgames.entitasredux": "https://github.com/jeffcampbellmakesgames/entitas-redux.git#releases/stable"
  1. Setup genesis based on documentation -> click on Update Genesis CLI and Install or Update All Plugins
  2. Create GenesisSettings and click on Auto Import
  3. Create a class with content for testing the attributes:
using JCMG.EntitasRedux;

[Game]
public class PrimaryComponent : IComponent
{
    [PrimaryEntityIndex]
    public int value;
}

[Game]
public class SecondaryComponent : IComponent
{
    [EntityIndex]
    public int value;
}

public class Controller
{
    public Controller()
    {
        var context = new Contexts();
        // should contain something like: context.Game.GetEntityWithPrimary
        // should contain something like: context.Game.GetEntitiesWithSecondary
    }
}
  1. Generate code via Generate button in GenesisSettings or shortcut CTRL+SHIFT+G

Expected behavior
Methods for getting data by indexes should be present in Game context, but they are not. It's not possible to use methods like context.Game.GetEntityWithPrimary() etc.

Screenshots

Genesis settings:
image

Genesis setup in project settings:
image

Additional context
Win 10, using Mono .NET 4.x in Unity player settings

[FEATURE REQUEST] Remove CustomComponentNameAttribute

Is your feature request related to a problem? Please describe.
When writing documentation for this library I noticed that [CustomComponentNameAttribute] is no longer used and is marked as obsolete in favor of using [ComponentName].

Describe the solution you'd like
This should be removed in a future release.

[FEATURE REQUEST] IPreInitializeSystem, for initialization that must be done before Initialize() but can't be done in a constructor

Is your feature request related to a problem? Please describe.

I have all of my Systems set up as ScriptableObjects. One major upside is that I can configure my Systems in the Unity editor; instead of having to screw around with dependency injection, I just add some fields. It's very designer-friendly, which is good because I don't expect to be a solo dev forever.

There are disadvantages, however. Chief among them is that the ScriptableObject life cycle is more complicated than that of a plain C# object (like Systems usually are). It's difficult to simply construct a system and throw it away like I regularly do in my test suite. I work around this by heavily using IInitializeSystem and ITeardownSystem. Problem solved; now I don't need to figure out when exactly Awake(), OnEnable(), OnDestroy(), or OnDisable() are called (and on which systems).

A related disadvantage is that I can't initialize systems with constructors; generally, this is where you would run logic that needs to be done before Initialize(), like setting up Collectors or Groups. I set those objects up in Initialize()...and then hit a weird bug in my code.

I needed to create some Entitys within Initialize(). This worked fine. However, I expected them to be tracked by a Collector on the first frame of execution; this didn't happen because the Entitys were being created before the Collector was, so my customized ReactiveSystem didn't notice them.

This wouldn't have happened if I could guarantee that there was some kind of set up phase that occurred before any Entity was created.

Describe the solution you'd like

Simple; an IPreInitializeSystem that looks something like this:

public interface IPreInitializeSystem
{
    void PreInitialize(IContexts contexts);
}

By convention, Systems in Entitas have a unary constructor that takes a Contexts as an argument. The system might then store the Contexts and use it to create Groups or Collectors (like in ReactiveSystems). Since I can't use constructors, this interface would be the next best thing.

The interface takes an IContexts because Contexts is usually generated in each project; the expectation is that you would cast it inside your implementation of PreInitialize().

There's a secondary advantage, too. Since my ScriptableSystems can't use constructors, I have to pass around a singleton with a Contexts everywhere. This interface would eliminate that need, simplifying the process of implementing Systems as ScriptableObjects.

I don't know what use IPreInitializeSystem would have in POCO-based Systems, but I can't see it getting in the way. It doesn't place any more burden on the developer than the other phases. Game devs are creative, I'm sure you'll figure something out.

Describe alternatives you've considered
See the first three paragraphs.

Additional context
I'm still using vanilla Entitas but I figured Redux would benefit from this idea, hence my feature request.

[BUG] Entity.CopyTo and Context.CloneTo methods not generated when zero components created

Describe the bug
After Generation Unity throws

_Assets\Generated\Game\GameContext.cs(40,10): error CS1061: 'GameEntity' does not contain a definition for 'CopyTo' and no accessible extension method 'CopyTo' accepting a first argument of type 'GameEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Input\InputBlueprintBehaviour.cs(38,12): error CS1061: 'InputEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'InputEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Game\GameBlueprintBehaviour.cs(38,12): error CS1061: 'GameEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'GameEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Game\GameBlueprint.cs(38,12): error CS1061: 'GameEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'GameEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Input\InputBlueprint.cs(38,12): error CS1061: 'InputEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'InputEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Input\InputContext.cs(40,10): error CS1061: 'InputEntity' does not contain a definition for 'CopyTo' and no accessible extension method 'CopyTo' accepting a first argument of type 'InputEntity' could be found (are you missing a using directive or an assembly reference?)_

Unity Version:
Unity 2020.1.8f

To Reproduce
Steps to reproduce the behavior:

  1. Create new Unity Project
  2. By using upm-cli Add Entitas Redux Package and NaughtyAttributes Package(Idk if relevant but could be)
  3. Follow the hello world tutorial
  4. Generate project files

Expected behavior
Stuff Generates without errors.

Screenshots
_Assembly Definitions for Entitas Redux are autoreferenced so it is not the case of generic null reference.
image
image
_

Additional context
I also use URP in my project. I even created a new project but the problem persists.

[FEATURE REQUEST] Add additional thread safety for static fields

Is your feature request related to a problem? Please describe.
There is a desire by some users to be able to use a Context on separate threads, particularly in the context of a game server. However some static fields are not decorated as being [ThreadStatic] so that the value of these fields are unique per thread. Some of these areas are described on an older PR here on the original Entitas repository.

Describe the solution you'd like
Ensure all static fields are decorated as being [ThreadStatic].

[BUG] DebugSystemsBehaviour shows wrong values for Update Systems if also reactive systems are present

Describe the bug
When debugging the runtime of systems in inspector with DebugSystemsBehaviour. It shows the wrong values for the update systems.

Unity Version:
Unity 2019.4.12f

To Reproduce

  1. create a new feature
  2. add an IReactiveSystem
  3. add an IUpdateSystem
  4. inspector show values of IUpdateSystem for IReactiveSystem

Expected behavior
The values should be of the right systems.

Additional context
The problem is that both system types will be added to _updateSystemInfos, but only IUpdateSystems will be added to _updateSystems. So there is an inconsistency between both lists. So why should it be handy to add IReactiveSystem to _updateSystemInfos?

If you want, I can create a PullRequest.

[FEATURE REQUEST] Configure Systems and Features through the inspector

Is your feature request related to a problem? Please describe.
Setting up systems through code is all fine and dandy, but being able to set them up through the Unity inspector would be handy. This can be done with most systems (IUpdate, ILateUpdate, etc) by using an IInitialize interface to set up the system. Reactive systems are a different story. One of the main driving forces behind a request like this is being able to set system fields through the inspector. You would either have to pass what you need through constructors, or create singleton entities that you can access. But this could leave you with a MonoBehavior that is loaded with fields that you can set in the inspector, and then when you create you systems, you pass them in. This can confuse the user as to what system needed that data. Having the ability to see at a glance that your RayCastToWorld system requires a camera to function would reduce the complexity. In my opinion. This could also allow the user to set up system configurations as prefabs. That way you can have a prefab of systems that you know work well, then set up a new one (or even a variant) for testing some newfangled feature.

Describe the solution you'd like
I would be nice if we could add systems to a list/array through the inspector.

Describe alternatives you've considered
I've tried wrapping systems in a constructorless class with the relevant fields, implement IInitialize and setup the system that way. It feels like too much indirection however. I've also thought about writing my own version of all the systems, but I lose the ability to Debug them through the Feature class (mainly because I don't fully understand the ins and outs of all the systems).

Additional context
One problem you could run into with this approach is that it could be hard to manage if you end up with a lot of systems in the inspector. Some way to organize them should probably be considered (system groups?). If the idea of system group sounds appealing, then my next request would be to be able to automate the process with an Attribute. Maybe something like GroupIn("Group Name") and then codegen up a SystemGroup that contains the systems. This could get tricky because everytime you codegen, you will lose any modifications made the the SystemGroup file. Would partial classes solve this?

[BUG] Unity Package Manager can't load Entitas-Redux

Describe the bug
When trying to add Entitas-Redux repo to Unity Package Manager it failed with an error.

Unity Version:
Unity 2019.4.12f1

To Reproduce

  1. Open a project
  2. Open package manager
  3. add a new package by git URL (https://github.com/jeffcampbellmakesgames/entitasredux.git#release/stable)
  4. See error
Cannot perform upm operation: Unable to add package [https://github.com/jeffcampbellmakesgames/entitasredux.git#release/stable]:
  Error when executing git command. fatal: could not read Username for 'https://github.com': terminal prompts disabled

  You may need to set up a Git credentials helper
  to access a private repository. [NotFound]

Expected behavior
Entitas_Redux package can be loaded and installed.

Additional context
The same occurs when directly typing it into manifest.json.

And as a little addition. It should also be possible to define a dependency for Unity Package Manager, isn't it? So that you don't have to manually install Genesis.

[FEATURE REQUEST] Add capability for separate Update, LateUpdate, and FixedUpdate systems on same Systems

Is your feature request related to a problem? Please describe.

As of right now, an IExecuteSystem and Systems offer a single Execute method. In the past, this has meant creating multiple contexts for executing at different update intervals such as Update, FixedUpdate, and LateUpdate. It might make more sense for Systems to instead have the ability for a user to also add a system as an Update, FixedUpdate, and/or LateUpdate system so that a user can execute a single context's systems at all three update intervals. In this way a user would be able to still separate contexts for update intervals using Execute if they chose to do so, or not use separate update intervals at all, but others could execute systems on the same entities on the appropriate interval.

Describe the solution you'd like

There is a bit of investigation to do here as far as an approach. It might make sense to add new interfaces for:

  • IUpdateSystem
  • ILateUpdateSystem
  • IFixedUpdateSystem

as well as add new API functionality for Systems for adding these systems, which would then be categorized correctly. Visual Debugging would also need to be updated to account for new categories of systems.

[FEATURE REQUEST] Add documentation for existing features

Is your feature request related to a problem? Please describe.
As of right now, the only existing documentation for the ECS portions of EntitasRedux can be found by looking at the original Entitas wiki here. Even so, not every aspect of the original Entitas was covered. This can make it difficult for new users to jump in and understand EntitasRedux workflows and concepts.

Describe the solution you'd like

I'd like for documentation to be created such that covers all of the code generation and ECS concepts of EntitasRedux. These docs should be available online and in some form as a PDF included with the package so that a user can open it locally. Menu items should be added to make it easy to open both the local PDF and a browser link to the online docs. If possible, API docs should be auto-generated from code so that it is easy to search the API.

Concepts Covered

  • Contexts
  • Components
  • Entities
  • Systems
  • Groups
  • Entity Indexes
  • Attributes

Other

  • Workflows and Tutorials
  • Visual Debugging (Attributes, Component Drawer, Type Drawer)
  • FAQ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.