Created
October 21, 2018 00:18
-
-
Save clinuxrulz/cfd15d15701437a6240d24f95c278241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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