pub enum VmLocation {
  Ui { front: bool, layer: u32 },
  World { front: bool, layer: u32 },
}

impl VmLocation {
  pub fn new() -> Self {
    Self::World { front: false, layer: 0 }
  }
  pub fn new_ui() -> Self {
    Self::Ui {
      front: false,
      layer: 30,
    }
  }
  pub fn new_child(layer: u32) -> Self {
    Self::World { front: false, layer }
  }
  pub fn new_child_ui(layer: u32) -> Self {
    Self::Ui { front: false, layer }
  }
  pub fn new_front() -> Self {
    Self::World { front: true, layer: 0 }
  }
  pub fn new_ui_front() -> Self {
    Self::Ui { front: true, layer: 30 }
  }
  pub fn new_child_front(layer: u32) -> Self {
    Self::World { front: true, layer }
  }
  pub fn new_child_ui_front(layer: u32) -> Self {
    Self::Ui { front: true, layer }
  }

  pub fn layer(&self) -> u32 {
    match self {
      VmLocation::Ui { layer, .. } => *layer,
      VmLocation::World { layer, .. } => *layer,
    }
  }
}
