Class: LZRTag::Map::Zone
- Inherits:
-
Object
- Object
- LZRTag::Map::Zone
- Defined in:
- lib/lzrtag/map/map_zone.rb
Instance Attribute Summary collapse
-
#centerPoint ⇒ Object
Returns the value of attribute centerPoint.
-
#coordinatesAsGPS ⇒ Object
Returns the value of attribute coordinatesAsGPS.
-
#data ⇒ Object
Returns the value of attribute data.
-
#polygon ⇒ Object
Returns the value of attribute polygon.
-
#radius ⇒ Object
Returns the value of attribute radius.
-
#style ⇒ Object
Returns the value of attribute style.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#teamMask ⇒ Object
Returns the value of attribute teamMask.
Class Method Summary collapse
Instance Method Summary collapse
- #affects_teams(teamList) ⇒ Object
- #ignores_teams(teamList) ⇒ Object
-
#initialize ⇒ Zone
constructor
A new instance of Zone.
- #inspect ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Zone
Returns a new instance of Zone.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lzrtag/map/map_zone.rb', line 17 def initialize() @centerPoint = [0, 0]; @radius = 0; @polygon = Array.new(); @coordinatesAsGPS = false; @teamMask = 255; @style = { color: "transparent", borderColor: "black" } @data = Hash.new(); end |
Instance Attribute Details
#centerPoint ⇒ Object
Returns the value of attribute centerPoint.
7 8 9 |
# File 'lib/lzrtag/map/map_zone.rb', line 7 def centerPoint @centerPoint end |
#coordinatesAsGPS ⇒ Object
Returns the value of attribute coordinatesAsGPS.
9 10 11 |
# File 'lib/lzrtag/map/map_zone.rb', line 9 def coordinatesAsGPS @coordinatesAsGPS end |
#data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/lzrtag/map/map_zone.rb', line 13 def data @data end |
#polygon ⇒ Object
Returns the value of attribute polygon.
8 9 10 |
# File 'lib/lzrtag/map/map_zone.rb', line 8 def polygon @polygon end |
#radius ⇒ Object
Returns the value of attribute radius.
7 8 9 |
# File 'lib/lzrtag/map/map_zone.rb', line 7 def radius @radius end |
#style ⇒ Object
Returns the value of attribute style.
15 16 17 |
# File 'lib/lzrtag/map/map_zone.rb', line 15 def style @style end |
#tag ⇒ Object
Returns the value of attribute tag.
5 6 7 |
# File 'lib/lzrtag/map/map_zone.rb', line 5 def tag @tag end |
#teamMask ⇒ Object
Returns the value of attribute teamMask.
11 12 13 |
# File 'lib/lzrtag/map/map_zone.rb', line 11 def teamMask @teamMask end |
Class Method Details
.from_raw_zone(rawZone) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/lzrtag/map/map_zone.rb', line 46 def self.from_raw_zone(rawZone) outZone = Zone.new(); outZone.tag = rawZone[:arguments]["tag"] || rawZone[:name]; outZone.polygon = rawZone[:polygon]; outZone.coordinatesAsGPS = true; if(rawZone[:style]) outZone.style = rawZone[:style]; end if(tMask = rawZone[:arguments]["teamMask"]) outZone.teamMask = tMask.to_i; rawZone[:arguments].delete "teamMask" end outZone.data = rawZone[:arguments]; return outZone end |
Instance Method Details
#affects_teams(teamList) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/lzrtag/map/map_zone.rb', line 33 def affects_teams(teamList) @teamMask = 0; [teamList].flatten.each do |t| @teamMask += (2<<t); end end |
#ignores_teams(teamList) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/lzrtag/map/map_zone.rb', line 39 def ignores_teams(teamList) @teamMask = 255; [teamList].flatten.each do |t| @teamMask -= (2<<t); end end |
#inspect ⇒ Object
90 91 92 |
# File 'lib/lzrtag/map/map_zone.rb', line 90 def inspect() return "#<Zone: #{to_h}>"; end |
#to_h ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/lzrtag/map/map_zone.rb', line 68 def to_h() outHash = Hash.new(); raise ArgumentError, "Tag needs to be set!" if(@tag.nil?); outHash[:tag] = @tag; outHash[:teamMask] = @teamMask; if(@radius > 0.1) outHash[:centerPoint] = @centerPoint; outHash[:radius] = @radius; else outHash[:polygon] = @polygon; end outHash[:coordinatesAsGPS] = @coordinatesAsGPS outHash[:style] = @style; outHash[:data] = @data; return outHash; end |