Skip to content

Commit 0fbbd36

Browse files
committed
Improve README
- Improve wording - Improve formatting - Improve example code
1 parent aefdcb5 commit 0fbbd36

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ The core of this library consists of two components:
162162

163163
However, most features that you'll be interacting with directly are implemented in other classes:
164164

165-
- There are many **built-in coroutine types** (subclasses of the `CoroutineBase` class) that implement various different features, such as delays, running coroutines in parallel, awaiting an async task, ...
165+
- There are many **built-in coroutine types** (subclasses of the `CoroutineBase` class) that implement various different features, such as delays, running coroutines in parallel, awaiting async tasks, ...
166166

167167
- The **most important coroutine** type is the `Coroutine` class. It allows you to define a coroutine in the intuitive / standard way with `IEnumerator`s (like in Unity).
168168

@@ -233,6 +233,12 @@ or:
233233
Co.Run(MyCoroutine());
234234
```
235235

236+
Both are equivalent to writing:
237+
238+
```csharp
239+
Co.Run(new Coroutine(MyCoroutine()));
240+
```
241+
236242
### Process Mode
237243

238244
When interacting with Godot's physics system, it's often necessary to run code in `_PhysicsProcess()` instead of the regular `_Process()` method.
@@ -249,7 +255,7 @@ new Coroutine(MyCoroutine(), processMode: CoProcessMode.Inherit);
249255
- `CoProcessMode.Physics` = run in physics frames.
250256
- `CoProcessMode.Inherit` = inherit the process mode from the parent coroutine.
251257

252-
This option is also available for other coroutine types, e.g. `ParallelCoroutine`. By default, coroutines **inherit** the process mode from their parents. If a coroutine has no parent, it defaults to `CoProcessMode.Normal`. This means that if you have a `ParallelCoroutine` that sets its process mode to `Physics`, all its child coroutines that are run in parallel will also run in physics frames (provided that they have their mode set to `Inherit`).
258+
This option is also available for other coroutine types, e.g. `ParallelCoroutine`. By default, coroutines **inherit** the process mode from their parents. If a coroutine has no parent, it defaults to `CoProcessMode.Normal`. This means that if you have a `ParallelCoroutine` that sets its process mode to `Physics`, all its child coroutines will also run in physics frames (provided that they have their mode set to `Inherit`).
253259

254260
The useful `Co` class also exposes the `processMode` parameter when creating coroutines:
255261

@@ -359,7 +365,7 @@ IEnumerator PlayGuiMoveAnimation() {
359365
- Waits until a certain condition is true.
360366

361367
- `WaitForSignalCoroutine`
362-
- `Co.WaitForSignal(obj, signal name)``
368+
- `Co.WaitForSignal(obj, signal name)`
363369
- Waits for a signal to be emitted.
364370

365371
- `AwaitCoroutine`
@@ -384,7 +390,7 @@ In order to set up a scene-local coroutine manager, simply add the `CoroutineMan
384390

385391
## Creating Custom Coroutines
386392

387-
You can easily create a custom coroutine type by creating a new class that inherits from `CoroutineBase`. For concrete examples, it's best to see how the built-in coroutines types are implemented by looking at the source code.
393+
You can easily create a custom coroutine type by creating a new class that inherits from `CoroutineBase`. For concrete examples, it's best to see how the built-in coroutines types are implemented by looking at the [source code](https://github.com/Inspiaaa/HCoroutines/tree/master/addons/HCoroutines/src/Coroutines).
388394

389395
#### Update Method
390396

@@ -466,6 +472,12 @@ public class AwaitFirstCoroutine : CoroutineBase
466472
foreach (var coroutine in coroutines)
467473
{
468474
StartCoroutine(coroutine);
475+
476+
// Check that the coroutine that was just started
477+
// has not finished already, causing this coroutine
478+
// to also stop.
479+
if (!IsAlive)
480+
return;
469481
}
470482
}
471483

0 commit comments

Comments
 (0)