Class WorldActivity

Summary

Create an instance of WorldActivity class with a given url slug and optional attributes and session credentials.

This class is responsible for all activity of a specified world including editing dropped assets, moving current visitors, etc.

Usage

await new WorldActivity(topia, "exampleWorld", {
attributes: { name: "Example World" },
credentials: { apiKey: "exampleKey", interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
});

Hierarchy

Constructors

Properties

credentials: undefined | InteractiveCredentials
jwt?: string
requestOptions: object
topia: Topia
urlSlug: string

Accessors

  • get visitors(): {
        [key: string]: Visitor;
    }
  • Returns {
        [key: string]: Visitor;
    }

Methods

  • Summary

    Retrieve all visitors currently in a world.

    Usage

    const visitors = await worldActivity.currentVisitors("exampleLandmarkZoneId", true);
    

    Parameters

    • Optional shouldIncludeAdminPermissions: boolean

    Returns Promise<{
        [key: string]: Visitor;
    }>

  • Parameters

    • __namedParameters: {
          error?: unknown;
          message?: string;
          params?: object;
          sdkMethod?: string;
      }
      • Optional error?: unknown
      • Optional message?: string
      • Optional params?: object
      • Optional sdkMethod?: string

    Returns {
        data: {};
        message: string;
        method: string;
        params: object;
        sdkMethod: undefined | string;
        stack: string;
        stackTrace: Error;
        status: number;
        success: boolean;
        url: string;
    }

    • data: {}
      • message: string
      • method: string
      • params: object
      • sdkMethod: undefined | string
      • stack: string
      • stackTrace: Error
      • status: number
      • success: boolean
      • url: string
    • Summary

      Retrieve all visitors currently in a Landmark Zone.

      Usage

      const visitors = await worldActivity.fetchVisitorsInZone({ droppedAssetId: "exampleDroppedAssetId" });
      

      Parameters

      • __namedParameters: {
            droppedAssetId?: string;
            shouldIncludeAdminPermissions?: boolean;
        }
        • Optional droppedAssetId?: string
        • Optional shouldIncludeAdminPermissions?: boolean

      Returns Promise<{
          [key: string]: Visitor;
      }>

    • Summary

      Move all visitors currently in a world to a single set of coordinates. Optionally refetch visitors, teleport or walk visitors to new location, and scatter visitors by any number so that they don't all move to the exact same location.

      Usage

      await worldActivity.moveAllVisitors({
      shouldFetchVisitors: true,
      shouldTeleportVisitors: true,
      scatterVisitorsBy: 40,
      x: 100,
      y: 100,
      });

      Result

      Updates each Visitor instance and worldActivity.visitors map.

      Parameters

      Returns Promise<undefined | (void | ResponseType)[]>

    • Summary

      Teleport or walk a list of visitors currently in a world to various coordinates.

      Usage

      const visitorsToMove = [
      {
      visitorObj: worldActivity.visitors["1"],
      shouldTeleportVisitor: true,
      x: 100,
      y: 100
      }, {
      visitorObj: worldActivity.visitors["2"],
      shouldTeleportVisitor: false,
      x: 100,
      y: 100
      }
      ];
      await worldActivity.moveVisitors(visitorsToMove);

      Result

      Updates each Visitor instance and worldActivity.visitors map.

      Parameters

      Returns Promise<(void | ResponseType)[]>

    • Returns AxiosInstance