Messages

import { Message } from "encompass-ecs";

Similar to Components, Messages are collections of data.

Messages are used to transmit data between Engines so they can manipulate the game state accordingly.

Unlike Components, Messages are temporary and are destroyed at the end of each frame.

For performance reasons, it is discouraged to create new objects to pass to messages, as this will cause garbage collection pressure.

You should not define default property values on Messages because Messages are reused internally for memory usage reasons.

Defining any logic on a Message is an anti-pattern.

Example

import { Message } from "encompass-ecs";

class MotionMessage extends Message {
    public component: PositionComponent;
    public x_delta: number;
    public y_delta: number;
}