Class: Beefdump::Map::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/beefdump/map/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_data) ⇒ Object

Returns a new instance of Object.



6
7
8
9
10
# File 'lib/beefdump/map/object.rb', line 6

def initialize(object_data)
  load_object_attributes!(object_data)

  load_properties!(object_data["properties"])
end

Instance Attribute Details

#blueprintObject (readonly)

Returns the value of attribute blueprint.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def blueprint
  @blueprint
end

#heightObject (readonly)

Returns the value of attribute height.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def height
  @height
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def properties
  @properties
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def type
  @type
end

#widthObject (readonly)

Returns the value of attribute width.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



4
5
6
# File 'lib/beefdump/map/object.rb', line 4

def y
  @y
end

Instance Method Details

#is_at?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/beefdump/map/object.rb', line 12

def is_at?(x, y)
  self.x >= x && self.x + self.width <= x && self.y >= y && self.y + self.height <= y
end