From c99e38199d216fc7fe8508d94a52adaf245f6ae1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 27 Dec 2023 23:18:54 +0800 Subject: [PATCH] update d.ts files. [skip CI] --- Assets/Script/Lib/Dora/en/Platformer.d.ts | 1184 +++++++++++++++++ Assets/Script/Lib/Dora/en/dora.d.ts | 8 +- Assets/Script/Lib/Dora/en/nvg.d.ts | 190 ++- .../Script/Lib/Dora/zh-Hans/Platformer.d.ts | 1184 +++++++++++++++++ Assets/Script/Lib/Dora/zh-Hans/dora.d.ts | 8 +- Assets/Script/Lib/Dora/zh-Hans/nvg.d.ts | 190 ++- 6 files changed, 2756 insertions(+), 8 deletions(-) diff --git a/Assets/Script/Lib/Dora/en/Platformer.d.ts b/Assets/Script/Lib/Dora/en/Platformer.d.ts index e69de29bb..6bc3a26de 100644 --- a/Assets/Script/Lib/Dora/en/Platformer.d.ts +++ b/Assets/Script/Lib/Dora/en/Platformer.d.ts @@ -0,0 +1,1184 @@ +/// + +import { + BodyType as Body, + PlayableType as Playable, + SizeType as Size, + SensorType as Sensor, + DictionaryType as Dictionary, + EntityType as Entity, + PhysicsWorldType as PhysicsWorld, + Vec2Type as Vec2, + NodeType as Node, + CameraType as Camera, + RectType as Rect, + BodyDefType as BodyDef, + Job, + Item, +} from 'dora'; + +declare module "Platformer" { + +/** A class that represents an action that can be performed by a "Unit". */ +class UnitAction { + + private constructor(); + + /** + * The length of the reaction time for the "UnitAction", in seconds. + * The reaction time will affect the AI check cycling time. + */ + reaction: number; + + /** + * The length of the recovery time for the "UnitAction", in seconds. + * The recovery time will mainly affect how long the `Playable` animation model will do transitions between animations played by different actions. + */ + recovery: number; + + /** The name of the "UnitAction". */ + readonly name: string; + + /** Whether the "Unit" is currently performing the "UnitAction" or not. */ + readonly doing: boolean; + + /** The elapsed time since the "UnitAction" was started, in seconds. */ + readonly elapsedTime: number; + + /** The "Unit" that owns this "UnitAction". */ + readonly owner: Unit; +} + +export type {UnitAction as UnitActionType}; + +/** A record that defines the parameters for a "UnitAction". */ +export interface UnitActionParam { + + /** The priority level for the "UnitAction". Higher priority (larger number) replaces lower priority "UnitActions". */ + priority: number; + + /** The length of the reaction time for the "UnitAction", in seconds. */ + reaction: number; + + /** The length of the recovery time for the "UnitAction", in seconds. */ + recovery: number; + + /** Whether the "UnitAction" is currently queued or not. */ + queued: boolean; + + /** + * A function that determines whether the "UnitAction" is currently available for the specified "Unit". + * @param owner (Unit) The "Unit" that owns the "UnitAction". + * @param action (UnitAction) The "UnitAction" to check availability for. + * @returns (boolean) True if the "UnitAction" is available for the "Unit", false otherwise. + */ + available(owner: Unit, action: UnitAction): boolean; + + /** + * A function that creates a new function or "Routine.Job" that represents the processing of the "UnitAction". + * @param owner (Unit) The "Unit" that will own the "UnitAction". + * @param action (UnitAction) The "UnitAction" to create the processing function or "Routine.Job" for. + * @param deltaTime (number) The time elapsed since the last frame. + * @returns (function or Routine.Job) A function or a "Routine.Job" that returns or yields true if the "UnitAction" is complete. + */ + create(owner: Unit, action: UnitAction, deltaTime: number): (deltaTime: number) => boolean | Job; + + /** + * A function that gets invoked when the specified "Unit" stops performing the "UnitAction". + * @param owner (Unit) The "Unit" that is stopping the "UnitAction". + */ + stop(owner: Unit): void; +} + +/** + * A record that defines and stores the behavior and properties of the "UnitAction" class. + * It is a singleton object that manages all "UnitAction" objects. + */ +interface UnitActionClass { + + /** + * Adds a new "UnitAction" to the "UnitActionClass" with the specified name and parameters. + * @param name The name of the new "UnitAction". + * @param param The parameters for the new "UnitAction". + */ + add(name: string, param: UnitActionParam): void; + + /** + * Removes all "UnitAction" objects from the "UnitActionClass". + */ + clear(): void; +} + +const unitActionClass: UnitActionClass; +export {unitActionClass as UnitAction}; + +/** + * A class represents a character or other interactive item in a game scene. + */ +class Unit extends Body { + + private constructor(); + + /** + * A property that references a "Playable" object for managing the animation state and playback of the "Unit". + */ + playable: Playable; + + /** + * A property that specifies the maximum distance at which the "Unit" can detect other "Unit" or objects. + */ + detectDistance: number; + + /** + * A property that specifies the size of the attack range for the "Unit". + */ + attackRange: Size; + + /** + * A boolean property that specifies whether the "Unit" is facing right or not. + */ + faceRight: boolean; + + /** + * A boolean property that specifies whether the "Unit" is receiving a trace of the decision tree for debugging purposes. + */ + receivingDecisionTrace: boolean; + + /** + * A string property that specifies the decision tree to use for the "Unit's" AI behavior. + * The decision tree object will be searched in The singleton instance Data.store. + */ + decisionTree: string; + + /** + * Whether the "Unit" is currently on a surface or not. + */ + readonly onSurface: boolean; + + /** + * A "Sensor" object for detecting ground surfaces. + */ + readonly groundSensor: Sensor; + + /** + * A "Sensor" object for detecting other "Unit" objects or physics bodies in the game world. + */ + readonly detectSensor: Sensor; + + /** + * A "Sensor" object for detecting other "Unit" objects within the attack sensor area. + */ + readonly attackSensor: Sensor; + + /** + * A "Dictionary" object for defining the properties and behavior of the "Unit". + */ + readonly unitDef: Dictionary; + + /** + * A property that specifies the current action being performed by the "Unit". + */ + readonly currentAction: UnitAction; + + /** + * The width of the "Unit". + */ + readonly width: number; + + /** + * The height of the "Unit". + */ + readonly height: number; + + /** + * An "Entity" object for representing the "Unit" in the ECS system. + */ + readonly entity: Entity; + + /** + * Adds a new "UnitAction" to the "Unit" with the specified name, and returns the new "UnitAction". + * @param name The name of the new "UnitAction". + * @returns The newly created "UnitAction". + */ + attachAction(name: string): UnitAction; + + /** + * Removes the "UnitAction" with the specified name from the "Unit". + * @param name The name of the "UnitAction" to remove. + */ + removeAction(name: string): void; + + /** + * Removes all "UnitAction" objects from the "Unit". + */ + removeAllActions(): void; + + /** + * Returns the "UnitAction" with the specified name, or null if the "UnitAction" does not exist. + * @param name The name of the "UnitAction" to retrieve. + * @returns The "UnitAction" with the specified name, or null. + */ + getAction(name: string): UnitAction | null; + + /** + * Calls the specified function for each "UnitAction" attached to the "Unit". + * @param func A function to call for each "UnitAction". + */ + eachAction(func: (action: UnitAction) => void): void; + + /** + * Starts the "UnitAction" with the specified name, and returns true if the "UnitAction" was started successfully. + * @param name The name of the "UnitAction" to start. + * @returns True if the "UnitAction" was started successfully, false otherwise. + */ + start(name: string): boolean; + + /** + * Stops the currently running "UnitAction". + */ + stop(): void; + + /** + * Returns true if the "Unit" is currently performing the specified "UnitAction", false otherwise. + * @param name The name of the "UnitAction" to check. + * @returns True if the "Unit" is currently performing the specified "UnitAction", false otherwise. + */ + isDoing(name: string): boolean; +} + +export type {Unit as UnitType}; + +/** + * A class for creating instances of Unit. + */ +interface UnitClass { + + /** + * The tag for the "GroundSensor" attached to each "Unit". + */ + readonly GroundSensorTag: number; + + /** + * The tag for the "DetectSensor" attached to each "Unit". + */ + readonly DetectSensorTag: number; + + /** + * The tag for the "AttackSensor" attached to each "Unit". + */ + readonly AttackSensorTag: number; + + /** + * A metamethod that creates a new "Unit" object. + * @param unitDef A "Dictionary" object that defines the properties and behavior of the "Unit". + * @param physicsworld A "PhysicsWorld" object that represents the physics simulation world. + * @param entity An "Entity" object that represents the "Unit" in the ECS system. + * @param pos A "Vec2" object that specifies the initial position of the "Unit". + * @param rot An optional number that specifies the initial rotation of the "Unit" (default is 0.0). + * @returns The newly created "Unit" object. + */ + ( + this: void, + unitDef: Dictionary, + physicsworld: PhysicsWorld, + entity: Entity, + pos: Vec2, + rot?: number + ): Unit; +} + +const unitClass: UnitClass; +export {unitClass as Unit}; + +/** + * An enum representing the possible relations between two groups. + */ +export const enum Relation { + Enemy = "Enemy", + Friend = "Friend", + Neutral = "Neutral", + Unknown = "Unknown", + Any = "Any" +} + +/** + * A singleton object that provides a centralized location for storing and accessing game-related data. + */ +interface Data { + + /** + * A group key representing the first index for a player group. + */ + readonly groupFirstPlayer: number; + + /** + * A group key representing the last index for a player group. + */ + readonly groupLastPlayer: number; + + /** + * A group key that won't have any contact with other groups by default. + */ + readonly groupHide: number; + + /** + * A group key that will have contacts with player groups by default. + */ + readonly groupDetectPlayer: number; + + /** + * A group key representing terrain that will have contacts with other groups by default. + */ + readonly groupTerrain: number; + + /** + * A group key that will have contacts with other groups by default. + */ + readonly groupDetection: number; + + /** + * A dictionary that can be used to store arbitrary data associated with string keys and various values globally. + */ + readonly store: Dictionary; + + /** + * A function that can be used to set a boolean value indicating whether two groups should be in contact or not. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @param contact A boolean indicating whether the two groups should be in contact. + */ + setShouldContact(groupA: number, groupB: number, contact: boolean): void; + + /** + * A function that can be used to get a boolean value indicating whether two groups should be in contact or not. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups should be in contact. + */ + getShouldContact(groupA: number, groupB: number): boolean; + + /** + * A function that can be used to set the relation between two groups. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @param relation The relation between the two groups. + */ + setRelation(groupA: number, groupB: number, relation: Relation): void; + + /** + * A function that can be used to get the relation between two groups. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns The relation between the two groups. + */ + getRelation(groupA: number, groupB: number): Relation; + + /** + * A function that can be used to get the relation between two bodies. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns The relation between the two bodies. + */ + getBodyRelation(bodyA: Body, bodyB: Body): Relation; + + /** + * A function that returns whether two groups have an "Enemy" relation. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups have an "Enemy" relation. + */ + isEnemy(groupA: number, groupB: number): boolean; + + /** + * A function that returns whether two bodies have an "Enemy" relation. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns Whether the two bodies have an "Enemy" relation. + */ + isBodyEnemy(bodyA: Body, bodyB: Body): boolean; + + /** + * A function that returns whether two groups have a "Friend" relation. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups have a "Friend" relation. + */ + isFriend(groupA: number, groupB: number): boolean; + + /** + * A function that returns whether two bodies have a "Friend" relation. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns Whether the two bodies have a "Friend" relation. + */ + isBodyFriend(bodyA: Body, bodyB: Body): boolean; + + /** + * A function that returns whether two groups have a "Neutral" relation. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups have a "Neutral" relation. + */ + isNeutral(groupA: number, groupB: number): boolean; + + /** + * A function that returns whether two bodies have a "Neutral" relation. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns Whether the two bodies have a "Neutral" relation. + */ + isBodyNeutral(bodyA: Body, bodyB: Body): boolean; + + /** + * A function that sets the bonus factor for a particular type of damage against a particular type of defense. + * @param damageType An integer representing the type of damage. + * @param defenseType An integer representing the type of defense. + * @param bonus A number representing the bonus. + */ + setDamageFactor(damageType: number, defenseType: number, bonus: number): void; + + /** + * A function that gets the bonus factor for a particular type of damage against a particular type of defense. + * @param damageType An integer representing the type of damage. + * @param defenseType An integer representing the type of defense. + * @returns A number representing the bonus factor. + */ + getDamageFactor(damageType: number, defenseType: number): number; + + /** + * A function that returns whether a body is a player or not. + * @param body The body to check. + * @returns Whether the body is a player. + */ + isPlayer(body: Body): boolean; + + /** + * A function that returns whether a body is terrain or not. + * @param body The body to check. + * @returns Whether the body is terrain. + */ + isTerrain(body: Body): boolean; + + /** + * A function that clears all data stored in the "Data" object, including user data in Data.store field. + * And reset some data to default values. + */ + clear(): void; +} + +const data: Data; +export {data as Data}; + +/** + * A class that specifies how a bullet object should interact with other game objects or units based on their relationship. + */ +class TargetAllow { + + /** + * Whether the bullet object can collide with terrain. + */ + terrainAllowed: boolean; + + /** + * A function that allows or disallows the bullet object to interact with a game object or unit, based on their relationship. + * @param relation The relationship between the bullet object and the other game object or unit. + * @param allow Whether the bullet object should be allowed to interact. + */ + allow(relation: Relation, allow: boolean): void; + + /** + * A function that determines whether the bullet object is allowed to interact with a game object or unit, based on their relationship. + * @param relation The relationship between the bullet object and the other game object or unit. + * @returns Whether the bullet object is allowed to interact. + */ + isAllow(relation: Relation): boolean; +} + +/** + * A class that specifies how a bullet object should interact with other game objects or units based on their relationship. + * @usage + * const targetAllow = new TargetAllow(); + * targetAllow.terrainAllowed = true; + * targetAllow.allow("Enemy", true); + */ +interface TargetAllowClass { + + /** + * Call this function to create an instance of TargetAllow. + * @returns An instance of TargetAllow. + */ + (this: void): TargetAllow; +} + +const targetAllowClass: TargetAllowClass; +export {targetAllowClass as TargetAllow}; + +/** + * A platform camera for 2D platformer games that can track a game unit's movement and keep it within the camera's view. + */ +class PlatformCamera extends Camera { + + private constructor(); + + /** + * The camera's position. + */ + position: Vec2; + + /** + * The camera's rotation in degrees. + */ + rotation: number; + + /** + * The camera's zoom factor, 1.0 means the normal size, 2.0 mean zoom to doubled size. + */ + zoom: number; + + /** + * The rectangular area within which the camera is allowed to view. + */ + boundary: Rect; + + /** + * The ratio at which the camera should move to keep up with the target's position. + * For example, set to `Vec2(1.0, 1.0)`, then the camera will keep up to the target's position right away. + * Set to Vec2(0.5, 0.5) or smaller value, then the camera will move halfway to the target's position each frame, resulting in a smooth and gradual movement. + */ + followRatio: Vec2; + + /** + * The game unit that the camera should track. + */ + followTarget: Node; +} + +/** + * A class that defines how to create instances of PlatformCamera. + */ +interface PlatformCameraClass { + + /** + * Creates a new instance of PlatformCamera. + * @param name [optional] The name of the new instance, default is an empty string. + * @returns The new PlatformCamera instance. + */ + (this: void, name?: string): PlatformCamera; +} + +const platformCameraClass: PlatformCameraClass; +export {platformCameraClass as PlatformCamera}; + +/** + * A class representing a 2D platformer game world with physics simulations. + */ +class PlatformWorld extends PhysicsWorld { + + private constructor(); + + /** + * The camera used to control the view of the game world. + */ + readonly camera: PlatformCamera; + + /** + * Moves a child node to a new order for a different layer. + * @param child The child node to be moved. + * @param newOrder The new order of the child node. + */ + moveChild(child: Node, newOrder: number): void; + + /** + * Gets the layer node at a given order. + * @param order The order of the layer node to get. + * @returns The layer node at the given order. + */ + getLayer(order: number): Node; + + /** + * Sets the parallax moving ratio for a given layer to simulate 3D projection effect. + * @param order The order of the layer to set the ratio for. + * @param ratio The new parallax ratio for the layer. + */ + setLayerRatio(order: number, ratio: Vec2): void; + + /** + * Gets the parallax moving ratio for a given layer. + * @param order The order of the layer to get the ratio for. + * @returns The parallax ratio for the layer. + */ + getLayerRatio(order: number): Vec2; + + /** + * Sets the position offset for a given layer. + * @param order The order of the layer to set the offset for. + * @param offset The new position offset for the layer. + */ + setLayerOffset(order: number, offset: Vec2): void; + + /** + * Gets the position offset for a given layer. + * @param order The order of the layer to get the offset for. + * @returns The position offset for the layer. + */ + getLayerOffset(order: number): Vec2; + + /** + * Swaps the positions of two layers. + * @param orderA The order of the first layer to swap. + * @param orderB The order of the second layer to swap. + */ + swapLayer(orderA: number, orderB: number): void; + + /** + * Removes a layer from the game world. + * @param order The order of the layer to remove. + */ + removeLayer(order: number): void; + + /** + * Removes all layers from the game world. + */ + removeAllLayers(): void; +} + +export type {PlatformWorld as PlatformWorldType}; + +/** + * A class for instantiating instances of PlatformWorld. + * @example + * ``` + * const world = PlatformWorldClass(); + * world.addTo(entry); + * ``` + */ +interface PlatformWorldClass { + + /** + * The metamethod to create a new instance of PlatformWorld. + * @returns A new instance of PlatformWorld. + */ + (this: void): PlatformWorld; +} + +const platformWorldClass: PlatformWorldClass; +export {platformWorldClass as PlatformWorld}; + +/** + * Represents a definition for a visual component of a game bullet or other visual item. + */ +class Face extends Node { + + /** + * Adds a child `Face` definition to it. + * @param face The child `Face` to add. + */ + addChild(face: Face): void; + + /** + * Returns a node that can be added to a scene tree for rendering. + * @returns The `Node` representing this `Face`. + */ + toNode(): Node; +} + +/** + * A record provides functions for creating instances of the `Face` component with different configurations. + * @example + * ``` + * import { Face } from "Platformer"; + * const faceA = Face("Image/file.png"); + * const faceB = Face(() => { + * return Sprite("Image/file.png"); + * }); + * faceA.toNode().addTo(entry); + * faceB.toNode().addTo(entry); + * ``` + */ +interface FaceClass { + + /** + * Creates a new `Face` definition using the specified attributes. + * @param faceStr A string for creating the `Face` component. + * Could be 'Image/file.png' and 'Image/items.clip|itemA'. + * @param point The position of the `Face` component, default is `Vec2.zero`. + * @param scale The scale of the `Face` component, default is 1.0. + * @param angle The angle of the `Face` component, default is 0.0. + * @returns The new `Face` component. + */ + ( + this: void, + faceStr: string, + point?: Vec2, + scale?: number, + angle?: number + ): Face; + + /** + * Creates a new `Face` definition using the specified attributes. + * @param createFunc A function that returns a `Node` representing the `Face` component. + * @param point The position of the `Face` component, default is `Vec2.zero`. + * @param scale The scale of the `Face` component, default is 1.0. + * @param angle The angle of the `Face` component, default is 0.0. + * @returns The new `Face` component. + */ + ( + this: void, + createFunc: () => Node, + point?: Vec2, + scale?: number, + angle?: number + ): Face; +} + +const faceClass: FaceClass; +export {faceClass as Face}; + +/** + * A class to represent a visual effect object like Particle, Frame Animation, or just a Sprite. + */ +class Visual extends Node { + + private constructor(); + + /** + * Whether the visual effect is currently playing or not. + */ + playing: boolean; + + /** + * Starts playing the visual effect. + */ + start(): void; + + /** + * Stops playing the visual effect. + */ + stop(): void; + + /** + * Automatically removes the visual effect from the game world when it finishes playing. + * @returns The same "Visual" object that was passed in as a parameter. + */ + autoRemove(): Visual; +} + +export type {Visual as VisualType}; + +/** +* A class for creating "Visual" objects. +*/ +interface VisualClass { + + /** + * Creates a new "Visual" object with the specified name. + * @param name The name of the new "Visual" object. + * Could be a particle file, a frame animation file, or an image file. + * @returns The new "Visual" object. + */ + (this: void, name: string): Visual; +} + +const visualClass: VisualClass; +export {visualClass as Visual}; + +/** A behavior tree framework for creating game AI structures. */ +export namespace Behavior { + +/** + * A blackboard object that can be used to store data for behavior tree nodes. + */ +class Blackboard { + + private constructor(); + + /** + * The time since the last frame update in seconds. + */ + deltaTime: number; + + /** + * The unit that the AI agent belongs to. + */ + owner: Unit; + + /** + * A method to index the blackboard properties. + * @param key The key to index. + * @returns The value associated with the key. + */ + [key: string]: Item; +} + +/** + * A leaf node in a behavior tree. + */ +class Leaf extends Object { + private constructor(); +} + +/** + * Creates a new sequence node that executes an array of child nodes in order. + * @param nodes An array of child nodes. + * @returns A new sequence node. + */ +export function Seq(nodes: Leaf[]): Leaf; + +/** + * Creates a new selector node that selects and executes one of its child nodes that will succeed. + * @param nodes An array of child nodes. + * @returns A new selector node. + */ +export function Sel(nodes: Leaf[]): Leaf; + +/** + * Creates a new condition node that executes a check handler function when executed. + * @param name The name of the condition. + * @param check A function that takes a blackboard object and returns a boolean value. + * @returns A new condition node. + */ +export function Con(name: string, check: (board: Blackboard) => boolean): Leaf; + +/** + * Creates a new action node that executes an action when executed. + * This node will block the execution until the action finishes. + * @param actionName The name of the action to execute. + * @returns A new action node. + */ +export function Act(actionName: string): Leaf; + +/** + * Creates a new command node that executes a command when executed. + * This node will return right after the action starts. + * @param actionName The name of the command to execute. + * @returns A new command node. + */ +export function Command(actionName: string): Leaf; + +/** + * Creates a new wait node that waits for a specified duration when executed. + * @param duration The duration to wait in seconds. + * @returns A new wait node. + */ +export function Wait(duration: number): Leaf; + +/** + * Creates a new countdown node that executes a child node continuously until a timer runs out. + * @param time The time limit in seconds. + * @param node The child node to execute. + * @returns A new countdown node. + */ +export function Countdown(time: number, node: Leaf): Leaf; + +/** + * Creates a new timeout node that executes a child node until a timer runs out. + * @param time The time limit in seconds. + * @param node The child node to execute. + * @returns A new timeout node. + */ +export function Timeout(time: number, node: Leaf): Leaf; + +/** + * Creates a new repeat node that executes a child node a specified number of times. + * @param times The number of times to execute the child node. + * @param node The child node to execute. + * @returns A new repeat node. + */ +export function Repeat(times: number, node: Leaf): Leaf; + +/** + * Creates a new repeat node that executes a child node repeatedly. + * @param node The child node to execute. + * @returns A new repeat node. + */ +export function Repeat(node: Leaf): Leaf; + +/** + * Creates a new retry node that executes a child node repeatedly until it succeeds or a maximum number of retries is reached. + * @param times The maximum number of retries. + * @param node The child node to execute. + * @returns A new retry node. + */ +export function Retry(times: number, node: Leaf): Leaf; + +/** + * Creates a new retry node that executes a child node repeatedly until it succeeds. + * @param node The child node to execute. + * @returns A new retry node. + */ +export function Retry(node: Leaf): Leaf; + +} // namespace Behavior + +/** + * The singleton record to retrieve information when executing the decision tree. + */ +interface AI { + + /** + * Gets an array of units in detection range that have the specified relation to current AI agent. + * @param relation The relation to filter the units by. + * @returns An array of units with the specified relation. + */ + getUnitsByRelation(relation: Relation): Unit[]; + + /** + * Gets an array of units that the AI has detected. + * @returns An array of detected units. + */ + getDetectedUnits(): Unit[]; + + /** + * Gets an array of bodies that the AI has detected. + * @returns An array of detected bodies. + */ + getDetectedBodies(): Body[]; + + /** + * Gets the nearest unit that has the specified relation to the AI. + * @param relation The relation to filter the units by. + * @returns The nearest unit with the specified relation. + */ + getNearestUnit(relation: Relation): Unit; + + /** + * Gets the distance to the nearest unit that has the specified relation to the AI agent. + * @param relation The relation to filter the units by. + * @returns The distance to the nearest unit with the specified relation. + */ + getNearestUnitDistance(relation: Relation): number; + + /** + * Gets an array of units that are within attack range. + * @returns An array of units in attack range. + */ + getUnitsInAttackRange(): Unit[]; + + /** + * Gets an array of bodies that are within attack range. + * @returns An array of bodies in attack range. + */ + getBodiesInAttackRange(): Body[]; +} + +/** + * A decision tree framework for creating game AI structures. + */ +export namespace Decision { + +/** + * A leaf node in a decision tree. + */ +class Leaf extends Object { + private constructor(); +} + +/** + * Creates a selector node with the specified child nodes. + * A selector node will go through the child nodes until one succeeds. + * @param nodes An array of `Leaf` nodes. + * @returns A `Leaf` node that represents a selector. + */ +export function Sel(nodes: Leaf[]): Leaf; + +/** + * Creates a sequence node with the specified child nodes. + * A sequence node will go through the child nodes until all nodes succeed. + * @param nodes An array of `Leaf` nodes. + * @returns A `Leaf` node that represents a sequence. + */ +export function Seq(nodes: Leaf[]): Leaf; + +/** + * Creates a condition node with the specified name and handler function. + * @param name The name of the condition. + * @param check The check function that takes a `Unit` parameter and returns a boolean result. + * @returns A `Leaf` node that represents a condition check. + */ +export function Con(name: string, check: (self: Unit) => boolean): Leaf; + +/** + * Creates an action node with the specified action name. + * @param actionName The name of the action to perform. + * @returns A `Leaf` node that represents an action. + */ +export function Act(actionName: string): Leaf; + +/** + * Creates an action node with the specified handler function. + * @param handler The handler function that takes a `Unit` parameter which is the running AI agent and returns an action. + * @returns A `Leaf` node that represents an action. + */ +export function Act(handler: (self: Unit) => string): Leaf; + +/** + * Creates a leaf node that represents accepting the current behavior tree. + * Always get a success result from this node. + * @returns A `Leaf` node. + */ +export function Accept(): Leaf; + +/** + * Creates a leaf node that represents rejecting the current behavior tree. + * Always get a failure result from this node. + * @returns A `Leaf` node. + */ +export function Reject(): Leaf; + +/** + * Creates a leaf node with the specified behavior tree as its root. + * It is possible to include a Behavior Tree as a node in a Decision Tree by using the Behave() function. + * This allows the AI to use a combination of decision-making and behavior execution to achieve its goals. + * @param name The name of the behavior tree. + * @param root The root node of the behavior tree. + * @returns A `Leaf` node. + */ +export function Behave(name: string, root: Behavior.Leaf): Leaf; + +/** + * The singleton instance to retrieve information while executing the decision tree. */ +export const AI: AI; + +} // namespace Decision + +/** + * A record type that specifies the properties and behaviors of a bullet object in the game. + */ +class BulletDef extends Object { + + private constructor(); + + /** + * The tag for the bullet object. + */ + tag: string; + + /** + * The effect that occurs when the bullet object ends its life. + */ + endEffect: string; + + /** + * The amount of time in seconds that the bullet object remains active. + */ + lifeTime: number; + + /** + * The radius of the bullet object's damage area. + */ + damageRadius: number; + + /** + * Whether the bullet object should be fixed for high speeds. + */ + highSpeedFix: boolean; + + /** + * The gravity vector that applies to the bullet object. + */ + gravity: Vec2; + + /** + * The visual item of the bullet object. + */ + face: Face; + + /** + * The physics body definition for the bullet object. + */ + bodyDef: BodyDef; + + /** + * The velocity vector of the bullet object. + */ + velocity: Vec2; + + /** + * Sets the bullet object's physics body as a circle. + * @param radius The radius of the circle. + */ + setAsCircle(radius: number): void; + + /** + * Sets the velocity of the bullet object. + * @param angle The angle of the velocity in degrees. + * @param speed The speed of the velocity. + */ + setVelocity(angle: number, speed: number): void; +} + +/** + * @example + * ``` + * import { BulletDef } from "Platformer"; + * const bulletDef = BulletDef(); + * ``` + */ +interface BulletDefClass { + (this: void): BulletDef; +} + +const bulletDefClass: BulletDefClass; +export {bulletDefClass as BulletDef}; + +/** + * A record type that defines the properties and behavior of a bullet object instance in the game. + */ +class Bullet extends Body { + + private constructor(); + + /** + * The `TargetAllow` object for the bullet object. + */ + targetAllow: TargetAllow; + + /** + * Whether the bullet object is facing right. + */ + readonly faceRight: boolean; + + /** + * Whether the bullet object should stop on impact. + */ + hitStop: boolean; + + /** + * The `Unit` object that fired the bullet. + */ + readonly emitter: Unit; + + /** + * The `BulletDef` object that defines the bullet's properties and behavior. + */ + readonly bulletDef: BulletDef; + + /** + * The `Node` object that appears as the bullet's visual item. + */ + face: Node; + + /** + * Destroys the bullet object instance. + */ + destroy(): void; +} + +/** +* A record type that creates new `Bullet` object instances. +*/ +interface BulletClass { + + /** + * A metamethod that creates a new `Bullet` object instance with the specified `BulletDef` and `Unit` objects. + * @param def The `BulletDef` object that defines the bullet's properties and behavior. + * @param owner The `Unit` object that fired the bullet. + * @returns The new `Bullet` object instance. + */ + (this: void, def: BulletDef, owner: Unit): Bullet; +} + +const bulletClass: BulletClass; +export {bulletClass as Bullet}; + +} // module "Platformer" diff --git a/Assets/Script/Lib/Dora/en/dora.d.ts b/Assets/Script/Lib/Dora/en/dora.d.ts index a1c44f34e..5a7b94812 100644 --- a/Assets/Script/Lib/Dora/en/dora.d.ts +++ b/Assets/Script/Lib/Dora/en/dora.d.ts @@ -1191,7 +1191,7 @@ export function Sequence(...actions: ActionDef[]): ActionDef; * The supported array data types. * This can be an integer, number, boolean, string, thread, ContainerItem. */ -type Item = number | boolean | string | LuaThread | ContainerItem; +export type Item = number | boolean | string | LuaThread | ContainerItem; /** * An array data structure that supports various operations. @@ -1489,7 +1489,7 @@ export {blendFuncClass as BlendFunc}; /** * The Job type, representing a coroutine thread. */ -type Job = BasicType<"Job", LuaThread>; +export type Job = BasicType<"Job", LuaThread>; /** * A singleton record for managing coroutines. @@ -4303,6 +4303,8 @@ class Sensor extends Object { contains(body: Body): boolean; } +export type {Sensor as SensorType}; + /** * A record called "BodyDef" to describe the properties of a physics body. * Inherits from `Object`. @@ -4541,7 +4543,7 @@ export {bodyDefClass as BodyDef}; */ class Body extends Node { - private constructor(); + protected constructor(); /** * The physics world that the body belongs to. diff --git a/Assets/Script/Lib/Dora/en/nvg.d.ts b/Assets/Script/Lib/Dora/en/nvg.d.ts index 59fc32d6e..dd7c2e2d3 100644 --- a/Assets/Script/Lib/Dora/en/nvg.d.ts +++ b/Assets/Script/Lib/Dora/en/nvg.d.ts @@ -1,5 +1,193 @@ /// +import { + Vec2Type as Vec2, + ColorType as Color, + RectType as Rect, + VGPaintType as VGPaint, + SizeType as Size, + Texture2DType as Texture2D +} from "dora"; + declare module "nvg" { -} \ No newline at end of file +class Transform { + private constructor(); + identity(): void; + translate(tx: number, ty: number): void; + scale(sx: number, sy: number): void; + rotate(a: number): void; + skewX(a: number): void; + skewY(a: number): void; + multiply(src: Transform): void; + inverseFrom(src: Transform): boolean; + applyPoint(src: Vec2): Vec2; +} + +export type {Transform as TransformType}; + +interface TransformClass { + (this: void): Transform; +} + +const transformClass: TransformClass; +export {transformClass as Transform}; + +export const enum LineCapMode { + Butt = "Butt", + Round = "Round", + Square = "Square", +} + +export const enum LineJoinMode { + Miter = "Miter", + Round = "Round", + Bevel = "Bevel", +} + +export const enum WindingMode { + CW = "CW", + CCW = "CCW", + Solid = "Solid", + Hole = "Hole", +} + +export const enum ArcDir { + CW = "CW", + CCW = "CCW", +} + +export const enum TextAlignMode { + Left = "Left", + Center = "Center", + Right = "Right", + Top = "Top", + Middle = "Middle", + Bottom = "Bottom", + Baseline = "Baseline", +} + +export const enum ImageFlag { + Mipmaps = "Mipmaps", + RepeatX = "RepeatX", + RepeatY = "RepeatY", + FlipY = "FlipY", + Premultiplied = "Premultiplied", + Nearest = "Nearest", +} + +interface nvg { + TouchPos(): Vec2; + LeftButtonPressed(): boolean; + RightButtonPressed(): boolean; + MiddleButtonPressed(): boolean; + MouseWheel(): number; + Save(): void; + Restore(): void; + Reset(): void; + CreateImage(w: number, h: number, filename: string, imageFlags?: ImageFlag[]): number; + CreateFont(name: string): number; + TextBounds(x: number, y: number, text: string, bounds: Rect): number; + TextBoxBounds(x: number, y: number, breakRowWidth: number, text: string): Rect; + Text(x: number, y: number, text: string): number; + TextBox(x: number, y: number, breakRowWidth: number, text: string): void; + StrokeColor(color: Color): void; + StrokePaint(paint: VGPaint): void; + FillColor(color: Color): void; + FillPaint(paint: VGPaint): void; + MiterLimit(limit: number): void; + StrokeWidth(size: number): void; + LineCap(cap: LineCapMode): void; + LineJoin(join: LineJoinMode): void; + GlobalAlpha(alpha: number): void; + ResetTransform(): void; + ApplyTransform(t: Transform): void; + CurrentTransform(t: Transform): void; + Translate(x: number, y: number): void; + Rotate(angle: number): void; + SkewX(angle: number): void; + SkewY(angle: number): void; + Scale(x: number, y: number): void; + ImageSize(image: number): Size; + DeleteImage(image: number): void; + NVGpaLinearGradient( + sx: number, + sy: number, + ex: number, + ey: number, + icol: Color, + ocol: Color + ): VGPaint; + NVGpaBoxGradient( + x: number, + y: number, + w: number, + h: number, + r: number, + f: number, + icol: Color, + ocol: Color + ): VGPaint; + NVGpaRadialGradient( + cx: number, + cy: number, + inr: number, + outr: number, + icol: Color, + ocol: Color + ): VGPaint; + NVGpaImagePattern( + ox: number, + oy: number, + ex: number, + ey: number, + angle: number, + image: number, + alpha: number + ): VGPaint; + Scissor(x: number, y: number, w: number, h: number): void; + IntersectScissor(x: number, y: number, w: number, h: number): void; + ResetScissor(): void; + BeginPath(): void; + MoveTo(x: number, y: number): void; + LineTo(x: number, y: number): void; + BezierTo(c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number): void; + QuadTo(cx: number, cy: number, x: number, y: number): void; + ArcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + ClosePath(): void; + PathWinding(dir: WindingMode): void; + Arc(cx: number, cy: number, r: number, a0: number, a1: number, dir: ArcDir): void; + Rect(x: number, y: number, w: number, h: number): void; + RoundedRect(x: number, y: number, w: number, h: number, r: number): void; + RoundedRectVarying( + x: number, + y: number, + w: number, + h: number, + radTopLeft: number, + radTopRight: number, + radBottomRight: number, + radBottomLeft: number + ): void; + Ellipse(cx: number, cy: number, rx: number, ry: number): void; + Circle(cx: number, cy: number, r: number): void; + Fill(): void; + Stroke(): void; + FindFont(name: string): number; + AddFallbackFontId(baseFont: number, fallbackFont: number): number; + AddFallbackFont(baseFont: string, fallbackFont: string): number; + FontSize(size: number): void; + FontBlur(blur: number): void; + TextLetterSpacing(spacing: number): void; + TextLineHeight(lineHeight: number): void; + TextAlign(align: TextAlignMode): void; + FontFaceId(font: number): void; + FontFace(font: string): void; + DoraSSR(): void; + GetDoraSSR(scale?: number): Texture2D; +} + +const nvg: nvg; +export = nvg; + +} // module "nvg" diff --git a/Assets/Script/Lib/Dora/zh-Hans/Platformer.d.ts b/Assets/Script/Lib/Dora/zh-Hans/Platformer.d.ts index e69de29bb..6bc3a26de 100644 --- a/Assets/Script/Lib/Dora/zh-Hans/Platformer.d.ts +++ b/Assets/Script/Lib/Dora/zh-Hans/Platformer.d.ts @@ -0,0 +1,1184 @@ +/// + +import { + BodyType as Body, + PlayableType as Playable, + SizeType as Size, + SensorType as Sensor, + DictionaryType as Dictionary, + EntityType as Entity, + PhysicsWorldType as PhysicsWorld, + Vec2Type as Vec2, + NodeType as Node, + CameraType as Camera, + RectType as Rect, + BodyDefType as BodyDef, + Job, + Item, +} from 'dora'; + +declare module "Platformer" { + +/** A class that represents an action that can be performed by a "Unit". */ +class UnitAction { + + private constructor(); + + /** + * The length of the reaction time for the "UnitAction", in seconds. + * The reaction time will affect the AI check cycling time. + */ + reaction: number; + + /** + * The length of the recovery time for the "UnitAction", in seconds. + * The recovery time will mainly affect how long the `Playable` animation model will do transitions between animations played by different actions. + */ + recovery: number; + + /** The name of the "UnitAction". */ + readonly name: string; + + /** Whether the "Unit" is currently performing the "UnitAction" or not. */ + readonly doing: boolean; + + /** The elapsed time since the "UnitAction" was started, in seconds. */ + readonly elapsedTime: number; + + /** The "Unit" that owns this "UnitAction". */ + readonly owner: Unit; +} + +export type {UnitAction as UnitActionType}; + +/** A record that defines the parameters for a "UnitAction". */ +export interface UnitActionParam { + + /** The priority level for the "UnitAction". Higher priority (larger number) replaces lower priority "UnitActions". */ + priority: number; + + /** The length of the reaction time for the "UnitAction", in seconds. */ + reaction: number; + + /** The length of the recovery time for the "UnitAction", in seconds. */ + recovery: number; + + /** Whether the "UnitAction" is currently queued or not. */ + queued: boolean; + + /** + * A function that determines whether the "UnitAction" is currently available for the specified "Unit". + * @param owner (Unit) The "Unit" that owns the "UnitAction". + * @param action (UnitAction) The "UnitAction" to check availability for. + * @returns (boolean) True if the "UnitAction" is available for the "Unit", false otherwise. + */ + available(owner: Unit, action: UnitAction): boolean; + + /** + * A function that creates a new function or "Routine.Job" that represents the processing of the "UnitAction". + * @param owner (Unit) The "Unit" that will own the "UnitAction". + * @param action (UnitAction) The "UnitAction" to create the processing function or "Routine.Job" for. + * @param deltaTime (number) The time elapsed since the last frame. + * @returns (function or Routine.Job) A function or a "Routine.Job" that returns or yields true if the "UnitAction" is complete. + */ + create(owner: Unit, action: UnitAction, deltaTime: number): (deltaTime: number) => boolean | Job; + + /** + * A function that gets invoked when the specified "Unit" stops performing the "UnitAction". + * @param owner (Unit) The "Unit" that is stopping the "UnitAction". + */ + stop(owner: Unit): void; +} + +/** + * A record that defines and stores the behavior and properties of the "UnitAction" class. + * It is a singleton object that manages all "UnitAction" objects. + */ +interface UnitActionClass { + + /** + * Adds a new "UnitAction" to the "UnitActionClass" with the specified name and parameters. + * @param name The name of the new "UnitAction". + * @param param The parameters for the new "UnitAction". + */ + add(name: string, param: UnitActionParam): void; + + /** + * Removes all "UnitAction" objects from the "UnitActionClass". + */ + clear(): void; +} + +const unitActionClass: UnitActionClass; +export {unitActionClass as UnitAction}; + +/** + * A class represents a character or other interactive item in a game scene. + */ +class Unit extends Body { + + private constructor(); + + /** + * A property that references a "Playable" object for managing the animation state and playback of the "Unit". + */ + playable: Playable; + + /** + * A property that specifies the maximum distance at which the "Unit" can detect other "Unit" or objects. + */ + detectDistance: number; + + /** + * A property that specifies the size of the attack range for the "Unit". + */ + attackRange: Size; + + /** + * A boolean property that specifies whether the "Unit" is facing right or not. + */ + faceRight: boolean; + + /** + * A boolean property that specifies whether the "Unit" is receiving a trace of the decision tree for debugging purposes. + */ + receivingDecisionTrace: boolean; + + /** + * A string property that specifies the decision tree to use for the "Unit's" AI behavior. + * The decision tree object will be searched in The singleton instance Data.store. + */ + decisionTree: string; + + /** + * Whether the "Unit" is currently on a surface or not. + */ + readonly onSurface: boolean; + + /** + * A "Sensor" object for detecting ground surfaces. + */ + readonly groundSensor: Sensor; + + /** + * A "Sensor" object for detecting other "Unit" objects or physics bodies in the game world. + */ + readonly detectSensor: Sensor; + + /** + * A "Sensor" object for detecting other "Unit" objects within the attack sensor area. + */ + readonly attackSensor: Sensor; + + /** + * A "Dictionary" object for defining the properties and behavior of the "Unit". + */ + readonly unitDef: Dictionary; + + /** + * A property that specifies the current action being performed by the "Unit". + */ + readonly currentAction: UnitAction; + + /** + * The width of the "Unit". + */ + readonly width: number; + + /** + * The height of the "Unit". + */ + readonly height: number; + + /** + * An "Entity" object for representing the "Unit" in the ECS system. + */ + readonly entity: Entity; + + /** + * Adds a new "UnitAction" to the "Unit" with the specified name, and returns the new "UnitAction". + * @param name The name of the new "UnitAction". + * @returns The newly created "UnitAction". + */ + attachAction(name: string): UnitAction; + + /** + * Removes the "UnitAction" with the specified name from the "Unit". + * @param name The name of the "UnitAction" to remove. + */ + removeAction(name: string): void; + + /** + * Removes all "UnitAction" objects from the "Unit". + */ + removeAllActions(): void; + + /** + * Returns the "UnitAction" with the specified name, or null if the "UnitAction" does not exist. + * @param name The name of the "UnitAction" to retrieve. + * @returns The "UnitAction" with the specified name, or null. + */ + getAction(name: string): UnitAction | null; + + /** + * Calls the specified function for each "UnitAction" attached to the "Unit". + * @param func A function to call for each "UnitAction". + */ + eachAction(func: (action: UnitAction) => void): void; + + /** + * Starts the "UnitAction" with the specified name, and returns true if the "UnitAction" was started successfully. + * @param name The name of the "UnitAction" to start. + * @returns True if the "UnitAction" was started successfully, false otherwise. + */ + start(name: string): boolean; + + /** + * Stops the currently running "UnitAction". + */ + stop(): void; + + /** + * Returns true if the "Unit" is currently performing the specified "UnitAction", false otherwise. + * @param name The name of the "UnitAction" to check. + * @returns True if the "Unit" is currently performing the specified "UnitAction", false otherwise. + */ + isDoing(name: string): boolean; +} + +export type {Unit as UnitType}; + +/** + * A class for creating instances of Unit. + */ +interface UnitClass { + + /** + * The tag for the "GroundSensor" attached to each "Unit". + */ + readonly GroundSensorTag: number; + + /** + * The tag for the "DetectSensor" attached to each "Unit". + */ + readonly DetectSensorTag: number; + + /** + * The tag for the "AttackSensor" attached to each "Unit". + */ + readonly AttackSensorTag: number; + + /** + * A metamethod that creates a new "Unit" object. + * @param unitDef A "Dictionary" object that defines the properties and behavior of the "Unit". + * @param physicsworld A "PhysicsWorld" object that represents the physics simulation world. + * @param entity An "Entity" object that represents the "Unit" in the ECS system. + * @param pos A "Vec2" object that specifies the initial position of the "Unit". + * @param rot An optional number that specifies the initial rotation of the "Unit" (default is 0.0). + * @returns The newly created "Unit" object. + */ + ( + this: void, + unitDef: Dictionary, + physicsworld: PhysicsWorld, + entity: Entity, + pos: Vec2, + rot?: number + ): Unit; +} + +const unitClass: UnitClass; +export {unitClass as Unit}; + +/** + * An enum representing the possible relations between two groups. + */ +export const enum Relation { + Enemy = "Enemy", + Friend = "Friend", + Neutral = "Neutral", + Unknown = "Unknown", + Any = "Any" +} + +/** + * A singleton object that provides a centralized location for storing and accessing game-related data. + */ +interface Data { + + /** + * A group key representing the first index for a player group. + */ + readonly groupFirstPlayer: number; + + /** + * A group key representing the last index for a player group. + */ + readonly groupLastPlayer: number; + + /** + * A group key that won't have any contact with other groups by default. + */ + readonly groupHide: number; + + /** + * A group key that will have contacts with player groups by default. + */ + readonly groupDetectPlayer: number; + + /** + * A group key representing terrain that will have contacts with other groups by default. + */ + readonly groupTerrain: number; + + /** + * A group key that will have contacts with other groups by default. + */ + readonly groupDetection: number; + + /** + * A dictionary that can be used to store arbitrary data associated with string keys and various values globally. + */ + readonly store: Dictionary; + + /** + * A function that can be used to set a boolean value indicating whether two groups should be in contact or not. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @param contact A boolean indicating whether the two groups should be in contact. + */ + setShouldContact(groupA: number, groupB: number, contact: boolean): void; + + /** + * A function that can be used to get a boolean value indicating whether two groups should be in contact or not. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups should be in contact. + */ + getShouldContact(groupA: number, groupB: number): boolean; + + /** + * A function that can be used to set the relation between two groups. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @param relation The relation between the two groups. + */ + setRelation(groupA: number, groupB: number, relation: Relation): void; + + /** + * A function that can be used to get the relation between two groups. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns The relation between the two groups. + */ + getRelation(groupA: number, groupB: number): Relation; + + /** + * A function that can be used to get the relation between two bodies. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns The relation between the two bodies. + */ + getBodyRelation(bodyA: Body, bodyB: Body): Relation; + + /** + * A function that returns whether two groups have an "Enemy" relation. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups have an "Enemy" relation. + */ + isEnemy(groupA: number, groupB: number): boolean; + + /** + * A function that returns whether two bodies have an "Enemy" relation. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns Whether the two bodies have an "Enemy" relation. + */ + isBodyEnemy(bodyA: Body, bodyB: Body): boolean; + + /** + * A function that returns whether two groups have a "Friend" relation. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups have a "Friend" relation. + */ + isFriend(groupA: number, groupB: number): boolean; + + /** + * A function that returns whether two bodies have a "Friend" relation. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns Whether the two bodies have a "Friend" relation. + */ + isBodyFriend(bodyA: Body, bodyB: Body): boolean; + + /** + * A function that returns whether two groups have a "Neutral" relation. + * @param groupA An integer representing the first group. + * @param groupB An integer representing the second group. + * @returns Whether the two groups have a "Neutral" relation. + */ + isNeutral(groupA: number, groupB: number): boolean; + + /** + * A function that returns whether two bodies have a "Neutral" relation. + * @param bodyA The first body. + * @param bodyB The second body. + * @returns Whether the two bodies have a "Neutral" relation. + */ + isBodyNeutral(bodyA: Body, bodyB: Body): boolean; + + /** + * A function that sets the bonus factor for a particular type of damage against a particular type of defense. + * @param damageType An integer representing the type of damage. + * @param defenseType An integer representing the type of defense. + * @param bonus A number representing the bonus. + */ + setDamageFactor(damageType: number, defenseType: number, bonus: number): void; + + /** + * A function that gets the bonus factor for a particular type of damage against a particular type of defense. + * @param damageType An integer representing the type of damage. + * @param defenseType An integer representing the type of defense. + * @returns A number representing the bonus factor. + */ + getDamageFactor(damageType: number, defenseType: number): number; + + /** + * A function that returns whether a body is a player or not. + * @param body The body to check. + * @returns Whether the body is a player. + */ + isPlayer(body: Body): boolean; + + /** + * A function that returns whether a body is terrain or not. + * @param body The body to check. + * @returns Whether the body is terrain. + */ + isTerrain(body: Body): boolean; + + /** + * A function that clears all data stored in the "Data" object, including user data in Data.store field. + * And reset some data to default values. + */ + clear(): void; +} + +const data: Data; +export {data as Data}; + +/** + * A class that specifies how a bullet object should interact with other game objects or units based on their relationship. + */ +class TargetAllow { + + /** + * Whether the bullet object can collide with terrain. + */ + terrainAllowed: boolean; + + /** + * A function that allows or disallows the bullet object to interact with a game object or unit, based on their relationship. + * @param relation The relationship between the bullet object and the other game object or unit. + * @param allow Whether the bullet object should be allowed to interact. + */ + allow(relation: Relation, allow: boolean): void; + + /** + * A function that determines whether the bullet object is allowed to interact with a game object or unit, based on their relationship. + * @param relation The relationship between the bullet object and the other game object or unit. + * @returns Whether the bullet object is allowed to interact. + */ + isAllow(relation: Relation): boolean; +} + +/** + * A class that specifies how a bullet object should interact with other game objects or units based on their relationship. + * @usage + * const targetAllow = new TargetAllow(); + * targetAllow.terrainAllowed = true; + * targetAllow.allow("Enemy", true); + */ +interface TargetAllowClass { + + /** + * Call this function to create an instance of TargetAllow. + * @returns An instance of TargetAllow. + */ + (this: void): TargetAllow; +} + +const targetAllowClass: TargetAllowClass; +export {targetAllowClass as TargetAllow}; + +/** + * A platform camera for 2D platformer games that can track a game unit's movement and keep it within the camera's view. + */ +class PlatformCamera extends Camera { + + private constructor(); + + /** + * The camera's position. + */ + position: Vec2; + + /** + * The camera's rotation in degrees. + */ + rotation: number; + + /** + * The camera's zoom factor, 1.0 means the normal size, 2.0 mean zoom to doubled size. + */ + zoom: number; + + /** + * The rectangular area within which the camera is allowed to view. + */ + boundary: Rect; + + /** + * The ratio at which the camera should move to keep up with the target's position. + * For example, set to `Vec2(1.0, 1.0)`, then the camera will keep up to the target's position right away. + * Set to Vec2(0.5, 0.5) or smaller value, then the camera will move halfway to the target's position each frame, resulting in a smooth and gradual movement. + */ + followRatio: Vec2; + + /** + * The game unit that the camera should track. + */ + followTarget: Node; +} + +/** + * A class that defines how to create instances of PlatformCamera. + */ +interface PlatformCameraClass { + + /** + * Creates a new instance of PlatformCamera. + * @param name [optional] The name of the new instance, default is an empty string. + * @returns The new PlatformCamera instance. + */ + (this: void, name?: string): PlatformCamera; +} + +const platformCameraClass: PlatformCameraClass; +export {platformCameraClass as PlatformCamera}; + +/** + * A class representing a 2D platformer game world with physics simulations. + */ +class PlatformWorld extends PhysicsWorld { + + private constructor(); + + /** + * The camera used to control the view of the game world. + */ + readonly camera: PlatformCamera; + + /** + * Moves a child node to a new order for a different layer. + * @param child The child node to be moved. + * @param newOrder The new order of the child node. + */ + moveChild(child: Node, newOrder: number): void; + + /** + * Gets the layer node at a given order. + * @param order The order of the layer node to get. + * @returns The layer node at the given order. + */ + getLayer(order: number): Node; + + /** + * Sets the parallax moving ratio for a given layer to simulate 3D projection effect. + * @param order The order of the layer to set the ratio for. + * @param ratio The new parallax ratio for the layer. + */ + setLayerRatio(order: number, ratio: Vec2): void; + + /** + * Gets the parallax moving ratio for a given layer. + * @param order The order of the layer to get the ratio for. + * @returns The parallax ratio for the layer. + */ + getLayerRatio(order: number): Vec2; + + /** + * Sets the position offset for a given layer. + * @param order The order of the layer to set the offset for. + * @param offset The new position offset for the layer. + */ + setLayerOffset(order: number, offset: Vec2): void; + + /** + * Gets the position offset for a given layer. + * @param order The order of the layer to get the offset for. + * @returns The position offset for the layer. + */ + getLayerOffset(order: number): Vec2; + + /** + * Swaps the positions of two layers. + * @param orderA The order of the first layer to swap. + * @param orderB The order of the second layer to swap. + */ + swapLayer(orderA: number, orderB: number): void; + + /** + * Removes a layer from the game world. + * @param order The order of the layer to remove. + */ + removeLayer(order: number): void; + + /** + * Removes all layers from the game world. + */ + removeAllLayers(): void; +} + +export type {PlatformWorld as PlatformWorldType}; + +/** + * A class for instantiating instances of PlatformWorld. + * @example + * ``` + * const world = PlatformWorldClass(); + * world.addTo(entry); + * ``` + */ +interface PlatformWorldClass { + + /** + * The metamethod to create a new instance of PlatformWorld. + * @returns A new instance of PlatformWorld. + */ + (this: void): PlatformWorld; +} + +const platformWorldClass: PlatformWorldClass; +export {platformWorldClass as PlatformWorld}; + +/** + * Represents a definition for a visual component of a game bullet or other visual item. + */ +class Face extends Node { + + /** + * Adds a child `Face` definition to it. + * @param face The child `Face` to add. + */ + addChild(face: Face): void; + + /** + * Returns a node that can be added to a scene tree for rendering. + * @returns The `Node` representing this `Face`. + */ + toNode(): Node; +} + +/** + * A record provides functions for creating instances of the `Face` component with different configurations. + * @example + * ``` + * import { Face } from "Platformer"; + * const faceA = Face("Image/file.png"); + * const faceB = Face(() => { + * return Sprite("Image/file.png"); + * }); + * faceA.toNode().addTo(entry); + * faceB.toNode().addTo(entry); + * ``` + */ +interface FaceClass { + + /** + * Creates a new `Face` definition using the specified attributes. + * @param faceStr A string for creating the `Face` component. + * Could be 'Image/file.png' and 'Image/items.clip|itemA'. + * @param point The position of the `Face` component, default is `Vec2.zero`. + * @param scale The scale of the `Face` component, default is 1.0. + * @param angle The angle of the `Face` component, default is 0.0. + * @returns The new `Face` component. + */ + ( + this: void, + faceStr: string, + point?: Vec2, + scale?: number, + angle?: number + ): Face; + + /** + * Creates a new `Face` definition using the specified attributes. + * @param createFunc A function that returns a `Node` representing the `Face` component. + * @param point The position of the `Face` component, default is `Vec2.zero`. + * @param scale The scale of the `Face` component, default is 1.0. + * @param angle The angle of the `Face` component, default is 0.0. + * @returns The new `Face` component. + */ + ( + this: void, + createFunc: () => Node, + point?: Vec2, + scale?: number, + angle?: number + ): Face; +} + +const faceClass: FaceClass; +export {faceClass as Face}; + +/** + * A class to represent a visual effect object like Particle, Frame Animation, or just a Sprite. + */ +class Visual extends Node { + + private constructor(); + + /** + * Whether the visual effect is currently playing or not. + */ + playing: boolean; + + /** + * Starts playing the visual effect. + */ + start(): void; + + /** + * Stops playing the visual effect. + */ + stop(): void; + + /** + * Automatically removes the visual effect from the game world when it finishes playing. + * @returns The same "Visual" object that was passed in as a parameter. + */ + autoRemove(): Visual; +} + +export type {Visual as VisualType}; + +/** +* A class for creating "Visual" objects. +*/ +interface VisualClass { + + /** + * Creates a new "Visual" object with the specified name. + * @param name The name of the new "Visual" object. + * Could be a particle file, a frame animation file, or an image file. + * @returns The new "Visual" object. + */ + (this: void, name: string): Visual; +} + +const visualClass: VisualClass; +export {visualClass as Visual}; + +/** A behavior tree framework for creating game AI structures. */ +export namespace Behavior { + +/** + * A blackboard object that can be used to store data for behavior tree nodes. + */ +class Blackboard { + + private constructor(); + + /** + * The time since the last frame update in seconds. + */ + deltaTime: number; + + /** + * The unit that the AI agent belongs to. + */ + owner: Unit; + + /** + * A method to index the blackboard properties. + * @param key The key to index. + * @returns The value associated with the key. + */ + [key: string]: Item; +} + +/** + * A leaf node in a behavior tree. + */ +class Leaf extends Object { + private constructor(); +} + +/** + * Creates a new sequence node that executes an array of child nodes in order. + * @param nodes An array of child nodes. + * @returns A new sequence node. + */ +export function Seq(nodes: Leaf[]): Leaf; + +/** + * Creates a new selector node that selects and executes one of its child nodes that will succeed. + * @param nodes An array of child nodes. + * @returns A new selector node. + */ +export function Sel(nodes: Leaf[]): Leaf; + +/** + * Creates a new condition node that executes a check handler function when executed. + * @param name The name of the condition. + * @param check A function that takes a blackboard object and returns a boolean value. + * @returns A new condition node. + */ +export function Con(name: string, check: (board: Blackboard) => boolean): Leaf; + +/** + * Creates a new action node that executes an action when executed. + * This node will block the execution until the action finishes. + * @param actionName The name of the action to execute. + * @returns A new action node. + */ +export function Act(actionName: string): Leaf; + +/** + * Creates a new command node that executes a command when executed. + * This node will return right after the action starts. + * @param actionName The name of the command to execute. + * @returns A new command node. + */ +export function Command(actionName: string): Leaf; + +/** + * Creates a new wait node that waits for a specified duration when executed. + * @param duration The duration to wait in seconds. + * @returns A new wait node. + */ +export function Wait(duration: number): Leaf; + +/** + * Creates a new countdown node that executes a child node continuously until a timer runs out. + * @param time The time limit in seconds. + * @param node The child node to execute. + * @returns A new countdown node. + */ +export function Countdown(time: number, node: Leaf): Leaf; + +/** + * Creates a new timeout node that executes a child node until a timer runs out. + * @param time The time limit in seconds. + * @param node The child node to execute. + * @returns A new timeout node. + */ +export function Timeout(time: number, node: Leaf): Leaf; + +/** + * Creates a new repeat node that executes a child node a specified number of times. + * @param times The number of times to execute the child node. + * @param node The child node to execute. + * @returns A new repeat node. + */ +export function Repeat(times: number, node: Leaf): Leaf; + +/** + * Creates a new repeat node that executes a child node repeatedly. + * @param node The child node to execute. + * @returns A new repeat node. + */ +export function Repeat(node: Leaf): Leaf; + +/** + * Creates a new retry node that executes a child node repeatedly until it succeeds or a maximum number of retries is reached. + * @param times The maximum number of retries. + * @param node The child node to execute. + * @returns A new retry node. + */ +export function Retry(times: number, node: Leaf): Leaf; + +/** + * Creates a new retry node that executes a child node repeatedly until it succeeds. + * @param node The child node to execute. + * @returns A new retry node. + */ +export function Retry(node: Leaf): Leaf; + +} // namespace Behavior + +/** + * The singleton record to retrieve information when executing the decision tree. + */ +interface AI { + + /** + * Gets an array of units in detection range that have the specified relation to current AI agent. + * @param relation The relation to filter the units by. + * @returns An array of units with the specified relation. + */ + getUnitsByRelation(relation: Relation): Unit[]; + + /** + * Gets an array of units that the AI has detected. + * @returns An array of detected units. + */ + getDetectedUnits(): Unit[]; + + /** + * Gets an array of bodies that the AI has detected. + * @returns An array of detected bodies. + */ + getDetectedBodies(): Body[]; + + /** + * Gets the nearest unit that has the specified relation to the AI. + * @param relation The relation to filter the units by. + * @returns The nearest unit with the specified relation. + */ + getNearestUnit(relation: Relation): Unit; + + /** + * Gets the distance to the nearest unit that has the specified relation to the AI agent. + * @param relation The relation to filter the units by. + * @returns The distance to the nearest unit with the specified relation. + */ + getNearestUnitDistance(relation: Relation): number; + + /** + * Gets an array of units that are within attack range. + * @returns An array of units in attack range. + */ + getUnitsInAttackRange(): Unit[]; + + /** + * Gets an array of bodies that are within attack range. + * @returns An array of bodies in attack range. + */ + getBodiesInAttackRange(): Body[]; +} + +/** + * A decision tree framework for creating game AI structures. + */ +export namespace Decision { + +/** + * A leaf node in a decision tree. + */ +class Leaf extends Object { + private constructor(); +} + +/** + * Creates a selector node with the specified child nodes. + * A selector node will go through the child nodes until one succeeds. + * @param nodes An array of `Leaf` nodes. + * @returns A `Leaf` node that represents a selector. + */ +export function Sel(nodes: Leaf[]): Leaf; + +/** + * Creates a sequence node with the specified child nodes. + * A sequence node will go through the child nodes until all nodes succeed. + * @param nodes An array of `Leaf` nodes. + * @returns A `Leaf` node that represents a sequence. + */ +export function Seq(nodes: Leaf[]): Leaf; + +/** + * Creates a condition node with the specified name and handler function. + * @param name The name of the condition. + * @param check The check function that takes a `Unit` parameter and returns a boolean result. + * @returns A `Leaf` node that represents a condition check. + */ +export function Con(name: string, check: (self: Unit) => boolean): Leaf; + +/** + * Creates an action node with the specified action name. + * @param actionName The name of the action to perform. + * @returns A `Leaf` node that represents an action. + */ +export function Act(actionName: string): Leaf; + +/** + * Creates an action node with the specified handler function. + * @param handler The handler function that takes a `Unit` parameter which is the running AI agent and returns an action. + * @returns A `Leaf` node that represents an action. + */ +export function Act(handler: (self: Unit) => string): Leaf; + +/** + * Creates a leaf node that represents accepting the current behavior tree. + * Always get a success result from this node. + * @returns A `Leaf` node. + */ +export function Accept(): Leaf; + +/** + * Creates a leaf node that represents rejecting the current behavior tree. + * Always get a failure result from this node. + * @returns A `Leaf` node. + */ +export function Reject(): Leaf; + +/** + * Creates a leaf node with the specified behavior tree as its root. + * It is possible to include a Behavior Tree as a node in a Decision Tree by using the Behave() function. + * This allows the AI to use a combination of decision-making and behavior execution to achieve its goals. + * @param name The name of the behavior tree. + * @param root The root node of the behavior tree. + * @returns A `Leaf` node. + */ +export function Behave(name: string, root: Behavior.Leaf): Leaf; + +/** + * The singleton instance to retrieve information while executing the decision tree. */ +export const AI: AI; + +} // namespace Decision + +/** + * A record type that specifies the properties and behaviors of a bullet object in the game. + */ +class BulletDef extends Object { + + private constructor(); + + /** + * The tag for the bullet object. + */ + tag: string; + + /** + * The effect that occurs when the bullet object ends its life. + */ + endEffect: string; + + /** + * The amount of time in seconds that the bullet object remains active. + */ + lifeTime: number; + + /** + * The radius of the bullet object's damage area. + */ + damageRadius: number; + + /** + * Whether the bullet object should be fixed for high speeds. + */ + highSpeedFix: boolean; + + /** + * The gravity vector that applies to the bullet object. + */ + gravity: Vec2; + + /** + * The visual item of the bullet object. + */ + face: Face; + + /** + * The physics body definition for the bullet object. + */ + bodyDef: BodyDef; + + /** + * The velocity vector of the bullet object. + */ + velocity: Vec2; + + /** + * Sets the bullet object's physics body as a circle. + * @param radius The radius of the circle. + */ + setAsCircle(radius: number): void; + + /** + * Sets the velocity of the bullet object. + * @param angle The angle of the velocity in degrees. + * @param speed The speed of the velocity. + */ + setVelocity(angle: number, speed: number): void; +} + +/** + * @example + * ``` + * import { BulletDef } from "Platformer"; + * const bulletDef = BulletDef(); + * ``` + */ +interface BulletDefClass { + (this: void): BulletDef; +} + +const bulletDefClass: BulletDefClass; +export {bulletDefClass as BulletDef}; + +/** + * A record type that defines the properties and behavior of a bullet object instance in the game. + */ +class Bullet extends Body { + + private constructor(); + + /** + * The `TargetAllow` object for the bullet object. + */ + targetAllow: TargetAllow; + + /** + * Whether the bullet object is facing right. + */ + readonly faceRight: boolean; + + /** + * Whether the bullet object should stop on impact. + */ + hitStop: boolean; + + /** + * The `Unit` object that fired the bullet. + */ + readonly emitter: Unit; + + /** + * The `BulletDef` object that defines the bullet's properties and behavior. + */ + readonly bulletDef: BulletDef; + + /** + * The `Node` object that appears as the bullet's visual item. + */ + face: Node; + + /** + * Destroys the bullet object instance. + */ + destroy(): void; +} + +/** +* A record type that creates new `Bullet` object instances. +*/ +interface BulletClass { + + /** + * A metamethod that creates a new `Bullet` object instance with the specified `BulletDef` and `Unit` objects. + * @param def The `BulletDef` object that defines the bullet's properties and behavior. + * @param owner The `Unit` object that fired the bullet. + * @returns The new `Bullet` object instance. + */ + (this: void, def: BulletDef, owner: Unit): Bullet; +} + +const bulletClass: BulletClass; +export {bulletClass as Bullet}; + +} // module "Platformer" diff --git a/Assets/Script/Lib/Dora/zh-Hans/dora.d.ts b/Assets/Script/Lib/Dora/zh-Hans/dora.d.ts index a1c44f34e..5a7b94812 100644 --- a/Assets/Script/Lib/Dora/zh-Hans/dora.d.ts +++ b/Assets/Script/Lib/Dora/zh-Hans/dora.d.ts @@ -1191,7 +1191,7 @@ export function Sequence(...actions: ActionDef[]): ActionDef; * The supported array data types. * This can be an integer, number, boolean, string, thread, ContainerItem. */ -type Item = number | boolean | string | LuaThread | ContainerItem; +export type Item = number | boolean | string | LuaThread | ContainerItem; /** * An array data structure that supports various operations. @@ -1489,7 +1489,7 @@ export {blendFuncClass as BlendFunc}; /** * The Job type, representing a coroutine thread. */ -type Job = BasicType<"Job", LuaThread>; +export type Job = BasicType<"Job", LuaThread>; /** * A singleton record for managing coroutines. @@ -4303,6 +4303,8 @@ class Sensor extends Object { contains(body: Body): boolean; } +export type {Sensor as SensorType}; + /** * A record called "BodyDef" to describe the properties of a physics body. * Inherits from `Object`. @@ -4541,7 +4543,7 @@ export {bodyDefClass as BodyDef}; */ class Body extends Node { - private constructor(); + protected constructor(); /** * The physics world that the body belongs to. diff --git a/Assets/Script/Lib/Dora/zh-Hans/nvg.d.ts b/Assets/Script/Lib/Dora/zh-Hans/nvg.d.ts index 59fc32d6e..dd7c2e2d3 100644 --- a/Assets/Script/Lib/Dora/zh-Hans/nvg.d.ts +++ b/Assets/Script/Lib/Dora/zh-Hans/nvg.d.ts @@ -1,5 +1,193 @@ /// +import { + Vec2Type as Vec2, + ColorType as Color, + RectType as Rect, + VGPaintType as VGPaint, + SizeType as Size, + Texture2DType as Texture2D +} from "dora"; + declare module "nvg" { -} \ No newline at end of file +class Transform { + private constructor(); + identity(): void; + translate(tx: number, ty: number): void; + scale(sx: number, sy: number): void; + rotate(a: number): void; + skewX(a: number): void; + skewY(a: number): void; + multiply(src: Transform): void; + inverseFrom(src: Transform): boolean; + applyPoint(src: Vec2): Vec2; +} + +export type {Transform as TransformType}; + +interface TransformClass { + (this: void): Transform; +} + +const transformClass: TransformClass; +export {transformClass as Transform}; + +export const enum LineCapMode { + Butt = "Butt", + Round = "Round", + Square = "Square", +} + +export const enum LineJoinMode { + Miter = "Miter", + Round = "Round", + Bevel = "Bevel", +} + +export const enum WindingMode { + CW = "CW", + CCW = "CCW", + Solid = "Solid", + Hole = "Hole", +} + +export const enum ArcDir { + CW = "CW", + CCW = "CCW", +} + +export const enum TextAlignMode { + Left = "Left", + Center = "Center", + Right = "Right", + Top = "Top", + Middle = "Middle", + Bottom = "Bottom", + Baseline = "Baseline", +} + +export const enum ImageFlag { + Mipmaps = "Mipmaps", + RepeatX = "RepeatX", + RepeatY = "RepeatY", + FlipY = "FlipY", + Premultiplied = "Premultiplied", + Nearest = "Nearest", +} + +interface nvg { + TouchPos(): Vec2; + LeftButtonPressed(): boolean; + RightButtonPressed(): boolean; + MiddleButtonPressed(): boolean; + MouseWheel(): number; + Save(): void; + Restore(): void; + Reset(): void; + CreateImage(w: number, h: number, filename: string, imageFlags?: ImageFlag[]): number; + CreateFont(name: string): number; + TextBounds(x: number, y: number, text: string, bounds: Rect): number; + TextBoxBounds(x: number, y: number, breakRowWidth: number, text: string): Rect; + Text(x: number, y: number, text: string): number; + TextBox(x: number, y: number, breakRowWidth: number, text: string): void; + StrokeColor(color: Color): void; + StrokePaint(paint: VGPaint): void; + FillColor(color: Color): void; + FillPaint(paint: VGPaint): void; + MiterLimit(limit: number): void; + StrokeWidth(size: number): void; + LineCap(cap: LineCapMode): void; + LineJoin(join: LineJoinMode): void; + GlobalAlpha(alpha: number): void; + ResetTransform(): void; + ApplyTransform(t: Transform): void; + CurrentTransform(t: Transform): void; + Translate(x: number, y: number): void; + Rotate(angle: number): void; + SkewX(angle: number): void; + SkewY(angle: number): void; + Scale(x: number, y: number): void; + ImageSize(image: number): Size; + DeleteImage(image: number): void; + NVGpaLinearGradient( + sx: number, + sy: number, + ex: number, + ey: number, + icol: Color, + ocol: Color + ): VGPaint; + NVGpaBoxGradient( + x: number, + y: number, + w: number, + h: number, + r: number, + f: number, + icol: Color, + ocol: Color + ): VGPaint; + NVGpaRadialGradient( + cx: number, + cy: number, + inr: number, + outr: number, + icol: Color, + ocol: Color + ): VGPaint; + NVGpaImagePattern( + ox: number, + oy: number, + ex: number, + ey: number, + angle: number, + image: number, + alpha: number + ): VGPaint; + Scissor(x: number, y: number, w: number, h: number): void; + IntersectScissor(x: number, y: number, w: number, h: number): void; + ResetScissor(): void; + BeginPath(): void; + MoveTo(x: number, y: number): void; + LineTo(x: number, y: number): void; + BezierTo(c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number): void; + QuadTo(cx: number, cy: number, x: number, y: number): void; + ArcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + ClosePath(): void; + PathWinding(dir: WindingMode): void; + Arc(cx: number, cy: number, r: number, a0: number, a1: number, dir: ArcDir): void; + Rect(x: number, y: number, w: number, h: number): void; + RoundedRect(x: number, y: number, w: number, h: number, r: number): void; + RoundedRectVarying( + x: number, + y: number, + w: number, + h: number, + radTopLeft: number, + radTopRight: number, + radBottomRight: number, + radBottomLeft: number + ): void; + Ellipse(cx: number, cy: number, rx: number, ry: number): void; + Circle(cx: number, cy: number, r: number): void; + Fill(): void; + Stroke(): void; + FindFont(name: string): number; + AddFallbackFontId(baseFont: number, fallbackFont: number): number; + AddFallbackFont(baseFont: string, fallbackFont: string): number; + FontSize(size: number): void; + FontBlur(blur: number): void; + TextLetterSpacing(spacing: number): void; + TextLineHeight(lineHeight: number): void; + TextAlign(align: TextAlignMode): void; + FontFaceId(font: number): void; + FontFace(font: string): void; + DoraSSR(): void; + GetDoraSSR(scale?: number): Texture2D; +} + +const nvg: nvg; +export = nvg; + +} // module "nvg"