Skip to content

Instantly share code, notes, and snippets.

@clinuxrulz
Created October 21, 2018 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clinuxrulz/cfd15d15701437a6240d24f95c278241 to your computer and use it in GitHub Desktop.
Save clinuxrulz/cfd15d15701437a6240d24f95c278241 to your computer and use it in GitHub Desktop.
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