Skip to content

Commit 3706c5f

Browse files
committed
remove import path and fixes for travis
1 parent 93415f8 commit 3706c5f

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ branch:
22
only:
33
- "master"
44
language: go
5-
go_import_path: engo.io/ecs
5+
go_import_path: github.com/EngoEngine/ecs
66
go:
77
- 1.6.2

README.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
[![Build Status](https://travis-ci.org/EngoEngine/ecs.svg?branch=master)](https://travis-ci.org/EngoEngine/ecs)
44

5-
This is our implementation of the "Entity Component System" model in Go. It was designed to be used in `engo`, however
5+
This is our implementation of the "Entity Component System" model in Go. It was designed to be used in `engo`, however
66
it is not dependent on any other packages so is able to be used wherever!
77

88
## Basics
99
In the Entity Component System paradigm, you have three elements;
1010

1111
* Entities
1212
* Components
13-
* Systems.
13+
* Systems.
1414

15-
In our implementation, we use the type `World` to work with those `System`s. Each `System` can have references to any number (including 0) of entities. And each `Entity` can have as many `Component`s as desired.
15+
In our implementation, we use the type `World` to work with those `System`s. Each `System` can have references to any number (including 0) of entities. And each `Entity` can have as many `Component`s as desired.
1616

1717
An example of creating a `World`, adding a `System` to it, and update all systems
1818
```go
19-
// Declare the world - you can also use "var world ecs.World"
19+
// Declare the world - you can also use "var world ecs.World"
2020
world := ecs.World{}
2121

22-
// You can add as many Systems here as you like. The RenderSystem provided by `engo` is just an example.
22+
// You can add as many Systems here as you like. The RenderSystem provided by `engo` is just an example.
2323
world.AddSystem(&engo.RenderSystem{})
2424

2525
// This will usually be called within the game-loop, in order to update all Systems on every frame.
@@ -39,10 +39,10 @@ type System interface {
3939
}
4040
```
4141

42-
What does this say? It needs to have an `Update` method (which is called from `world.Update`), and it needs to have a `Remove(ecs.BasicEntity)` method. Why require a Remove method, but not an Add method? Because there's no 'generic' `Add` method (the parameters may change), while in order to remove something, all you need it the unique identifier (as provided by the `BasicEntity`).
42+
What does this say? It needs to have an `Update` method (which is called from `world.Update`), and it needs to have a `Remove(ecs.BasicEntity)` method. Why require a Remove method, but not an Add method? Because there's no 'generic' `Add` method (the parameters may change), while in order to remove something, all you need it the unique identifier (as provided by the `BasicEntity`).
4343

4444
### Initialization
45-
Optionally, your `System` may implement the `Initializer` interface, which allows you to do initialization for the given `World`. Basically, it allows you to initialize values, without having to call the function manually before adding it to the `World`. Whenever you add a `System` (one that implements the `Initializer` interface) to the world, the `New` method will be called.
45+
Optionally, your `System` may implement the `Initializer` interface, which allows you to do initialization for the given `World`. Basically, it allows you to initialize values, without having to call the function manually before adding it to the `World`. Whenever you add a `System` (one that implements the `Initializer` interface) to the world, the `New` method will be called.
4646

4747
```go
4848
type Initializer interface {
@@ -53,7 +53,7 @@ type Initializer interface {
5353
```
5454

5555
### Priority
56-
Optionally, your `System` may implement the `Prioritizer` interface, which allows the `World` to sort the `System`s based on that priority. If omitted, a value of `0` is assumed.
56+
Optionally, your `System` may implement the `Prioritizer` interface, which allows the `World` to sort the `System`s based on that priority. If omitted, a value of `0` is assumed.
5757

5858
```go
5959
type Prioritizer interface {
@@ -65,7 +65,7 @@ type Prioritizer interface {
6565
## Entities and Components
6666
Where do the entities come in? All game-logic has to be done within `System`s (the `Update` method, to be precise)). `Component`s store data (which is used by those `System`s). An `Entity` is no more than a wrapper which combines multiple `Component`s and adds a unique identifier to the whole. This unique identifier is nothing magic: simply an incrementing integer value - nothing to worry about.
6767

68-
> Because the precise definition of those `Component`s can vary, this `ecs` package provides no `Component`s -- we only provide examples here. The `engo.io/engo/common` package offers lots of `Component`s and `System`s to work with, out of the box.
68+
> Because the precise definition of those `Component`s can vary, this `ecs` package provides no `Component`s -- we only provide examples here. The `github.com/EngoEngine/engo/common` package offers lots of `Component`s and `System`s to work with, out of the box.
6969
7070
Let's view an example:
7171

@@ -87,7 +87,7 @@ type Player struct {
8787
}
8888
```
8989

90-
Here, the type `Player` is made out of three elements: the unique identifier (`ecs.BasicEntity`) and two `Component`s. A `System` may make use of one or more of those `Component`s. Which are required, is defined by the `Add` method on that `System`.
90+
Here, the type `Player` is made out of three elements: the unique identifier (`ecs.BasicEntity`) and two `Component`s. A `System` may make use of one or more of those `Component`s. Which are required, is defined by the `Add` method on that `System`.
9191

9292
Let's view a few examples:
9393

@@ -111,7 +111,7 @@ for _, system := range world.Systems() {
111111

112112
// Use a type-switch to figure out which System is which
113113
switch sys := system.(type) {
114-
114+
115115
// Create a case for each System you want to use
116116
case *MySystem1:
117117
sys.Add(&player.BasicEntity, &player.SpaceComponent)
@@ -121,13 +121,13 @@ for _, system := range world.Systems() {
121121
}
122122
```
123123

124-
That is all there is to it.
124+
That is all there is to it.
125125

126126
## Custom Systems - How to save Entities?
127127

128-
You more than likely will want to create `System`s yourself. We will now go in depth on what you should do when defining your own `Add` method for your `System`. As seen above, you can create any number (and type of) parameters you want.
128+
You more than likely will want to create `System`s yourself. We will now go in depth on what you should do when defining your own `Add` method for your `System`. As seen above, you can create any number (and type of) parameters you want.
129129

130-
> We do ask you to let *the first argument* be of type `*ecs.BasicEntity` - as a general rule.
130+
> We do ask you to let *the first argument* be of type `*ecs.BasicEntity` - as a general rule.
131131
132132
Your `System` should include an array, slice or map in which to store those entities. Now it is important to note that you're not receiving entities per se -- you are receiving references to the `Component`s you need. The actual `Entity` (type `Player` in our example) may contain way more `Component`s. You will most-likely want to create a struct for you to store those pointers in. An example:
133133

@@ -147,10 +147,10 @@ func (m *MyAwesomeSystem) Add(basic *ecs.BasicEntity, space *SpaceComponent) {
147147
```
148148

149149
> ### NOTE
150-
> As a convention, please include "System" in the name of your `System` -- at the end. When you define a struct (which contains pointers, as opposed to the `Player` struct we created earlier), please replace that `System` part with `Entity`. You should **only** use this newly-created struct in your similarly-named `System`. You will usually *never* want to export that `Entity` definition, as it is only being used in that `System`. If your system would be called `BallMovementSystem`, then your struct would be called `ballMovementEntity`.
150+
> As a convention, please include "System" in the name of your `System` -- at the end. When you define a struct (which contains pointers, as opposed to the `Player` struct we created earlier), please replace that `System` part with `Entity`. You should **only** use this newly-created struct in your similarly-named `System`. You will usually *never* want to export that `Entity` definition, as it is only being used in that `System`. If your system would be called `BallMovementSystem`, then your struct would be called `ballMovementEntity`.
151151
152152
### Removing Entities from your System
153-
Your `System` must implement the `Remove` method as specified by the `System` interface. Whenever you start storing entities, you should define this method in such a way, that it removes the custom-created non-exported `Entity`-struct from the array, slice or map. An `ecs.BasicEntity` is given for you to figure out which element in the array, slice or map it is.
153+
Your `System` must implement the `Remove` method as specified by the `System` interface. Whenever you start storing entities, you should define this method in such a way, that it removes the custom-created non-exported `Entity`-struct from the array, slice or map. An `ecs.BasicEntity` is given for you to figure out which element in the array, slice or map it is.
154154

155155
```go
156156
// Remove removes the Entity from the System. This is what most Remove methods will look like
@@ -160,7 +160,7 @@ func (m *MyAwesomeSystem) Remove(basic ecs.BasicEntity) {
160160
if entity.ID() == basic.ID() {
161161
delete = index
162162
break
163-
}
163+
}
164164
}
165165
if delete >= 0 {
166166
m.entities = append(m.entities[:delete], m.entities[delete+1:]...)
@@ -169,18 +169,18 @@ func (m *MyAwesomeSystem) Remove(basic ecs.BasicEntity) {
169169

170170
// OR, if you were using a `map` instead of a `slice`:
171171

172-
// Remove removes the Entity from the System. As you see, removing becomes easier when using a `map`.
172+
// Remove removes the Entity from the System. As you see, removing becomes easier when using a `map`.
173173
func (m *MyAwesomeSystem) Remove(basic ecs.BasicEntity) {
174174
delete(m.entities, basic.ID())
175175
}
176176
//
177177
```
178178

179179
> #### NOTE
180-
> Even though that a `map` looks easier, if you want to loop over that `map` each frame, writing those additional lines to use a `slice` instead, is definitely worth it in terms of runtime performance. Iterating over a `map` is a lot slower.
180+
> Even though that a `map` looks easier, if you want to loop over that `map` each frame, writing those additional lines to use a `slice` instead, is definitely worth it in terms of runtime performance. Iterating over a `map` is a lot slower.
181181
182182
## Custom Systems - The Update method
183-
Whatever your `System` does on the `Update` method, is up to you. Each `System` is unique in that sense. If you're storing entities, then you might want to loop over them each frame. Again, this depends on your use-case.
183+
Whatever your `System` does on the `Update` method, is up to you. Each `System` is unique in that sense. If you're storing entities, then you might want to loop over them each frame. Again, this depends on your use-case.
184184

185185
```go
186186
func (m *MyAwesomeSystem) Update(dt float32) {
@@ -249,14 +249,14 @@ func (m *MySystem) AddByInterface(o ecs.Identifier) {
249249
}
250250
```
251251

252-
To use the system, instead of `w.AddSystem()` use
252+
To use the system, instead of `w.AddSystem()` use
253253

254254
```go
255255
var myable *Myable
256256
w.AddSystemInterface(&MySystem{}, myable, nil)
257257
```
258258

259-
### Note
259+
### Note
260260
This takes **a pointer to** the interface that the system needs implemented to use AddByInterface.
261261

262262
Finally, to add an entity, rather than looping through all the systems, you can just

doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
//
3434
// For instance, an animation system may render entities possessing animation
3535
// components.
36-
package ecs // import "engo.io/ecs"
36+
package ecs

0 commit comments

Comments
 (0)