Class: Budgie::ChangeMap

Inherits:
Object
  • Object
show all
Defined in:
lib/budgie/change_map.rb

Instance Method Summary collapse

Constructor Details

#initialize(scene) ⇒ ChangeMap

Returns a new instance of ChangeMap.



3
4
5
6
7
8
9
# File 'lib/budgie/change_map.rb', line 3

def initialize(scene)
  @map = scene.map
  @palette = scene.palette
  @draw_map = scene.draw_map
  @selection = scene.selection
  @draw_picker_map = scene.draw_picker_map
end

Instance Method Details

#placeObject

Places a new block next to the selected one



12
13
14
15
16
17
18
19
# File 'lib/budgie/change_map.rb', line 12

def place
  s = @selection
  return unless s.selected

  @map[s.new_x, s.new_y, s.new_z] = @palette.index(s.r, s.g, s.b)
  @draw_map.update_partial s.new_x, s.new_y, s.new_z
  @draw_picker_map.update_partial s.new_x, s.new_y, s.new_z
end

#removeObject

Remove selected block from the map



32
33
34
35
36
37
38
39
# File 'lib/budgie/change_map.rb', line 32

def remove
  s = @selection
  return unless s.selected

  @map[s.x, s.y, s.z] = nil
  @draw_map.update_partial s.x, s.y, s.z
  @draw_picker_map.update_partial s.x, s.y, s.z
end

#replaceObject

Replaces selected block’s color



22
23
24
25
26
27
28
29
# File 'lib/budgie/change_map.rb', line 22

def replace
  s = @selection
  return unless s.selected

  @map[s.x, s.y, s.z] = @palette.index(s.r, s.g, s.b)
  @draw_map.update_partial s.x, s.y, s.z
  @draw_picker_map.update_partial s.x, s.y, s.z
end