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

18
lib/orders/camera_move.rb Normal file
View File

@@ -0,0 +1,18 @@
IMICRTS::Order.define_handler(IMICRTS::Order::CAMERA_MOVE, arguments: [:player_id, :x, :y, :zoom]) do |order, director|
director.player(order.player_id).camera.move_to(order.x, order.y, order.zoom)
end
IMICRTS::Order.define_serializer(IMICRTS::Order::CAMERA_MOVE) do |order, director|
# Order ID: char as C
# Player ID: char as C
# Position X/Y: Double as G
# Zoom: Double as G
[IMICRTS::Order::CAMERA_MOVE, order.player_id, order.x, order.y, order.zoom].pack("CCGGG")
end
IMICRTS::Order.define_deserializer(IMICRTS::Order::CAMERA_MOVE) do |string, director|
# Player ID | Camera X | Camera Y | Camera Zoom
# char | double | double | double
string.unpack("CGGG")
end