You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: new class DomainOption and lifecycle Update (#9)
* feat: new class DomainOption and lifecycle Update
* chore: update README, some warnninng
* chore: add @NetVarr example for unit test
* chore: add dirty-data-class for unit test
* feat: add quick accessor for IComp
* refactor: comp-*
* refactor: handle class 'Domain' ref in class 'Entity'
Copy file name to clipboardExpand all lines: README.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,8 @@ For [example](https://netcodejs.github.io/netcode/example/) site, you can view c
23
23
Component is not class in the real sense. All class with `@NetComp(className: string)` will be collectively referred to as component.You should mark the property that need synchronize with `@NetVar(type: DataType)` and `@NetArr(type: DataType)` for array.
24
24
25
25
```typescript
26
-
@NetComp("Vector")
27
-
classVectorComp {
26
+
@NetSerable("Vector")
27
+
classVector {
28
28
@NetVar(DataType.float)
29
29
x:number=0;
30
30
@NetVar(DataType.float)
@@ -37,10 +37,10 @@ class VectorComp {
37
37
It allows for nested use.
38
38
39
39
```typescript
40
-
@NetComp("Transform")
41
-
classTransformComp {
42
-
@NetVar(VectorComp)
43
-
position:VectorComp=newVectorComp();
40
+
@NetSerable("Transform")
41
+
classTransformCompextendsIComp{
42
+
@NetVar(Vector)
43
+
position:Vector=newVector();
44
44
@NetVar(DataType.float)
45
45
rotation:number=0;
46
46
}
@@ -51,7 +51,8 @@ class TransformComp {
51
51
Component also support rpc. When tagged with `@NetRpc(type: RpcType)`, the method could convert to networking function.
52
52
53
53
```typescript
54
-
classTransformComp {
54
+
@NetSerable("Transform")
55
+
classTransformCompextendsIComp {
55
56
// ... as above
56
57
@NetRpc(RpcType.CLIENT)
57
58
move(x:number, y:number) {
@@ -66,12 +67,11 @@ class TransformComp {
66
67
In netcode, entity is unit node.It can include and manage a series of _components_. It can be registed by _Domain_. For usage refer to Cocos(Node-Component) or unity(GameObject-Monobehaviour).
67
68
68
69
```typescript
69
-
const people =newEntity();
70
-
const transAdd =people.add(TransformComp);
70
+
const people =newEntity(newTransformComp());
71
71
// It is the same as transAdd above.
72
72
const transGet =people.get(TransformComp);
73
73
people.has(TransformComp); // It will be true;
74
-
trans.x=123;
74
+
trans.position.x=123;
75
75
```
76
76
77
77
Otherwises, it provides a more accessible way that use property `$comps` after `add()`.
0 commit comments