the-world-engine
Version:
three.js based, unity like game engine for browser
77 lines (76 loc) • 3.07 kB
TypeScript
import { Component } from "../../hierarchy_object/Component";
import type { GridObjectCollideMap } from "./GridObjectCollideMap";
/**
* collider work with `GridObjectCollideMap`
*
* coordinate system is same as world coordinate system (positive x is right, positive y is up)
*
* important: grid position data is stored as string ("x_y" format)
* so this component might not work properly if this component's gameObject.position is not integer
*
* don't use this component on dynamic gameObject you can only use this component on static gameObject (don't move your gameObject)
*/
export declare class GridCollider extends Component {
private readonly _collideMap;
private _showCollideSpot;
private _collideSpotIsShowing;
private readonly _colliderImages;
private _gridObjectCollideMap;
private _collideInfoAddedToMap;
private readonly _initializeFunctions;
private _started;
start(): void;
onEnable(): void;
onDisable(): void;
onDestroy(): void;
/**
* add collider, relative to object space center
* @param x x position in object space grid
* @param y y position in object space grid
* @returns
*/
addCollider(x: number, y: number): void;
/**
* add collider from two dimensional array. array left bottom is (0, 0) in object space grid coordinate system
* @param array array that contains 1 or 0. 1 means collider is there
* @param xOffset array x offset, if you want to add collider from array[1][3] to (2, 3) you should set xOffset = 1
* @param yOffset array y offset, if you want to add collider from array[3][1] to (3, 2) you should set yOffset = 1
* @returns
*/
addColliderFromTwoDimensionalArray(array: (1 | 0)[][], xOffset: number, yOffset: number): void;
/**
* remove collider at position
* @param x x position in grid
* @param y y position in grid
* @returns
*/
removeCollider(x: number, y: number): void;
private addColliderImages;
private removeColliderImages;
private addDebugImage;
private removeDebugImage;
private addCollideInfoToMap;
private addAllCollideInfoToMap;
private removeCollideInfoFromMap;
private removeAllCollideInfoFromMap;
/**
* `GridObjectCollideMap` component is used to store collider information in a grid. (default: null)
*
* when set this property, it will automatically add collider information to grid.
*/
get gridObjectCollideMap(): GridObjectCollideMap | null;
/**
* `GridObjectCollideMap` component is used to store collider information in a grid. (default: null)
*
* when set this property, it will automatically add collider information to grid.
*/
set gridObjectCollideMap(value: GridObjectCollideMap | null);
/**
* if this property is true, collider will be displayed. (default: false)
*/
get showCollideSpot(): boolean;
/**
* if this property is true, collider will be displayed. (default: false)
*/
set showCollideSpot(value: boolean);
}