#ecuzzillo1106 any idea what is the meant
1 messages · Page 1 of 1 (latest)
i doubt anybody thought about it. it seems to me that you are using transform hierarchies in a rather unique way
i'm sort of curious about what your overall scheme is and why these things are in the hierarchy relationship they are
it looks like this basically.
What I want is to process all entities from System to each Planet and attach SharedComponent that matches system
So whole hierarchy of system will have same unique shared component that differs from other systems
I don't want to attach any components manually to each individual prefab
i'd say that's surprising in itself. how many entities are in a given system?
(i'm surprised you want each system to have entirely separate archetypes from every other system. i would think you would have things in common to process between different systems)
for the default scenario 😅
that's not a very big number
yeah, but add to it other systems
number of which is about to jump into around 50
ok, but having a unique shared component for each one means they cant' be batched together in a chunk
which slows everything down
why do you want to do that?
shared component is required for game logic
that separates
entities that coexist in same world
paste some of said logic?
private partial struct FillMapJob : IJob
{
[DeallocateOnJobCompletion] public NativeArray<ArchetypeChunk> chunks;
public NativeMultiHashMap<int, TargetData> map;
[ReadOnly] public EntityTypeHandle entityHandle;
[ReadOnly] public ComponentTypeHandle<LocalToWorld> ltwHandle;
[ReadOnly] public ComponentTypeHandle<StarNormal> starHandle;
public void Execute()
{
var count = 0;
foreach (var chunk in chunks)
{
count += chunk.Count;
}
map.Clear();
if (map.Capacity < count) map.Capacity = count;
foreach (var chunk in chunks)
{
var entities = chunk.GetNativeArray(entityHandle);
var ltws = chunk.GetNativeArray(ltwHandle);
var starID = chunk.GetNativeArray(starHandle)[0].systemID;
for (var i = 0; i < entities.Length; i++)
{
map.Add(starID, new TargetData { entity = entities[i], position = ltws[i].Position });
}
}
}
}
here I create hashmap of all potential targets for target finder
based of their system index
which is key in HashMap
so later AI can use that map to know
which objects exist in the same system
and which it can interact with
curious why is this not using ijobchunk?
legacy code, still haven't upgraded project past conversion
and starnormal is a shared component huh
no, it used to be a copy of it
but IComp
will be removed as soon as I finish migration
since there are unmanaged shared comps now
i wonder if you didnt' need the copy since the archetype knows the shared component index of all its shared components
which is unique for each unique shared component value
anyways, key point is how I add components to children of transforms
is there even a way to query through game objects like old conversion system?
i have no idea but i'm sorry to report that i think you are unique here, and moreover you are using transform hierarchies as a grouping system, which is definitely a bad pattern
true
which i agree is better
wait but hold on
this job you posted
that only runs at startup, right?
no, it's running every tick
do solar systems get stuff added and removed from them?
hmm
so here's my idea
the root of the solar system gets converted to some entity, let's call that the root entity
on that root entity, you can put a component with a list of all the system's targets
when you bake the parent, i bet it'll let you look at its gameobject transform children, and you can write down some ID of each of them
I already did similiar stuff trying to solve gameobject field reference
hmmm, not really
in BakingSystem, there's no access to game objects
at least, not that I know of
yeah, you can actually GetEntity
of any game object
in subscene
it'll be a valid entity
but you can't modify it's archetype in any way
but you dont' need to
if you just write it down in the collection on your parent object
yeah, that's what I'll have to do I guess
then when objects enter and leave the solar system, you modify that collection
overall it feels like it added one extra step to conversion, ngl
if previously you solved everything at once, now you make extra step by creating temporary baking components
so in general, my increasing opinion is that baking is just the best. can be painful up front, but the restrictions mean that it's much harder to destroy your iteration time
I understand doing ECS in runtime, but in baking...