protected override void process(Entity entity) { Position focusPosition = (Position)_PositionMapper.get(entity); CameraFocus focus = (CameraFocus)_CameraFocusMapper.get(entity); ViewPort cameraView = (ViewPort)_ViewportMapper.get(_Camera); Vector2 cPos = cameraView.getOrigin(); Vector2 center = cPos + cameraView.getDimensions() / 2; Vector2 fPos = focusPosition.Pos; float dist, radius; dist = Vector2.Distance(fPos, center); radius = focus.getFocusRadius(); if (dist > radius) { Vector2 vec = Vector2.Subtract(fPos, center); vec.Normalize(); cPos += Vector2.Multiply(vec, dist - radius); cameraView.setOrigin(cPos); } }