Skip to content

EntityView ​

Class of @v12-engine/client

ts
export declare class EntityView implements Placed

An entity as the player knows it. Positions of the last two snapshots are kept to draw the frames in between

Members ​

constructor ​

ts
constructor(
    state: EntityState, 
    def: UnitTypeDef, 
    game: Registry);

Constructs a new instance of the EntityView class

apply ​

ts
apply(state: EntityState): void;

Takes a new snapshot's state in: moves the previous position and facing back, and drops them to the new where it jumped or appeared

asleep ​

ts
get asleep(): boolean;

A creep sleeping through the night

at ​

ts
at(alpha: number, out?: Vec2): Vec2;

Where it is drawn at alpha between the last two ticks. Into out when given, which is what the frame loop does: a new object for every entity every frame would be a lot of garbage

attackTiming ​

ts
attackTiming(weapon?: number): {
        swing: number;
        period: number;
        recovery: number;
    } | undefined;

How long its attack takes, the way the simulation times it: from the start of the swing to the hit (the windup), from one swing to the next, and how long it is held after the hit (AttackDef.recovery). Of its first attack, or the one at that place (UnitTypeDef.attacks)

carries beta ​

ts
get carries(): readonly string[] | undefined;

The items it carries, by id: anyone who sees it sees that (inventorySlots)

construction ​

ts
get construction(): number | undefined;

How far it is built, 0..1: undefined once it stands (constructionSite)

def ​

ts
readonly def: UnitTypeDef;

The unit type's definition it is made from, which the type's stats and looks come from

facing ​

ts
facing: number;

Which way it faces now, in radians

form beta ​

ts
get form(): FormSent | undefined;

The form a hero is in (form): what it was, what made it, until when, what it learns in it. Undefined for one that is itself

game ​

ts
readonly game: Registry;

The game it is in, which the stats it starts with depend on

health ​

ts
get health(): number;

Its health now

hero beta ​

ts
get hero(): HeroSent | undefined;

What this player is told of a hero: its level, its experience (its side's, everyone's where the rules share it), its points and what it can learn (its side's). Undefined for what is no hero (heroState)

hidden ​

ts
get hidden(): boolean;

Inside something, so not on the map

hurt ​

ts
hurt: boolean;

Has lost health, and shows it: worked out once a snapshot, for what asks every frame (the bars). What never shows its health (trees, mines, what cannot be hurt) is never hurt

id ​

ts
get id(): number;

The entity's id in the game, as world.spawn gave it

inSight ​

ts
get inSight(): boolean;

In sight right now, as opposed to remembered

inventory beta ​

ts
get inventory(): (CarriedItem | null)[] | undefined;

The slots of what it carries, null for an empty one: for the player's own and their allies' that carry items (inventorySlots)

isBuilding ​

ts
get isBuilding(): boolean;

Whether it is a building

isResource ​

ts
get isResource(): boolean;

Whether it is a resource, such as a mine or a tree

isStructure ​

ts
get isStructure(): boolean;

Whether it is a building or a resource: anything that is not a unit

isUnit ​

ts
get isUnit(): boolean;

Whether it is a unit (not a building or resource)

learns beta ​

ts
get learns(): readonly string[];

What a hero learns, in order: its form's while it is in one (learnsOf), its type's otherwise. Nothing for what is no hero

level beta ​

ts
get level(): number | undefined;

A hero's level: undefined for what is no hero (heroState)

likeness ​

ts
get likeness(): {
        type: string;
        owner: PlayerId;
    } | undefined;

The type and owner it is drawn as, when it is not its own (SpawnOptions.looksLike)

load beta ​

ts
get load(): GatheringInfo | undefined;

What a worker of the player's or an ally's carries, and of what (gathering)

look ​

ts
get look(): string | undefined;

Which of the models of its type it is drawn with, when the map says

maxHealth ​

ts
get maxHealth(): number;

Its largest health, from its state, or the type's base value where the state has none

maxMana ​

ts
get maxMana(): number;

Its largest mana, from its state, or the type's base value where the state has none

operational ​

ts
get operational(): boolean;

Whether it is finished and works: a building under construction is not

own ​

ts
get own(): import("@v12-engine/engine").OwnEntityState | undefined;

Own units and buildings come with everything there is to know about them

owner ​

ts
get owner(): number;

The player who owns it

pos ​

ts
readonly pos: Vec2;

Where it is at the last snapshot, in cells; changed in place by apply

prevFacing ​

ts
prevFacing: number;

Which way it faced at the snapshot before, in radians, which a frame eases from

prevPos ​

ts
readonly prevPos: Vec2;

Where it was at the snapshot before, in cells, which a frame between two snapshots eases from

queue beta ​

ts
get queue(): readonly QueueItemState[];

What a building of the player's or an ally's makes, the first being made: empty for one that makes nothing, or another's (productionQueue)

rally beta ​

ts
get rally(): Vec2 | undefined;

Where what a building of the player's or an ally's makes goes once out (productionQueue)

rect ​

ts
get rect(): Rect;

Its footprint on the ground as a rectangle around its position, in cells, or one of its radius where it has none

scale ​

ts
get scale(): number;

How big it is drawn

seen ​

ts
seen: number;

The last snapshot it was in, see GameState.apply

settle ​

ts
settle(): void;

Nothing changed since the last snapshot: it is where it was, and is drawn there, not sliding again from where it stood before (which would start over with every snapshot that left it as it was, a shake)

state ​

ts
state: EntityState;

The latest snapshot's state of the entity; apply replaces it

stats ​

ts
get stats(): Readonly<Stats>;

What it is capable of right now, with everything that changes it counted in

unseen ​

ts
get unseen(): boolean;

Invisible to enemies right now: it is the player's, or they found it

upgrade beta ​

ts
get upgrade(): {
        to: string;
        progress: number;
    } | undefined;

The type it is turning into and how far, 0..1, for everyone who sees it: undefined for one that is not (UnitTypeDef.upgradesTo)