mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-16 00:02:33 +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:
@@ -8,6 +8,8 @@ tiles = [
|
||||
|
||||
IMICRTS::Entity.define_entity(:barracks, :building, 400, "Builds and soldiers", tiles) do |entity|
|
||||
entity.has(:building)
|
||||
entity.has(:waypoint)
|
||||
entity.has(:spawner)
|
||||
entity.has(:build_queue)
|
||||
|
||||
entity.radius = 44
|
||||
|
||||
@@ -8,6 +8,8 @@ tiles = [
|
||||
|
||||
IMICRTS::Entity.define_entity(:construction_yard, :building, 2_000, "Provides radar and builds construction workers", tiles) do |entity|
|
||||
entity.has(:building)
|
||||
entity.has(:waypoint)
|
||||
entity.has(:spawner)
|
||||
entity.has(:build_queue)
|
||||
entity.has(:sidebar_actions)
|
||||
entity.component(:sidebar_actions).add(:add_to_build_queue, {entity: :construction_worker})
|
||||
@@ -39,9 +41,18 @@ IMICRTS::Entity.define_entity(:construction_yard, :building, 2_000, "Provides ra
|
||||
|
||||
|
||||
emitters.each do |pos|
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: pos)
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: pos, emitting: false)
|
||||
end
|
||||
|
||||
entity.on_tick do
|
||||
|
||||
if entity.component(:building).data.state == :idle
|
||||
item = entity.component(:build_queue).queue.first
|
||||
|
||||
entity.particle_emitters.each_with_index do |emitter, i|
|
||||
emitter.emitting = true
|
||||
emitter.emitting = !!item if i < 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,8 @@ tiles = [
|
||||
|
||||
IMICRTS::Entity.define_entity(:helipad, :building, 1_000, "Builds and rearms helicopters", tiles) do |entity|
|
||||
entity.has(:building)
|
||||
entity.has(:waypoint)
|
||||
entity.has(:spawner)
|
||||
entity.has(:build_queue)
|
||||
entity.has(:sidebar_actions)
|
||||
entity.component(:sidebar_actions).add(:add_to_build_queue, {entity: :helicopter})
|
||||
|
||||
@@ -34,6 +34,13 @@ IMICRTS::Entity.define_entity(:power_plant, :building, 800, "Generates power", t
|
||||
|
||||
entity.on_tick do
|
||||
# entity.produce_power
|
||||
|
||||
if entity.component(:building).data.state == :idle
|
||||
|
||||
entity.particle_emitters.each do |emitter|
|
||||
emitter.emitting = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# define_singleton_method(:produce_power) do
|
||||
|
||||
@@ -23,8 +23,14 @@ IMICRTS::Entity.define_entity(:refinery, :building, 1_400, "Generates credits",
|
||||
p1.x += 2
|
||||
p1.y += 12
|
||||
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1)
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1, emitting: false)
|
||||
|
||||
entity.on_tick do
|
||||
if entity.component(:building).data.state == :idle
|
||||
|
||||
entity.particle_emitters.each do |emitter|
|
||||
emitter.emitting = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,8 @@ tiles = [
|
||||
|
||||
IMICRTS::Entity.define_entity(:war_factory, :building, 2_000, "Builds units", tiles) do |entity|
|
||||
entity.has(:building)
|
||||
entity.has(:waypoint)
|
||||
entity.has(:spawner)
|
||||
entity.has(:build_queue)
|
||||
entity.has(:sidebar_actions)
|
||||
entity.component(:sidebar_actions).add(:add_to_build_queue, {entity: :jeep})
|
||||
@@ -29,9 +31,14 @@ IMICRTS::Entity.define_entity(:war_factory, :building, 2_000, "Builds units", ti
|
||||
p2 = p1.clone
|
||||
p2.y += 31
|
||||
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1)
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p2)
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1, emitting: false)
|
||||
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p2, emitting: false)
|
||||
|
||||
entity.on_tick do
|
||||
item = entity.component(:build_queue).queue.first
|
||||
|
||||
entity.particle_emitters.each do |pe|
|
||||
pe.emitting = !!item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ IMICRTS::Entity.define_entity(:jeep, :unit, 400, "Attacks ground targets") do |e
|
||||
entity.max_health = 100.0
|
||||
|
||||
entity.body_image = "vehicles/jeep/jeep.png"
|
||||
entity.shell_image = "vehicles/jeep/tank_shell.png"
|
||||
entity.shell_image = "vehicles/jeep/jeep_shell.png"
|
||||
|
||||
entity.component(:turret).shell_image = "vehicles/jeep/jeep_turret_shell.png"
|
||||
entity.component(:turret).center.y = 0.3125
|
||||
|
||||
Reference in New Issue
Block a user