Giter Club home page Giter Club logo

Comments (4)

benmoran56 avatar benmoran56 commented on August 12, 2024

Thanks for opening the ticket, and I'm glad you're enjoying esper.

Can I ask why it's important that entities have the same ID after loading?
The proposed patch would work, but it's a bit outside of typical ECS structure.
The Entity ID happens to be an integer, but it's meant as a throw-away value.

Instead of storing the ID, if possible, I would recommend using a Component to "tag" specific Entities.

class Player:
    pass

class EnemyTypeA:
    pass

class EnemyTypeB:
    pass

There may of course be multiple of the enemy types, but there would only be one entity tagged with Player. This allows you to specifically query that entity, if you need to.

from esper.

woogyface avatar woogyface commented on August 12, 2024

I already use components as "Tags" and it works fine how i use it but my game has "unpredictable" Enemies aka an Entity with a random set of Components. It may work with a restructure of my db layout. I might make it possible without using the entity id as a key but changing components would be hard.

having a db without entity id as key might be look like this:
Entity

row_id components
1 "Position(7,3,0);Color(255,0,0);Faction(12);IsGiant();IsOrc();IsNPC();DialogTree(44);Level(3)"
2 "Position(7,3,0);Color(255,0,0);Faction(12);MoreRandomComponents()"
3 "Position(7,3,0);Color(255,0,0);Faction(12);EvenMoreComponents()"

that way i have just one table in my db (what i don't really want to happen) and i don't need the entity id as a key as i can distinguish by the components. Now just imaging what i have to do to change the Position of a specific entity. i gets messy real fast.

my other solution would be to add a secondary id component to my entities like a RandomEntity having components Position, Color, Faction, etc AND a must have SecondaryIdComponent() like a string or another int which is different for every Entity.

It just might be "the problem saving ECS to a DB". I've never done it and it might be a stupid use case but i want to do like that to learn it.

Having a way to create known entities with specific ids would be the easiest solution for me. if it's not complieant with an ECS than that's ok. I have ways to work around it but it would make my life a little bit easier :D

from esper.

benmoran56 avatar benmoran56 commented on August 12, 2024

Sorry for leaving this hanging for so long.
I think for the main Esper releases I want to keep it as-is, just for performance reasons (even if very small).

That said, it would be pretty easy to subclass World with a custom create_known_entity(id) method. It could probably work alongside the existing method as well. Would that work for you?

from esper.

benmoran56 avatar benmoran56 commented on August 12, 2024

Closing this due to lack of follow up.
On careful consideration, I don't think this makes sense in mainline esper, due to placing relevance on what is supposed to be nothing more than a UUID (even if it's an int in implementation).

This behavior can be achieved using a custom function. If you need help in producing something like that, please follow up or open a new ticket. Thanks!

from esper.

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.