mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-16 08:02:36 +00:00
Moved 'building' entity definitions into 'structures', renamed building component to structure, moved svgs the same.
This commit is contained in:
60
lib/entities/structures/construction_yard.rb
Normal file
60
lib/entities/structures/construction_yard.rb
Normal 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
|
||||
Reference in New Issue
Block a user