Skip to content

Commit 8076b82

Browse files
Kelwanzaucy
authored andcommitted
Initial commit, work with @zaucy refining docs (#50)
1 parent 0d331dd commit 8076b82

File tree

10 files changed

+108
-65
lines changed

10 files changed

+108
-65
lines changed
Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,68 @@
11
<article>
22
<h1 id="ecs">What is ECS?</h1>
33
<p>
4-
ECS stands for Entity Component System. It's an architecture that uses data
5-
assocation over traditional methods like inheritance. Up to this point it's
6-
been most commonly used for designing video games (Although it can and has
7-
been used elsewhere)
4+
Entity Component System (ECS) is an architecture that uses data assocation
5+
over traditional methods like inheritance. It's been most commonly used in
6+
video game development. We'll give a brief overview in relation to Ecsact,
7+
but you can read more about ECS on
8+
<a
9+
href="https://en.wikipedia.org/wiki/Entity_component_system"
10+
target="_blank"
11+
><span class="i24">open_in_new</span>Wikipedia</a
12+
>.
813
</p>
914

1015
<h2 id="entities">Entities</h2>
1116
<p>
12-
An entitiy is a unique identifer that can hold zero or more components.
13-
Components can be added or removed from the entity dynamically
17+
An entitiy is a unique identifer that can be associated with zero or more
18+
unique components. Components can be added or removed from the entity
19+
dynamically.
1420
</p>
1521

1622
<h2 id="components">Components</h2>
1723
<p>
18-
A component is a datatype that can be attached to an entity. Components
19-
don't hold any behaviours and provides ways to be iterated over in systems
24+
A component holds data and associates with an entity. Components don't
25+
define behaviour, they provide state for systems.
2026
</p>
2127

2228
<pre><code ecsactLangSyntax>
2329
// Creates a component in Ecsact called Health
2430
component Health {{'{'}}
25-
int32 value;
31+
// Maintains the state of how much "health" an entity has
32+
i32 value;
2633
{{'}'}}
34+
35+
// A tag to associate an entity with being "dead"
36+
component Dead;
2737
</code></pre>
2838

2939
<h2 id="systems">Systems</h2>
3040
<p>
31-
A system iterates over entities with the request components. They can add,
32-
remove, and manipulate the data on components. This changes the behaviour of
33-
an entity and alters its state through associated components
41+
A system is a defined function that matches with entities meeting its
42+
capabilities. They can add, remove, and manipulate the data on components.
43+
This changes the behaviour of an entity and alters state through its
44+
associated components.
3445
</p>
3546
<pre><code ecsactLangSyntax>
36-
// This system iterates over every entity that has a Health Component
37-
system UpdateHealth {{'{'}}
38-
required Health;
47+
// This system is run for every "alive" entity that has a Health Component
48+
system CheckDead {{'{'}}
49+
readonly Health;
50+
// If the value of health is 0, the entity will be considered dead
51+
adds Dead;
3952
{{'}'}}
4053
</code></pre>
4154

4255
<h2>Benefits to using ECS</h2>
43-
<p>
44-
ECS has high reusability and prevents creating constrictive design. With the
45-
right components, an entity can be anything
46-
</p>
56+
<ul>
57+
<h3>Performance</h3>
58+
<p>Add performance benefits here</p>
59+
<div>
60+
<h3>Composition over inheritance</h3>
61+
<p>
62+
-- Separate data and behaviour, allowing you to mix and match easily and
63+
quickly.
64+
</p>
65+
<h3>Try to add more</h3>
66+
</div>
67+
</ul>
4768
</article>

src/app/docs/setup/setup.component.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h2>Setting up Ecsact</h2>
44
<p>
55
Learn about integrations, custom use, and various ways that Ecsact can be
6-
implemented
6+
implemented.
77
</p>
88

99
<h3 id="unity-integration">Unity Integration</h3>
@@ -42,19 +42,19 @@ <h4 id="unity-ecsact">Unity Integration: Creating the .ecsact File</h4>
4242
main package example;
4343

4444
component Example {{'{'}}
45-
int32 example_value;
45+
i32 example_value;
4646
{{'}'}}
4747

4848
system UseExample {{'{'}}
49-
required Example;
49+
readwrite Example;
5050
{{'}'}}
5151
</code></pre>
5252

5353
<p>
5454
<span class="i48">info</span>
5555
Check out the
5656
<a routerLink="/docs/lang" routerLinkActive="active">Language</a> section
57-
to learn more about Ecsact syntax
57+
to learn more about Ecsact syntax.
5858
</p>
5959
<p>
6060
<b>NOTE:</b> You may get errors about missing components that you will
@@ -73,7 +73,7 @@ <h4 id="unity-ecsact">Unity Integration: Creating the .ecsact File</h4>
7373
</p>
7474

7575
<h4 id="ecsact-code-output">Ecsact code output</h4>
76-
<p>When the code is generated in C# and any other language being used</p>
76+
<p>When the code is generated in C# and any other language being used:</p>
7777
<ul class="list-disc list-inside">
7878
<li>Packages are namespaces</li>
7979
<li>Components are structs</li>
@@ -98,14 +98,14 @@ <h4 id="using-unity-ecsact">Using the Unity Integration</h4>
9898
<pre><code prism language="csharp" class="language-csharp">ecsactRuntimeInstance.core.CreateRegistry()</code></pre>
9999
<p>
100100
Or you can use the default registry in the settings with the default
101-
runner. If you're interested, read the next section
101+
runner. If you're interested, read the next section.
102102
</p>
103103
<p>IMAGE HERE</p>
104104

105105
<h4 id="default runner">Default Runner</h4>
106106
<p>
107107
If you want to avoid creating and destroying instances of registries, you
108-
can set up the default runner in the Ecsact settings
108+
can set up the default runner in the Ecsact settings.
109109
</p>
110110
<ol>
111111
<li>
@@ -155,7 +155,7 @@ <h4>Without Using Systems</h4>
155155
</p>
156156
<p>
157157
First, we'll create an entity using the runtime instance we declared
158-
earlier. This returns a unique integer we can use to identify it
158+
earlier. This returns a unique integer we can use to identify it.
159159
</p>
160160
<pre><code prism language="csharp">entityId = runtime.core.CreateEntity(runner.registryId);</code></pre>
161161

@@ -178,7 +178,7 @@ <h4>Without Using Systems</h4>
178178
<p>
179179
Because we are using the FixedUpdate runner, we'll want to declare the
180180
<code>FixedUpdate()</code> function in Unity.From there, we'll retrieve
181-
the component from the entity we created
181+
the component from the entity we created.
182182
</p>
183183

184184
<pre><code prism language="csharp" class="language-csharp">
@@ -192,7 +192,7 @@ <h4>Without Using Systems</h4>
192192
<p>
193193
Now that we have an instance of the component, we can modify its
194194
underlying data. In this case we only have "example_value", we'll increase
195-
its value by 1 per FixedUpdate
195+
its value by 1 per FixedUpdate.
196196
</p>
197197

198198
<pre><code prism language="csharp" class="language-csharp">
@@ -202,7 +202,7 @@ <h4>Without Using Systems</h4>
202202

203203
<p>
204204
With the value increasing by 1, we want a simple way to see the result of
205-
our changes. Let's log it out in the console
205+
our changes. Let's log it out in the console.
206206
</p>
207207

208208
<pre><code prism language="csharp" class="language-csharp">
@@ -212,7 +212,7 @@ <h4>Without Using Systems</h4>
212212
<p>
213213
So the value has increased by 1, but how do we make sure the values inside
214214
of the component is changed the next time it's retrieved? We'll call a
215-
function to update the component so the changes you make are permanent
215+
function to update the component so the changes you make are permanent.
216216
</p>
217217
<pre><code prism language="csharp" class="language-csharp">
218218
// Update the component value on each FixedUpdate
@@ -238,7 +238,7 @@ <h4>Without Using Systems</h4>
238238
<h5>Next steps</h5>
239239
<p>
240240
If you enjoyed using Ecsact, and see the potential it can offer then check
241-
out how systems can be used. SOME LINK TO systems tutorial
241+
out how systems can be used. SOME LINK TO systems tutorial.
242242
</p>
243243
<div>Next Steps Filler</div>
244244
<div>Next Steps Filler</div>

src/app/docs/unity/defaults/defaults.component.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ <h3>ExecutionOptions</h3>
5151
</section>
5252
<section>
5353
<h2 id="pool">Pool</h2>
54-
<p>The pool requires Unity Sync to be enabled</p>
54+
<p>
55+
The pool is made for Unity Sync, and only available when it's enabled in
56+
your <code>settings</code>.
57+
</p>
58+
<h3>Target Scene</h3>
59+
<p>
60+
You can ensure that an entity only spawns in a scene using
61+
<code>Pool.targetScene</code>
62+
</p>
63+
<h3>Root Game Object</h3>
64+
<p>
65+
You can make your entity a child a singular GameObject using
66+
<code>Pool.rootGameObject</code>
67+
</p>
68+
<h3>Set Preferred Entity Game Object</h3>
69+
<p>
70+
Instead of creating a new GameObject by default for each entity, you can
71+
set your own preffered GameObject using
72+
<code>Pool.SetPreferredEntityGameObject</code>
73+
</p>
5574
</section>
5675
</article>

src/app/docs/unity/entities/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ng_ts_project(
1818
deps = [
1919
"//src/components/code-block-variation",
2020
"//src/components/ecsact-lang-syntax",
21+
"//src/components/prism",
2122
"@npm//@angular/common",
2223
"@npm//@angular/core",
2324
"@npm//@angular/router",

src/app/docs/unity/entities/entities.component.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ <h2>Using the Registry</h2>
88
ID of the entity created
99
</p>
1010
<code-block-variation>
11-
<pre codeBlockVariationOption><code prism language="csharp">
12-
int entityId = Ecsact.Defaults.Registry.CreateEntity();
13-
</code></pre>
11+
<pre
12+
codeBlockVariationOption><code prism language="csharp">int entityId = Ecsact.Defaults.Registry.CreateEntity();</code></pre>
1413
</code-block-variation>
1514
</section>
1615
<section>
17-
<h2>Dynamic Entity</h2>
16+
<h2 id="dynamic_entity">Dynamic Entity</h2>
1817
<p>
1918
A convenient Monobehaviour that allows you to create an entity and add
2019
components to it through the Unity UI
2120
</p>
2221
<img src="assets/DynamicEntityExample.png" width="300" height="300" />
2322
</section>
23+
<p>
24+
Note: The dynamic entity uses
25+
<a routerLink="/docs/unity/defaults" fragment="pool"
26+
>SetPreferredEntityGameObject</a
27+
>
28+
when Unity Sync is enabled.
29+
</p>
2430
<section>
2531
<h2>Generating Entities</h2>
2632
<p>
@@ -29,8 +35,8 @@ <h2>Generating Entities</h2>
2935
</p>
3036
<code-block-variation>
3137
<pre codeBlockVariationOption><code ecsactLangSyntax>
32-
component Component A{{'{'}}{{'}'}};
33-
component Component B{{'{'}}{{'}'}};
38+
component ComponentA;
39+
component ComponentB;
3440

3541
system GenerateEntity {{'{'}}
3642
generates {{'{'}}

src/app/docs/unity/entities/entities.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ import {RouterModule} from '@angular/router';
44
import {EntitiesComponent} from './entities.component';
55
import {CodeBlockVariationModule} from '../../../../components/code-block-variation/code-block-variation.module';
66
import {EcsactLangSyntaxModule} from '../../../../components/ecsact-lang-syntax/ecsact-lang-syntax.module';
7+
import {PrismModule} from '../../../../components/prism/prism.module';
78

89
@NgModule({
910
declarations: [EntitiesComponent],
10-
imports: [RouterModule, CodeBlockVariationModule, EcsactLangSyntaxModule],
11+
imports: [
12+
RouterModule,
13+
CodeBlockVariationModule,
14+
EcsactLangSyntaxModule,
15+
PrismModule,
16+
],
1117
exports: [EntitiesComponent],
1218
bootstrap: [],
1319
})

src/app/docs/unity/system-impl/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ng_ts_project(
1717
],
1818
deps = [
1919
"//src/components/code-block-variation",
20+
"//src/components/prism",
2021
"@npm//@angular/common",
2122
"@npm//@angular/core",
2223
"@npm//@angular/router",

src/app/docs/unity/system-impl/system-impl.component.html

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ <h1>Implementing Systems in Unity</h1>
77
<section>
88
<h2>System Declaration</h2>
99
<p>
10-
Systems have a <code>Unity Attribute</code> in its implementation. The
11-
type name of the system is put here to get the correct
12-
<code>context</code>. The context holds the logic of the system. This
13-
includes getting components, generating entities and retrieving data on
14-
actions.
10+
Systems have a <code>C# Attribute</code> in its implementation. The type
11+
name of the system is put here to get the correct <code>context</code>.
12+
The context holds the logic of the system. This includes getting
13+
components, generating entities and retrieving data on actions.
1514
</p>
1615
<code-block-variation>
1716
<pre codeBlockVariationOption><code prism language="csharp">
1817
[Ecsact.DefaultSystemImpl(typeof(example.ExampleSystem))]
19-
public static void AddToExampleSystem
20-
( EcsactRuntime.SystemExecutionContext context
21-
)
22-
{{'{'}}
18+
public static void AddToExampleSystem(EcsactRuntime.SystemExecutionContext context) {{'{'}}
2319
// Get component from the context
2420
var value = context.Get<{{'example.Example'}}>();
2521
{{'}'}}

src/app/docs/unity/system-impl/system-impl.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {NgModule} from '@angular/core';
22
import {RouterModule} from '@angular/router';
33
import {CodeBlockVariationModule} from '../../../../components/code-block-variation/code-block-variation.module';
4+
import {PrismModule} from '../../../../components/prism/prism.module';
45

56
import {SystemImplComponent} from './system-impl.component';
67

78
@NgModule({
89
declarations: [SystemImplComponent],
9-
imports: [RouterModule, CodeBlockVariationModule],
10+
imports: [RouterModule, CodeBlockVariationModule, PrismModule],
1011
exports: [SystemImplComponent],
1112
bootstrap: [],
1213
})
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import { NgModule } from '@angular/core';
2-
import { CommonModule } from '@angular/common';
3-
import { EcsactLangSyntaxComponent } from './ecsact-lang-syntax.component';
4-
5-
1+
import {NgModule} from '@angular/core';
2+
import {CommonModule} from '@angular/common';
3+
import {EcsactLangSyntaxComponent} from './ecsact-lang-syntax.component';
64

75
@NgModule({
8-
declarations: [
9-
EcsactLangSyntaxComponent
10-
],
11-
imports: [
12-
CommonModule
13-
],
14-
exports: [
15-
EcsactLangSyntaxComponent
16-
]
6+
declarations: [EcsactLangSyntaxComponent],
7+
imports: [CommonModule],
8+
exports: [EcsactLangSyntaxComponent],
179
})
18-
export class EcsactLangSyntaxModule { }
10+
export class EcsactLangSyntaxModule {}

0 commit comments

Comments
 (0)