diff --git a/AlgebraicDataflowArchitectureModel/models/GameEngine.model b/AlgebraicDataflowArchitectureModel/models/GameEngine.model index b8173e4..8d05235 100644 --- a/AlgebraicDataflowArchitectureModel/models/GameEngine.model +++ b/AlgebraicDataflowArchitectureModel/models/GameEngine.model @@ -11,15 +11,15 @@ } native channel CameraPositionUpdate { - in scene.camera.transform.position(curPos: Json, updatePosition(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} + in scene.camera.transform.position(curPos: Json, updatePosition(nextPos.x, nextPos.y, nextPos.z)) = nextPos } native channel CameraRotationUpdate { - in scene.camera.transform.rotation(curRot: Json, updateRotation(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} + in scene.camera.transform.rotation(curRot: Json, updateRotation(nextRot.x, nextRot.y, nextRot.z)) = nextRot } native channel CameraScaleUpdate { - in scene.camera.transform.scale(curScale: Json, updateScale(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} + in scene.camera.transform.scale(curScale: Json, updateScale(nextScale.x, nextScale.y, nextScale.z)) = nextScale } native channel CameraProjectionUpdate { @@ -27,17 +27,36 @@ } native channel EntityPositionUpdate(eid: Str) { - in scene.entities.{eid}.transform.position(curPos: Json, updatePosition(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} + in scene.entities.{eid}.transform.position(curPos: Json, updatePosition(nextPos.x, nextPos.y, nextPos.z)) = nextPos } native channel EntityRotationUpdate(eid: Str) { - in scene.entities.{eid}.transform.rotation(curRot: Json, updateRotation(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} + in scene.entities.{eid}.transform.rotation(curRot: Json, updateRotation(nextRot.x, nextRot.y, nextRot.z)) = nextRot } native channel EntityScaleUpdate(eid: Str) { - in scene.entities.{eid}.transform.scale(curScale: Json, updateScale(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} + in scene.entities.{eid}.transform.scale(curScale: Json, updateScale(nextScale.x, nextScale.y, nextScale.z)) = nextScale } native channel EntitySpriteUpdate(eid: Str) { in scene.entities.{eid}.mesh(curMesh: Json, updateSprite(spritePath: Str)) = {"type": "sprite", "sprite": spritePath} } + +channel AddSprite { + out scene.entities(entityDB: Map, addSprite(eid: Str, spritePath: Str)) = insert(entityDB, eid, { + "transform": { + "position": {"x": 0.0, "y": 0.0, "z": 0.0}, + "rotation": {"x": 0.0, "y": 0.0, "z": 0.0}, + "scale": {"x": 1.0, "y": 1.0, "z": 1.0} + }, + "mesh": {"type": "sprite", "sprite": spritePath} + }) +} + +channel MoveEntity(eid: Str) { + out scene.entities.{eid}.transform.position(curPos: Json, move(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} +} + +channel RotateEntity(eid: Str) { + out scene.entities.{eid}.transform.rotation(curRot: Json, rotate(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z} +}