Skip to content

Commit 57cfa88

Browse files
committed
Merge branch 'main' of https://github.com/csprance/gecs
2 parents 76d5aad + 16d7bc3 commit 57cfa88

File tree

1 file changed

+21
-29
lines changed

1 file changed

+21
-29
lines changed

README.md

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Here's how to create a new component:
8989

9090
```gdscript
9191
# c_bounce.gd
92-
class_name CBounce
92+
class_name C_Bounce
9393
extends Component
9494
9595
@export var normal := Vector2.ZERO
@@ -130,12 +130,12 @@ extends System
130130
131131
func query():
132132
# All entities that all have transform, velocity and bounce components
133-
return q.with_all([CTransform, CVelocity, CBounce])
133+
return q.with_all([C_Transform, C_Velocity, C_Bounce])
134134
135135
func process(entity: Entity, delta: float):
136-
var c_bounce: CBounce = entity.get_component(CBounce)
136+
var c_bounce = entity.get_component(C_Bounce) as C_Bounce
137137
if c_bounce.should_bounce:
138-
var c_velocity: CVelocity = entity.get_component(CVelocity)
138+
var c_velocity = entity.get_component(C_Velocity) as C_Velocity
139139
c_velocity.direction = c_bounce.normal
140140
c_bounce.should_bounce = false
141141
```
@@ -165,11 +165,11 @@ func _ready() -> void:
165165
166166
func _process(delta):
167167
# Process only systems in the "gameplay" group
168-
ECS.process(delta, "gameplay")
168+
world.process(delta, "gameplay")
169169
170170
func _physics_process(delta):
171171
# Process only systems in the "physics" group
172-
ECS.process(delta, "physics")
172+
world.process(delta, "physics")
173173
```
174174

175175
## Example Project
@@ -183,7 +183,7 @@ To illustrate the usage of GECS, let's look at an example project that simulates
183183

184184
```gdscript
185185
# c_bounce.gd
186-
class_name CBounce
186+
class_name C_Bounce
187187
extends Component
188188
189189
@export var normal := Vector2.ZERO
@@ -194,7 +194,7 @@ extends Component
194194

195195
```gdscript
196196
# c_velocity.gd
197-
class_name CVelocity
197+
class_name C_Velocity
198198
extends Component
199199
200200
@export var direction := Vector2.ZERO
@@ -205,7 +205,7 @@ extends Component
205205

206206
```gdscript
207207
# c_transform.gd
208-
class_name CTransform
208+
class_name C_Transform
209209
extends Component
210210
211211
@export var transform: Transform2D
@@ -237,7 +237,7 @@ func on_ready() -> void:
237237
Utils.sync_transform(self)
238238
```
239239

240-
Includes `CPlayerMovement`, `CVelocity`, `CTransform`, and `CFriction` components.
240+
Includes `C_PlayerMovement`, `C_Velocity`, `C_Transform`, and `C_Friction` components.
241241

242242
### Systems
243243

@@ -249,12 +249,12 @@ class_name BounceSystem
249249
extends System
250250
251251
func query():
252-
return q.with_all([CTransform, CVelocity, CBounce])
252+
return q.with_all([C_Transform, C_Velocity, C_Bounce])
253253
254254
func process(entity: Entity, delta: float):
255-
var c_bounce: CBounce = entity.get_component(CBounce)
255+
var c_bounce = entity.get_component(C_Bounce) as C_Bounce
256256
if c_bounce.should_bounce:
257-
var c_velocity: CVelocity = entity.get_component(CVelocity)
257+
var c_velocity = entity.get_component(C_Velocity) as C_Velocity
258258
c_velocity.direction = c_bounce.normal
259259
c_bounce.should_bounce = false
260260
```
@@ -267,11 +267,11 @@ class_name VelocitySystem
267267
extends System
268268
269269
func query():
270-
return q.with_all([CVelocity, CTransform])
270+
return q.with_all([C_Velocity, C_Transform])
271271
272272
func process(entity: Entity, delta: float):
273-
var c_velocity: CVelocity = entity.get_component(CVelocity)
274-
var c_transform: CTransform = entity.get_component(CTransform)
273+
var c_velocity = entity.get_component(C_Velocity) as C_Velocity
274+
var c_transform = entity.get_component(C_Transform) as C_Transform
275275
var velocity_vector: Vector2 = c_velocity.direction.normalized() * c_velocity.speed
276276
c_transform.transform.origin += velocity_vector * delta
277277
```
@@ -284,7 +284,7 @@ class_name Transform2DSystem
284284
extends System
285285
286286
func query():
287-
return q.with_all([CTransform])
287+
return q.with_all([C_Transform])
288288
289289
func process(entity: Entity, delta):
290290
Utils.sync_transform(entity)
@@ -316,14 +316,14 @@ q
316316
**Example**:
317317

318318
```gdscript
319-
var entities_with_velocity_and_not_captured = q.with_all([CVelocity]).with_none([CCaptured])
319+
var entities_with_velocity_and_not_captured = q.with_all([C_Velocity]).with_none([C_Captured])
320320
```
321321

322322
**Group Searching with Query Builder**
323323

324324
GECS supports filtering entities by Godot Group directly via the QueryBuilder. For example:
325325
```gdscript
326-
var entities = q.with_all([CVelocity]).with_group("enemy")
326+
var entities = q.with_all([C_Velocity]).with_group("enemy")
327327
```
328328
This returns only entities with the specified components and that belong to the "enemy" group.
329329

@@ -337,10 +337,10 @@ Systems have properties that allow for customizing their execution:
337337
Example:
338338
```gdscript
339339
func _physics_process(delta):
340-
ECS.process(delta, "physics")
340+
world.process(delta, "physics")
341341
342342
func _process(delta):
343-
ECS.process(delta, "gameplay")
343+
world.process(delta, "gameplay")
344344
```
345345
This will only process systems that are in the "physics" group in the physics process function and gameplay system in the _process function
346346

@@ -354,14 +354,6 @@ Systems can be assigned to specific groups, enabling you to control when and how
354354

355355
In your system script, set the `group` property to specify which group the system belongs to. These are not the same as godot groups.
356356

357-
**Import and Export World Functionality**
358-
359-
GECS now allows you to save and load the entire world state. Use these methods:
360-
- `ECS.export_world(file_path)` to export the current world state.
361-
- `ECS.import_world(file_path)` to import a saved world state into the world. Optionally purge the world
362-
363-
These functions facilitate state persistence and dynamic world loading.
364-
365357
### Pause Functionality
366358

367359
GECS systems inherit the regular Godot process modes, letting you choose whether they should run during pause.

0 commit comments

Comments
 (0)