Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
npx commitlint --edit $1
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
npx lint-staged
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ For [example](https://netcodejs.github.io/netcode/example/) site, you can view c
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.

```typescript
@NetComp("Vector")
class VectorComp {
@NetSerable("Vector")
class Vector {
@NetVar(DataType.float)
x: number = 0;
@NetVar(DataType.float)
Expand All @@ -37,10 +37,10 @@ class VectorComp {
It allows for nested use.

```typescript
@NetComp("Transform")
class TransformComp {
@NetVar(VectorComp)
position: VectorComp = new VectorComp();
@NetSerable("Transform")
class TransformComp extends IComp {
@NetVar(Vector)
position: Vector = new Vector();
@NetVar(DataType.float)
rotation: number = 0;
}
Expand All @@ -51,7 +51,8 @@ class TransformComp {
Component also support rpc. When tagged with `@NetRpc(type: RpcType)`, the method could convert to networking function.

```typescript
class TransformComp {
@NetSerable("Transform")
class TransformComp extends IComp {
// ... as above
@NetRpc(RpcType.CLIENT)
move(x: number, y: number) {
Expand All @@ -66,12 +67,11 @@ class TransformComp {
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).

```typescript
const people = new Entity();
const transAdd = people.add(TransformComp);
const people = new Entity(new TransformComp());
// It is the same as transAdd above.
const transGet = people.get(TransformComp);
people.has(TransformComp); // It will be true;
trans.x = 123;
trans.position.x = 123;
```

Otherwises, it provides a more accessible way that use property `$comps` after `add()`.
Expand Down
3 changes: 2 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
],
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
["@babel/plugin-proposal-class-properties", { loose: true }],
["@babel/proposal-class-properties", { legacy: true }],
"babel-plugin-parameter-decorator",
],
};
Loading