{"action":"created","comment":{"url":"https://api.github.com/repos/polyfox/moon-packages/pulls/comments/35013703","id":35013703,"diff_hunk":"@@ -119,24 +96,127 @@ def get_component(entity, component_sym) # component is class here\n       # @param [Entity] entity\n       # @return [Array<Component>]  components\n       def get_components(entity)\n-        @components.each_with_object([]) do |a, r|\n-          (key, hash) = *a\n-          if d = hash[entity]\n-            r.push(d)\n+        @components.each_with_object([]) do |pair, acc|\n+          (_, entities) = *pair\n+          if comp = entities[entity]\n+            acc.push(comp)\n           end\n         end\n       end\n \n-      ##\n+      # Adds a component for the given entity\n+      #\n       # @param [Entity] entity\n       # @param [Component] component\n       def add_component(entity, component)\n-        component_sym = component.class.registered\n-        set_component(entity, component_sym, component)\n+        component_sym = component.symbol\n+        set_component entity, component_sym, component\n+      end\n+\n+      # Removes a component for an entity by symbol\n+      #\n+      # @param [Entity] entity\n+      # @param [Symbol] component_sym\n+      def remove_component_by_symbol(entity, component_sym)\n+        set_component entity, component_sym, nil\n+      end\n+\n+      # Removes a component\n+      #\n+      # @param [Entity] entity\n+      # @param [Component] component\n+      def remove_component(entity, component)\n+        remove_component_by_symbol(entity, component.symbol)\n+      end\n+\n+      # Removes all components associated with the entity\n+      #\n+      # @param [Entity] entity\n+      # @return [void]\n+      def remove_entity_components(entity)\n+        @components.each_pair do |comp, entities|\n+          entities.delete(entity)\n+        end\n+      end\n+\n+      # Adds an entity to the world\n+      #\n+      # @param [Entity] entity\n+      # @return [Entity] Returns the added entity\n+      private def add_entity(entity)\n+        @entities << entity\n+        on_entity_added entity\n+        entity\n+      end\n+\n+      # Retrieves an entity object by id\n+      #\n+      # @return [Entity, nil]\n+      def get_entity_by_id(id)\n+        @entities.find { |e| e.id == id }\n+      end\n+\n+      # @param [Entity] entity\n+      # @return [Entity, nil] returns the deleted entity, or nil if not found\n+      def remove_entity(entity)\n+        if e = @entities.delete(entity)\n+          remove_entity_components e\n+          on_entity_removed e\n+          e\n+        end\n+      end\n+\n+      # Removes an entity by id\n+      #\n+      # @param [String] id\n+      def remove_entity_by_id(id)\n+        remove_entity get_entity_by_id(id)\n+      end\n+\n+      # Adds a new Entity to the world, an optional prefab can be provided,\n+      # in which the entity will copy from.\n+      #\n+      # @param [Entity] prefab  an entity instance to generate from\n+      # @return [Entity] a new entity\n+      def spawn(prefab = nil)\n+        entity = Entity.new(self)\n+        entity.copy prefab if prefab","path":"lib/moon/packages/entity_system/world.rb","position":253,"original_position":253,"commit_id":"d22abfdcdffc345122c3b14ae51236fbd931ef5a","original_commit_id":"d22abfdcdffc345122c3b14ae51236fbd931ef5a","user":{"login":"archSeer","id":1372918,"avatar_url":"https://avatars.githubusercontent.com/u/1372918?v=3","gravatar_id":"","url":"https://api.github.com/users/archSeer","html_url":"https://github.com/archSeer","followers_url":"https://api.github.com/users/archSeer/followers","following_url":"https://api.github.com/users/archSeer/following{/other_user}","gists_url":"https://api.github.com/users/archSeer/gists{/gist_id}","starred_url":"https://api.github.com/users/archSeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archSeer/subscriptions","organizations_url":"https://api.github.com/users/archSeer/orgs","repos_url":"https://api.github.com/users/archSeer/repos","events_url":"https://api.github.com/users/archSeer/events{/privacy}","received_events_url":"https://api.github.com/users/archSeer/received_events","type":"User","site_admin":false},"body":"Behaves differently from the original?","created_at":"2015-07-20T16:25:50Z","updated_at":"2015-07-20T16:25:50Z","html_url":"https://github.com/polyfox/moon-packages/pull/2#discussion_r35013703","pull_request_url":"https://api.github.com/repos/polyfox/moon-packages/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/polyfox/moon-packages/pulls/comments/35013703"},"html":{"href":"https://github.com/polyfox/moon-packages/pull/2#discussion_r35013703"},"pull_request":{"href":"https://api.github.com/repos/polyfox/moon-packages/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/polyfox/moon-packages/pulls/2","id":40360193,"html_url":"https://github.com/polyfox/moon-packages/pull/2","diff_url":"https://github.com/polyfox/moon-packages/pull/2.diff","patch_url":"https://github.com/polyfox/moon-packages/pull/2.patch","issue_url":"https://api.github.com/repos/polyfox/moon-packages/issues/2","number":2,"state":"open","locked":false,"title":"Optimize","user":{"login":"IceDragon200","id":1649873,"avatar_url":"https://avatars.githubusercontent.com/u/1649873?v=3","gravatar_id":"","url":"https://api.github.com/users/IceDragon200","html_url":"https://github.com/IceDragon200","followers_url":"https://api.github.com/users/IceDragon200/followers","following_url":"https://api.github.com/users/IceDragon200/following{/other_user}","gists_url":"https://api.github.com/users/IceDragon200/gists{/gist_id}","starred_url":"https://api.github.com/users/IceDragon200/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IceDragon200/subscriptions","organizations_url":"https://api.github.com/users/IceDragon200/orgs","repos_url":"https://api.github.com/users/IceDragon200/repos","events_url":"https://api.github.com/users/IceDragon200/events{/privacy}","received_events_url":"https://api.github.com/users/IceDragon200/received_events","type":"User","site_admin":false},"body":"More like fix everything and anything that was broken or broke, *shrug*","created_at":"2015-07-20T14:53:10Z","updated_at":"2015-07-20T16:25:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f91428006e024afc97e7ee036dd04ed89b9fd844","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/polyfox/moon-packages/pulls/2/commits","review_comments_url":"https://api.github.com/repos/polyfox/moon-packages/pulls/2/comments","review_comment_url":"https://api.github.com/repos/polyfox/moon-packages/pulls/comments{/number}","comments_url":"https://api.github.com/repos/polyfox/moon-packages/issues/2/comments","statuses_url":"https://api.github.com/repos/polyfox/moon-packages/statuses/d22abfdcdffc345122c3b14ae51236fbd931ef5a","head":{"label":"polyfox:optimize","ref":"optimize","sha":"d22abfdcdffc345122c3b14ae51236fbd931ef5a","user":{"login":"polyfox","id":12349419,"avatar_url":"https://avatars.githubusercontent.com/u/12349419?v=3","gravatar_id":"","url":"https://api.github.com/users/polyfox","html_url":"https://github.com/polyfox","followers_url":"https://api.github.com/users/polyfox/followers","following_url":"https://api.github.com/users/polyfox/following{/other_user}","gists_url":"https://api.github.com/users/polyfox/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfox/subscriptions","organizations_url":"https://api.github.com/users/polyfox/orgs","repos_url":"https://api.github.com/users/polyfox/repos","events_url":"https://api.github.com/users/polyfox/events{/privacy}","received_events_url":"https://api.github.com/users/polyfox/received_events","type":"Organization","site_admin":false},"repo":{"id":24205072,"name":"moon-packages","full_name":"polyfox/moon-packages","owner":{"login":"polyfox","id":12349419,"avatar_url":"https://avatars.githubusercontent.com/u/12349419?v=3","gravatar_id":"","url":"https://api.github.com/users/polyfox","html_url":"https://github.com/polyfox","followers_url":"https://api.github.com/users/polyfox/followers","following_url":"https://api.github.com/users/polyfox/following{/other_user}","gists_url":"https://api.github.com/users/polyfox/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfox/subscriptions","organizations_url":"https://api.github.com/users/polyfox/orgs","repos_url":"https://api.github.com/users/polyfox/repos","events_url":"https://api.github.com/users/polyfox/events{/privacy}","received_events_url":"https://api.github.com/users/polyfox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/polyfox/moon-packages","description":"Scripts for the moon game engine","fork":false,"url":"https://api.github.com/repos/polyfox/moon-packages","forks_url":"https://api.github.com/repos/polyfox/moon-packages/forks","keys_url":"https://api.github.com/repos/polyfox/moon-packages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/polyfox/moon-packages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/polyfox/moon-packages/teams","hooks_url":"https://api.github.com/repos/polyfox/moon-packages/hooks","issue_events_url":"https://api.github.com/repos/polyfox/moon-packages/issues/events{/number}","events_url":"https://api.github.com/repos/polyfox/moon-packages/events","assignees_url":"https://api.github.com/repos/polyfox/moon-packages/assignees{/user}","branches_url":"https://api.github.com/repos/polyfox/moon-packages/branches{/branch}","tags_url":"https://api.github.com/repos/polyfox/moon-packages/tags","blobs_url":"https://api.github.com/repos/polyfox/moon-packages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/polyfox/moon-packages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/polyfox/moon-packages/git/refs{/sha}","trees_url":"https://api.github.com/repos/polyfox/moon-packages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/polyfox/moon-packages/statuses/{sha}","languages_url":"https://api.github.com/repos/polyfox/moon-packages/languages","stargazers_url":"https://api.github.com/repos/polyfox/moon-packages/stargazers","contributors_url":"https://api.github.com/repos/polyfox/moon-packages/contributors","subscribers_url":"https://api.github.com/repos/polyfox/moon-packages/subscribers","subscription_url":"https://api.github.com/repos/polyfox/moon-packages/subscription","commits_url":"https://api.github.com/repos/polyfox/moon-packages/commits{/sha}","git_commits_url":"https://api.github.com/repos/polyfox/moon-packages/git/commits{/sha}","comments_url":"https://api.github.com/repos/polyfox/moon-packages/comments{/number}","issue_comment_url":"https://api.github.com/repos/polyfox/moon-packages/issues/comments{/number}","contents_url":"https://api.github.com/repos/polyfox/moon-packages/contents/{+path}","compare_url":"https://api.github.com/repos/polyfox/moon-packages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/polyfox/moon-packages/merges","archive_url":"https://api.github.com/repos/polyfox/moon-packages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/polyfox/moon-packages/downloads","issues_url":"https://api.github.com/repos/polyfox/moon-packages/issues{/number}","pulls_url":"https://api.github.com/repos/polyfox/moon-packages/pulls{/number}","milestones_url":"https://api.github.com/repos/polyfox/moon-packages/milestones{/number}","notifications_url":"https://api.github.com/repos/polyfox/moon-packages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/polyfox/moon-packages/labels{/name}","releases_url":"https://api.github.com/repos/polyfox/moon-packages/releases{/id}","created_at":"2014-09-18T21:04:59Z","updated_at":"2015-05-08T20:01:20Z","pushed_at":"2015-07-20T14:53:10Z","git_url":"git://github.com/polyfox/moon-packages.git","ssh_url":"git@github.com:polyfox/moon-packages.git","clone_url":"https://github.com/polyfox/moon-packages.git","svn_url":"https://github.com/polyfox/moon-packages","homepage":null,"size":1300,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"polyfox:master","ref":"master","sha":"26223462c4d6447eacfdf80cfb8c47c7ef4620ad","user":{"login":"polyfox","id":12349419,"avatar_url":"https://avatars.githubusercontent.com/u/12349419?v=3","gravatar_id":"","url":"https://api.github.com/users/polyfox","html_url":"https://github.com/polyfox","followers_url":"https://api.github.com/users/polyfox/followers","following_url":"https://api.github.com/users/polyfox/following{/other_user}","gists_url":"https://api.github.com/users/polyfox/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfox/subscriptions","organizations_url":"https://api.github.com/users/polyfox/orgs","repos_url":"https://api.github.com/users/polyfox/repos","events_url":"https://api.github.com/users/polyfox/events{/privacy}","received_events_url":"https://api.github.com/users/polyfox/received_events","type":"Organization","site_admin":false},"repo":{"id":24205072,"name":"moon-packages","full_name":"polyfox/moon-packages","owner":{"login":"polyfox","id":12349419,"avatar_url":"https://avatars.githubusercontent.com/u/12349419?v=3","gravatar_id":"","url":"https://api.github.com/users/polyfox","html_url":"https://github.com/polyfox","followers_url":"https://api.github.com/users/polyfox/followers","following_url":"https://api.github.com/users/polyfox/following{/other_user}","gists_url":"https://api.github.com/users/polyfox/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfox/subscriptions","organizations_url":"https://api.github.com/users/polyfox/orgs","repos_url":"https://api.github.com/users/polyfox/repos","events_url":"https://api.github.com/users/polyfox/events{/privacy}","received_events_url":"https://api.github.com/users/polyfox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/polyfox/moon-packages","description":"Scripts for the moon game engine","fork":false,"url":"https://api.github.com/repos/polyfox/moon-packages","forks_url":"https://api.github.com/repos/polyfox/moon-packages/forks","keys_url":"https://api.github.com/repos/polyfox/moon-packages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/polyfox/moon-packages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/polyfox/moon-packages/teams","hooks_url":"https://api.github.com/repos/polyfox/moon-packages/hooks","issue_events_url":"https://api.github.com/repos/polyfox/moon-packages/issues/events{/number}","events_url":"https://api.github.com/repos/polyfox/moon-packages/events","assignees_url":"https://api.github.com/repos/polyfox/moon-packages/assignees{/user}","branches_url":"https://api.github.com/repos/polyfox/moon-packages/branches{/branch}","tags_url":"https://api.github.com/repos/polyfox/moon-packages/tags","blobs_url":"https://api.github.com/repos/polyfox/moon-packages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/polyfox/moon-packages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/polyfox/moon-packages/git/refs{/sha}","trees_url":"https://api.github.com/repos/polyfox/moon-packages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/polyfox/moon-packages/statuses/{sha}","languages_url":"https://api.github.com/repos/polyfox/moon-packages/languages","stargazers_url":"https://api.github.com/repos/polyfox/moon-packages/stargazers","contributors_url":"https://api.github.com/repos/polyfox/moon-packages/contributors","subscribers_url":"https://api.github.com/repos/polyfox/moon-packages/subscribers","subscription_url":"https://api.github.com/repos/polyfox/moon-packages/subscription","commits_url":"https://api.github.com/repos/polyfox/moon-packages/commits{/sha}","git_commits_url":"https://api.github.com/repos/polyfox/moon-packages/git/commits{/sha}","comments_url":"https://api.github.com/repos/polyfox/moon-packages/comments{/number}","issue_comment_url":"https://api.github.com/repos/polyfox/moon-packages/issues/comments{/number}","contents_url":"https://api.github.com/repos/polyfox/moon-packages/contents/{+path}","compare_url":"https://api.github.com/repos/polyfox/moon-packages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/polyfox/moon-packages/merges","archive_url":"https://api.github.com/repos/polyfox/moon-packages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/polyfox/moon-packages/downloads","issues_url":"https://api.github.com/repos/polyfox/moon-packages/issues{/number}","pulls_url":"https://api.github.com/repos/polyfox/moon-packages/pulls{/number}","milestones_url":"https://api.github.com/repos/polyfox/moon-packages/milestones{/number}","notifications_url":"https://api.github.com/repos/polyfox/moon-packages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/polyfox/moon-packages/labels{/name}","releases_url":"https://api.github.com/repos/polyfox/moon-packages/releases{/id}","created_at":"2014-09-18T21:04:59Z","updated_at":"2015-05-08T20:01:20Z","pushed_at":"2015-07-20T14:53:10Z","git_url":"git://github.com/polyfox/moon-packages.git","ssh_url":"git@github.com:polyfox/moon-packages.git","clone_url":"https://github.com/polyfox/moon-packages.git","svn_url":"https://github.com/polyfox/moon-packages","homepage":null,"size":1300,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/polyfox/moon-packages/pulls/2"},"html":{"href":"https://github.com/polyfox/moon-packages/pull/2"},"issue":{"href":"https://api.github.com/repos/polyfox/moon-packages/issues/2"},"comments":{"href":"https://api.github.com/repos/polyfox/moon-packages/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/polyfox/moon-packages/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/polyfox/moon-packages/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/polyfox/moon-packages/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/polyfox/moon-packages/statuses/d22abfdcdffc345122c3b14ae51236fbd931ef5a"}}}}