Closed hhyyrylainen closed 3 months ago
I would give it intermediate or maybe even difficult label as cilia looks pretty much similiar to nucleus in terms of node structure and it's hard to find any code setting nucleus specifically different than other organelles. Most closely related code I found is: https://github.com/Revolutionary-Games/Thrive/blob/master/src/microbe_stage/systems/MicrobeVisualsSystem.cs#L362
Actually the problem might be that other cilia nodes aren't directly parented to the root node:
The magic is this (the attached script on the nucleus visuals scene root node):
(in the Nucleus.tscn scene)
As long as the scene structure is the same for cilia that will work, if different a new mode / script needs to be made that works like OrganelleMeshWithChildren but for cilia (perhaps a generic interface like IOrganelleMeshWithChildren could be added that other code uses to support both the nucleus and cilia).
Would setting GetChildren()
to include internal do?
Very likely not as those shouldn't be internal nodes, and as the hierarchy is so deep it shouldn't work as is.
I suggest making a new Interface IOrganelleMeshWithChildren that OrganelleMeshWithChildren implements and all outside code uses that interface instead of the edxplicit class. Then adding a new class OrganelleMeshWithExplicitChildren (also implementing the interface) that allows setting a list of node references / paths and then writing something like:
public void GetChildrenMaterials(List<ShaderMaterial> result, bool quiet = false)
{
bool found = false;
foreach (var node in MeshChildren /* you need to create this as an export property of list type */)
{
if (mesh.MaterialOverride is ShaderMaterial shaderMaterial)
{
result.Add(shaderMaterial);
found = true;
}
else
{
GD.PrintErr("Incorrect child mesh path set");
}
}
if (!found && !quiet)
GD.PrintErr("Could not find any child geometry instances to get materials from");
}
If it would have customizable list of nodes to change colour of, why not do it for nucleus too (Totally not excuse to not do interfaces)?
Well I mean it's probably slightly more efficient to not require a Export property to be set? Though I'm not sure if that's actually the case (compared to how long assigning a list export property takes). I would just leave the Nucleus code as-is as it works fine and doesn't require any external editor setup properties.
Problem is most likely the cilia not implementing the multipart organelle mesh approach. Should be just a case of looking at how that was done for the nucleus and duplicating that for the cilia so that it can let the colouring system to know all the parts of the model.