Git Product home page Git Product logo

Comments (15)

grumpyoldman1066 avatar grumpyoldman1066 commented on April 28, 2024 1

I'd love a straight C#/Monogame example as well. I can't get this working. It generates the files, and those files show up in my project, but the component list has zero components and none of their code is generated. Generating code in Unity worked fine for me.

Is there something I'm missing or should I wait for the executable generator?

from entitas.

mike991166 avatar mike991166 commented on April 28, 2024 1

Just want to add support for a nice MonoGame example. I'm having the same problem as others where no component code is actually generated. I'm excited to try this, but unable to proceed. Thanks for any help you can provide.

from entitas.

sschmid avatar sschmid commented on April 28, 2024 1

I updated the wiki Install-Entitas-and-first-steps.

I created a simple C# project for you with the code generator already set up.
This should help getting started.

https://github.com/sschmid/EntitasPure

Have fun! :)

from entitas.

sschmid avatar sschmid commented on April 28, 2024

Hi,
yes Entitas also works without Unity. Here's an example on how you can use the code generator outside of Unity
https://github.com/sschmid/Entitas-CSharp/blob/develop/Entitas.CodeGenerator/Program.cs

You have to make sure to add the generated files to your project, but I guess you can automate this, too.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

Hey, I updated the wiki and added a new page
"Install Entitas and first steps"
https://github.com/sschmid/Entitas-CSharp/wiki/Install-Entitas-and-first-steps

That might help

from entitas.

Thraka avatar Thraka commented on April 28, 2024

Hi. I'm new here too. I don't see how this gets my own component into the system. I created a new console project, added the generation/entitas code in it, I call your generation code from the wiki yet the generated types do not have my PositionComponent listed. What do I need to do exactly to hook all this up?

from entitas.

sschmid avatar sschmid commented on April 28, 2024

When you generate new files be created. The code generator doesn't add them to the *.csproj file. This means your IDE is not aware of those files. Try to add sth like this to your *.csproj file

<ItemGroup>
  <Compile Include="path/to/generated/folder/**" />
</ItemGroup>

If that doesn't work we should try to find a way to automatically add those generated files to the project. We figured out a way with roslyn for windows already, but it doesn't work on mac yet.

from entitas.

Thraka avatar Thraka commented on April 28, 2024

My generated output folder does not have any code related to my component class I made. It just has pool classes.

My component class in my generator project

namespace EntitasCodeGeneration
{
    public class PositionComponent :IComponent
    {
        public int X;
        public int Y;
        public int Z;
    }
}

If I use your sample code. This does not cause my component to suddenly be generated

Generator project (which has the component class in it)

static void Main(string[] args)
{
    Console.WriteLine("Building SadConsole entities");

    // All code generators that should be used
    var codeGenerators = new ICodeGenerator[] {
                                new ComponentIndicesGenerator(),
                                new ComponentExtensionsGenerator(),
                                new PoolAttributesGenerator(),
                                new PoolsGenerator(),
                                new BlueprintsGenerator()
    };

    // Specify all pools
    var poolNames = new[] { "Core" };

    // Specify all blueprints
    var blueprintNames = new string[0];

    var assembly = Assembly.GetAssembly(typeof(SadConsole.Game.Entitas.Entity)); // I compiled entitas into a library which I reference in this project.
    var provider = new TypeReflectionProvider(assembly.GetTypes(), poolNames, blueprintNames);

    const string path = "./Generated/";
    var files = CodeGenerator.Generate(provider, path, codeGenerators);

    foreach (var file in files)
    {
        Console.WriteLine(file.generatorName + ": " + file.fileName);
    }

    Console.WriteLine("Done. Press any key...");
    Console.Read();

}

from entitas.

Thraka avatar Thraka commented on April 28, 2024

I looked a bit more into it and I figured out why it doesn't generate anything for me. I changed the namespace of all the entitas code and you do a type.fullname == "Entitas.xxxx" check on things 😞 How come the code generator doesn't do a type == typeof(Entitas.xxx) instead?

from entitas.

sschmid avatar sschmid commented on April 28, 2024

I plan to provide the code generator as an executable in the future. As a first step it was necessary to check for the type with string comparison, since the executable doesn't contain Entitas.IComponent etc. I want to move the code generator to a separate project since the ultimate master plan is to offer a roslyn based code generator (or to basically enable any kind of source parsing, e.g. reflection, roslyn, json or etc)

from entitas.

Thraka avatar Thraka commented on April 28, 2024

That sounds awesome. Especially because people could generate into other languages. I still voice my opinion for a good example of a non-unity project as an example though :)

One thing you could do is have a init system where the consumer provides all the types you know the generator needs.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

I'll have to check. So far I used Entitas mainly with Unity, but I like to keep it working for c# only projects, too.

from entitas.

Thraka avatar Thraka commented on April 28, 2024

@mike991166 It may be the difference in methodology. It seems that you don't create an "entitas.dll" library and reference that. You include the entire code base in your game project. I have two projects:

  1. My game project which also defines components used by entitas.
  2. My generation project.

Both projects have the entire entitas code base. The generation project includes my component files from my main project. When the generation project runs, it outputs the generated files into a folder for my main project. Then back in my main project I exclude the "generated" folder and include it again to pick up all the new files.

from entitas.

mike991166 avatar mike991166 commented on April 28, 2024

Thanks, that did it.

from entitas.

Thraka avatar Thraka commented on April 28, 2024

@mike991166 I just wanted to comment that I played around with this for a while and I find it very hard to use in a non-unity project. I've now started to test thelinuxlich/artemis_CSharp and it seems to play really nice with MonoGame. The tutorial website is simple and gets you started. However, there is also a sample MonoGame game where you can explore a full implementation of it.

So far I really like it, however, I really, really, love the entitas way building out the entity to have the components built in and miss that.

from entitas.

Related Issues (20)

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.