chione 0.5.0 → 0.6.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +2 -150
- data/History.md +8 -0
- data/Rakefile +1 -1
- data/lib/chione.rb +1 -1
- data/lib/chione/system.rb +25 -3
- data/lib/chione/world.rb +20 -2
- data/spec/chione/system_spec.rb +57 -0
- data/spec/chione/world_spec.rb +16 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74a32ca8c0efb477b978216b6371d24c2cf2fabd037dade6424fdf3cda693bc8
|
|
4
|
+
data.tar.gz: cdc91fa64ece44754a3e4f687836195113779f96f64a7a01dffb64a6dcf3ed75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a21d24764d7ca1745ac3dbc5741a0782a569c1beb68cb643de4d6fff5f01ea03f12db588206c5941ed51d7c762210f1b0dba4d45a81b26d44fc7b47144cbe35
|
|
7
|
+
data.tar.gz: d15d0593e77f38c31fd437d6580e576466ddd45c50646b80502b7196b21ddfad7ca68f3c7a1a3dfdf8ff073d9f5fcacef8cc5711b7978e34de27877ea22116d0
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/ChangeLog
CHANGED
|
@@ -1,151 +1,3 @@
|
|
|
1
|
-
2018-06-02 Michael Granger <ged@FaerieMUD.org>
|
|
2
|
-
|
|
3
|
-
* .hgtags:
|
|
4
|
-
Added tag v0.5.0 for changeset 1fb4fb6761f2
|
|
5
|
-
[4a799c04f87f] [tip]
|
|
6
|
-
|
|
7
|
-
* .hgsigs:
|
|
8
|
-
Added signature for changeset 8b19a6b5fb12
|
|
9
|
-
[1fb4fb6761f2] [v0.5.0]
|
|
10
|
-
|
|
11
|
-
* History.md, chione.gemspec, lib/chione.rb:
|
|
12
|
-
Bump the minor version, update history.
|
|
13
|
-
[8b19a6b5fb12]
|
|
14
|
-
|
|
15
|
-
* README.md, Rakefile, chione.gemspec:
|
|
16
|
-
Update URLs, copyright dates
|
|
17
|
-
[349fe4d64ec7]
|
|
18
|
-
|
|
19
|
-
* lib/chione/archetype.rb, lib/chione/system.rb:
|
|
20
|
-
Fix blank archetype inspect details
|
|
21
|
-
[c64a0a142f5e]
|
|
22
|
-
|
|
23
|
-
* lib/chione/world.rb, spec/chione/world_spec.rb:
|
|
24
|
-
Update configuration to use chione namespace
|
|
25
|
-
[27a0eec7c366]
|
|
26
|
-
|
|
27
|
-
2017-12-11 Michael Granger <ged@FaerieMUD.org>
|
|
28
|
-
|
|
29
|
-
* .hgtags:
|
|
30
|
-
Added tag v0.4.0 for changeset 61536d84d951
|
|
31
|
-
[e23f5a4ba13d]
|
|
32
|
-
|
|
33
|
-
* .hgsigs:
|
|
34
|
-
Added signature for changeset b86a9cde058d
|
|
35
|
-
[61536d84d951] [v0.4.0]
|
|
36
|
-
|
|
37
|
-
* History.md, chione.gemspec, lib/chione.rb:
|
|
38
|
-
Bump the minor version, update history.
|
|
39
|
-
[b86a9cde058d]
|
|
40
|
-
|
|
41
|
-
* .ruby-version, lib/chione/system.rb, lib/chione/world.rb,
|
|
42
|
-
spec/chione/system_spec.rb:
|
|
43
|
-
Refactor tick and timing events.
|
|
44
|
-
|
|
45
|
-
COMPAT: the arguments passed to System.every_tick blocks are now
|
|
46
|
-
only the delta and the tick count.
|
|
47
|
-
[38c42eb46418]
|
|
48
|
-
|
|
49
|
-
2017-10-04 Michael Granger <ged@FaerieMUD.org>
|
|
50
|
-
|
|
51
|
-
* lib/chione/world.rb:
|
|
52
|
-
Normalize entity IDs in the World API
|
|
53
|
-
[d5736d289092]
|
|
54
|
-
|
|
55
|
-
* lib/chione/entity.rb, lib/chione/world.rb,
|
|
56
|
-
spec/chione/entity_spec.rb:
|
|
57
|
-
Pass init args through Component.add_component
|
|
58
|
-
[ba43a21631c5]
|
|
59
|
-
|
|
60
|
-
* lib/chione/system.rb:
|
|
61
|
-
Fix API docs for Chione::System::on
|
|
62
|
-
[7ee9fc0c0c8e]
|
|
63
|
-
|
|
64
|
-
* certs/ged.pem:
|
|
65
|
-
Update gem-signing cert
|
|
66
|
-
[e7986014f2c2]
|
|
67
|
-
|
|
68
|
-
2017-07-21 Michael Granger <ged@FaerieMUD.org>
|
|
69
|
-
|
|
70
|
-
* chione.gemspec, lib/chione.rb, lib/chione/archetype.rb,
|
|
71
|
-
lib/chione/aspect.rb, lib/chione/component.rb, lib/chione/system.rb,
|
|
72
|
-
lib/chione/world.rb, spec/chione/archetype_spec.rb,
|
|
73
|
-
spec/chione/component_spec.rb, spec/chione/system_spec.rb:
|
|
74
|
-
Work on System execution and Component construction
|
|
75
|
-
|
|
76
|
-
- Add constructor arguments to component-creation paths
|
|
77
|
-
- Add Aspect#archetype and Archetype.from_aspect
|
|
78
|
-
- Add a processing block to Component field declaration
|
|
79
|
-
[e0452d211146]
|
|
80
|
-
|
|
81
|
-
2017-07-12 Michael Granger <ged@FaerieMUD.org>
|
|
82
|
-
|
|
83
|
-
* chione.gemspec, lib/chione.rb, lib/chione/component.rb:
|
|
84
|
-
Add the entity ID to Component's inspect output
|
|
85
|
-
[7f1190b563a6]
|
|
86
|
-
|
|
87
|
-
* spec/chione/component_spec.rb:
|
|
88
|
-
Add coverage for Component #inspect.
|
|
89
|
-
[2de145d530d5]
|
|
90
|
-
|
|
91
|
-
* lib/chione/aspect.rb, lib/chione/system.rb, lib/chione/world.rb,
|
|
92
|
-
spec/chione/aspect_spec.rb, spec/chione/system_spec.rb:
|
|
93
|
-
Add caching and #inserted/#removed callbacks for aspect-membership
|
|
94
|
-
to Systems.
|
|
95
|
-
[6eed9e4055be]
|
|
96
|
-
|
|
97
|
-
2017-07-11 Michael Granger <ged@FaerieMUD.org>
|
|
98
|
-
|
|
99
|
-
* .gems, Manifest.txt, Rakefile, chione.gemspec,
|
|
100
|
-
lib/chione/archetype.rb, lib/chione/aspect.rb, lib/chione/entity.rb,
|
|
101
|
-
lib/chione/fixtures.rb, lib/chione/fixtures/entities.rb,
|
|
102
|
-
lib/chione/iterating_system.rb, lib/chione/system.rb,
|
|
103
|
-
lib/chione/world.rb, spec/chione/aspect_spec.rb,
|
|
104
|
-
spec/chione/iterating_system_spec.rb, spec/chione/system_spec.rb,
|
|
105
|
-
spec/chione/world_spec.rb, spec/spec_helper.rb:
|
|
106
|
-
Start adding system execution strategies
|
|
107
|
-
|
|
108
|
-
- Add fixtures collection
|
|
109
|
-
- Add Aspect#matches? to match individual entities
|
|
110
|
-
- Rename some component-API methods on the World for clarity (with
|
|
111
|
-
aliases to the old methods)
|
|
112
|
-
- Add Chione::IteratingSystem
|
|
113
|
-
- Add stubs for System#inserted and #removed
|
|
114
|
-
[783c4a657041]
|
|
115
|
-
|
|
116
|
-
2017-07-07 Michael Granger <ged@FaerieMUD.org>
|
|
117
|
-
|
|
118
|
-
* lib/chione/component.rb, lib/chione/world.rb,
|
|
119
|
-
spec/chione/component_spec.rb:
|
|
120
|
-
Add the entity ID to components on registration
|
|
121
|
-
[cf37f1305ad2]
|
|
122
|
-
|
|
123
|
-
* lib/chione/system.rb, spec/chione/system_spec.rb:
|
|
124
|
-
Remove aspects from event handler declarations.
|
|
125
|
-
[a8f3ac7113c3]
|
|
126
|
-
|
|
127
|
-
* lib/chione/system.rb, spec/chione/aspect_spec.rb,
|
|
128
|
-
spec/chione/system_spec.rb:
|
|
129
|
-
Checkpoint before undoing experimental event-based system execution
|
|
130
|
-
model
|
|
131
|
-
[f89f24dfb25c]
|
|
132
|
-
|
|
133
|
-
2017-07-05 Michael Granger <ged@FaerieMUD.org>
|
|
134
|
-
|
|
135
|
-
* lib/chione/system.rb, lib/chione/world.rb,
|
|
136
|
-
spec/chione/system_spec.rb:
|
|
137
|
-
Add execution models to Systems
|
|
138
|
-
[c9e80cf737e7]
|
|
139
|
-
|
|
140
|
-
2017-06-30 Michael Granger <ged@FaerieMUD.org>
|
|
141
|
-
|
|
142
|
-
* README.md, lib/chione/archetype.rb, lib/chione/aspect.rb,
|
|
143
|
-
lib/chione/entity.rb, lib/chione/system.rb, lib/chione/world.rb,
|
|
144
|
-
spec/chione/aspect_spec.rb, spec/chione/entity_spec.rb,
|
|
145
|
-
spec/chione/system_spec.rb, spec/chione/world_spec.rb:
|
|
146
|
-
Refactor for thinner entities and systems with named aspects
|
|
147
|
-
[d69678296749]
|
|
148
|
-
|
|
149
1
|
2017-06-06 Michael Granger <ged@FaerieMUD.org>
|
|
150
2
|
|
|
151
3
|
* lib/chione/aspect.rb, lib/chione/component.rb, lib/chione/entity.rb,
|
|
@@ -153,7 +5,7 @@
|
|
|
153
5
|
Pull up common #inspect functionality into a mixin
|
|
154
6
|
|
|
155
7
|
...and use it everywhere.
|
|
156
|
-
[0eb1e6c25953]
|
|
8
|
+
[0eb1e6c25953] [tip]
|
|
157
9
|
|
|
158
10
|
* lib/chione/world.rb, spec/chione/world_spec.rb:
|
|
159
11
|
Added World#remove_system and _manager; publish the instance of
|
|
@@ -164,7 +16,7 @@
|
|
|
164
16
|
|
|
165
17
|
* .hgtags:
|
|
166
18
|
Added tag v0.3.0 for changeset c91f71b3d7d9
|
|
167
|
-
[06fdcde9eb00]
|
|
19
|
+
[06fdcde9eb00] [github/master]
|
|
168
20
|
|
|
169
21
|
* .hgsigs:
|
|
170
22
|
Added signature for changeset 0d453cae95c3
|
data/History.md
CHANGED
data/Rakefile
CHANGED
|
@@ -44,7 +44,7 @@ hoespec = Hoe.spec 'chione' do |spec|
|
|
|
44
44
|
spec.dependency 'rdoc-generator-fivefish', '~> 0.3', :developer
|
|
45
45
|
spec.dependency 'rdoc', '~> 5.1', :developer
|
|
46
46
|
|
|
47
|
-
spec.require_ruby_version( '>=2.
|
|
47
|
+
spec.require_ruby_version( '>=2.5.0' )
|
|
48
48
|
spec.hg_sign_tags = true if spec.respond_to?( :hg_sign_tags= )
|
|
49
49
|
spec.check_history_on_release = true if spec.respond_to?( :check_history_on_release= )
|
|
50
50
|
|
data/lib/chione.rb
CHANGED
data/lib/chione/system.rb
CHANGED
|
@@ -46,6 +46,10 @@ class Chione::System
|
|
|
46
46
|
# System is started.
|
|
47
47
|
singleton_attr_reader :event_handlers
|
|
48
48
|
|
|
49
|
+
##
|
|
50
|
+
# Systems to be injected by the world when this System is started.
|
|
51
|
+
singleton_attr_reader :injected_systems
|
|
52
|
+
|
|
49
53
|
|
|
50
54
|
### Add the specified +component_types+ to the Aspect of this System as being
|
|
51
55
|
### required in any entities it processes.
|
|
@@ -62,6 +66,18 @@ class Chione::System
|
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
|
|
69
|
+
### Dependency-injection: declare one or more +systems+ that should be passed to #start
|
|
70
|
+
### by the running World.
|
|
71
|
+
def self::inject( *systems )
|
|
72
|
+
systems.each do |system_type|
|
|
73
|
+
system_type = system_type.to_sym
|
|
74
|
+
system_class = Chione::System.get_subclass( system_type )
|
|
75
|
+
attr_accessor( "#{system_type}_system" )
|
|
76
|
+
self.injected_systems[ system_type ] = system_class
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
65
81
|
### Declare a block that is called once whenever an event matching +event_name+ is
|
|
66
82
|
### broadcast to the World.
|
|
67
83
|
def self::on( event_name, &block )
|
|
@@ -91,6 +107,7 @@ class Chione::System
|
|
|
91
107
|
super
|
|
92
108
|
subclass.instance_variable_set( :@aspects, DEFAULT_ASPECT_HASH.clone )
|
|
93
109
|
subclass.instance_variable_set( :@event_handlers, self.event_handlers&.dup || [] )
|
|
110
|
+
subclass.instance_variable_set( :@injected_systems, self.injected_systems&.dup || {} )
|
|
94
111
|
end
|
|
95
112
|
|
|
96
113
|
|
|
@@ -120,9 +137,14 @@ class Chione::System
|
|
|
120
137
|
|
|
121
138
|
|
|
122
139
|
### Start the system.
|
|
123
|
-
def start
|
|
124
|
-
self.log.info "Starting the %p system; %d event handlers to register" %
|
|
125
|
-
[ self.class, self.class.event_handlers.length ]
|
|
140
|
+
def start( **injected_systems )
|
|
141
|
+
self.log.info "Starting the %p system; %d injected systems, %d event handlers to register" %
|
|
142
|
+
[ self.class, injected_systems.length, self.class.event_handlers.length ]
|
|
143
|
+
|
|
144
|
+
injected_systems.each do |name, other_system|
|
|
145
|
+
self.public_send( "#{name}_system=", other_system )
|
|
146
|
+
end
|
|
147
|
+
|
|
126
148
|
self.class.event_handlers.each do |event_name, method_name|
|
|
127
149
|
callback = self.method( method_name )
|
|
128
150
|
self.log.info "Registering %p as a callback for '%s' events." % [ callback, event_name ]
|
data/lib/chione/world.rb
CHANGED
|
@@ -114,7 +114,8 @@ class Chione::World
|
|
|
114
114
|
def start
|
|
115
115
|
@main_thread = Thread.new do
|
|
116
116
|
Thread.current.abort_on_exception = true
|
|
117
|
-
|
|
117
|
+
Thread.current.name = "Main World"
|
|
118
|
+
self.log.info "Main thread (%p) started." % [ Thread.current ]
|
|
118
119
|
@world_threads.add( Thread.current )
|
|
119
120
|
@world_threads.enclose
|
|
120
121
|
|
|
@@ -162,9 +163,11 @@ class Chione::World
|
|
|
162
163
|
def start_systems
|
|
163
164
|
self.log.info "Starting %d Systems" % [ self.systems.length ]
|
|
164
165
|
self.systems.each do |system_class, sys|
|
|
166
|
+
injections = self.make_injection_hash_for( system_class )
|
|
167
|
+
|
|
165
168
|
self.log.debug " starting %p" % [ system_class ]
|
|
166
169
|
start = Time.now
|
|
167
|
-
sys.start
|
|
170
|
+
sys.start( **injections )
|
|
168
171
|
finish = Time.now
|
|
169
172
|
self.log.debug " started in %0.5fs" % [ finish - start ]
|
|
170
173
|
end
|
|
@@ -499,6 +502,21 @@ class Chione::World
|
|
|
499
502
|
protected
|
|
500
503
|
#########
|
|
501
504
|
|
|
505
|
+
### Return a Hash of the loaded Chione::Systems that +system_class+ has requested
|
|
506
|
+
### be injected into it.
|
|
507
|
+
def make_injection_hash_for( system_class )
|
|
508
|
+
self.log.debug "Injecting %d other system/s into %p" %
|
|
509
|
+
[ system_class.injected_systems.length, system_class ]
|
|
510
|
+
return system_class.injected_systems.each_with_object({}) do |(name, injected_class), hash|
|
|
511
|
+
self.log.debug " inject %p: %p" % [ name, injected_class ]
|
|
512
|
+
system = self.systems[ injected_class ] or
|
|
513
|
+
raise "Can't inject %p into %p: not configured to run it" %
|
|
514
|
+
[ injected_class, system_class]
|
|
515
|
+
hash[ name ] = system
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
|
|
502
520
|
### Update any entity caches in the system when an +entity+ has its +components+ hash changed.
|
|
503
521
|
def update_entity_caches( entity, components )
|
|
504
522
|
entity = entity.id if entity.respond_to?( :id )
|
data/spec/chione/system_spec.rb
CHANGED
|
@@ -290,5 +290,62 @@ describe Chione::System do
|
|
|
290
290
|
|
|
291
291
|
end
|
|
292
292
|
|
|
293
|
+
|
|
294
|
+
describe "dependency-injection" do
|
|
295
|
+
|
|
296
|
+
let( :subclass1 ) do
|
|
297
|
+
Class.new( described_class )
|
|
298
|
+
end
|
|
299
|
+
let( :subclass2 ) do
|
|
300
|
+
Class.new( described_class )
|
|
301
|
+
end
|
|
302
|
+
let( :world ) { Chione::World.new }
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
before( :each ) do
|
|
306
|
+
@real_derivatives = described_class.derivatives.dup
|
|
307
|
+
# Pretend that the anonymous classes have names so they can be injected by name
|
|
308
|
+
described_class.derivatives.merge!( 'events' => subclass1, 'physics' => subclass2 )
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
after( :each ) do
|
|
312
|
+
described_class.derivatives.replace( @real_derivatives )
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
it "allows one system to have another system injected into it" do
|
|
317
|
+
subclass1.inject( :physics )
|
|
318
|
+
|
|
319
|
+
world.add_system( subclass1 )
|
|
320
|
+
world.add_system( subclass2 )
|
|
321
|
+
world.start_systems
|
|
322
|
+
|
|
323
|
+
result = world.systems[ subclass1 ].physics_system
|
|
324
|
+
|
|
325
|
+
expect( result ).to be_a( subclass2 )
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
it "allows systems to inject one another" do
|
|
330
|
+
subclass1.inject( :physics )
|
|
331
|
+
subclass2.inject( :events )
|
|
332
|
+
|
|
333
|
+
world.add_system( subclass1 )
|
|
334
|
+
world.add_system( subclass2 )
|
|
335
|
+
world.start_systems
|
|
336
|
+
|
|
337
|
+
expect( world.systems[subclass1].physics_system ).to be_a( subclass2 )
|
|
338
|
+
expect( world.systems[subclass2].events_system ).to be_a( subclass1 )
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
it "raises an error if the system to inject can't be loaded" do
|
|
343
|
+
expect {
|
|
344
|
+
subclass1.inject( :tantalus )
|
|
345
|
+
}.to raise_error( /couldn't find a system named 'tantalus'/i )
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
end
|
|
349
|
+
|
|
293
350
|
end
|
|
294
351
|
|
data/spec/chione/world_spec.rb
CHANGED
|
@@ -410,6 +410,22 @@ describe Chione::World do
|
|
|
410
410
|
world.stop
|
|
411
411
|
end
|
|
412
412
|
|
|
413
|
+
|
|
414
|
+
it "raises an error if a system wants to inject a system that hasn't been added" do
|
|
415
|
+
@real_derivatives = Chione::System.derivatives.dup
|
|
416
|
+
Chione::System.derivatives[ 'warning' ] = Class.new( Chione::System ) do
|
|
417
|
+
def self::name; "WarningSystem"; end
|
|
418
|
+
end
|
|
419
|
+
test_system.inject( :warning )
|
|
420
|
+
world.add_system( test_system )
|
|
421
|
+
|
|
422
|
+
expect {
|
|
423
|
+
world.start_systems
|
|
424
|
+
}.to raise_error( /can't inject/i )
|
|
425
|
+
ensure
|
|
426
|
+
Chione::System.derivatives.replace( @real_derivatives )
|
|
427
|
+
end
|
|
428
|
+
|
|
413
429
|
end
|
|
414
430
|
|
|
415
431
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chione
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Granger
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
X0qdrKi+2aZZ0NGuFj9AItBsVmAvkBGIpX4TEKQp5haEbPpmaqO5nIIhV26PXmyT
|
|
36
36
|
OMKv6pWsoS81vw5KAGBmfX8nht/Py90DQrbRvakATGI=
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date: 2018-06
|
|
38
|
+
date: 2018-07-06 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: loggability
|
|
@@ -298,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
298
298
|
requirements:
|
|
299
299
|
- - ">="
|
|
300
300
|
- !ruby/object:Gem::Version
|
|
301
|
-
version: 2.
|
|
301
|
+
version: 2.5.0
|
|
302
302
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
303
|
requirements:
|
|
304
304
|
- - ">="
|
|
@@ -306,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
306
306
|
version: '0'
|
|
307
307
|
requirements: []
|
|
308
308
|
rubyforge_project:
|
|
309
|
-
rubygems_version: 2.7.
|
|
309
|
+
rubygems_version: 2.7.6
|
|
310
310
|
signing_key:
|
|
311
311
|
specification_version: 4
|
|
312
312
|
summary: An Entity/Component System framework inspired by Artemis
|
metadata.gz.sig
CHANGED
|
Binary file
|