Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static nz.sodium.Cell<Axes3D> watchEntityAxes(
nz.sodium.Cell<Option<EcsReadOnlySceneContext>> cSceneCtxOp,
nz.sodium.Stream<EcsSceneChanges> sSceneChanges,
int entityId
) {
return nz.sodium.Cell.switchC(watchEntityComponentOp(cSceneCtxOp, sSceneChanges, entityId, Axes3DComponent.ecsComponent).lift(
watchEntityComponentOp(cSceneCtxOp, sSceneChanges, entityId, ChildComponent.ecsComponent),
(Option<Axes3DComponent> axesOp, Option<ChildComponent> parentOp) -> {
Option<Integer> parentIdOp = parentOp.map(ChildComponent::parentId);
Axes3D localAxes = axesOp.map(Axes3DComponent::axes3D).orSome(Axes3D.identity);
if (parentIdOp.isNone()) {
return new sodium.Cell<>(localAxes);
} else {
int parentId = parentIdOp.some();
return watchEntityAxes(cSceneCtxOp, sSceneChanges, parentId).map(
(Axes3D parentAxes) ->
parentAxes.fromThisSpace(localAxes)
);
}
}
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.