mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-15 15:52:34 +00:00
Added spawner and waypoint components, added building_set_waypoint order, particle emitters can now toggle their emission, buildings can now build and spawn units, buildings now dynamically emit smoke when working and no longer when building, added player2 to default game for testing.
This commit is contained in:
23
lib/components/spawner.rb
Normal file
23
lib/components/spawner.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class IMICRTS
|
||||
class Spawner < Component
|
||||
def tick(tick_id)
|
||||
# TODO: Ensure that a build order is created before working on entity
|
||||
|
||||
item = @parent.component(:build_queue).queue.first
|
||||
|
||||
if item
|
||||
item.progress += 1
|
||||
|
||||
if item.progress >= 100 # TODO: Define work units required for construction
|
||||
@parent.component(:build_queue).queue.shift
|
||||
|
||||
spawn_point = @parent.position.clone
|
||||
spawn_point.y += 96 # TODO: Use one of entity's reserved tiles for spawning
|
||||
|
||||
ent = @parent.director.spawn_entity(player_id: @parent.player.id, name: item.entity.name, position: spawn_point)
|
||||
ent.target = @parent.component(:waypoint).waypoint if @parent.component(:waypoint)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user