-
How to change entity's archtype runtime? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Structural changes are in development right now :) till those are available i recommend to either emulate them or to implement them quickly by yourself. The fastest way is to simulate such changes by wrapping your removeable component into some sort of wrapper. public struct Enabled<T>{
public bool enabled;
public T component;
}
var archetype = new []{ typeof(Transform), typeof(Enabled<Hit>)};
var entity = world.Create(archetype);
ref var cmp = entity.Get<Enabled<Hit>>();
cmp.enabled = true;
world.Query(in query, (ref Transform t, ref Enabled<Hit> hit) => {
if(!hit.enabled) continue;
//Logic
}); You could also implement them yourself by getting the entities archetype and modifying that one. However real structural changes aswell as multithreaded queries will be available in the next few days, already in development :) |
Beta Was this translation helpful? Give feedback.
-
I recently updated Arch (https://github.com/genaray/Arch/releases/tag/1.0.13), now structural changes are implemented by default :) entity.Add<T>(new T());
entity.Remove<T>(); Check it out ! ^^ |
Beta Was this translation helpful? Give feedback.
I recently updated Arch (https://github.com/genaray/Arch/releases/tag/1.0.13), now structural changes are implemented by default :)
Check it out ! ^^