神岛 API 文档 - ArenaPro版
    Preparing search index...

    GameWorld 是引擎 API 的主要入口点。使用此对象可以控制场景的全局属性,如天气、一天中的时间等,并对存在于世界中的所有 GameEntity 进行搜索。

    The GameWorld is the main entry point for the engine API. Use this object to control global properties of the scene, such as weather, time of day, etc., and to search for all GameEntitys that exist in the world.

    Index

    Animation

    Chat

    Entities

    Entity

    Health

    Interaction

    Other

    Physics

    Player

    Search

    Server

    Sound

    Tick

    Weather

    Zone

    Animation

    animate: (
        keyframes: Partial<GameWorldKeyframe>[],
        playbackInfo?: Partial<GameAnimationPlaybackConfig>,
    ) => GameAnimation<GameWorldKeyframe, GameWorld>

    Type declaration

    在世界对象上播放一个基于关键帧的动画。

    Plays a keyframe-based animation on the world object.

    定义动画行为的关键帧数组。

    An array of keyframes that define the animation's behavior.

    动画的播放配置选项。

    Playback configuration options for the animation.

    返回一个 GameAnimation 对象,用于控制动画的播放。

    Returns a GameAnimation object to control the animation's playback.

    getAnimations: () => GameAnimation<GameWorldKeyframe, GameWorld>[]

    获取当前在世界对象上播放的所有动画。

    Gets all animations currently playing on the world object.

    一个包含所有世界动画的 GameAnimation 数组。

    An array of GameAnimation objects for all world animations.

    getEntityAnimations: () => GameAnimation<GameEntityKeyframe, GameEntity>[]

    获取当前在所有实体上播放的动画。

    Gets all animations currently playing on any entity.

    一个包含所有实体动画的 GameAnimation 数组。

    An array of GameAnimation objects for all entity animations.

    getPlayerAnimations: () => GameAnimation<GamePlayerKeyframe, GamePlayer>[]

    获取当前在所有玩家上播放的动画。

    Gets all animations currently playing on any player.

    一个包含所有玩家动画的 GameAnimation 数组。

    An array of GameAnimation objects for all player animations.

    Chat

    addTempChatPlayer: (chatId: string, userIds: string[]) => Promise<string[]>

    Type declaration

      • (chatId: string, userIds: string[]): Promise<string[]>
      • Parameters

        • chatId: string
        • userIds: string[]

        Returns Promise<string[]>

    将一个或多个用户添加到一个特定的临时聊天频道。

    Adds one or more users to a specific temporary chat channel.

    目标聊天频道的 ID。

    The ID of the target chat channel.

    要添加的用户的 ID 列表。

    An array of user IDs to add.

    返回一个 Promise,解析为已成功添加的用户的 ID 列表。

    A Promise that resolves with an array of user IDs that were successfully added.

    createTempChat: (userIds?: string[]) => Promise<string>

    Type declaration

      • (userIds?: string[]): Promise<string>
      • Parameters

        • OptionaluserIds: string[]

        Returns Promise<string>

    创建一个临时聊天频道。

    Creates a temporary chat channel.

    频道中初始用户的 ID 列表。

    An array of user IDs to initially include in the channel.

    返回一个 Promise,解析为新创建的聊天频道的 ID。

    A Promise that resolves with the ID of the newly created chat channel.

    destroyTempChat: (chatIds: string[]) => Promise<string[]>

    Type declaration

      • (chatIds: string[]): Promise<string[]>
      • Parameters

        • chatIds: string[]

        Returns Promise<string[]>

    销毁一个或多个临时聊天频道。

    Destroys one or more temporary chat channels.

    要销毁的聊天频道的 ID 列表。

    An array of chat channel IDs to destroy.

    返回一个 Promise,解析为已成功销毁的聊天频道的 ID 列表。

    A Promise that resolves with an array of chat channel IDs that were successfully destroyed.

    getTempChats: () => Promise<string[]>

    Type declaration

    获取当前地图中所有存在的临时聊天频道的列表。

    Gets a list of all existing temporary chat channels in the current map.

    返回一个 Promise,解析为一个包含所有临时聊天频道 ID 的数组。

    A Promise that resolves with an array of all temporary chat channel IDs.

    getTempChatUsers: (chatId: string) => Promise<string[]>

    Type declaration

      • (chatId: string): Promise<string[]>
      • Parameters

        • chatId: string

        Returns Promise<string[]>

    查询特定临时聊天频道内的所有用户。

    Queries all users within a specific temporary chat channel.

    要查询的聊天频道的 ID。

    The ID of the chat channel to query.

    返回一个 Promise,解析为一个包含该频道内所有用户 ID 的数组。

    A Promise that resolves with an array of all user IDs in the channel.

    removeTempChatPlayer: (chatId: string, userIds: string[]) => Promise<string[]>

    Type declaration

      • (chatId: string, userIds: string[]): Promise<string[]>
      • Parameters

        • chatId: string
        • userIds: string[]

        Returns Promise<string[]>

    从一个特定的临时聊天频道中移除一个或多个用户。

    Removes one or more users from a specific temporary chat channel.

    目标聊天频道的 ID。

    The ID of the target chat channel.

    要移除的用户的 ID 列表。

    An array of user IDs to remove.

    返回一个 Promise,解析为已成功移除的用户的 ID 列表。

    A Promise that resolves with an array of user IDs that were successfully removed.

    Entities

    createEntity: (config: Partial<GameEntityConfig>) => GameEntity

    Type declaration

    创建一个新的 GameEntity 或复制一个现有实体。 如果超出实体配额,则返回 null

    Creates a new GameEntity or duplicates an existing one. Returns null if the entity quota is exceeded.

    实体的初始值集或要复制的新实体。

    A set of initial values for the entity or the new entity to be duplicated.

    具有给定参数的新创建的实体。

    The newly created entity with the given parameters.

    entityQuota: () => number

    返回脚本当前还可以创建的实体数量配额。

    Returns the remaining number of entities that the script is allowed to create.

    querySelector: (selector: string) => GameEntity

    Type declaration

    使用类似于 jQuery 选择器的语法搜索游戏中的实体,并返回匹配的第一个实体。 更多示例参见 GameSelectorString

    Searches for entities in the game using a syntax similar to jQuery selectors and returns the first matching entity. For more examples, see GameSelectorString.

    选择器搜索模式。

    The selector search pattern.

    匹配选择器的第一个实体,如果找不到则返回 null

    The first entity that matches the selector, or null if not found.

    testSelector: (selector: string, entity: GameEntity) => boolean

    Type declaration

      • (selector: string, entity: GameEntity): boolean
      • Parameters

        Returns boolean

    测试给定实体是否匹配选择器模式。

    Tests if a given entity matches a selector pattern.

    要测试的选择器模式。

    The selector pattern to test.

    要测试的实体。

    The entity to test.

    如果实体匹配选择器,则返回 true,否则返回 false

    Returns true if the entity matches the selector, otherwise false.

    • Parameters

      • selector: "player"

      Returns GamePlayerEntity[]

      使用类似于 jQuery 选择器的语法搜索游戏中的实体,并返回所有匹配的实体。 更多示例参见 GameSelectorString

      Searches for entities in the game using a syntax similar to jQuery selectors and returns all matching entities. For more examples, see GameSelectorString.

      选择器搜索模式。

      The selector search pattern.

      所有匹配选择器的实体数组。

      An array of all entities that match the selector.

    • Parameters

      • selector: string

      Returns GameEntity[]

      使用类似于 jQuery 选择器的语法搜索游戏中的实体,并返回所有匹配的实体。 更多示例参见 GameSelectorString

      Searches for entities in the game using a syntax similar to jQuery selectors and returns all matching entities. For more examples, see GameSelectorString.

      选择器搜索模式。

      The selector search pattern.

      所有匹配选择器的实体数组。

      An array of all entities that match the selector.

    Entity

    等待下一个实体接触事件。

    Waits for the next entity contact event.

    nextEntityCreate: GameEventFuture<GameEntityEvent>

    等待下一个实体创建事件。

    Waits for the next entity create event.

    nextEntityDestroy: GameEventFuture<GameEntityEvent>

    等待下一个实体销毁事件。

    Waits for the next entity destroy event.

    等待下一个实体分离事件。

    Waits for the next entity separate event.

    等待下一个实体进入流体的事件。

    Waits for the next event of an entity entering a fluid.

    等待下一个实体离开流体的事件。

    Waits for the next event of an entity leaving a fluid.

    等待下一个实体接触体素事件。

    Waits for the next entity-voxel contact event.

    等待下一个实体与体素分离的事件。

    Waits for the next event where an entity separates from a voxel.

    当两个实体开始接触时触发的事件。

    Event fired when two entities start contacting each other.

    当世界中创建新实体时触发的事件。

    Event fired when a new entity is created in the world.

    当世界中的实体被销毁时触发的事件。

    Event fired when an entity in the world is destroyed.

    当两个实体停止接触时触发的事件。

    Event fired when two entities stop contacting each other.

    当一个实体进入流体时触发的事件。

    Event fired when an entity enters a fluid.

    当一个实体离开流体时触发的事件。

    Event fired when an entity leaves a fluid.

    当一个实体开始接触一个体素(方块)时触发的事件。

    Event fired when an entity starts contacting a voxel (block).

    当一个实体停止接触一个体素(方块)时触发的事件。

    Event fired when an entity stops contacting a voxel (block).

    Health

    等待下一个实体死亡事件。

    Waits for the next entity die event.

    等待下一个实体受到伤害事件。

    Waits for the next entity take damage event.

    当任何实体死亡时触发的事件。

    Event fired when any entity dies.

    当玩家重生时触发的事件。

    Event triggered when a player respawns.

    当任何实体受到伤害时触发的事件。

    Event fired when any entity takes damage.

    Interaction

    等待下一个互动事件。

    Waits for the next interaction event.

    当玩家与实体或UI元素互动时触发的事件。

    Event fired when a player interacts with an entity or UI element.

    Other

    等待下一次玩家重生事件。

    Waits for the next player respawn event.

    url: URL

    当前运行世界的公共 URL。

    The public URL of the currently running world.

    Physics

    addCollisionFilter: (aSelector: string, bSelector: string) => void

    禁用所有匹配 aSelector 和 bSelector 的实体之间的碰撞。

    Disables collisions between all entities matching aSelector and bSelector.

    第一组实体的选择器。

    The selector for the first group of entities.

    第二组实体的选择器。

    The selector for the second group of entities.

    airFriction: number

    空气摩擦力。

    The air friction.

    clearCollisionFilters: () => void

    清除所有已设置的碰撞过滤器。

    Clears all configured collision filters.

    collisionFilters: () => string[][]

    Type declaration

      • (): string[][]
      • Returns string[][]

    返回当前所有活动的碰撞过滤器列表。

    Returns a list of all currently active collision filters.

    所有当前活动的碰撞过滤器。

    All currently active collision filters.

    gravity: number

    全局重力。

    The global gravity.

    removeCollisionFilter: (aSelector: string, bSelector: string) => void

    移除 aSelector 和 bSelector 之间的碰撞过滤器。

    Removes the collision filter between aSelector and bSelector.

    第一组实体的选择器。

    The selector for the first group of entities.

    第二组实体的选择器。

    The selector for the second group of entities.

    useOBB: boolean

    是否使用 OBB(Oriented Bounding Box)刚体进行物理计算。

    Whether to use OBB (Oriented Bounding Box) rigid bodies for physics calculations.

    Player

    等待下一个聊天事件。

    Waits for the next chat event.

    等待下一个点击事件。

    Waits for the next click event.

    等待下一个玩家加入事件。

    Waits for the next player join event.

    等待下一个玩家离开事件。

    Waits for the next player leave event.

    nextPlayerPurchaseSuccess: GameEventFuture<GamePurchaseSuccessEvent>

    等待下一个玩家成功购买事件。

    Waits for the next successful player purchase event.

    等待下一个按钮按下事件。

    Waits for the next button press event.

    等待下一个按钮释放事件。

    Waits for the next button release event.

    当任何玩家在聊天中发言时触发的事件。

    Event fired when any player speaks in the chat.

    当玩家点击一个实体或体素时触发的事件。

    Event fired when a player clicks on an entity or voxel.

    当有新玩家加入游戏时触发的事件。

    Event fired when a new player joins the game.

    当有玩家离开游戏时触发的事件。

    Event fired when a player leaves the game.

    onPlayerPurchaseSuccess: GameEventChannel<GamePurchaseSuccessEvent>

    当玩家成功完成一次购买时触发的事件。

    Event fired when a player successfully completes a purchase.

    当玩家按下已绑定的输入按钮时触发的事件。

    Event fired when a player presses a bound input button.

    当玩家释放已绑定的输入按钮时触发的事件。

    Event fired when a player releases a bound input button.

    say: (message: string) => void

    向所有玩家广播一条消息。

    Broadcasts a message to all players.

    要广播的文本消息。

    The text message to broadcast.

    teleport: TeleportType

    提供将玩家传送到同一地图组内其他地图的能力。

    Provides the ability to teleport the player to other maps within the same map group.

    Search

    raycast: (
        origin: GameVector3,
        direction: GameVector3,
        options?: Partial<GameRaycastOptions>,
    ) => GameRaycastResult

    Type declaration

    origin 沿 direction 投射一条光线,并返回第一个命中的结果。

    Casts a ray from origin along direction and returns the first hit result.

    光线的起点。

    The starting point of the ray.

    光线的方向。

    The direction of the ray.

    可选的配置参数。

    Optional configuration parameters.

    关于光线投射结果的信息。

    Information about the raycast result.

    searchBox: (bounds: GameBounds3) => GameEntity[]

    Type declaration

    搜索并返回所有包含在指定边界框内的实体。

    Searches for and returns all entities contained within the specified bounding box.

    要搜索的边界框。

    The bounding box to search within.

    所有完全包含在 bounds 内的实体数组。

    An array of all entities fully contained within bounds.

    Server

    projectName: string

    项目的名称(只读)。

    The name of the project (read-only).

    serverId: string

    当前服务器的唯一标识符。

    The unique identifier for the current server.

    Sound

    ambientSound: GameSoundEffect

    全局播放的背景环境声音。

    The ambient background sound played globally.

    breakVoxelSound: GameSoundEffect

    当方块被破坏时播放的声音效果。

    The sound effect played when a voxel is broken.

    placeVoxelSound: GameSoundEffect

    当方块被放置时播放的声音效果。

    The sound effect played when a voxel is placed.

    playerJoinSound: GameSoundEffect

    当玩家加入游戏时播放的声音效果。

    The sound effect played when a player joins the game.

    playerLeaveSound: GameSoundEffect

    当玩家离开游戏时播放的声音效果。

    The sound effect played when a player leaves the game.

    sound: (
        spec:
            | string
            | { pitch?: number; position?: GameVector3; sample: any; volume?: number },
        config?: GameSoundEffectConfig,
    ) => Sound

    Type declaration

      • (
            spec:
                | string
                | { pitch?: number; position?: GameVector3; sample: any; volume?: number },
            config?: GameSoundEffectConfig,
        ): Sound
      • Parameters

        • spec:
              | string
              | { pitch?: number; position?: GameVector3; sample: any; volume?: number }
          • string
          • { pitch?: number; position?: GameVector3; sample: any; volume?: number }
            • Optionalpitch?: number

              音高,可以为负数。

              The pitch, which can be a negative number.

            • Optionalposition?: GameVector3

              音频在游戏世界中的三维位置。

              The 3D position of the audio in the game world.

            • sample: any

              用于标识音频样本的字符串。

              A string to identify the audio sample.

            • Optionalvolume?: number

              音量,范围从 0 到 1。

              The volume, ranging from 0 to 1.

        • Optionalconfig: GameSoundEffectConfig

        Returns Sound

    在指定位置播放一个声音效果。

    Plays a sound effect at a specified location.

    声音的规格。可以是一个包含样本、位置、音量和音高信息的对象,也可以是直接指定样本名称的字符串。

    The specification for the sound. Can be an object containing sample, position, volume, and pitch information, or a string specifying the sample name directly.

    额外的声音效果配置。

    Additional sound effect configuration.

    返回一个 Sound 对象,用于控制声音的播放。

    Returns a Sound object to control the sound's playback.

    Tick

    currentTick: number

    当前的游戏 tick 数,用于记录时间点或事件序列中的位置。

    The current game tick count, used to record the position in time or an event sequence.

    等待下一个游戏 tick 事件。

    Waits for the next game tick event.

    每个游戏 tick 触发的事件。一个 tick 是一个游戏世界更新周期。

    Event fired on every game tick. A tick is a single update cycle of the game world.

    Weather

    fogColor: GameRGBColor

    雾的颜色。

    The color of the fog.

    fogHeightFalloff: number

    高度雾衰减率。

    The rate at which the fog attenuates with height.

    fogHeightOffset: number

    雾开始的高度。

    The height at which the fog starts.

    fogStartDistance: number

    雾开始的距离。

    The distance at which the fog starts.

    fogUniformDensity: number

    均匀雾的量(如果大于 0,则看不到天空盒)。

    The amount of uniform fog (if greater than 0, the skybox is not visible).

    lightMode: "natural" | "manual"

    用于天空和环境光的照明模式。

    The lighting mode for the sky and ambient light.

    lunarPhase: number

    月球的相位。必须在 0 和 1 之间。

    The phase of the moon. Must be between 0 and 1.

    maxFog: number

    最大雾量。

    The maximum amount of fog.

    rainColor: GameRGBAColor

    雨的颜色。

    The color of the rain.

    rainDensity: number

    雨的密度。

    The density of the rain.

    rainDirection: GameVector3

    雨的方向。

    The direction of the rain.

    rainInterference: number

    雨的干扰量。

    The amount of rain interference.

    rainSizeHi: number

    雨滴的最大尺寸。

    The maximum size of the raindrops.

    rainSizeLo: number

    雨滴的最小尺寸。

    The minimum size of the raindrops.

    rainSpeed: number

    雨的速度。

    The speed of the rain.

    skyBackLight: GameRGBColor

    天空后方(+z 方向)的环境光颜色(仅当 lightMode'manual' 时生效)。

    The ambient light color at the back of the sky (+z direction) (only effective when lightMode is 'manual').

    skyBottomLight: GameRGBColor

    天空底部(-y 方向)的环境光颜色(仅当 lightMode'manual' 时生效)。

    The ambient light color at the bottom of the sky (-y direction) (only effective when lightMode is 'manual').

    skyFrontLight: GameRGBColor

    天空前方(-z 方向)的环境光颜色(仅当 lightMode'manual' 时生效)。

    The ambient light color at the front of the sky (-z direction) (only effective when lightMode is 'manual').

    skyLeftLight: GameRGBColor

    天空左侧(-x 方向)的环境光颜色(仅当 lightMode'manual' 时生效)。

    The ambient light color on the left side of the sky (-x direction) (only effective when lightMode is 'manual').

    skyRightLight: GameRGBColor

    天空右侧(+x 方向)的环境光颜色(仅当 lightMode'manual' 时生效)。

    The ambient light color on the right side of the sky (+x direction) (only effective when lightMode is 'manual').

    skyTopLight: GameRGBColor

    天空顶部(+y 方向)的环境光颜色(仅当 lightMode'manual' 时生效)。

    The ambient light color at the top of the sky (+y direction) (only effective when lightMode is 'manual').

    snowColor: GameRGBAColor

    雪的颜色。

    The color of the snow.

    snowDensity: number

    雪的密度。

    The density of the snow.

    snowFallSpeed: number

    雪的下落速度。

    The speed at which the snow falls.

    snowSizeHi: number

    雪的最大尺寸。

    The maximum size of the snow.

    snowSizeLo: number

    雪的最小尺寸。

    The minimum size of the snow.

    snowSpinSpeed: number

    雪的旋转速度。

    The speed at which the snow rotates.

    snowTexture: string

    雪的纹理。

    The texture of the snow.

    sunDirection: GameVector3

    太阳的方向(仅当 lightMode'manual' 时生效)。

    The direction of the sun (only effective when lightMode is 'manual').

    sunFrequency: number

    太阳在天空中移动的频率。值越高,太阳移动越快。

    The frequency at which the sun moves across the sky. Higher values make the sun move faster.

    sunLight: GameRGBColor

    太阳光的光照颜色(仅当 lightMode'manual' 时生效)。

    The color of the sunlight (only effective when lightMode is 'manual').

    sunPhase: number

    太阳在天空中的初始相位。一天中的时间通过以下公式计算: timeOfDay = (sunPhase + sunFrequency * tick) % 1

    The initial phase of the sun in the sky. The time of day is calculated with the formula: timeOfDay = (sunPhase + sunFrequency * tick) % 1

    Zone

    addZone: (config: Partial<GameZoneConfig>) => GameZone

    Type declaration

    在世界中创建一个新的区域。

    Creates a new zone in the world.

    用于配置新区域的 GameZoneConfig 对象。

    The GameZoneConfig object to configure the new zone.

    新创建的 GameZone 对象。

    The newly created GameZone object.

    removeZone: (trigger: GameZone) => void

    从世界中移除一个区域。

    Removes a zone from the world.

    要移除的 GameZone 对象。

    The GameZone object to remove.

    zones: () => GameZone[]

    Type declaration

    获取世界中所有区域的列表。

    Gets a list of all zones in the world.

    一个包含所有 GameZone 对象的数组。

    An array of all GameZone objects.