Skip to content

Commit

Permalink
feat(client): Interior API (#325)
Browse files Browse the repository at this point in the history
* feat(client): Interior API

* chore(client): add description for getForInteriorID

* chore(client): add example

* fix(client): typo
  • Loading branch information
xxshady authored Nov 21, 2024
1 parent 10111ce commit 09e1e25
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,14 @@ declare module "alt-client" {
readonly propertyUpdateTicks: number[][];
}

/**
* Axis-Aligned Bounding Box.
*/
export interface IAABB {
min: number;
max: number;
}

export class BaseObject extends shared.BaseObject {
/**
* Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true).
Expand Down Expand Up @@ -4564,5 +4572,80 @@ declare module "alt-client" {
public static register(path: string): Font;
}

export class Interior {
protected constructor();

/**
* Create interior instance by id. Throws if id is invalid (for example, when it's 0).
*
* @example
* ```js
* // Get the interior where our local player is currently in
* const interiorId = natives.getInteriorFromEntity(alt.Player.local);
* if (interiorId !== 0) {
* const interior = alt.Interior.getForInteriorID(interiorId);
*
* // Output room count of it
* alt.log({
* roomCount: interior.roomCount
* });
* } else {
* alt.logError("Interior id is 0, seems like player is outside");
* }
* ```
*/
public static getForInteriorID(id: number): Interior;

public readonly id: number;
public readonly pos: shared.Vector3;
public readonly rot: shared.Vector3;
public readonly roomCount: number;
public readonly portalCount: number;
public readonly entitiesExtents: IAABB;

/**
* Get room by it's hash. Throws if room hash is invalid.
*/
public getRoomByHash(hash: number): InteriorRoom;

/**
* Get room by it's index: from 0 to {@link roomCount}, for example if `roomCount = 2`, room indexes will be 0 and 1.
* Throws if room index is invalid.
*/
public getRoomByIndex(index: number): InteriorRoom;

/**
* Get portal by it's index: from 0 to {@link portalCount}, for example if `portalCount = 2`, portal indexes will be 0 and 1.
* Throws if portal index is invalid.
*/
public getPortalByIndex(index: number): InteriorPortal;
}

export class InteriorRoom {
public readonly index: number;
public readonly name: string;
public readonly nameHash: number;
public flag: number;
public timecycle: number;
public extents: IAABB;
}

export class InteriorPortal {
public readonly index: number;
public readonly cornerCount: number;
public readonly entityCount: number;
public roomFrom: number;
public roomTo: number;
public flag: number;

public getCornerPos(cornerIndex: number): shared.Vector3;
public setCornerPos(cornerIndex: number, value: shared.Vector3): void;
public getEntityArchetype(entityIndex: number): number;
public getEntityFlag(entityIndex: number): number;
public setEntityFlag(entityIndex: number, flag: number): void;
public getEntityPos(entityIndex: number): shared.Vector3;
public getEntityRot(entityIndex: number): shared.Vector3;
}

export * from "alt-shared";
}

0 comments on commit 09e1e25

Please sign in to comment.