lib/demiurge.rb
# StateItems are transient and can be created, recreated or
# destroyed without warning. They need to be hooked up to the
# various Ruby code for their actions. The code for actions isn't
# serialized. Instead, each action is referred to by name, and the
# engine loads up all the item-name/action-name combinations when
# it reads the Ruby World Files. This means an action can be
# referred to by its name when serialized, but the actual code
# changes any time the world files are reloaded.
StateItems are transient and can be created, recreated or
destroyed without warning. They need to be hooked up to the
various Ruby code for their actions. The code for actions isn't
serialized. Instead, each action is referred to by name, and the
engine loads up all the item-name/action-name combinations when
it reads the Ruby World Files. This means an action can be
referred to by its name when serialized, but the actual code
changes any time the world files are reloaded.
StateItems are transient and can be created recreated or destroyed without warning . They need to be hooked up to the various Ruby code for their actions . The code for actions isn ' t serialized . Instead each action is referred to by name and the engine loads up all the item - name / action - name combinations when it reads the Ruby World Files . This means an action can be referred to by its name when serialized but the actual code changes any time the world files are reloaded .
def register_actions_by_item_and_action_name(item_actions)
      item_actions.each do |item_name, act_hash|
        if @item_actions[item_name]
          act_hash.each do |action_name, opts|
            existing = @item_actions[item_name][action_name]
            if existing
              ActionItem::ACTION_LEGAL_KEYS.each do |key|
                if existing[key] && opts[key] && existing[key] != opts[key]
                  raise "Can't register action #{action_name.inspect} for item #{item_name.inspect}, conflict for key #{key.inspect}!"
                end
              end
              existing.merge!(opts)
            else
              @item_actions[item_name][action_name] = opts
            end
          end
        else
          @item_actions[item_name] = act_hash
        end
      end
    end
def register_actions_by_item_and_action_name ( item_actions ) item_actions . each do | item_name , act_hash | if @item_actions [ item_name ] act_hash . each do | action_name , opts | existing = @item_actions [ item_name ] [ action_name ] if existing ActionItem :: ACTION_LEGAL_KEYS . each do | key | if existing [ key ] && opts [ key ] && existing [ key ] != opts [ key ] raise "Can't register action #{action_name.inspect} for item #{item_name.inspect}, conflict for key #{key.inspect}!" end end existing . merge! ( opts ) else @item_actions [ item_name ] [ action_name ] = opts end end else @item_actions [ item_name ] = act_hash end end end
StateItems are transient and can be created, recreated or
destroyed without warning.
StateItems are transient and can be created recreated or destroyed without warning .
item_actions