mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-16 00:02:33 +00:00
added on_order handler to entities and components, added visibility map
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
class IMICRTS
|
||||
class Player
|
||||
attr_reader :id, :name, :color, :team, :entities, :orders, :camera, :spawnpoint
|
||||
attr_reader :id, :name, :color, :team, :bot, :visiblity_map, :entities, :orders, :camera, :spawnpoint
|
||||
attr_reader :selected_entities
|
||||
def initialize(id:, spawnpoint:, name: nil, color: IMICRTS::TeamColors.values.sample, team: nil)
|
||||
|
||||
def initialize(id:, spawnpoint:, name: nil, color: IMICRTS::TeamColors.values.sample, team: nil, bot: false, visiblity_map:)
|
||||
@id = id
|
||||
@spawnpoint = spawnpoint
|
||||
@name = name ? name : "Novice-#{id}"
|
||||
@color = color
|
||||
@team = team
|
||||
@bot = bot
|
||||
@visiblity_map = visiblity_map
|
||||
|
||||
@entities = []
|
||||
@orders = []
|
||||
@@ -24,7 +27,7 @@ class IMICRTS
|
||||
@camera_moved = (@last_camera_position - @camera.position.clone).sum > @camera_move_threshold
|
||||
@last_camera_position = @camera.position.clone
|
||||
|
||||
@entities.each { |ent| ent.tick(tick_id) }
|
||||
@entities.each { |ent| ent.tick(tick_id); @visiblity_map.update(ent) }
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -45,6 +48,7 @@ class IMICRTS
|
||||
|
||||
class ScheduledOrder
|
||||
attr_reader :order_id, :tick_id, :serialized_order
|
||||
|
||||
def initialize(order_id, tick_id, serialized_order)
|
||||
@order_id = order_id
|
||||
@tick_id, @serialized_order = tick_id, serialized_order
|
||||
|
||||
Reference in New Issue
Block a user