Revolutionary-Games / Thrive

The main repository for the development of the evolution game Thrive.
https://revolutionarygamesstudio.com/
Other
2.84k stars 503 forks source link

Editor cell speed calculation is incorrect when the layout is offset (with flagella) #2094

Open hhyyrylainen opened 3 years ago

hhyyrylainen commented 3 years ago

When placed normally speed is correct: img

When offset (which works as the hexes are repositioned when exiting the editor): img

So the speed calculation algorithm needs to be updated to take offset into account. In case it turns out to be too slow now, it'll need to be moved to run in a background task.

For reference the code the editor uses to calculate the speed is here: https://github.com/Revolutionary-Games/Thrive/blob/68f6dc2ae6cb8185241ce44335b8be3b0f43d97c/src/microbe_stage/editor/MicrobeEditor.cs#L764

hhyyrylainen commented 3 years ago

I think that this can be solved pretty easily by calculating the cell's center of mass in that CalculateSpeed method and then using that instead of 0,0. If we want to get fancy the editor could have a center of mass property that is calculated only whenever needed (similarly to the placed visuals that skip updating for each organelle in a multi organelle edit).

hhyyrylainen commented 2 years ago

There's a very closely related problem with the ATP calculation as that's also affected by the flagella position: https://github.com/Revolutionary-Games/Thrive/issues/3432

Oliveriver commented 2 years ago

Just tested this as I'm looking into fixing https://github.com/Revolutionary-Games/Thrive/issues/3432, and it appears this part of the issue was already fixed by https://github.com/Revolutionary-Games/Thrive/pull/2754. At least, I can't reproduce this issue anymore. No matter where I build a given cell, its speed is the same.

EDIT: Unless there's a flagellum at (0, 0), explained in that other issue.

hhyyrylainen commented 1 year ago

This issue might also be the root cause for: https://github.com/Revolutionary-Games/Thrive/issues/3552