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

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

    Index

    Other

    tick

    互动

    健康

    区域

    声音

    天气

    实体

    搜索

    物理

    玩家

    聊天

    Other

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

    往特定频道增加用户

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

    在世界对象上播放动画

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

    创建临时聊天频道

    currentTick: number

    当前的滴答数 用于记录当前的时间点或事件序列中的位置

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

    销毁临时聊天频道

    getAnimations: () => GameAnimation<GameWorldKeyframe, GameWorld>[]
    getEntityAnimations: () => GameAnimation<GameEntityKeyframe, GameEntity>[]
    getPlayerAnimations: () => GameAnimation<GamePlayerKeyframe, GamePlayer>[]
    getTempChats: () => Promise<string[]>

    读取当前地图存在的临时聊天频道

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

    查询特定频道内用户

    lightMode: "natural" | "manual"

    用于天空和环境光的照明类型

    nextEntityCreate: GameEventFuture<GameEntityEvent>
    nextEntityDestroy: GameEventFuture<GameEntityEvent>
    nextPlayerPurchaseSuccess: GameEventFuture<GamePurchaseSuccessEvent>
    projectName: string

    项目的名称(只读)

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

    往特定频道删减用户

    removeZone: (trigger: GameZone) => void
    searchBox: (bounds: GameBounds3) => GameEntity[]

    搜索包含在边界框内的所有实体

    Type declaration

    serverId: string

    当前服务器id

    sound: (spec: any) => Sound

    在指定位置播放声音

    teleport: TeleportType

    地图组内传送能力,能够令 Player 被传送到其他地图中

    url: URL

    当前运行世界公共 URL

    tick

    每个 tick 调用的事件处理程序

    互动

    健康

    当实体死亡时调用

    当实体受到伤害时调用

    区域

    zones: () => GameZone[]

    区域

    声音

    ambientSound: GameSoundEffect

    背景环境声音,全局播放

    breakVoxelSound: GameSoundEffect

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

    placeVoxelSound: GameSoundEffect

    当方块被放置时播放的声音

    playerJoinSound: GameSoundEffect

    当玩家加入时播放的声音

    playerLeaveSound: GameSoundEffect

    当玩家离开时播放的声音

    天气

    fogColor: GameRGBColor

    雾的颜色

    fogHeightFalloff: number

    高度雾衰减率

    fogHeightOffset: number

    雾开始的高度

    fogStartDistance: number

    雾开始的距离

    fogUniformDensity: number

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

    lunarPhase: number

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

    maxFog: number

    最大雾量

    rainColor: GameRGBAColor

    雨的颜色

    rainDensity: number

    雨的密度

    rainDirection: GameVector3

    雨的方向

    rainInterference: number

    雨的干扰程度

    rainSizeHi: number

    雨的最大尺寸

    rainSizeLo: number

    雨的最小尺寸

    rainSpeed: number

    雨的速度

    skyBackLight: GameRGBColor

    +z 方向的环境光值(仅当 ambientLightMode === 'manual' 时使用)

    skyBottomLight: GameRGBColor

    -y 方向的环境光值(仅当 ambientLightMode === 'manual' 时使用)

    skyFrontLight: GameRGBColor

    -z 方向的环境光值(仅当 ambientLightMode === 'manual' 时使用)

    skyLeftLight: GameRGBColor

    -x 方向的环境光值(仅当 ambientLightMode === 'manual' 时使用)

    skyRightLight: GameRGBColor

    +x 方向的环境光值(仅当 ambientLightMode === 'manual' 时使用)

    skyTopLight: GameRGBColor

    +y 方向的环境光值(仅当 ambientLightMode === 'manual' 时使用)

    snowColor: GameRGBAColor

    雪的颜色

    snowDensity: number

    雪的密度

    snowFallSpeed: number

    雪的下落速度

    snowSizeHi: number

    雪的最大尺寸

    snowSizeLo: number

    雪的最小尺寸

    snowSpinSpeed: number

    雪的旋转速度

    snowTexture: string

    雪的纹理

    sunDirection: GameVector3

    太阳的方向(仅当 ambientLightMode === 'manual' 时使用)

    sunFrequency: number

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

    sunLight: GameRGBColor

    太阳的光照强度(仅当 ambientLightMode === 'manual' 时使用)

    sunPhase: number

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

    实体

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

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

    Type declaration

    entityQuota: () => number

    返回脚本允许创建的剩余实体数量

    当两个实体发生碰撞时调用

    当创建实体时调用

    当两个实体停止碰撞时调用

    当实体进入流体时调用

    当实体离开流体时调用

    当实体接触方块时调用

    当实体停止接触方块时调用

    querySelector: (selector: string) => GameEntity

    可以使用类似于 jQuery 选择器的语法搜索游戏中的实体。 更多示例参见 GameSelectorString

    Type declaration

      • (selector: string): GameEntity
      • Parameters

        • selector: string

          选择器搜索模式

        Returns GameEntity

        匹配选择器的第一个实体

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

    测试实体上的选择器

    Type declaration

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

        • selector: string

          要测试的选择器模式

        • entity: GameEntity

          要测试的实体

        Returns boolean

    搜索

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

    origin 沿 direction 射出一条光线

    Type declaration

    物理

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

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

    Type declaration

      • (aSelector: string, bSelector: string): void
      • Parameters

        • aSelector: string

          第一组实体的选择器

        • bSelector: string

          第二组实体的选择器

        Returns void

    airFriction: number

    空气摩擦力的量

    clearCollisionFilters: () => void

    清除所有碰撞过滤器

    collisionFilters: () => string[][]

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

    Type declaration

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

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

    gravity: number

    引力场的量和方向

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

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

    Type declaration

      • (aSelector: string, bSelector: string): void
      • Parameters

        • aSelector: string

          第一组实体的选择器

        • bSelector: string

          第二组实体的选择器

        Returns void

    useOBB: boolean

    使用 OBB 刚体来解决物理问题

    玩家

    当玩家发言时调用

    当玩家点击对象时调用

    当玩家加入游戏时调用

    当玩家离开游戏时调用

    onPlayerPurchaseSuccess: GameEventChannel<GamePurchaseSuccessEvent>

    当玩家购买产品成功时调用

    当玩家按下按钮时调用

    当玩家释放按钮时调用

    say: (message: string) => void

    广播一条消息给所有玩家

    Type declaration

      • (message: string): void
      • Parameters

        • message: string

          要广播的文本

        Returns void

    聊天

    当销毁实体时调用