colyseus/colyseus-construct3

On Field Change not working

Alaadel opened this issue · 1 comments

Using On Field Change doesn't trigger in C3. I have to use On State Change.
The provided examples didn't test this event.

Here is my server code:

import { Schema, Context, type } from "@colyseus/schema";

export class ServerRoomState extends Schema {

  @type("uint8") phase: number = 0;
  
  goToPhase(phase: number) {  console.log("goToPhase", phase);
      this.phase = phase;
  }
}

Using On Field Change in Construct 3 (with parameter Path=phase) doesn't trigger.

I have made another test using a remix of the https://glitch.com/edit/#!/colyseus-construct3.
Here is my code:
in State.ts:

width = WORLD_SIZE;
  height = WORLD_SIZE;
  @type("uint8") test1: number = 0;
  @type("uint8") test2: number = 0;
  @type("uint8") test3: number = 0;
// ...

in ArenaRoom.ts:

this.onMessage("mouse", (client, messageString) => {
      const message = JSON.parse(messageString)
      const entity = this.state.entities.get(client.sessionId);

      // skip dead players
      if (!entity) {
        console.log("DEAD PLAYER ACTING...");
        return;
      }

      this.state.test1 = Math.random() * 12;
      this.state.test2 = Math.random() * 102;
      this.state.test3 = Math.random() * 121;
// ...

my client:
onfield.zip

Observed result:
using OnFieldChange for test1, test2, and test3 only fires test3.