kiwi-ecs 0.0.2 → 0.0.3
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/README.md +145 -0
- metadata +11 -145
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ecb91b181779636d95d7c72fb3e8bcb6713498253b03ea8dc033a9e99027f59
|
4
|
+
data.tar.gz: 1e06daecfa95b5ecd6f3a6faca0a3b4385dd501ceed81ab9b6816ba62cc327df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a2f1676d8883b1e0bdbecd4138e5c424482bedd23a945a815444c86eae88c692b769ebe8cbbfc00910b47ba4219bed79bce5e6c4f678c71de784a5e4078869
|
7
|
+
data.tar.gz: '08a375f932ad364d8194bd97cfd71578eaad9631e8e989c76bfb9dbd33cdacc83c93ba6afd740ee2dc3c80e79fb7576c2c213d912fffee0285ddf155fa85c54f'
|
data/README.md
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# Kiwi
|
2
|
+
|
3
|
+
Kiwi is a versatile entity component system focussing on fast iteration and a nice api.
|
4
|
+
|
5
|
+
To get started, read the [usage guide](#usage) below.
|
6
|
+
|
7
|
+
[](https://github.com/Jomy10/kiwi-ecs-ruby/actions/workflows/tests.yml)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
The library is available from [ruby gems](https://rubygems.org/gems/kiwi-ecs):
|
12
|
+
|
13
|
+
```sh
|
14
|
+
gem install kiwi-ecs
|
15
|
+
```
|
16
|
+
|
17
|
+
To use it in your ruby source files:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'kiwi-ecs'
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### The world
|
26
|
+
|
27
|
+
The world is the main object that controls the ecs.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
world = World.new
|
31
|
+
```
|
32
|
+
|
33
|
+
### Components
|
34
|
+
|
35
|
+
Creating a component is as simple as declaring a struct:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Position = Struct.new :x, :y
|
39
|
+
```
|
40
|
+
|
41
|
+
Classes can also be used instead of structs
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
class Velocity
|
45
|
+
attr_accessor :x
|
46
|
+
attr_accessor :y
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
### Entities
|
51
|
+
|
52
|
+
An entity is spawned with a set of components:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
entityId = world.spawn(Position.new(10, 10))
|
56
|
+
|
57
|
+
world.spawn(Position.new(3, 5), Velocity.new(1.5, 0.0))
|
58
|
+
```
|
59
|
+
|
60
|
+
The `world.spawn(*components)` function will return the id of the spawned entity.
|
61
|
+
|
62
|
+
Killing an entity can be done using `world.kill(entityId)`:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
world.kill(entityId)
|
66
|
+
```
|
67
|
+
|
68
|
+
### Systems
|
69
|
+
|
70
|
+
#### Queries
|
71
|
+
|
72
|
+
Queries can be constructed as follows:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
# Query all position componentss
|
76
|
+
world.query(Position) do |pos|
|
77
|
+
puts pos
|
78
|
+
end
|
79
|
+
|
80
|
+
# Query all entities having a position and a velocity component, and their entity ids
|
81
|
+
world.query_with_ids(Position, Velocity) do |id, pos, vel|
|
82
|
+
# ...
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
### Flags
|
87
|
+
|
88
|
+
Entities can be tagged using flags
|
89
|
+
|
90
|
+
#### Defining flags
|
91
|
+
|
92
|
+
A flag is an integer
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
module Flags
|
96
|
+
Player = 0
|
97
|
+
Enemy = 1
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
#### Setting flags
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
id = world.spawn
|
105
|
+
|
106
|
+
world.set_flag(id, Flags::Player)
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Removing a flag
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
world.remove_flag(id, Flags::Player)
|
113
|
+
```
|
114
|
+
|
115
|
+
#### Checking wether an entity has a flag
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
world.has_flag(id, Flags::Player)
|
119
|
+
```
|
120
|
+
|
121
|
+
#### Filtering queries with flags
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
world.query_with_ids(Pos)
|
125
|
+
.filter do |id, pos|
|
126
|
+
world.has_flag(id, Flags::Player)
|
127
|
+
end
|
128
|
+
.each do |id, pos|
|
129
|
+
# Do something with the filtered query
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
133
|
+
The `hasFlags` function is also available for when you want to check multiple flags.
|
134
|
+
|
135
|
+
## Road map
|
136
|
+
|
137
|
+
- [ ] System groups
|
138
|
+
|
139
|
+
## Contributing
|
140
|
+
|
141
|
+
Contributors are welcome to open an issue requesting new features or fixes or opening a pull request for them.
|
142
|
+
|
143
|
+
## License
|
144
|
+
|
145
|
+
The library is licensed under LGPLv3.
|
metadata
CHANGED
@@ -1,158 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kiwi-ecs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Everaert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
16
|
-
Kiwi is a versatile entity component system focussing on fast iteration and a nice api.
|
17
|
-
|
18
|
-
To get started, read the [usage guide](#usage) below.
|
19
|
-
|
20
|
-
[](https://github.com/Jomy10/kiwi-ecs-ruby/actions/workflows/tests.yml)
|
21
|
-
|
22
|
-
## Installation
|
23
|
-
|
24
|
-
This library is currently not on ruby gems, but will arrive shortly.
|
25
|
-
|
26
|
-
To use it now, simple `git clone https://github.com/jomy10/kiwi-ecs-ruby`.
|
27
|
-
|
28
|
-
Then incude the world.rb file in your ruby files like so:
|
29
|
-
|
30
|
-
```ruby
|
31
|
-
require_relative 'kiwi-ecs-ruby/src/world.rb'
|
32
|
-
```
|
33
|
-
|
34
|
-
## Usage
|
35
|
-
|
36
|
-
### The world
|
37
|
-
|
38
|
-
The world is the main object that controls the ecs.
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
world = World.new
|
42
|
-
```
|
43
|
-
|
44
|
-
### Components
|
45
|
-
|
46
|
-
Creating a component is as simple as declaring a struct:
|
47
|
-
|
48
|
-
```ruby
|
49
|
-
Position = Struct.new :x, :y
|
50
|
-
```
|
51
|
-
|
52
|
-
Classes can also be used instead of structs
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
class Velocity
|
56
|
-
attr_accessor :x
|
57
|
-
attr_accessor :y
|
58
|
-
end
|
59
|
-
```
|
60
|
-
|
61
|
-
### Entities
|
62
|
-
|
63
|
-
An entity is spawned with a set of components:
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
entityId = world.spawn(Position.new(10, 10))
|
67
|
-
|
68
|
-
world.spawn(Position.new(3, 5), Velocity.new(1.5, 0.0))
|
69
|
-
```
|
70
|
-
|
71
|
-
The `world.spawn(*components)` function will return the id of the spawned entity.
|
72
|
-
|
73
|
-
Killing an entity can be done using `world.kill(entityId)`:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
world.kill(entityId)
|
77
|
-
```
|
78
|
-
|
79
|
-
### Systems
|
80
|
-
|
81
|
-
#### Queries
|
82
|
-
|
83
|
-
Queries can be constructed as follows:
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
# Query all position componentss
|
87
|
-
world.query(Position) do |pos|
|
88
|
-
puts pos
|
89
|
-
end
|
90
|
-
|
91
|
-
# Query all entities having a position and a velocity component, and their entity ids
|
92
|
-
world.query_with_ids(Position, Velocity) do |id, pos, vel|
|
93
|
-
# ...
|
94
|
-
end
|
95
|
-
```
|
96
|
-
|
97
|
-
### Flags
|
98
|
-
|
99
|
-
Entities can be tagged using flags
|
100
|
-
|
101
|
-
#### Defining flags
|
102
|
-
|
103
|
-
A flag is an integer
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
module Flags
|
107
|
-
Player = 0
|
108
|
-
Enemy = 1
|
109
|
-
end
|
110
|
-
```
|
111
|
-
|
112
|
-
#### Setting flags
|
113
|
-
|
114
|
-
```ruby
|
115
|
-
id = world.spawn
|
116
|
-
|
117
|
-
world.set_flag(id, Flags::Player)
|
118
|
-
```
|
119
|
-
|
120
|
-
#### Removing a flag
|
121
|
-
|
122
|
-
```ruby
|
123
|
-
world.remove_flag(id, Flags::Player)
|
124
|
-
```
|
125
|
-
|
126
|
-
#### Checking wether an entity has a flag
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
world.has_flag(id, Flags::Player)
|
130
|
-
```
|
131
|
-
|
132
|
-
#### Filtering queries with flags
|
133
|
-
|
134
|
-
```ruby
|
135
|
-
# TODO
|
136
|
-
```
|
137
|
-
|
138
|
-
The `hasFlags` function is also available for when you want to check multiple flags.
|
139
|
-
|
140
|
-
## Road map
|
141
|
-
|
142
|
-
- [ ] System groups
|
143
|
-
|
144
|
-
## Contributing
|
145
|
-
|
146
|
-
Contributors are welcome to open an issue requesting new features or fixes or opening a pull request for them.
|
147
|
-
|
148
|
-
## License
|
149
|
-
|
150
|
-
The library is licensed under LGPLv3.
|
151
|
-
email:
|
13
|
+
description: Kiwi is a versatile entity component system that is focussed on fast
|
14
|
+
iteration and a nice api
|
15
|
+
email:
|
152
16
|
executables: []
|
153
17
|
extensions: []
|
154
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
19
|
+
- README.md
|
155
20
|
files:
|
21
|
+
- README.md
|
156
22
|
- lib/arch_store.rb
|
157
23
|
- lib/archetype.rb
|
158
24
|
- lib/bitmap.rb
|
@@ -164,7 +30,7 @@ homepage: https://github.com/jomy10/kiwi-ecs-ruby
|
|
164
30
|
licenses:
|
165
31
|
- LGPL-3.0-or-later
|
166
32
|
metadata: {}
|
167
|
-
post_install_message:
|
33
|
+
post_install_message:
|
168
34
|
rdoc_options: []
|
169
35
|
require_paths:
|
170
36
|
- lib
|
@@ -179,8 +45,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
45
|
- !ruby/object:Gem::Version
|
180
46
|
version: '0'
|
181
47
|
requirements: []
|
182
|
-
rubygems_version: 3.3.
|
183
|
-
signing_key:
|
48
|
+
rubygems_version: 3.3.26
|
49
|
+
signing_key:
|
184
50
|
specification_version: 4
|
185
51
|
summary: An entity component system with a nice api, fit for a variety of use cases
|
186
52
|
test_files: []
|