Keep layer, and add it to the map if it is made.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(TerrainBody), | intent(inout) | :: | self | |||
| type(MapLayer), | intent(in) | :: | layer |
the layer as given |
subroutine add_layer(self, layer) type(TerrainBody), intent(inout) :: self type(MapLayer), intent(in) :: layer !! the layer as given type(MapLayer), allocatable :: tmp(:) if (.not. allocated(self%layers)) allocate(self%layers(4)) if (self%n_layers == size(self%layers)) then allocate(tmp(2 * self%n_layers)) tmp(1:self%n_layers) = self%layers(1:self%n_layers) call move_alloc(tmp, self%layers) end if self%n_layers = self%n_layers + 1 self%layers(self%n_layers) = layer if (c_associated(self%map)) call apply_layer(self, layer) end subroutine add_layer