Code Monkey home page Code Monkey logo

Comments (6)

fritzy avatar fritzy commented on May 13, 2024

Component and Entity types are currently world specific for optimization reasons, but it wouldn't affect the API to change it (WorldEntity might need to change the TypeScript definition a bit). I'm certainly open to making it easier to use entities and components in more than one world. What use-case do you have in mind?

from ape-ecs.

jcorbin avatar jcorbin commented on May 13, 2024

A couple of current use cases I have in mind:

  • independent/unsynchronized simulation regions, e.g. not ticking everything all the time
  • independent spatial regions, without affording for that internally with an additional coordinate or "plane" tag

Speaking of spatial sharding, what's your take on an index for collision detection?

from ape-ecs.

fritzy avatar fritzy commented on May 13, 2024

That makes a lot of sense. I'll make it a priority. I think I can do it without a 2.0, but it might need to be API breaking. We'll see! I'll keep you in the loop.

from ape-ecs.

fritzy avatar fritzy commented on May 13, 2024

Components can now be registered to multiple worlds in the portability branch.
I'll start thinking about the ability to copy and move entities between worlds in the future.

from ape-ecs.

jcorbin avatar jcorbin commented on May 13, 2024

Fantastic, for an update on where I'm at, am currently pursuing "what if I just used DOM elements literally as an ECS, what with data attributes, CSS variables, quereySelectorAll, and such"; you can see a working demo here: https://jspit.vercel.app/domgeon.html

fwiw, my approach to FOV / lighting does provide a potential use case for copy/moving between between worlds:

  • there is the objective world ( in domgeon terms the "solid tile plane" ); it serves as the source of truth, where movement and interaction happens
  • the lighting simulation gets calculated in the objective world ( by (re)computing --light CSS variables using a modified shadowcasting algorithm )
  • but we don't draw the objective world, rather what we do is copy in-FOV tiles out of the objective world, into a subjective plane, after first clearing any copied light values from the prior round
  • I plan to later use this same approach for AI, so that they also only see their own subjective copy of the world, sensed through LOS/FOV observations

Now, currently for domgeon, this is all just so much div.grid div.plane div.tile elements; how would I map it onto a more formalized ECS, not sure.

And a parting thought: copying between ECSes seems to me just a lighter weight version of (de)serialzing, which ECSes are supposed to afford quite well in general; not sure what ape-ecs's current story is around loading/saving tho?

from ape-ecs.

fritzy avatar fritzy commented on May 13, 2024

You can run getObject on a world, entity, or component. The results can be used as the definition in createEntity/createEntities.

from ape-ecs.

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.