draco 0.5.0 → 0.5.1
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
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/draco.rb +19 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1886b23bb2d098362aa4452b25922fc98fb033fd86f0b8360586da1406bd5810
|
4
|
+
data.tar.gz: 9c0e7314c301c7b879ec71bbe8eb8966b04d6c85093d176a2d0c658cb0ad5b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ebe2a5000a3966d4269df1ee0fb7046b0c830f8f5ed589e918d953665da8e0d1f8992d71fb9f2f2b76339fd390821f4732b60488f84daad6ceec3638caa715
|
7
|
+
data.tar.gz: 3f617f62d43e4c680a7983278b465cf5498594883581ad0571368a10ef59e80a35969a1c7cdfbdab114ee808b718782433e467761fdf8fc952229643d6d2e27e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -92,7 +92,7 @@ Often we have types of entities that are reused throughout the game. We can defi
|
|
92
92
|
```ruby
|
93
93
|
class Goblin < Draco::Entity
|
94
94
|
component Position, x: 50, y: 50
|
95
|
-
component
|
95
|
+
component Tag(:visible)
|
96
96
|
end
|
97
97
|
|
98
98
|
goblin = Goblin.new
|
@@ -123,7 +123,7 @@ entities that include all of the given components.
|
|
123
123
|
|
124
124
|
```ruby
|
125
125
|
class RenderSpriteSystem < Draco::System
|
126
|
-
filter
|
126
|
+
filter Tag(:visible), Position, Sprite
|
127
127
|
|
128
128
|
def tick(args)
|
129
129
|
# You can also access the world that called the system.
|
data/lib/draco.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# An Entity Component System is an architectural pattern used in game development to decouple behavior from objects.
|
6
6
|
module Draco
|
7
7
|
# Public: The version of the library. Draco uses semver to version releases.
|
8
|
-
VERSION = "0.5.
|
8
|
+
VERSION = "0.5.1"
|
9
9
|
|
10
10
|
# Public: A general purpose game object that consists of a unique id and a collection of Components.
|
11
11
|
class Entity
|
@@ -39,6 +39,15 @@ module Draco
|
|
39
39
|
@default_components[component] = defaults
|
40
40
|
end
|
41
41
|
|
42
|
+
# Public: Creates a tag Component. If the tag already exists, return it.
|
43
|
+
#
|
44
|
+
# name - The string or symbol name of the component.
|
45
|
+
#
|
46
|
+
# Returns a class with subclass Draco::Component.
|
47
|
+
def self.Tag(name) # rubocop:disable Naming/MethodName
|
48
|
+
Draco::Tag(name)
|
49
|
+
end
|
50
|
+
|
42
51
|
class << self
|
43
52
|
# Internal: Returns the default components for the class.
|
44
53
|
attr_reader :default_components
|
@@ -300,9 +309,6 @@ module Draco
|
|
300
309
|
end
|
301
310
|
end
|
302
311
|
|
303
|
-
# Internal: Empty module to enable Tag() method.
|
304
|
-
module Tag; end
|
305
|
-
|
306
312
|
# Public: Creates a new empty component at runtime. If the given Class already exists, it reuses the existing Class.
|
307
313
|
#
|
308
314
|
# name - The symbol or string name of the component. It can be either camelcase or underscored.
|
@@ -349,6 +355,15 @@ module Draco
|
|
349
355
|
sub.instance_variable_set(:@filter, [])
|
350
356
|
end
|
351
357
|
|
358
|
+
# Public: Creates a tag Component. If the tag already exists, return it.
|
359
|
+
#
|
360
|
+
# name - The string or symbol name of the component.
|
361
|
+
#
|
362
|
+
# Returns a class with subclass Draco::Component.
|
363
|
+
def self.Tag(name) # rubocop:disable Naming/MethodName
|
364
|
+
Draco::Tag(name)
|
365
|
+
end
|
366
|
+
|
352
367
|
# Public: Initializes a new System.
|
353
368
|
#
|
354
369
|
# entities - The Entities to operate on (default: []).
|