Extracted movement and turret into 'components' that entity get add to its self when defined

This commit is contained in:
2019-11-20 09:08:54 -06:00
parent 82db9dd14d
commit 2d70736753
8 changed files with 145 additions and 50 deletions

View File

@@ -1,4 +1,6 @@
IMICRTS::Entity.define_entity(:harvester, :unit, 1400, "Harvests ore") do |entity, director|
entity.has(:movement)
entity.radius = 10
entity.movement = :ground
entity.max_health = 100.0
@@ -28,7 +30,7 @@ IMICRTS::Entity.define_entity(:harvester, :unit, 1400, "Harvests ore") do |entit
entity.define_singleton_method(:seek_refinery) do
end
entity.define_singleton_method(:rotate_towards) do |target|
entity.component(:movement).define_singleton_method(:rotate_towards) do |target|
entity.angle = Gosu.angle(target.x, target.y, entity.position.x, entity.position.y)
end
end