Added last 2 units, added sidebar actions and build queue components, entities can now have their build actions put on the sidebar

This commit is contained in:
2019-11-21 14:04:33 -06:00
parent 902e48d53a
commit cec0c45932
12 changed files with 107 additions and 8 deletions

View File

@@ -0,0 +1,27 @@
class IMICRTS
class SidebarActions < Component
Action = Struct.new(:label, :image, :description, :block)
attr_reader :actions
def initialize(parent:)
@parent = parent
@actions = []
end
def add(action, *args)
case action
when :add_to_build_queue
action = Action.new
ent = IMICRTS::Entity.get(args.first)
action.label = ent.name.to_s
action.description = "Cost: #{ent.cost}\n#{ent.description}"
action.block = proc { @parent.component(:build_queue).add(args.first) }
@actions << action
else
raise "Unhandled sidebar action: #{action.inspect}"
end
end
end
end