163 questions
2
votes
1
answer
100
views
Pass borrowed ref cell value into function trait
I'm working on an ECS system, but in order to iterate across pairs of queries, I need to be able to fetch components only for a limited scope when executing a system. To do this, I'm trying to make a ...
2
votes
1
answer
120
views
Don't understand how borrowed value doesn't live long enough when used with GATs
This problem has a ton of architecture behind it, so I'm going to do my best to minimize it.
I am working on an ECS framework (not very original). I have the ability to choose storage type via ...
3
votes
1
answer
86
views
How can I use trait objects and monomorphism together
I run into this same problem with a different flavor over and over and I'm not sure entirely how to describe it, so I'll simply give an example and explain how I'm stuck.
I'm working on an ECS system ...
2
votes
1
answer
96
views
How do I know when the spawn-commands are finished?
I am writing an asteroids-like game in rust with the bevy game-engine as a learning-project.
The gameplay works fine (the ship can shoot at asteroids until there are no more), but I have difficulties ...
1
vote
0
answers
89
views
How to have different implementation for tuple of references vs tuple of values
I'm trying to write an ECS system that can query components by value, reference, or mutable reference. For this, I want a different implementation for various tuple types as an Archetype.
trait ...
0
votes
1
answer
86
views
How can I pass a generic function to a class in C#
I'm currently working on a Entity Component System (ECS) for a game I'm developing in C# and Monogame.
My GameObject class has a dictionary with all its components, and this method is written to ...
0
votes
2
answers
132
views
How to iterate over different structs in C++ using a single function
I'm developing an Entity Component System (ECS) in C++ and I'm trying to find an efficient way to iterate over different component structs using a single function. Here's an example of my component ...
1
vote
1
answer
183
views
Function pointers vs polymorphism in a game engine ECS architecture [closed]
So I have a question about ECS and how to structure it in a way that's performant in C++. Say I want to have components that are just data, and systems that are just logic, and I want to execute all ...
0
votes
1
answer
184
views
How can I edit the transform component of a child entity?
I have a TextBundle as a Children of an Entity with a SpriteBundle.
I want to change the transform of both of these in a query, I tried something like this:
mut query: Query<(Entity, &Creature, ...
1
vote
1
answer
215
views
C# Returning Struct by ref results in copy
I tried to store and retrieve structs by reference using C#. What actually happened is that each struct that I attempted to retrieve was copied, and not returned by ref as instructed.
I have a "...
1
vote
2
answers
86
views
Template function with variadic arguments speciaization
Is it possible somehow to do template function specialization like this:
template<typename T, typename... Args>
void Func(size_t id, Args... args) { std::cout << "1\n" }
...
0
votes
1
answer
84
views
Typescript function to accept array or single instance of constructor and return list
EDIT: reproducible link to typescript's playground
I also found a solution that is in the link as well, though I don't actually understand why my first one doesn't work if anyone still wants to ...
1
vote
1
answer
60
views
branding with type predicates in intersections
I have a small problem that I've been unable to solve after several hours.
I don't know if a sharper mind could offer me a solution?
I'm using a method that returns a predicates : this is xxx.
It's ...
1
vote
1
answer
72
views
Middle static Classes without interface in typescript
I am currently exploring an alternative to an approach that previously worked but has some complexities in JavaScript that I would like to avoid.
So, I've reconsidered the TypeScript layer a bit, and ...
0
votes
1
answer
188
views
Copy from Render World to Main World using Bevy 0.12/0.13
I would like to copy a resource from the render world to the main world. How can I achieve this?
e.g., I have a resource like this:
#[derive(Resource, Clone, Deref, ExtractResource, Reflect)]
pub ...
1
vote
1
answer
57
views
Anonymous static class infer composition no infer correctly
i get weird behavior here,
if i assign a default array in generic of Compositor<CT extends ComponentType[]=[]>
ts keep infer ComponentType[] instead of [] to my type SystemWithRule !
this make ...
1
vote
0
answers
41
views
how allow tuple generic to union generic?
Hi how i can allow a class with tuple as generic to be pass to a function with a class with union generic ?
is it possible , is there a suggestion you can give me ?
thanks
Here the code , i want pass ...
1
vote
1
answer
35
views
No matching function call insert for unorded_map containing shared pointer templates
I am trying to implement a toy ECS for a hobby engine, and am following a small tutorial to kick-start it. An extremely bare-bones implementation using the tutorial is the following
#pragma once
#...
0
votes
1
answer
79
views
C# Is there a way to use ref return as an out parameter?
I am playing around with LeoEcs and I keep writing the following code:
if(!entity.HasComponent<T>())
return;
ref T comp = ref entity.GetComponent<T>();
This looks pretty tame, but it ...
0
votes
0
answers
67
views
Array element reference being set to partially incorrect memory address and data
I am at the point in the custom ECS I'm making where I am trying to retrieve components I've stored. The issue is when I try to access the array element as a reference it ends up having a memory ...
0
votes
0
answers
225
views
Unity ECS: Segmentation fault when creating a large number of entities
I wrote a simple test program that creates 100 entities per frame, each entity has a buffer, as follows:
void Execute(Entity projectileEntity, [ChunkIndexInQuery] int chunkIndex, ref LocalTransform ...
-2
votes
1
answer
55
views
Using Junit4 for game tests based on libgdx/ECS. Tests failing if executed together
Long story short: I am developing a small game with libgdx/ECS (Entity-Component-System) and had now mutiple times the issue that I changed the code and afterwards some other behavior was not working ...
1
vote
1
answer
456
views
This expression is not callable, Each members of the union
I have aligned my approach with my nearest current architecture, striving to minimize complexity as much as possible.
I have aimed for the closest approximation to a satisfactory result, but I ...
0
votes
0
answers
106
views
Trying to access gameobjects from other loaded scene
Basically, i have a player script in DontDestroyOnLoad(), and i have other gameobjects (enemies) that i want to access from the other loaded scene.
foreach(Enemy enemy in FindObjectsOfType<...
1
vote
0
answers
456
views
Unique Entity Types in an Archetype-based ECS
I am currently designing an Entity Component System (ECS) where each entity is of a unique type:
template <typename... ComponentTypes>
struct Entity
{
using Signature = std::tuple<...
0
votes
0
answers
373
views
How do I make a connection between an entity and a component in an ECS?
Recently I started learning about ECS and I decided to try and create a very basic implementation on my own. I made myself an enum with the component names and two basic components:
enum Components {
...
1
vote
0
answers
131
views
Would an ECS-specific programming language be helpful?
I've thought about creating a programming language specifically for developing ECS, but I do not have enough experience to conclude whether or not it would be useful at all or not. Can anyone give me ...
1
vote
1
answer
54
views
Is there any way to store reference of member object 'A' of a class inside another member object 'B' of the same class?
I can't access/modify the member object of wrapper class by another member object of the same class.
Basically, I have a transform object and collider object inside a gameobject and I wish to access ...
2
votes
0
answers
201
views
How can I have multiple forces act on an entity in Bevy?
I'm making a game in rust, in Bevy with Rapier2d physics. I want to apply forces to the entities from different functions (systems).
How is multiple external forces added to entities?
1
vote
1
answer
83
views
TypeScript: accept an array of different generics and return a merged type
I'm trying to figure out Entity Component System and for usability I need to be able to pass an array of different Component definitions and get a merged type as a result.
I'm trying to do this:
const ...
0
votes
1
answer
277
views
Why is this ECS benchmark not showing the expected performance improvements despite using CPU cache?
I am trying to implement an Entity Component System (ECS) in C# using structs or arrays, but the performance is not that much better than using classes and objects. Despite utilizing techniques such ...
1
vote
0
answers
54
views
Domain Logic in an Entity Component System
Where to put the domain logic in an Entity Component System?
For sure you will not put it onto the Entity (number) itself but you can implement it as method on the Component but also as Method on the ...
0
votes
1
answer
90
views
How to filter an array based on type parameters typeof
I want to write a simple entity component system.
class Component {
}
class Entity {
readonly components: Array<Component> = []
}
class T extends Component {}
class F extends Component {
...
0
votes
0
answers
134
views
Is there type system with subtype relation that support exclusive struct field?
TLDR:
Is there a type system which allows we to express a type (constraint/interface) I = NoField<'a'>, such that for all type T, if T <: I, then T is a struct and does not have a specific ...
1
vote
0
answers
440
views
Is there an easy method to use ECS for abilities?
I'm trying to use ECS in a project that has classes with different abilities and I'm curious to know how to implement that using ECS or if it's even a good idea to use ECS in the first place.
Note: ...
0
votes
2
answers
122
views
Pointer to Struct Value Memory Leak
I am designing an ECS and I have a struct that holds two values: an array of integers and a double pointer. I also have another structure that holds a pointer to the previous struct.
I'm able to ...
1
vote
1
answer
2k
views
Entt - Iterate over all the entities in Entt Entity Component System
I am adding Entt Ecs to my project
I wonder while iterating throughout the registry with Registry.each([&](auto EntityID)
Is there any chance we can get EntityID as entt:null?
If there is then I ...
0
votes
1
answer
105
views
A-Frame: Error when using tracked-controls-webxr
I am using the A-Frame watcher plugin to create the scene, I was creating two entities for left and right tracked-controls-webxr. When I start my dev server from webpack I get this error:
core:a-node:...
0
votes
0
answers
261
views
C++ make_unique() changing member attributes' values
I am developing a small game in SDL2 and am in the process of implementing a Quadtree for collision detection in the ECS I have written. The structure of my Quadtree class is similar to this one and ...
0
votes
2
answers
279
views
Single-data components in ECS with inheritance : downsides?
Let's say I have a component Position. This component has only one data, its... position. So it could be defined as this:
struct Position
{
Vector2 value;
};
But it's really redondant in access ...
1
vote
1
answer
302
views
Component System OnUpdate Running Unintentionally in Other Scenes (Including New Ones)
I have a class that inherits from ComponentSystem in ECS and for some reason the OnUpdate function is being called unintentionally in every scene. Even if I create a new blank scene, the loop is ...
1
vote
1
answer
1k
views
Unity ECS : System does not find entities
I am having a problem with Unity ECS. My system does not find my entity with its query. This is my setup : I am currently testing with just one entity, that is created by a prefab, using this function ...
0
votes
1
answer
415
views
Wrapper over a templated class with more than one template parameter pack
I'm writting a thin wrapper over a class from a third-party library.
My code looks like this:
template<typename TArg1, typename... TPack1, typename... TPack2>
class MyWrapper<TArg1, TPack1...,...
1
vote
0
answers
121
views
Why does modifying an array of primitives reduce its performance?
I am looking into the performance of object lookup vs array lookup for a particle system.
Each particle just has x, y values. I can either store these in an object, array, or two separate arrays, one ...
0
votes
1
answer
475
views
Multiple mutable queries with Legion ECS
I am using the Legion ECS and trying to use multiple mutable queries and running into some borrow checker constraints.
I basically want to update the state of components by comparing with all of the ...
1
vote
1
answer
270
views
How to get all derived classes from a base class in C++?
I'm implementing a game engine in C++ which uses an ECS (Entity-Component-System).
Each GameObject can have multiple Components (stored in GameObject's std::vector<Component*> _components).
I ...
0
votes
0
answers
460
views
How to implement systems in ECS pattern/is my implementation reasonable?
I'm currently working on a simple game/game engine in C++ that uses an Entity Component System design pattern (wanted to learn how they worked), where each entity is just an ID to link to it's ...
-1
votes
1
answer
236
views
I need resources to fully understand ECS design pattern
so I'm new to the game making world and I come from object oriented preceptive on things but I want learn every thing about entity component system pattern ,how it works ,how to draw the diagrams and ...
1
vote
2
answers
214
views
How do I create a class with reference member and vector of pointers?
I am fairly new to C++ and am working on a personal project. I want to create a vector<Entity*> entitities in C++ where each Entity object is unique. I have a class inside header Entity.h that I ...
0
votes
1
answer
310
views
C++ static allocation of associative map
I'm writing a shared library in C++ and have the (mostly educational) goal to have every bit of heap allocation done by the library to live in a single, contiguous block, allocated at initialization ...