class LZRTag::Map::Zone

Attributes

centerPoint[RW]
coordinatesAsGPS[RW]
data[RW]
polygon[RW]
radius[RW]
style[RW]
tag[RW]
teamMask[RW]

Public Class Methods

from_raw_zone(rawZone) click to toggle source
# 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
new() click to toggle source
# 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

Public Instance Methods

affects_teams(teamList) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/lzrtag/map/map_zone.rb, line 90
def inspect()
        return "#<Zone: #{to_h}>";
end
to_h() click to toggle source
# 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