Giter VIP home page Giter VIP logo

uecs's Introduction


 __    __   _______   ______     _______.
|  |  |  | |   ____| /      |   /       |
|  |  |  | |  |__   |  ,----'  |   (----`
|  |  |  | |   __|  |  |        \   \    
|  `--'  | |  |____ |  `----.----)   |   
 \______/  |_______| \______|_______/    
                                         

⭐ Star us on GitHub — it helps!

repo-size tag license

UECS

Ubpa Entity-Component-System in Unity3D-style

Compiler compatibility

  • Clang/LLVM >= 10.0
  • GCC >= 10.0
  • MSVC >= 1926

Tested platforms:

  • Windows 10: VS2019 16.8.5

  • Ubuntu 20: GCC 10.2, Clang 11.0

  • MacOS 11.0 : GCC 10.2

    AppleClang 12 and Clang 11 is not supported

Documentation

Example

#include <UECS/UECS.hpp>

using namespace Ubpa::UECS;

struct Position { float val; };
struct Velocity { float val; };

struct MoverSystem {
  static void OnUpdate(Schedule& schedule) {
    schedule.RegisterEntityJob(
      [](const Velocity* v, Position* p) {
        p->val += v->val;
      },
      "Mover"
    );
  }
};

int main() {
  World w;
  w.entityMngr.cmptTraits.Register<Position, Velocity>();
  w.systemMngr.RegisterAndActivate<MoverSystem>();
  w.entityMngr.Create(Ubpa::TypeIDs_of<Position, Velocity>);
  w.Update();
}

other examples

Licensing

You can copy and paste the license summary from below.

MIT License

Copyright (c) 2020 Ubpa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

uecs's People

Contributors

ubpa 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uecs's Issues

Possible problems

  1. 请问是否可能存在 entityTableFreeEntry.size() 大于 entityTable.size() 的情况?
    比如: 先创建几个实体, 然后将他们全部销毁, 最后调用 EntityMngr::TotalEntityNum() 试图获取实体数量.

    std::size_t TotalEntityNum() const noexcept { return entityTable.size() - entityTableFreeEntry.size(); }

  2. 请问 e.index 是否可能在 EntityMngr::entityTableFreeEntry 中呢?

    return e.index < entityTable.size() && e.version == entityTable[e.index].version && entityTable[e.index].archetype;

因为没有完整的阅读源码, 若我有地方没注意到请见谅.

build with cmake 3.16.6 vs 2019

CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FetchContent.cmake:915 (message):
Build step for ucontainer failed: 1
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.16/Modules/FetchContent.cmake:1006 (__FetchContent_directPopulate)
C:/Program Files/CMake/share/cmake-3.16/Modules/FetchContent.cmake:1047 (FetchContent_Populate)
build/_deps/ucmake-src/cmake/UbpaPackage.cmake:78 (FetchContent_MakeAvailable)
build/_deps/ucmake-src/cmake/UbpaPackage.cmake:85 (Ubpa_AddDepPro)
CMakeLists.txt:11 (Ubpa_AddDep)

erase the Entity, the chunk idx changed

Archetype.cpp
std::size_t Archetype::Erase(EntityAddress addr)
chunks.erase(std::find(chunks.begin(), chunks.end(), chunk));

you erase a vector, so the index of the elements after the iterator all changed;
but in entityTable in EntityMngr, some may still ref to the old index , is this some bug?

I have red some of UECS, there is a issue

Chunk.cpp 69 std::size_t Chunk::Erase(std::size_t idx)

movedEntityIdx = reinterpret_cast<Entity*>(dstBuffer + head->GetCmptInfos()[entityTypeIdx].offset + sizeof(Entity) * srcIdxInChunk)->index;

the sizeof(Entity), I think it may something like sizeof(tagSize), for
I think you put the Entity as a component with its compoents , right?
But this is an old version, may be you have changed ,or something I understood wrong

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.