-- | Create a new environment for game module
newLambdaCubeEnv :: MonadAppHost t m => LambdaCubeOptions s -> m (LambdaCubeEnv t)
newLambdaCubeEnv opts = do
  pipelines <- liftIO $ newIORef mempty
  storages <- liftIO $ newIORef (0, mempty)
  order <- liftIO $ newIORef mempty
  return LambdaCubeEnv {
      lambdaEnvOptions     = opts { lambdaOptsNext = () }
    , lambdaEnvPipelines   = pipelines
    , lambdaEnvStorages    = storages
    , lambdaEnvRenderOrder = order
    }

-- | Update viewport size of all storages
newLambdaCubeEnv :: MonadAppHost t m => LambdaCubeOptions s -> m (LambdaCubeEnv t)
newLambdaCubeEnv opts = do
  pipelines <- liftIO $ newIORef mempty
  storages <- liftIO $ newIORef (0, mempty)
  order <- liftIO $ newIORef mempty
  return LambdaCubeEnv {
      lambdaEnvOptions     = opts { lambdaOptsNext = () }
    , lambdaEnvPipelines   = pipelines
    , lambdaEnvStorages    = storages
    , lambdaEnvRenderOrder = order
    }

-- | Update viewport size of all storages
newLambdaCubeEnv opts = do
  pipelines <- liftIO $ newIORef mempty
  storages <- liftIO $ newIORef (0, mempty)
  order <- liftIO $ newIORef mempty
  return LambdaCubeEnv {
      lambdaEnvOptions     = opts { lambdaOptsNext = () }
    , lambdaEnvPipelines   = pipelines
    , lambdaEnvStorages    = storages
    , lambdaEnvRenderOrder = order
    }

-- | Update viewport size of all storages