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:
2021-01-01 10:18:16 -06:00
parent 0b3897451e
commit 74458dbfd0
22 changed files with 200 additions and 36 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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})

View File

@@ -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

View File

@@ -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

View File

@@ -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