Moved 'building' entity definitions into 'structures', renamed building component to structure, moved svgs the same.

This commit is contained in:
2021-01-15 11:05:57 -06:00
parent 36f79c6f57
commit e30d73d4d7
19 changed files with 29 additions and 29 deletions

View File

@@ -0,0 +1,24 @@
tiles = [
[false, false, false, false, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, :path, :path, :path, false],
]
IMICRTS::Entity.define_entity(:barracks, :structure, 400, 40, "Builds and heals soldiers", tiles) do |entity|
unless entity.proto_entity
entity.has(:structure)
entity.has(:waypoint)
entity.has(:spawner)
entity.has(:build_queue)
end
entity.radius = 44
entity.max_health = 100.0
entity.shell_image = "buildings/barracks/barracks.png"
entity.on_tick do
end
end

View File

@@ -0,0 +1,60 @@
tiles = [
[false, false, false, false, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, :path, :path, :path, false],
]
IMICRTS::Entity.define_entity(:construction_yard, :structure, 2_000, 310, "Provides radar and builds construction workers", tiles) do |entity|
unless entity.proto_entity
entity.has(:structure)
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 })
end
entity.radius = 40
entity.max_health = 100.0
entity.body_image = "buildings/construction_yard/construction_yard.png"
entity.shell_image = "buildings/construction_yard/construction_yard_shell.png"
entity.overlay_image = "buildings/construction_yard/construction_yard_overlay.png"
position = entity.position.clone
position.z = IMICRTS::ZOrder::OVERLAY
emitters = []
p1 = position.clone
p1.x -= 25
p1.y -= 8
p2 = p1.clone
p2.y += 25
p3 = position.clone
p3.x += 8
p3.y -= 15
p4 = p3.clone
p4.x += 21
emitters.push(p1, p2, p3, p4)
emitters.each do |pos|
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: pos, emitting: false)
end
entity.on_tick do
if entity.component(:structure).construction_complete?
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

@@ -0,0 +1,27 @@
tiles = [
[false, false, false, false, false],
[false, false, true, false, false],
[false, true, true, true, false],
[false, false, true, false, false],
[false, false, false, false, false],
]
IMICRTS::Entity.define_entity(:helipad, :structure, 1_000, 100, "Builds and rearms aircraft", tiles) do |entity|
unless entity.proto_entity
entity.has(:structure)
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 })
end
entity.radius = 26
entity.max_health = 100.0
entity.shell_image = "buildings/helipad/helipad_shell.png"
entity.overlay_image = "buildings/helipad/helipad_overlay.png"
entity.on_tick do
end
end

View File

@@ -0,0 +1,50 @@
tiles = [
[false, false, false, false, false],
[false, false, true, false, false],
[false, false, true, false, false],
[false, false, true, false, false],
[false, false, :path, false, false],
]
IMICRTS::Entity.define_entity(:power_plant, :structure, 800, 45, "Generates power", tiles) do |entity|
unless entity.proto_entity
entity.has(:structure)
end
entity.radius = 24
entity.max_health = 100.0
entity.body_image = "buildings/power_plant/power_plant.png"
entity.shell_image = "buildings/power_plant/power_plant_shell.png"
entity.overlay_image = "buildings/power_plant/power_plant_overlay.png"
position = entity.position.clone
position.z = IMICRTS::ZOrder::OVERLAY
emitters = []
p1 = position.clone
p1.y -= 14
p2 = p1.clone
p2.y += 40
emitters.push(p1, p2)
emitters.each do |pos|
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: pos, emitting: false)
end
entity.on_tick do
# entity.produce_power
if entity.component(:structure).construction_complete?
entity.particle_emitters.each do |emitter|
emitter.emitting = true
end
end
end
# define_singleton_method(:produce_power) do
# @player.power += 10
# end
end

View File

@@ -0,0 +1,38 @@
tiles = [
[false, false, false, false, false],
[false, true, true, false, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, false, :path, :path, false],
]
IMICRTS::Entity.define_entity(:refinery, :structure, 1_400, 200, "Generates credits", tiles) do |entity|
unless entity.proto_entity
entity.has(:structure)
end
entity.radius = 44
entity.max_health = 100.0
entity.body_image = "buildings/refinery/refinery.png"
entity.shell_image = "buildings/refinery/refinery_shell.png"
entity.overlay_image = "buildings/refinery/refinery_overlay.png"
position = entity.position.clone
position.z = IMICRTS::ZOrder::OVERLAY
p1 = position.clone
p1.x += 2
p1.y += 12
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1, emitting: false)
entity.on_tick do
if entity.component(:structure).data.state == :idle
entity.particle_emitters.each do |emitter|
emitter.emitting = true
end
end
end
end

View File

@@ -0,0 +1,48 @@
tiles = [
[false, false, false, false, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, true, true, true, false],
[false, :path, :path, :path, false],
]
IMICRTS::Entity.define_entity(:war_factory, :structure, 2_000, 310, "Builds and repairs ground vehicles", tiles) do |entity|
unless entity.proto_entity
entity.has(:structure)
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 })
entity.component(:sidebar_actions).add(:add_to_build_queue, { entity: :tank })
entity.component(:sidebar_actions).add(:add_to_build_queue, { entity: :harvester })
end
entity.radius = 48
entity.max_health = 100.0
entity.shell_image = "buildings/war_factory/war_factory_shell.png"
entity.overlay_image = "buildings/war_factory/war_factory_overlay.png"
position = entity.position.clone
position.z = IMICRTS::ZOrder::OVERLAY
p1 = position.clone
p1.x += 32
p1.y -= 9
p2 = p1.clone
p2.y += 31
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1, emitting: false)
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p2, emitting: false)
entity.on_tick do
if entity.component(:structure).construction_complete?
item = entity.component(:build_queue).queue.first
entity.particle_emitters.each do |pe|
pe.emitting = !!item
end
end
end
end