-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vectorstate schema to avoid sync for individual posX,posY for player
- Loading branch information
1 parent
134c199
commit e9d6116
Showing
5 changed files
with
78 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Schema, type } from "@colyseus/schema"; | ||
import SAT from "sat"; | ||
export class VectorState extends Schema { | ||
// Key : sessionId | ||
@type("number") x = 0; | ||
@type("number") y = 0; | ||
constructor(x: number = 0, y: number = 0) { | ||
super(); | ||
this.x = x; | ||
this.y = y; | ||
} | ||
getVector() { | ||
return new SAT.Vector(this.x, this.y); | ||
} | ||
setVector(v: SAT.Vector) { | ||
this.x = v.x; | ||
this.y = v.y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters