Orders are now de/serializable, and scheduleable, Entities now show a circle around themselves when selected and draw a line to their target

This commit is contained in:
2019-10-09 11:32:59 -05:00
parent 2a179ed935
commit d6615872ba
15 changed files with 246 additions and 33 deletions

View File

@@ -1,10 +1,12 @@
class IMICRTS
class Player
attr_reader :id, :name, :entities, :orders, :camera
attr_reader :id, :name, :color, :team, :entities, :orders, :camera
attr_reader :selected_entities
def initialize(id:, name: nil)
def initialize(id:, name: nil, color: Gosu::Color.rgb(rand(150..200), rand(100..200), rand(150..200)), team: nil)
@id = id
@name = name ? name : "Novice-#{id}"
@color = color
@team = team
@entities = []
@orders = []
@@ -17,6 +19,10 @@ class IMICRTS
def tick(tick_id)
end
def update
@entities.each(&:update)
end
def entity(id)
@entities.find { |ent| ent.id == id }
end
@@ -24,5 +30,16 @@ class IMICRTS
def next_entity_id
@current_entity_id += 1
end
class ScheduledOrder
attr_reader :tick_id, :serialized_order
def initialize(order_id, tick_id, serialized_order)
@order_id = order_id
@tick_id, @serialized_order = tick_id, serialized_order
raise ArgumentError, "Tick ID is nil!" unless @tick_id
raise ArgumentError, "Serialized order for #{Order.order_name(order_id)} is nil!" unless @serialized_order
end
end
end
end