import * as RE from 'rogue-engine'; import RapierMovementController from './RapierMovementController.re'; import ShipCannonController from './ShipCannonController.re'; export default class PlayerPawnInput extends RE.Component { movementController:RapierMovementController cannonController:ShipCannonController awake() { } start() { this.object3d.traverse(obj => { const components = RE.getObjectComponents(obj); components.forEach(comp => { if (comp instanceof RapierMovementController) { this.movementController = comp } }); }); this.object3d.traverse(obj => { const components = RE.getObjectComponents(obj); components.forEach(comp => { if (comp instanceof ShipCannonController) { this.cannonController = comp } }); }); } update() { if (RE.Input.keyboard.getKeyPressed("KeyW")) { this.movementController.thrust = true } if (RE.Input.keyboard.getKeyPressed("KeyA")) { this.movementController.rotateLeft = true } if (RE.Input.keyboard.getKeyPressed("KeyS")) { this.movementController.brake = true } if (RE.Input.keyboard.getKeyPressed("KeyD")) { this.movementController.rotateRight = true } if(RE.Input.keyboard.getKeyDown("Space")) { this.cannonController.fireLeft = true this.cannonController.fireRight = true this.cannonController.fireForward = true } } } RE.registerComponent(PlayerPawnInput);