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,5 +1,12 @@
|
||||
class IMICRTS
|
||||
class Spawner < Component
|
||||
attr_accessor :spawnpoint
|
||||
|
||||
def setup
|
||||
@spawnpoint = @parent.position.clone
|
||||
@spawnpoint.y += 64
|
||||
end
|
||||
|
||||
def tick(tick_id)
|
||||
item = @parent.component(:build_queue).queue.first
|
||||
|
||||
@@ -12,5 +19,15 @@ class IMICRTS
|
||||
item.completed = true
|
||||
@parent.director.schedule_order(IMICRTS::Order::BUILD_UNIT_COMPLETE, @parent.player.id, @parent.id)
|
||||
end
|
||||
|
||||
def on_order(type, order)
|
||||
case type
|
||||
when IMICRTS::Order::BUILD_UNIT_COMPLETE
|
||||
item = @parent.component(:build_queue).queue.shift
|
||||
|
||||
ent = @parent.director.spawn_entity(player_id: @parent.player.id, name: item.entity.name, position: @spawnpoint)
|
||||
ent.target = @parent.component(:waypoint).waypoint if @parent.component(:waypoint)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user