159 questions
0
votes
0
answers
57
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
110
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
100
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
93
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
146
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
74
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
68
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
50
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
64
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
101
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
50
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 ...
0
votes
0
answers
20
views
How to cast a unique_ptr of base class to template derived class?
I have a base class for components and a derived class for my ECS arch. I need to store different types of values so my derived class is a template class.
Base class & template derived class :
...
1
vote
1
answer
30
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
73
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
61
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
186
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
46
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
342
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
89
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
364
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
320
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
85
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
46
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
182
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
82
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
206
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
46
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
70
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
124
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
375
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
111
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
78
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
248
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
1
answer
240
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
268
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 ...
0
votes
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
379
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
119
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
432
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
211
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
418
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
81
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
203
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
274
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 ...
2
votes
2
answers
933
views
C++ How to cache a variable of template type T in a class?
Suppose that I have a Foo class like this, and I need many instances of it.
class Foo {
public:
Pool* bars; // a global list of bars, each may have a different type
template<typename T&...
2
votes
1
answer
786
views
Typescript variadic generic class, accepting a variable number of class objects which extend a common base?
I am trying to design an entity-component system in typescript. My goal is to create a variadic generic abstract System class that takes component classes as generic arguments.
The idea is that ...
0
votes
0
answers
1k
views
Creating a scene graph / hierarchy using an entity component system
I do not seem to find any good resources on how to organize entities from an ecs into a scene graph / hierarchical structure e.g. for a 3D editor.
Im talking about something like:
-root
-player
-...
1
vote
0
answers
292
views
How can I search for another entity inside a Specs system?
I've been playing around with Rust by following along with Roguelike Tutorial, and have started to branch out a bit in hopes of creating some kind of nature simulation.
In my simple POC, I'm trying to ...