kiwi-ecs 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c28c74f941f35abc3fe5ae1d565f8942f7676b01341e4c3efeef7969dcb1512
4
- data.tar.gz: 6ac603e29b87be9c27da787dc330291f8c6bc8ce28e8807e4b8d36294609638e
3
+ metadata.gz: 6c92559b41133eb2dc4efeb25ae91bce5ddc356eed0b4164cbc284b5c8ca4eac
4
+ data.tar.gz: b213c479a15483424f08617bf5fb7c5b0895c8866804f4adaa0912068e6d1819
5
5
  SHA512:
6
- metadata.gz: db0833836918141ec6f231b943c9c2fb6455e232c6d451cb46b80ff949eb245a164d037dfd984054af69019bf717ebe380734c6a74a1493db429623ed22825d1
7
- data.tar.gz: a1d9e6d195d65505ea25f21f5cc98224c4bf4729adaca7fb4a0fa9725a74e3748956853d7fda3e22d6108eab4d98651a612a10b847784f8bee3c99f47f3bd7b3
6
+ metadata.gz: 23611a5577855aa6f67245e195942009d08535c82d4bfb5d737bc3d8c9ff9914a09cdc66c5ff920e90cbdc02038b221d8fabdc5111fd20c60bb1e94a4a185d86
7
+ data.tar.gz: 2adf271c5166619053826369b1458abd4b44d679f02f394f1e6da6cfef86dcb82db67f03d841e7747bd55942fd26b4e64aefa07b7f9f5de2ab30ea030f062aff
data/lib/archetype.rb CHANGED
@@ -1,7 +1,7 @@
1
- ComponentColumn = Struct.new(:components)
2
-
3
1
  module Kiwi
4
2
  module Internal
3
+ ComponentColumn = Struct.new(:components)
4
+
5
5
  class Archetype
6
6
  # @params [Array<Integer>] componentIds
7
7
  def initialize(componentIds)
data/lib/kiwi-ecs.rb CHANGED
@@ -5,14 +5,14 @@
5
5
  # Copyright (C) 2023 Jonas Everaert
6
6
  #
7
7
  # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
9
  # the Free Software Foundation, either version 3 of the License, or
10
10
  # (at your option) any later version.
11
11
  #
12
12
  # This program is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
15
+ # GNU Lesser General Public License for more details.
16
16
  #
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
data/lib/query.rb CHANGED
@@ -25,6 +25,12 @@ module Query
25
25
  .active_components(componentIds)
26
26
  end
27
27
 
28
+ if componentType.size == 1
29
+ result = result.map do |c|
30
+ c[0]
31
+ end
32
+ end
33
+
28
34
  if block_given?
29
35
  result.each do |a|
30
36
  yield a
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiwi-ecs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Everaert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-11 00:00:00.000000000 Z
11
+ date: 2023-08-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  == Description
15
- Kiwi is a versatile entity component system that is focussed on fast iteration and a nice api
15
+
16
+ ["Kiwi is a versatile entity component system focussing on fast iteration and a nice api.\n", "\n", "To get started, read the [usage guide](#usage) below.\n", "\n", "[![Tests](https://github.com/Jomy10/kiwi-ecs-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/Jomy10/kiwi-ecs-ruby/actions/workflows/tests.yml)\n", "\n", "## Installation\n", "\n", "The library is available from [ruby gems](https://rubygems.org/gems/kiwi-ecs):\n", "\n", "```sh\n", "gem install kiwi-ecs\n", "```\n", "\n", "To use it in your ruby source files:\n", "\n", "```ruby\n", "require 'kiwi-ecs'\n", "```\n", "\n", "## Usage\n", "\n", "### The world\n", "\n", "The world is the main object that controls the ecs.\n", "\n", "```ruby\n", "world = Kiwi::World.new\n", "```\n", "\n", "### Components\n", "\n", "Creating a component is as simple as declaring a struct:\n", "\n", "```ruby\n", "Position = Struct.new :x, :y\n", "```\n", "\n", "Classes can also be used instead of structs\n", "\n", "```ruby\n", "class Velocity\n", " attr_accessor :x\n", " attr_accessor :y\n", "end\n", "```\n", "\n", "### Entities\n", "\n", "An entity is spawned with a set of components:\n", "\n", "```ruby\n", "entityId = world.spawn(Position.new(10, 10))\n", "\n", "world.spawn(Position.new(3, 5), Velocity.new(1.5, 0.0))\n", "```\n", "\n", "The `world.spawn(*components)` function will return the id of the spawned entity.\n", "\n", "Killing an entity can be done using `world.kill(entityId)`:\n", "\n", "```ruby\n", "world.kill(entityId)\n", "```\n", "\n", "### Systems\n", "\n", "#### Queries\n", "\n", "Queries can be constructed as follows:\n", "\n", "```ruby\n", "# Query all position componentss\n", "world.query(Position) do |pos|\n", " puts pos\n", "end\n", "\n", "# Query all entities having a position and a velocity component, and their entity ids\n", "world.query_with_ids(Position, Velocity) do |id, pos, vel|\n", " # ...\n", "end\n", "```\n", "\n", "### Flags\n", "\n", "Entities can be tagged using flags\n", "\n", "#### Defining flags\n", "\n", "A flag is an integer\n", "\n", "```ruby\n", "module Flags\n", " Player = 0\n", " Enemy = 1\n", "end\n", "```\n", "\n", "#### Setting flags\n", "\n", "```ruby\n", "id = world.spawn\n", "\n", "world.set_flag(id, Flags::Player)\n", "```\n", "\n", "#### Removing a flag\n", "\n", "```ruby\n", "world.remove_flag(id, Flags::Player)\n", "```\n", "\n", "#### Checking wether an entity has a flag\n", "\n", "```ruby\n", "world.has_flag(id, Flags::Player)\n", "```\n", "\n", "#### Filtering queries with flags\n", "\n", "```ruby\n", "world.query_with_ids(Pos)\n", " .filter do |id, pos|\n", " world.has_flag(id, Flags::Player)\n", " end\n", " .each do |id, pos|\n", " # Do something with the filtered query\n", " end\n", "```\n", "\n", "The `hasFlags` function is also available for when you want to check multiple flags.\n", "\n", "## Road map\n", "\n", "- [ ] System groups\n", "\n", "## Contributing\n", "\n", "Contributors are welcome to open an issue requesting new features or fixes or opening a pull request for them.\n", "\n", "## License\n", "\n", "The library is licensed under LGPLv3.\n"]
16
17
  email:
17
18
  executables: []
18
19
  extensions: []