sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7.03k stars 1.11k forks source link

PrimaryEntityIndex/EntityIndex attributes not generating matcher code #1023

Closed FutureProg closed 1 year ago

FutureProg commented 1 year ago

After running Jenny it looks like the Id component I've made isn't being generated.

Here's the component code:

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

Error after building: Error CS0117 'GameMatcher' does not contain a definition for 'Id' Assembly-CSharp, Assembly-CSharp.Player

This is while using the same Jenny.properties from the Match-One project.

Entitas Version

sschmid commented 1 year ago

@FutureProg Just check in Match-One and it worked as expected. Can you share your Jenny.properties?

FutureProg commented 1 year ago
Jenny.SearchPaths = Jenny/Plugins/Entitas, \
                    Jenny/Plugins/Jenny, \
                    Assets/Entitas
Jenny.Plugins = Entitas.CodeGeneration.Plugins, \
                Entitas.Roslyn.CodeGeneration.Plugins, \
                Entitas.VisualDebugging.CodeGeneration.Plugins, \
                Jenny.Plugins, \
                Jenny.Plugins.Unity
Jenny.PreProcessors = Jenny.Plugins.ValidateProjectPathPreProcessor
Jenny.DataProviders = Entitas.CodeGeneration.Plugins.ContextDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider
Jenny.CodeGenerators = Entitas.CodeGeneration.Plugins.ComponentContextApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentEntityApiInterfaceGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentLookupGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextAttributeGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextMatcherGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextsGenerator, \
                       Entitas.CodeGeneration.Plugins.EntityGenerator, \
                       Entitas.CodeGeneration.Plugins.EntityIndexGenerator, \
                       Entitas.CodeGeneration.Plugins.EventEntityApiGenerator, \
                       Entitas.CodeGeneration.Plugins.EventListenerComponentGenerator, \
                       Entitas.CodeGeneration.Plugins.EventListenerInterfaceGenerator, \
                       Entitas.CodeGeneration.Plugins.EventSystemGenerator, \
                       Entitas.CodeGeneration.Plugins.EventSystemsGenerator, \
                       Entitas.Roslyn.CodeGeneration.Plugins.CleanupSystemGenerator, \
                       Entitas.Roslyn.CodeGeneration.Plugins.CleanupSystemsGenerator, \
                       Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, \
                       Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator
Jenny.PostProcessors = Jenny.Plugins.AddFileHeaderPostProcessor, \
                       Jenny.Plugins.CleanTargetDirectoryPostProcessor, \
                       Jenny.Plugins.MergeFilesPostProcessor, \
                       Jenny.Plugins.UpdateCsprojPostProcessor, \
                       Jenny.Plugins.WriteToDiskPostProcessor, \
                       Jenny.Plugins.ConsoleWriteLinePostProcessor
Jenny.Server.Port = 3333
Jenny.Client.Host = localhost
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Input
Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false
Jenny.Plugins.ProjectPath = Assembly-CSharp.csproj
Jenny.Plugins.TargetDirectory = Assets
sschmid commented 1 year ago

Looks good. Can you generate again and share the output?

Can you please also try within Match-One?

FutureProg commented 1 year ago

So I tried just refreshing the project instead of building the assembly in Visual Studio and it worked. Guessing I either need to build Assembly-CSharp and Assembly-CSharp.Player or build the entire project to get it going.

AVAVT commented 1 year ago

Are you using VSCode?

I have similar experience and the reason is VSCode doesn't add new file to the project assembly, so you have to switch to Unity first (so Unity can add the new file to project), then you can generate.

sschmid commented 1 year ago

Ok cool. Yes, It needs Assembly-CSharp.csproj as specified in Jenny.Plugins.ProjectPath = Assembly-CSharp.csproj.

sschmid commented 1 year ago

@AVAVT Really? VS doesn't add new file to the project immediately? That would be very inconvenient.

FutureProg commented 1 year ago

VS does, VSCode doesn't I believe. Might need a command or something to do that.

AVAVT commented 1 year ago

VS does, VSCode doesn't I believe. Might need a command or something to do that.

^ confirm.

But VS looks horrible so I'd live with inconvenience over eye surgery 😅