chione 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a4db53fed99c571b08d2413fc895bc32eef38194
4
+ data.tar.gz: 17972162d89c66ebc0d4e1f35aa2af2c667c6437
5
+ SHA512:
6
+ metadata.gz: e0e7538d0a928b90104586a5d70ee46068c2d8b8999b940e40a0f342720ec33c8f3407eea3a9baab2ae244330314175438a4975c32e3ba0486f09522a5c5d09b
7
+ data.tar.gz: 8af6a0b44089392eee195ea85fbdc57a9bc9f69f3b5cab431a7321185a1afcc84ce7d99a304a9c7f9de12f74c49a9da182912a70f42968ae6ce60e11723274b5
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/.gemtest ADDED
File without changes
data/.rdoc_options ADDED
@@ -0,0 +1,22 @@
1
+ --- !ruby/object:RDoc::Options
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include:
5
+ - "."
6
+ charset: UTF-8
7
+ exclude:
8
+ hyperlink_all: false
9
+ line_numbers: true
10
+ locale:
11
+ locale_dir: locale
12
+ locale_name:
13
+ main_page:
14
+ markup: markdown
15
+ output_decoration: true
16
+ page_dir:
17
+ show_hash: true
18
+ tab_width: 4
19
+ template_stylesheets: []
20
+ title:
21
+ visibility: :protected
22
+ webcvs:
data/.simplecov ADDED
@@ -0,0 +1,14 @@
1
+ # Simplecov config
2
+
3
+ SimpleCov.start do
4
+ add_filter 'spec'
5
+ add_filter 'integration'
6
+ add_group "Needing tests" do |file|
7
+ file.covered_percent < 90
8
+ end
9
+
10
+ if ENV['CIRCLE_ARTIFACTS']
11
+ dir = ENV['CIRCLE_ARTIFACTS'] + "/coverage"
12
+ coverage_dir( dir )
13
+ end
14
+ end
data/ChangeLog ADDED
@@ -0,0 +1,114 @@
1
+ 2015-07-13 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * lib/chione/behaviors.rb:
4
+ Add a shared-behaviors collection
5
+ [5ac263b85052] [github/master, tip]
6
+
7
+ * lib/chione/world.rb, spec/chione/world_spec.rb:
8
+ Add support for more than one GameWorld callback per event pattern
9
+ [bd5d3d7c9a25]
10
+
11
+ * lib/chione/entity.rb, spec/chione/entity_spec.rb:
12
+ Add an error-checking method for fetching components from entities
13
+ [e05eecf441a9]
14
+
15
+ 2015-07-06 Michael Granger <ged@FaerieMUD.org>
16
+
17
+ * lib/chione/world.rb, spec/chione/world_spec.rb:
18
+ Send the System or Manager class instead of its name in added events
19
+ [8b8c61d98bbe]
20
+
21
+ 2015-07-03 Michael Granger <ged@FaerieMUD.org>
22
+
23
+ * Manifest.txt, chione.gemspec, circle.yml:
24
+ Switch to Semaphore CI.
25
+ [0c557d993116]
26
+
27
+ * README.md:
28
+ Add some ECS resources to the README
29
+ [e52690bee302]
30
+
31
+ 2015-07-02 Michael Granger <ged@FaerieMUD.org>
32
+
33
+ * .simplecov:
34
+ Trying a different coverage artifact path
35
+ [4608ebd79e6d]
36
+
37
+ * .simplecov, circle.yml:
38
+ Attempting to get coverage artifacts working
39
+ [645d40b6661d]
40
+
41
+ * spec/chione/world_spec.rb:
42
+ Fix some world specs
43
+ [4a0c788679d9]
44
+
45
+ * .circle.yml, circle.yml:
46
+ Rename .circle.yml to circle.yml. Ugh.
47
+ [b601a62a3282]
48
+
49
+ * Rakefile:
50
+ Add `test` alias for `spec` task
51
+ [1bc69f3c5f84]
52
+
53
+ * .circle.yml:
54
+ Trying out circleci for CI
55
+ [ddf85c924542]
56
+
57
+ * lib/chione/world.rb, spec/chione/world_spec.rb:
58
+ Start Systems and Managers added to running worlds.
59
+ [413fa0a7e63b]
60
+
61
+ 2015-06-26 Michael Granger <ged@FaerieMUD.org>
62
+
63
+ * lib/chione/manager.rb, lib/chione/system.rb, lib/chione/world.rb,
64
+ spec/chione/world_spec.rb:
65
+ Add system/manager start/stop to the World, distinguish between
66
+ #started? and #running?
67
+ [4e8b849d2465]
68
+
69
+ 2015-06-24 Michael Granger <ged@FaerieMUD.org>
70
+
71
+ * Rakefile, chione.gemspec:
72
+ Fix version of fivefish generator
73
+ [c6e04d3d5e33]
74
+
75
+ * lib/chione/manager.rb, lib/chione/system.rb, lib/chione/world.rb,
76
+ spec/chione/world_spec.rb:
77
+ Allow systems/managers to be created with args, start them if added
78
+ when the world is already running
79
+ [38215d3ce09a]
80
+
81
+ * .rdoc_options, Rakefile:
82
+ Include .md files in docs generation
83
+ [6f5aae40418c]
84
+
85
+ * README.md:
86
+ Fix up the README formatting
87
+ [eaf39049bdba]
88
+
89
+ 2015-06-23 Michael Granger <ged@FaerieMUD.org>
90
+
91
+ * History.md, History.rdoc, Manifest.txt, README.md, README.rdoc,
92
+ Rakefile:
93
+ Convert README and History to markdown
94
+ [b2b9437fce76]
95
+
96
+ 2015-06-22 Michael Granger <ged@FaerieMUD.org>
97
+
98
+ * .travis.yml, Gemfile, History.rdoc, Manifest.txt, README.rdoc,
99
+ Rakefile, cert/ged.pem, chione.gemspec:
100
+ Update build system stuff.
101
+ [89e6682e9be9]
102
+
103
+ * .gems, .hgignore, .pryrc, .rvmrc, .simplecov, .tm_properties,
104
+ History.rdoc, Manifest.txt, README.rdoc, Rakefile, experiments
105
+ /fnmatch-vs-regex.rb, lib/chione.rb, lib/chione/aspect.rb,
106
+ lib/chione/assemblage.rb, lib/chione/component.rb,
107
+ lib/chione/entity.rb, lib/chione/manager.rb, lib/chione/mixins.rb,
108
+ lib/chione/system.rb, lib/chione/world.rb,
109
+ spec/chione/aspect_spec.rb, spec/chione/assemblage_spec.rb,
110
+ spec/chione/component_spec.rb, spec/chione/entity_spec.rb,
111
+ spec/chione/manager_spec.rb, spec/chione/system_spec.rb,
112
+ spec/chione/world_spec.rb, spec/chione_spec.rb, spec/spec_helper.rb:
113
+ Initial implementation
114
+ [a566bf207cc5]
data/History.rdoc ADDED
@@ -0,0 +1,9 @@
1
+ == v0.0.2 [2015-07-13] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Fix a couple of build problems.
4
+
5
+
6
+ == v0.0.1 (unreleased) [2015-07-13] Michael Granger <ged@FaerieMUD.org>
7
+
8
+ Initial release.
9
+
data/Manifest.txt ADDED
@@ -0,0 +1,27 @@
1
+ .rdoc_options
2
+ .simplecov
3
+ ChangeLog
4
+ History.rdoc
5
+ Manifest.txt
6
+ README.rdoc
7
+ Rakefile
8
+ lib/chione.rb
9
+ lib/chione/aspect.rb
10
+ lib/chione/assemblage.rb
11
+ lib/chione/behaviors.rb
12
+ lib/chione/component.rb
13
+ lib/chione/entity.rb
14
+ lib/chione/manager.rb
15
+ lib/chione/mixins.rb
16
+ lib/chione/system.rb
17
+ lib/chione/world.rb
18
+ spec/chione/aspect_spec.rb
19
+ spec/chione/assemblage_spec.rb
20
+ spec/chione/component_spec.rb
21
+ spec/chione/entity_spec.rb
22
+ spec/chione/manager_spec.rb
23
+ spec/chione/mixins_spec.rb
24
+ spec/chione/system_spec.rb
25
+ spec/chione/world_spec.rb
26
+ spec/chione_spec.rb
27
+ spec/spec_helper.rb
data/README.rdoc ADDED
@@ -0,0 +1,96 @@
1
+ = Chione
2
+
3
+ home :: http://faelidth.org/chione
4
+ code :: http://bitbucket.org/ged/chione
5
+ github :: http://github.com/ged/chione
6
+ docs :: http://faelidth.org/chione/docs
7
+
8
+
9
+ == Description
10
+
11
+ An Entity/Component System framework inspired by Artemis.
12
+
13
+ This library is still experimental. I am writing it by extracting out ideas from
14
+ a multi-user game I'm working on, and things may change radically if I find
15
+ that parts of it don't work or could be done a better way.
16
+
17
+ That said, let me know if you're using it for anything and I'll try to keep
18
+ you abreast of any changes I'm considering, and I'm happy to chat about ideas
19
+ for making it better via email or the project's Gitter channel:
20
+
21
+ {rdoc-image:https://badges.gitter.im/Join%20Chat.svg}[https://gitter.im/ged/chione]
22
+
23
+
24
+
25
+ == Prerequisites
26
+
27
+ * Ruby 2.2
28
+
29
+
30
+ == Installation
31
+
32
+ $ gem install chione
33
+
34
+
35
+ == Resources
36
+
37
+ Articles/posts on ECS:
38
+
39
+ * http://gameprogrammingpatterns.com/component.html
40
+ * http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/
41
+ * http://www.richardlord.net/blog/what-is-an-entity-framework
42
+ * http://www.richardlord.net/blog/why-use-an-entity-framework
43
+ * http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/
44
+
45
+ Other ECS Frameworks:
46
+
47
+ * https://github.com/junkdog/artemis-odb (Java)
48
+ * https://github.com/libgdx/ashley (Java)
49
+ * http://www.ashframework.org/ (ActionScript)
50
+
51
+
52
+ == Contributing
53
+
54
+ You can check out the current development source with Mercurial via its
55
+ {project page}[http://bitbucket.org/ged/chione]. Or if you prefer Git, via
56
+ {its Github mirror}[https://github.com/ged/chione].
57
+
58
+ After checking out the source, run:
59
+
60
+ $ rake newb
61
+
62
+ This task will install any missing dependencies, run the tests/specs,
63
+ and generate the API documentation.
64
+
65
+
66
+ == License
67
+
68
+ Copyright (c) 2015, Michael Granger
69
+ All rights reserved.
70
+
71
+ Redistribution and use in source and binary forms, with or without
72
+ modification, are permitted provided that the following conditions are met:
73
+
74
+ * Redistributions of source code must retain the above copyright notice,
75
+ this list of conditions and the following disclaimer.
76
+
77
+ * Redistributions in binary form must reproduce the above copyright notice,
78
+ this list of conditions and the following disclaimer in the documentation
79
+ and/or other materials provided with the distribution.
80
+
81
+ * Neither the name of the author/s, nor the names of the project's
82
+ contributors may be used to endorse or promote products derived from this
83
+ software without specific prior written permission.
84
+
85
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
86
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
87
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
89
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
90
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
91
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
92
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
93
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
94
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95
+
96
+
data/Rakefile ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rake/clean'
4
+
5
+ begin
6
+ require 'hoe'
7
+ rescue LoadError
8
+ abort "This Rakefile requires 'hoe' (gem install hoe)"
9
+ end
10
+
11
+ GEMSPEC = 'chione.gemspec'
12
+
13
+
14
+ Hoe.plugin :mercurial
15
+ Hoe.plugin :signing
16
+ Hoe.plugin :deveiate
17
+
18
+ Hoe.plugins.delete :rubyforge
19
+
20
+ hoespec = Hoe.spec 'chione' do |spec|
21
+ spec.readme_file = 'README.rdoc'
22
+ spec.history_file = 'History.rdoc'
23
+ spec.license 'BSD'
24
+
25
+ spec.developer 'Michael Granger', 'ged@FaerieMUD.org'
26
+
27
+ spec.dependency 'loggability', '~> 0.11'
28
+ spec.dependency 'configurability', '~> 2.2'
29
+ spec.dependency 'uuid', '~> 2.3'
30
+
31
+ spec.dependency 'hoe-deveiate', '~> 0.3', :developer
32
+ spec.dependency 'simplecov', '~> 0.7', :developer
33
+ spec.dependency 'rdoc-generator-fivefish', '~> 0.1', :developer
34
+
35
+ spec.require_ruby_version( '>=2.2.1' )
36
+ spec.hg_sign_tags = true if spec.respond_to?( :hg_sign_tags= )
37
+ spec.check_history_on_release = true if spec.respond_to?( :check_history_on_release= )
38
+
39
+ spec.rdoc_locations << "yhaliwell:/usr/local/www/public/chione/docs"
40
+ end
41
+
42
+
43
+
44
+ ENV['VERSION'] ||= hoespec.spec.version.to_s
45
+
46
+ # Ensure the specs pass before checking in
47
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :gemspec, :spec ]
48
+
49
+ task :test => :spec
50
+
51
+ # Rebuild the ChangeLog immediately before release
52
+ task :prerelease => 'ChangeLog'
53
+ CLOBBER.include( 'ChangeLog' )
54
+
55
+ desc "Build a coverage report"
56
+ task :coverage do
57
+ ENV["COVERAGE"] = 'yes'
58
+ Rake::Task[:spec].invoke
59
+ end
60
+ CLOBBER.include( 'coverage' )
61
+
62
+
63
+ # Use the fivefish formatter for docs generated from development checkout
64
+ if File.directory?( '.hg' )
65
+ require 'rdoc/task'
66
+
67
+ Rake::Task[ 'docs' ].clear
68
+ RDoc::Task.new( 'docs' ) do |rdoc|
69
+ rdoc.main = "README.rdoc"
70
+ rdoc.markup = 'markdown'
71
+ rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
72
+ rdoc.generator = :fivefish
73
+ rdoc.title = 'Chione'
74
+ rdoc.rdoc_dir = 'doc'
75
+ end
76
+ end
77
+
78
+
79
+ task :gemspec => GEMSPEC
80
+ file GEMSPEC => __FILE__
81
+ task GEMSPEC do |task|
82
+ spec = $hoespec.spec
83
+ spec.files.delete( '.gemtest' )
84
+ spec.signing_key = nil
85
+ spec.cert_chain = ['certs/ged.pem']
86
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
87
+ File.open( task.name, 'w' ) do |fh|
88
+ fh.write( spec.to_ruby )
89
+ end
90
+ end
91
+
92
+ CLOBBER.include( GEMSPEC.to_s )
data/lib/chione.rb ADDED
@@ -0,0 +1,37 @@
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
3
+
4
+ require 'uuid'
5
+ require 'loggability'
6
+
7
+ # An Entity/Component System inspired by Artemis
8
+ module Chione
9
+ extend Loggability
10
+
11
+ # Loggability API -- set up a log host
12
+ log_as :chione
13
+
14
+
15
+ # Gem version
16
+ VERSION = '0.0.2'
17
+
18
+
19
+ require 'chione/mixins'
20
+
21
+ autoload :Aspect, 'chione/aspect'
22
+ autoload :Assemblage, 'chione/assemblage'
23
+ autoload :Component, 'chione/component'
24
+ autoload :Entity, 'chione/entity'
25
+ autoload :Manager, 'chione/manager'
26
+ autoload :System, 'chione/system'
27
+ autoload :World, 'chione/world'
28
+
29
+ ##
30
+ # The global UUID object for generating new UUIDs
31
+ class << self; attr_reader :uuid ; end
32
+ @uuid = UUID.new
33
+
34
+ end # module Chione
35
+
36
+ # vim: set nosta noet ts=4 sw=4:
37
+
@@ -0,0 +1,163 @@
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
3
+
4
+ require 'set'
5
+ require 'loggability'
6
+
7
+ require 'chione' unless defined?( Chione )
8
+
9
+
10
+ # An expression of component-matching criteria used to find entities that should be
11
+ # processed by a System.
12
+ class Chione::Aspect
13
+ extend Loggability
14
+
15
+
16
+ # Loggability API -- log to the chione logger
17
+ log_to :chione
18
+
19
+
20
+ ### Return a new Aspect that will match entities with at least one of the specified
21
+ ### +component_types+.
22
+ def self::with_one_of( *component_types )
23
+ return self.new( one_of: component_types.flatten )
24
+ end
25
+
26
+
27
+ ### Return a new Aspect that will match entities with all of the specified
28
+ ### +component_types+.
29
+ def self::with_all_of( *component_types )
30
+ return self.new( all_of: component_types.flatten )
31
+ end
32
+
33
+
34
+ ### Return a new Aspect that will match entities with none of the specified
35
+ ### +component_types+.
36
+ def self::with_none_of( *component_types )
37
+ return self.new( none_of: component_types.flatten )
38
+ end
39
+
40
+
41
+ ### Create a new empty Aspect
42
+ def initialize( one_of: [], all_of: [], none_of: [] )
43
+ @one_of = Set.new( one_of )
44
+ @all_of = Set.new( all_of )
45
+ @none_of = Set.new( none_of )
46
+ end
47
+
48
+
49
+ ### Copy constructor.
50
+ def initialize_copy( other )
51
+ super
52
+ @one_of = @one_of.dup
53
+ @all_of = @all_of.dup
54
+ @none_of = @none_of.dup
55
+ end
56
+
57
+
58
+ ######
59
+ public
60
+ ######
61
+
62
+ # The Set of component types which matching entities must have at least one of.
63
+ attr_reader :one_of
64
+
65
+ # The Set of component types which matching entities must have all of.
66
+ attr_reader :all_of
67
+
68
+ # The Set of component types which matching entities must not have any of.
69
+ attr_reader :none_of
70
+
71
+
72
+ ### Return a dup of this Aspect that also requires that matching entities have at least
73
+ ### one of the given +component_types+.
74
+ def with_one_of( *component_types )
75
+ return self.dup_with( one_of: component_types.flatten )
76
+ end
77
+ alias_method :and_one_of, :with_one_of
78
+
79
+
80
+ ### Return a dup of this Aspect that also requires that matching entities have all
81
+ ### of the given +component_types+.
82
+ def with_all_of( *component_types )
83
+ return self.dup_with( all_of: component_types.flatten )
84
+ end
85
+ alias_method :and_all_of, :with_all_of
86
+
87
+
88
+ ### Return a dup of this Aspect that also requires that matching entities have none
89
+ ### of the given +component_types+.
90
+ def with_none_of( *component_types )
91
+ return self.dup_with( none_of: component_types.flatten )
92
+ end
93
+ alias_method :and_none_of, :with_none_of
94
+
95
+
96
+ ### Returns true if the receiver is an empty aspect, i.e., matches all entities.
97
+ def empty?
98
+ return [ self.one_of, self.all_of, self.none_of ].all?( &:empty? )
99
+ end
100
+
101
+
102
+ ### Return a human-readable String representation of the Aspect.
103
+ def inspect
104
+ parts = []
105
+ parts << self.one_of_description
106
+ parts << self.all_of_description
107
+ parts << self.none_of_description
108
+ parts.compact!
109
+
110
+ str = "#<%p:%#0x matching entities" % [ self.class, self.object_id * 2 ]
111
+ if parts.empty?
112
+ str << " with any components"
113
+ else
114
+ str << parts.join( ', ' )
115
+ end
116
+ str << ">"
117
+
118
+ return str
119
+ end
120
+
121
+
122
+ #########
123
+ protected
124
+ #########
125
+
126
+ ### Return a String describing the components matching entities must have at
127
+ ### least one of.
128
+ def one_of_description
129
+ return nil if self.one_of.empty?
130
+ return " with at least one of: %s" % [ self.one_of.map(&:name).join(', ') ]
131
+ end
132
+
133
+
134
+ ### Return a String describing the components matching entities must have all of.
135
+ def all_of_description
136
+ return nil if self.all_of.empty?
137
+ return " with all of: %s" % [ self.all_of.map(&:name).join(', ') ]
138
+ end
139
+
140
+
141
+ ### Return a String describing the components matching entities must not have any of.
142
+ def none_of_description
143
+ return nil if self.none_of.empty?
144
+ return " with none of: %s" % [ self.none_of.map(&:name).join(', ') ]
145
+ end
146
+
147
+
148
+ ### Return a copy of the receiver with the specified additional +required+ and
149
+ ### +excluded+ components.
150
+ def dup_with( one_of: [], all_of: [], none_of: [] )
151
+ self.log.debug "Making dup of %p with one_of: %p, all_of: %p, none_of: %p" %
152
+ [ self, one_of, all_of, none_of ]
153
+
154
+ copy = self.dup
155
+ copy.one_of.merge( one_of )
156
+ copy.all_of.merge( all_of )
157
+ copy.none_of.merge( none_of )
158
+
159
+ self.log.debug " dup is: %p" % [ copy ]
160
+ return copy
161
+ end
162
+
163
+ end # class Chione::Aspect