All files / ts/components/entities/base entityState.ts

100% Statements 23/23
100% Branches 0/0
100% Functions 7/7
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 591x 1x 1x                       1x                                 79x 79x 79x 79x 79x   79x 79x 79x 79x 79x 79x 79x 79x       2x       2x       4x    
import { IBounds2, Bounds2 } from "../../../models/bounds2.js";
import { IVector2, Vector2 } from "../../../models/vector2.js";
import { IEntityBase, EntityBase } from "./entityBase.js";
 
export interface IEntityState extends IEntityBase {
    zIndex: number;
    opacity: number;
    scale: number;
    rotation: number;
    velocity: number;
    hitBox: IBounds2;
    direction: IVector2;
    transformOrigin: IVector2;
}
export class EntityState extends EntityBase implements IEntityState {
 
    protected _hitBoxOffsetX: number;
    protected _hitBoxOffsetY: number;
    protected _drawHitBox: boolean;
    protected _lastHitBox: IBounds2;
 
    public zIndex: number;
    public opacity: number;
    public scale: number;
    public rotation: number;
    public velocity: number;
    public hitBox: IBounds2;
    public direction: IVector2;
    public transformOrigin: IVector2;
 
    public constructor() {
        super();
        this._hitBoxOffsetX = 0;
        this._hitBoxOffsetY = 0;
        this._drawHitBox = false;
        this._lastHitBox = new Bounds2();
 
        this.zIndex = 0;
        this.opacity = 1;
        this.scale = 1;
        this.velocity = 0;
        this.rotation = 0;
        this.hitBox = new Bounds2();
        this.direction = new Vector2();
        this.transformOrigin = new Vector2(0.5, 0.5);
    }
 
    protected isActiveChanged(value: boolean): void {
        this.children.forEach(child => child.isActive = value);
    }
 
    protected isVisibleChanged(value: boolean): void {
        this.children.forEach(child => child.isVisible = value);
    }
 
    protected isEnabledChanged(value: boolean): void {
        this.children.forEach(child => child.isEnabled = value);
    }
}