mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-14 07:12:34 +00:00
Stubbed Connection, added #next_entity_id to Player, made Director store and pass to Player the current_tick
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
class IMICRTS
|
||||
class Director
|
||||
attr_reader :current_tick
|
||||
def initialize(map:, players:, networking_mode: :virtual, tick_rate: 10)
|
||||
@map = map
|
||||
@players = players
|
||||
@connection = IMICRTS::Connection.new(director: self, mode: networking_mode)
|
||||
@networking_mode = networking_mode
|
||||
@tick_rate = tick_rate
|
||||
|
||||
@last_tick_at = Gosu.milliseconds
|
||||
@tick_time = 1000.0 / @tick_rate
|
||||
@current_tick = 0
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -15,11 +18,14 @@ class IMICRTS
|
||||
@last_tick_at = Gosu.milliseconds
|
||||
|
||||
tick
|
||||
@connection.update
|
||||
end
|
||||
end
|
||||
|
||||
def tick
|
||||
@players.each(&:tick)
|
||||
@players.each { |player| player.tick(@current_tick) }
|
||||
|
||||
@current_tick += 1
|
||||
end
|
||||
|
||||
def player(id)
|
||||
|
||||
Reference in New Issue
Block a user