@casual-simulation/aux-common
Version:
Common library for AUX projects
1,244 lines • 49.4 kB
TypeScript
import type { Bot, Workspace, AuxDomain, BotShape, BotTags, BotLabelAnchor, DimensionVisualizeMode, PrecalculatedBot, PrecalculatedTags, BotsState, BotSpace, PortalType, BotSubShape, BotOrientationMode, BotAnchorPoint, BotLOD, BotLabelAlignment, BotScaleMode, MeetPortalAnchorPoint, RuntimeBot, BotLabelFontSize, BotLabelWordWrap, MenuBotForm, PortalCameraControlsMode, MenuBotResolvedHoverStyle, PortalCameraType, BotCursorType, BotLabelPadding, SystemPortalPane, MenuBotSubtype, BotMeshPositioningMode, MapPortalKind } from './Bot';
import type { BotCalculationContext } from './BotCalculationContext';
import type { EaseType, Easing, PartialBot } from '../bots';
import type { BotObjectsContext } from './BotObjectsContext';
import { DateTime } from 'luxon';
import { Rotation, Vector2, Vector3 } from '../math';
export declare let isFormulaObjectSymbol: symbol;
export declare let ShortId_Length: number;
/**
* The default energy for actions.
*/
export declare const DEFAULT_ENERGY: number;
export type SimulationIdParseResult = SimulationIdParseFailure | SimulationIdParseSuccess;
export interface SimulationIdParseFailure {
success: false;
}
export interface SimulationIdParseSuccess {
success: true;
channel?: string;
host?: string;
}
export declare const POSSIBLE_DIMENSION_VISUALIZERS: readonly ["*"];
/**
* Defines an interface that represents the difference between
* to BotsState objects.
*/
export interface BotsStateDiff {
addedBots: Bot[];
removedBots: string[];
updatedBots: Bot[];
}
/**
* Determines whether the given tag value is a valid value or if
* it represents nothing.
* @param value The value.
*/
export declare function hasValue(value: unknown): value is string | number | boolean | object;
/**
* Converts the given value to a string.
* @param value The value that should be rendered into a string.
* @returns
*/
export declare function convertToString(value: any): string;
/**
* Cleans the bot by removing any null or undefined properties.
* @param bot The bot to clean.
*/
export declare function cleanBot(bot: Bot): Bot;
/**
* Determines if the given workspace is currently minimized.
* @param workspace The workspace.
*/
export declare function isMinimized(calc: BotCalculationContext, workspace: Workspace): boolean;
/**
* Determines if the given bot contains data for a dimension.
*/
export declare function isDimension(calc: BotCalculationContext, dimensionBot: Bot): boolean;
/**
* Determines if the given dimension bot is being visualized in the viewport.
*/
export declare function isVisibleDimension(calc: BotCalculationContext, dimensionBot: Bot): boolean;
/**
* Filters the given list of bots by whether they belong to the given selection.
* @param bots The bots to filter.
* @param selectionId The selection to check.
*/
export declare function filterBotsBySelection<TBot extends Bot>(bots: TBot[], selectionId: string): TBot[];
/**
* Gets whether the bot is pointable.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function isBotPointable(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets whether the bot is focusable.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function isBotFocusable(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets a list of tags that the given bots contain.
*
* @param bots The array of bots that the list of tags should be retrieved
* for.
* @param currentTags The current array of tags that is being displayed.
* The new list will try to preserve the order of the tags
* in this list.
* @param extraTags The list of tags that should not be removed from the
* output list.
* @param allowedTags The list of tags that should be allowed in the output list.
*/
export declare function botTags(bots: Bot[], currentTags: string[], extraTags: string[], allowedTags?: string[]): {
tag: string;
space: string;
}[];
export declare function getAllBotTags(bots: Bot[], includeHidden: boolean): string[];
/**
* Find bots that match the short ids.
* @param bots The bots to search through.
* @param shortIds The short ids to search for.
* @returns bot array or null if no matches found.
*/
export declare function botsFromShortIds(bots: Bot[], shortIds: string[]): Bot[];
/**
* Find bot that matches the short id.
* @param bots The bots to search through.
* @param shortId The short id to search for.
* @returns bot or undefined if no match found.
*/
export declare function botFromShortId(bots: Bot[], shortId: string): Bot;
/**
* Return the short id for the bot.
* @param bot The bot to get short id for.
*/
export declare function getShortId(bot: Bot | string): string;
/**
* Determines if the given tag is a hidden tag.
* @param tag The tag to test.
*/
export declare function isHiddenTag(tag: string): boolean;
/**
* Determines if the given bot is a runtime bot.
* @param bot The bot to check.
*/
export declare function isRuntimeBot(bot: any): bot is RuntimeBot;
export declare function isPrecalculated(bot: Bot | PrecalculatedBot): bot is PrecalculatedBot;
export declare function isExistingBot(bot: Bot | PrecalculatedBot): bot is Bot;
/**
* Gets the space that the given bot lives in.
* @param bot The bot.
*/
export declare function getBotSpace(bot: Bot): BotSpace;
export declare function calculateBotValue(context: BotObjectsContext | null, object: Bot | PrecalculatedBot, tag: keyof BotTags): any;
export declare function calculateRawBotValue(context: BotObjectsContext | null, object: Bot | PrecalculatedBot, tag: keyof BotTags): any;
/**
* Calculates the list of bot IDs that are stored in the given tag in the given bot.
* @param bot The bot.
* @param tag The tag.
*/
export declare function calculateBotIds(object: Bot | PrecalculatedBot, tag: keyof BotTags): string[];
export declare function calculateFormattedBotValue(context: BotCalculationContext, bot: Bot, tag: string): string;
/**
* Determines if the given value represents a formula.
*/
export declare function isFormula(value: unknown): value is string;
/**
* Determines if the given value represents a script.
* @param value The value.
*/
export declare function isScript(value: unknown): value is string;
/**
* Determines if the given value represents a script.
* @param value The value.
*/
export declare function isModule(value: unknown): value is string;
/**
* Determiens if the given value represents a bot link.
* @param value The value.
*/
export declare function isBotLink(value: unknown): value is string;
/**
* Parses the given value into a list of Bot IDs if it is a link.
* Returns null if the value is not a bot link.
* @param value The value to parse.
*/
export declare function parseBotLink(value: unknown): string[];
/**
* Creates a bot link that links to the given bot IDs.
* @param botIds The IDs of the bots to link to.
*/
export declare function createBotLink(botIds: string[]): string;
/**
* Determines if the given value represents a date time.
* @param value The value.
*/
export declare function isBotDate(value: unknown): value is string;
/**
* Parses the given value into a date time object.
* Returns null if the value is not a date.
* @param value The value to parse.
*/
export declare function parseBotDate(value: unknown): DateTime;
/**
* Formats the given value into a parseable string.
* @param value The date to format.
*/
export declare function formatBotDate(value: DateTime): string;
/**
* Parses the given value into a script.
* Returns the script if the value is a script.
* Returns null if the value is not a script.
* @param value The value to parse.
*/
export declare function parseScript(value: unknown): string | null;
/**
* Parses the given value into a script.
* Returns the script if the value is a script.
* Returns the value if it is not a script.
* @param value The value to parse.
*/
export declare function parseScriptSafe(value: string): string;
/**
* Parses the given value into a module script.
* Returns the module script if the value is a module.
* Returns null if the value is not a module.
* @param value The value to parse.
*/
export declare function parseModule(value: unknown): string | null;
/**
* Parses the given value into a script.
* Returns the script if the value is a script.
* Returns the value if it is not a script.
* @param value The value to parse.
*/
export declare function parseModuleSafe(value: string): string;
/**
* Parses the given value into a formula.
* Returns the formula if the value is a formula.
* Returns null if the value is not a formula.
* @param value The value to parse.
*/
export declare function parseFormula(value: string): string | null;
/**
* Parses the given value into a formula.
* Returns the JSON if the value is a formula.
* Returns the value if it is not a formula.
* @param value The value to parse.
*/
export declare function parseFormulaSafe(value: string): string;
/**
* Trims the leading script symbol off the given tag.
*/
export declare function trimPortalScript(scriptPrefixes: string[], tag: string): string;
/**
* Trims the leading script symbol off the given tag.
*/
export declare function trimPrefixedScript(prefix: string, tag: string): string;
/**
* Determines if the given value is for a script entrypoint.
* @param prefix The prefix to check against.
* @param value The value to check.
*/
export declare function isPortalScript(prefix: string, value: unknown): boolean;
export declare function hasPortalScript(prefixes: string[], value: unknown): boolean;
/**
* Determines which of the given script prefixes the given value matches.
* @param prefixes The script prefixes to test against the value.
* @param value The value to test.
* @returns
*/
export declare function getScriptPrefix(prefixes: string[], value: unknown): string;
/**
* Determines if the given value represents a number.
*/
export declare function isNumber(value: string): boolean;
/**
* Determines if the given value is a string that is tagged with the 📝 emoji.
* @param value The value to check.
*/
export declare function isTaggedString(value: unknown): value is string;
/**
* Parses the given tagged string into a regular string value.
* @param value The value that should be parsed as a string.
*/
export declare function parseTaggedString(value: string): string;
/**
* Determines if the given value starts with the 🔢 emoji tag.
* @param value The value to test.
*/
export declare function isTaggedNumber(value: string): boolean;
/**
* Parses the given tagged number into a regular number value.
* @param value The value to parse.
*/
export declare function parseTaggedNumber(value: string): string;
/**
* Parses the given value into a number.
* @param value The value to parse.
*/
export declare function parseNumber(value: string): number;
/**
* Determines if the given value is a valid real number and returns it if it is.
* If it is not, then the given default value will be returned.
* @param value The value to check for real-ness. All numerical values are considered real except NaN, and +/- Infinity.
* @param defaultIfInvalid The default value to return if the value is not real.
*/
export declare function realNumberOrDefault(value: unknown, defaultIfInvalid: number): number;
/**
* Formats the given value into a parseable vector string.
* @param vector The vector to format.
*/
export declare function formatBotVector(vector: {
x: number;
y: number;
z?: number;
}): string;
/**
* Determines if the given value represents a bot vector value.
* @param value The value to check.
*/
export declare function isBotVector(value: unknown): value is string;
/**
* Parses the given value into a Vector2 or Vector3 value.
* @param value The value to parse as a bot vector.
*/
export declare function parseBotVector(value: unknown): Vector2 | Vector3 | null;
/**
* Formats the given value into a parseable rotation string.
* @param vector The vector to format.
*/
export declare function formatBotRotation(rotation: Rotation | {
x: number;
y: number;
z: number;
w: number;
}): string;
/**
* Determines if the given value represents a bot rotation.
* @param value The value to check.
*/
export declare function isBotRotation(value: unknown): value is string;
/**
* Parses the given value into a Rotation value.
* @param value The value to parse as a bot vector.
*/
export declare function parseBotRotation(value: unknown): Rotation | null;
/**
* Determines if the given object is a bot.
* @param object The object to check.
*/
export declare function isBot(object: any): object is Bot;
/**
* Gets the array of objects in the given state that are currently active.
* @param state The state to get the active objects of.
*/
export declare function getActiveObjects(state: BotsState): Bot[];
/**
* Determines if the given tag is "well known".
* @param tag The tag.
*/
export declare function isTagWellKnown(tag: string): boolean;
/**
* Determines if the bots are equal disregarding well-known hidden tags
* and their IDs. Bot "appearance equality" means instead of asking "are these bots exactly the same?"
* we ask "are these bots functionally the same?". In this respect we care about things like color, label, etc.
* We also care about things like draggable but not _position, _index _selection, etc.
*
* You can determine if a tag is "well-known" by using isTagWellKnown().
* @param first The first bot.
* @param second The second bot.
*/
export declare function doBotsAppearEqual(first: Bot, second: Bot, options?: BotAppearanceEqualityOptions): boolean;
export interface BotAppearanceEqualityOptions {
ignoreId?: boolean;
}
/**
* Defines an interface that represents the result of validating a tag.
*/
export interface TagValidation {
valid: boolean;
'tag.required'?: TagRequired;
'tag.invalidChar'?: TagInvalidChar;
}
export interface TagRequired {
}
export interface TagInvalidChar {
char: string;
}
/**
* Validates the given tag and returns any errors for it.
* @param tag The tag.
*/
export declare function validateTag(tag: string): TagValidation;
/**
* Gets a partial bot that toggles whether the given bot is apart of the given selection.
* @param bot The bot.
* @param selectionId The ID of the selection.
* @param userId The User that is adding the bot to the selection.
*/
export declare function toggleBotSelection(bot: Bot, selectionId: string, userId: string): {
tags: {
[selectionId]: boolean;
};
};
/**
* Gets the color that the given user bot should appear as.
* @param calc The bot calculation context.
* @param userBot The user bot.
* @param globalsBot The globals bot.
* @param domain The domain.
*/
export declare function getUserBotColor(calc: BotCalculationContext, userBot: Bot, domain: AuxDomain): string;
/**
* Gets the menu ID that is used for the given user.
* @param userBot The bot for the user.
*/
export declare function getUserMenuId(calc: BotCalculationContext, userBot: Bot): any;
/**
* Gets the list of bots that are in the user's menu.
* @param calc The bot calculation context.
* @param userBot The user bot to use.
*/
export declare function getBotsInMenu(calc: BotCalculationContext, userBot: Bot): Bot[];
/**
* Gets the list of bots that are in the given dimension.
* @param calc The bot calculation context.
* @param dimension The dimension to search for bots in.
*/
export declare function botsInDimension(calc: BotCalculationContext, dimension: string): Bot[];
/**
* Gets a diff that adds a bot to the given dimension.
* If the bot is already in the dimension, then nothing happens.
* If other bots are already at the given position, then the bot will be placed at the topmost index.
* @param calc The bot calculation context.
* @param dimension The dimension that the bot should be added to.
* @param x The x position that the bot should be placed at.
* @param y The x position in the dimension that the bot should be placed at.
* @param index The index that the bot should be placed at.
*/
export declare function addToDimensionDiff(calc: BotCalculationContext, dimension: string, x?: number, y?: number, index?: number): BotTags;
/**
* Gets a diff that removes a bot from the given dimension.
* @param calc The bot calculation context.
* @param dimension The dimension that the bot should be removed from.
*/
export declare function removeFromDimensionDiff(calc: BotCalculationContext, dimension: string): BotTags;
/**
* Gets a diff that sets a bot's position in the given dimension.
* @param calc The bot calculation context.
* @param dimension The dimension.
* @param x The X position.
* @param y The Y position.
* @param index The index.
*/
export declare function setPositionDiff(calc: BotCalculationContext, dimension: string, x?: number, y?: number, index?: number): BotTags;
/**
* Gets the bot update needed to add the given bot to the given user's menu.
* @param calc The calculation context.
* @param userBot The bot of the user.
* @param id The ID that should be used for the menu item. This is separate from bot ID.
* @param index The index that the bot should be added to. Positive infinity means add at the end. 0 means add at the beginning.
*/
export declare function addBotToMenu(calc: BotCalculationContext, userBot: Bot, id: string, index?: number): PartialBot;
/**
* Gets the bot update needed to remove a bot from the given user's menu.
* @param calc The bot calculation context.
* @param userBot The bot of the user.
*/
export declare function removeBotFromMenu(calc: BotCalculationContext, userBot: Bot): PartialBot;
/**
* Gets the list of tags that are on the given bot.
* @param bot
*/
export declare function tagsOnBot(bot: PartialBot): string[];
/**
* Gets the specified tag value from the specified bot.
* @param bot The bot that the tag should be retrieved from.
* @param tag The tag to retrieve.
*/
export declare function getTag(bot: PartialBot, tag: string): any;
/**
* Gets the specified tag from the specified bot.
* @param bot The bot that the tag should be retrieved from.
* @param tag The tag to retrieve.
*/
export declare function getBotTag(bot: Bot, tag: string): any;
/**
* Creates a new codimensionntext ID.
*/
export declare function createDimensionId(): string;
/**
* Creates a bot with a new ID and the given tags.
* @param id The ID of the bot.
* @param tags The tags to use in the bot.
* @param space The space of the bot.
*/
export declare function createBot(id?: string, tags?: Bot['tags'], space?: BotSpace): Bot;
export declare function createPrecalculatedBot(id?: string, values?: PrecalculatedTags, tags?: Bot['tags'], space?: BotSpace): PrecalculatedBot;
/**
* Calculates the grid scale for the given workspace.
* @param workspace
*/
export declare function calculateGridScale(calc: BotCalculationContext, workspace: Bot, defaultSurfaceScale?: number, defaultGridScale?: number): number;
/**
* Calculates the grid scale from the given constants.
* @param surfaceScale
* @param gridScale
*/
export declare function calculateGridScaleFromConstants(surfaceScale: number, gridScale: number): number;
/**
* Calculates the difference between the two given states.
* In particular, it calculates which operations need to be performed on prev in order to get current.
* The returned object contains the bots that were added, removed, and/or updated between the two states.
* This operation runs in O(n) time where n is the number of bots.
* @param prev The previous state.
* @param current The current state.
*/
export declare function calculateStateDiff(prev: BotsState, current: BotsState): BotsStateDiff;
/**
* Trims the leading # symbol off the given tag.
*/
export declare function trimTag(tag: string): string;
/**
* Trims the leading # symbol and trailing () symbols from the given tag.
* @param tag The tag.
*/
export declare function trimEvent(tag: string): string;
/**
* Gets a list of strings from the given bot and tag.
* @param calc The bot calculation context.
* @param bot The bot.
* @param tag The tag.
*/
export declare function getBotStringList(calc: BotCalculationContext, bot: Bot, tag: string): string[];
/**
* Gets the AUX_BOT_VERSION number that the given bot was created with.
* If not specified, then undefined is returned.
* @param calc The bot calculation context.
* @param bot THe bot.
*/
export declare function getBotVersion(calc: BotCalculationContext, bot: Bot): number;
/**
* Gets the index that the given bot is at in the given dimension.
* @param calc The calculation context to use.
* @param bot The bot.
* @param dimension The dimension.
*/
export declare function getBotIndex(calc: BotCalculationContext, bot: Bot, dimension: string): number;
/**
* Gets the position value from the given bot and tag.
* @param bot The bot.
* @param tag The tag.
*/
export declare function getTagPosition(bot: Bot, tag: string, defaultValue?: number): {
x: number;
y: number;
z: number;
};
/**
* Gets the rotation value from the given bot and tag.
* @param bot The bot.
* @param tag The tag.
*/
export declare function getTagRotation(bot: Bot, tag: string): Rotation;
/**
* Gets the position that the given bot is at in the given dimension.
* @param calc The calculation context to use.
* @param bot The bot.
* @param dimension The dimension.
*/
export declare function getBotPosition(calc: BotCalculationContext, bot: Bot, dimension: string): {
x: number;
y: number;
z: number;
};
/**
* Gets the rotation that the given bot is at in the given dimension.
* @param calc The calculation context to use.
* @param bot The bot.
* @param dimension The dimension.
*/
export declare function getBotRotation(calc: BotCalculationContext, bot: Bot, dimension: string): Rotation;
/**
* Calculates the auxScaleX, auxScaleY, and auxScaleZ values from the given object.
* @param context The calculation context.
* @param obj The object.
* @param multiplier The value that scale values should be multiplied by.
* @param defaultScale The default value.
* @param prefix The optional prefix for the tags. Defaults to `aux.`
*/
export declare function getBotScale(context: BotCalculationContext, obj: Bot, defaultScale?: number, prefix?: string): {
x: number;
y: number;
z: number;
};
/**
* Gets the shape of the bot.
* @param calc The calculation context to use.
* @param bot The bot.
*/
export declare function getBotShape(calc: BotCalculationContext, bot: Bot): BotShape;
export declare function getDefaultEasing(easing: Easing | EaseType | ((progress: number) => number)): Easing;
export declare function getEasing(easing: Easing | EaseType | ((progress: number) => number)): any;
export declare function getTweenEasing(easing: Easing): any;
/**
* Gets the form of a menu bot.
* @param calc The calculation context to use.
* @param bot The bot.
*/
export declare function getMenuBotForm(calc: BotCalculationContext, bot: Bot): MenuBotForm;
/**
* Gets the formSubType of menu bot.
* @param calc The calculation context to use.
* @param bot The bot.
* @returns
*/
export declare function getMenuBotSubtype(calc: BotCalculationContext, bot: Bot): MenuBotSubtype;
/**
* Gets the form of a menu bot.
* @param calc The calculation context to use.
* @param bot The bot.
*/
export declare function getMenuBotHoverStyle(calc: BotCalculationContext, bot: Bot): MenuBotResolvedHoverStyle;
/**
* Gets the sub-shape of the bot.
* @param calc The calculation context to use.
* @param bot The bot.
*/
export declare function getBotSubShape(calc: BotCalculationContext, bot: Bot): BotSubShape;
/**
* Gets the anchor position for the bot's label.
* @param calc The calculation context to use.
* @param bot The bot.
*/
export declare function getBotLabelAnchor(calc: BotCalculationContext, bot: Bot): BotLabelAnchor;
export declare function getBotTagAnchor(calc: BotCalculationContext, bot: Bot, tag: string): BotLabelAnchor;
/**
* Determines whether the given anchor is a floating anchor.
* @param anchor The anchor to check.
*/
export declare function isFloatingAnchor(anchor: BotLabelAnchor): anchor is "floating" | "floatingBillboard";
/**
* Gets the text alignment for the bot's label.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotLabelAlignment(calc: BotCalculationContext, bot: Bot): BotLabelAlignment;
/**
* Gets the amount of padding that should be used to auto-sized labels.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotLabelPadding(calc: BotCalculationContext, bot: Bot): BotLabelPadding;
/**
* Gets the scale mode for the bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotScaleMode(calc: BotCalculationContext, bot: Bot): BotScaleMode;
/**
* Gets the mesh positioning mode for the bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotMeshPositioningMode(calc: BotCalculationContext, bot: Bot): BotMeshPositioningMode;
/**
* Gets the orientation mode for the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotOrientationMode(calc: BotCalculationContext, bot: Bot): BotOrientationMode;
/**
* Gets the anchor point for the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotAnchorPoint(calc: BotCalculationContext, bot: Bot): BotAnchorPoint;
/**
* Ensures that the given bot anchor point value is valid by converting the given value to a valid anchor point value.
* @param value The value.
*/
export declare function calculateAnchorPoint(value: BotAnchorPoint): "top" | "front" | "back" | "left" | "right" | "center" | "bottom" | readonly [number, number, number];
export declare function getMapPortalKind(bot: Bot): MapPortalKind;
export declare function calculateMapPortalKind(value: string): MapPortalKind | null;
/**
* Calculates the 3D offset of the anchor point.
* @param point The anchor point.
*/
export declare function calculateAnchorPointOffset(point: BotAnchorPoint): {
x: number;
y: number;
z: number;
};
/**
* Gets the anchor point offset for the bot in AUX coordinates.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getAnchorPointOffset(calc: BotCalculationContext, bot: Bot): {
x: number;
y: number;
z: number;
};
export declare function getPortalAnchorPoint(calc: BotCalculationContext, bot: Bot, tag: string, defaultValue: MeetPortalAnchorPoint): MeetPortalAnchorPoint;
/**
* Gets the meet portal anchor point for the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotMeetPortalAnchorPoint(calc: BotCalculationContext, bot: Bot): MeetPortalAnchorPoint;
/**
* Gets the tag portal anchor point for the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotTagPortalAnchorPoint(calc: BotCalculationContext, bot: Bot): MeetPortalAnchorPoint;
/**
* Gets the bot portal anchor point for the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotPortalAnchorPoint(calc: BotCalculationContext, bot: Bot): MeetPortalAnchorPoint;
/**
* Gets the system portal pane that is currently set on the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getSystemPortalPane(calc: BotCalculationContext, bot: Bot): SystemPortalPane;
/**
* Gets the system portal pane that is currently open.
* Returns null if the system portal is not open.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getOpenSystemPortalPane(calc: BotCalculationContext, bot: Bot): SystemPortalPane;
/**
* Gets the camera type for the given portal bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getCameraType(calc: BotCalculationContext, bot: Bot): PortalCameraType;
/**
* Gets the anchor point offset for the bot in AUX coordinates.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotMeetPortalAnchorPointOffset(calc: BotCalculationContext, bot: Bot): {
top?: string;
right?: string;
bottom?: string;
left?: string;
height?: string;
width?: string;
'min-height'?: string;
'min-width'?: string;
};
/**
* Gets the CSS that should be used for the given cursor value.
* @param cursor The cursor.
*/
export declare function getCursorCSS(cursor: BotCursorType): string;
/**
* Gets the cursor that has been configured on the given bot.
* Returns null if the bot does not have a valid string value.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotCursor(calc: BotCalculationContext, bot: Bot): BotCursorType;
/**
* Gets the cursor that has been configured as the portal cursor for the given bot.
* Returns null if the bot does not have a valid string value.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getPortalCursor(calc: BotCalculationContext, bot: Bot): BotCursorType;
/**
* Gets the anchor point offset for the bot in AUX coordinates.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getBotTagPortalAnchorPointOffset(calc: BotCalculationContext, bot: Bot): {
top?: string;
right?: string;
bottom?: string;
left?: string;
height?: string;
width?: string;
'min-height'?: string;
'min-width'?: string;
};
/**
* Calculates the CSS style for the given meet portal anchor point.
*/
export declare function calculateMeetPortalAnchorPointOffset(anchorPoint: MeetPortalAnchorPoint): {
top?: string;
right?: string;
bottom?: string;
left?: string;
height?: string;
width?: string;
'min-height'?: string;
'min-width'?: string;
};
/**
* Gets whether the bot has a tag to enable LODs.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function botHasLOD(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Calcualtes the LOD that a bot should be in based on the virtual distance, minimum threshold, and maximum threshold.
* @param virtualDistance The percentage of the screen that the bot takes up.
* @param minThreshold The minimum LOD threshold.
* @param maxThreshold The maximum LOD threshold.
*/
export declare function calculateBotLOD(virtualDistance: number, minThreshold: number, maxThreshold: number): BotLOD;
/**
* Calculates the portal camera controls mode that the given bot has set.
* @param calc The calculation context.
* @param bot The portal config bot.
*/
export declare function calculatePortalCameraControlsMode(calc: BotCalculationContext, bot: Bot): PortalCameraControlsMode;
/**
* Calculates the label font size that the given bot has set.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function calculateLabelFontSize(calc: BotCalculationContext, bot: Bot): BotLabelFontSize;
/**
* Calculates the label word wrapping mode that the given bot has set.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function calculateLabelWordWrapMode(calc: BotCalculationContext, bot: Bot): BotLabelWordWrap;
/**
* Determines if the given bot is a config bot for the given dimension.
* @param calc The calculation context.
* @param bot The bot to check.
* @param dimension The dimension to check if the bot is the config of.
*/
export declare function isConfigForContext(calc: BotCalculationContext, bot: Bot, dimension: string): boolean;
/**
* Gets whether the dimension(s) that the given bot represents are locked.
* Uses at the auxPortalLocked tag to determine whether it is locked.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function isDimensionLocked(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets the list of contexts that the given bot is a config bot for.
* @param calc The calculation context.
* @param bot The bot that represents the dimension.
*/
export declare function getBotConfigDimensions(calc: BotCalculationContext, bot: Bot): string[];
/**
* Parses a list of dimension names from the given value.
* @param value The value to parse.
*/
export declare function parseBotConfigDimensions(value: any): string[];
/**
* Calculates the dimensions that are stored on the given bot and portal tag.
* @param bot The Bot.
* @param tag The portal tag.
* @returns
*/
export declare function calculateDimensions(bot: Bot, tag: string): string[];
/**
* Gets a value from the given dimension bot.
* @param calc The calculation context.
* @param dimensionBot The bot that represents the dimension.
* @param name The name of the value to get.
*/
export declare function getDimensionValue(calc: BotCalculationContext, dimensionBot: Bot, name: string): any;
/**
* Gets the ID of the bot that the given bot should be transformed by.
* @param calc The bot calculation context.
* @param bot The bot to check.
*/
export declare function getBotTransformer(calc: BotCalculationContext, bot: Bot): string;
/**
* Gets whether the given bot is movable.
* @param calc The calculation context.
* @param bot The bot to check.
*/
export declare function isBotMovable(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets whether the given bot is listening for shouts or whispers.
* @param calc The calculation context.
* @param bot The bot to check.
*/
export declare function isBotListening(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets whether the given bot's dimension is movable.
* @param calc The calculation context.
* @param bot The bot to check.
*/
export declare function isDimensionMovable(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets the position that the dimension should be at using the given bot.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionPosition(calc: BotCalculationContext, bot: Bot): {
x: number;
y: number;
z: number;
};
/**
* Gets the rotation that the dimension should be at using the given bot.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionRotation(calc: BotCalculationContext, bot: Bot): {
x: number;
y: number;
z: number;
};
/**
* Gets whether the dimension is minimized.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionMinimized(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets the color of the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionColor(calc: BotCalculationContext, bot: Bot): string;
/**
* Gets the size of the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionSize(calc: BotCalculationContext, bot: Bot): number;
/**
* Gets the auxDimensionVisualize mode from the given bot.
* @param calc The calculation context.
* @param bot The bot.
*/
export declare function getDimensionVisualizeMode(calc: BotCalculationContext, bot: Bot): DimensionVisualizeMode;
/**
* Gets the grid of the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getBuilderDimensionGrid(calc: BotCalculationContext, bot: Bot): {
[key: string]: number;
};
/**
* Gets the height of the specified grid on the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
* @param key The key for the grid position to lookup in the dimension grid.
*/
export declare function getDimensionGridHeight(calc: BotCalculationContext, bot: Bot, key: string): number;
/**
* Gets the grid scale of the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionGridScale(calc: BotCalculationContext, bot: Bot): number;
/**
* Gets the scale of the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionScale(calc: BotCalculationContext, bot: Bot): number;
/**
* Gets the default height of the dimension.
* @param calc The calculation context to use.
* @param bot The bot that represents the dimension.
*/
export declare function getDimensionDefaultHeight(calc: BotCalculationContext, bot: Bot): number;
/**
* Filters the given list of objects to those matching the given workspace ID and grid position.
* The returned list is in the order of their indexes.
* @param calc The bot calculation context to use.
* @param dimension The ID of the dimension that the objects need to be on.
* @param position The position that the objects need to be at.
*/
export declare function objectsAtDimensionGridPosition(calc: BotCalculationContext, dimension: string, position: {
x: number;
y: number;
}): Bot[];
/**
* Calculates whether the given bot should be stacked onto another bot or if
* it should be combined with another bot.
* @param calc The bot calculation context.
* @param dimension The dimension.
* @param gridPosition The grid position that the bot is being dragged to.
* @param bot The bot that is being dragged.
*/
export declare function getDropBotFromGridPosition(calc: BotCalculationContext, dimension: string, gridPosition: {
x: number;
y: number;
}, ...bots: (Bot | BotTags)[]): {
other: Bot;
};
/**
* Filters the given list of objects to those that are assigned to the given workspace ID.
* @param objects The objects to filter.
* @param workspaceId The ID of the workspace that the objects need to be on,
*/
export declare function objectsAtWorkspace(objects: Bot[], workspaceId: string): Bot[];
/**
* Duplicates the given bot and returns a new bot with a new ID but the same tags.
* The bot will be exactly the same as the previous except for 3 things.
* First, it will have a different ID.
* Second, it will never be marked as destroyed.
* Third, it will not have any well known tags. (see isTagWellKnown())
* @param calc The bot calculation context.
* @param bot The bot to duplicate.
* @param data The optional data that should override the existing bot data.
*/
export declare function duplicateBot(calc: BotCalculationContext, bot: Bot, data?: PartialBot): Bot;
/**
* Filters the given list of tags by whether they are well known or used in a dimension.
* @param calc The bot calculation context.
* @param tags The list of tags to filter.
*/
export declare function filterWellKnownAndDimensionTags(calc: BotCalculationContext, tags: string[]): string[];
/**
* Gets the list of contexts that the given calculation dimension contains.
* @param calc The bot calculation context.
*/
export declare function getDimensions(calc: BotCalculationContext): string[];
/**
* Determines if the given tag is well known or in one of the given dimensions.
* @param tag The tag to check.
* @param dimensions The dimensions to check the tag against.
*/
export declare function isWellKnownOrDimension(tag: string, dimensions: string[]): any;
/**
* Determines if the given value is some bot tags.
* @param value The value to test.
*/
export declare function isBotTags(value: any): value is BotTags;
export declare function simulationIdToString(id: SimulationIdParseSuccess): string;
export declare function parseSimulationId(id: string): SimulationIdParseSuccess;
/**
* Normalizes the given URL so that it will load the AUX bot instead of the web application.
* @param url The URL.
*/
export declare function normalizeAUXBotURL(url: string): string;
/**
* Calculates the value of the given tag on the given bot. If the result is not a bot, then the given default value
* is returned.
* @param context The context.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use if the tag doesn't exist or the result is not a bot.
*/
export declare function calculateBotValueAsBot(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: Bot): Bot;
/**
* Calculates the value of the given tag on the given bot as a list of strings.
* @param context The calculation context.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value.
*/
export declare function calculateStringListTagValue(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: string[]): string[];
/**
* Calculates the value of the given tag on the given bot. If the result is not a number, then the given default value
* is returned.
* @param context The calculation context.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use if the tag doesn't exist or the result is not a number.
*/
export declare function calculateNumericalTagValue(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: number): number;
/**
* Calculates the value of the given tag on the given bot. If the result is not a boolean, then the given default value is returned.
* @param context The context.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use.
*/
export declare function calculateBooleanTagValue(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: boolean): boolean;
/**
* Calculates the value of the given tag on the given bot. If the result is not a stirng, then the given default value is returned.
* @param context THe context.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use.
*/
export declare function calculateStringTagValue(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: string): string;
/**
* Calcualtes the given of the given tag on the given bot as a bot ID.
* @param context The context.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use.
*/
export declare function calculateBotIdTagValue(bot: Bot, tag: string, defaultValue: string): string;
/**
* Calculates the value of the given tag on the given bot as a vector.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use.
*/
export declare function calculateBotVectorTagValue(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: Vector2 | Vector3): Vector2 | Vector3;
/**
* Calculates the value of the given tag on the given bot as a rotation.
* @param bot The bot.
* @param tag The tag.
* @param defaultValue The default value to use.
*/
export declare function calculateBotRotationTagValue(context: BotCalculationContext, bot: Bot, tag: string, defaultValue: Rotation): Rotation;
/**
* Determines if the given bot is able to be destroyed.
* Defaults to true.
* @param calc The bot calculation context.
* @param bot The bot to check.
*/
export declare function isDestroyable(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Determines if the given bot is able to be edited by the bot sheet.
* Defaults to true.
* @param calc The bot calculation context.
* @param bot The bot to check.
*/
export declare function isEditable(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Determines if the given bot is trying to load a simulation.
* @param calc The calculation context.
* @param bot The bot to check.
*/
export declare function isSimulation(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Gets the server tag from the given bot.
* @param calc The bot calculation context to use.
* @param bot The bot.
*/
export declare function getBotChannel(calc: BotCalculationContext, bot: Bot): string;
/**
* Gets the first bot which is in the aux.channels dimension that has the server tag set to the given ID.
* @param calc The bot calculation context.
* @param id The ID to search for.
*/
export declare function getChannelBotById(calc: BotCalculationContext, id: string): Bot;
/**
* Returns wether or not the given bot resides in the given dimension id.
* @param context The bot calculation context to run formulas with.
* @param bot The bot.
* @param dimensionId The id of the dimension that we are asking if the bot is in.
*/
export declare function isBotInDimension(context: BotCalculationContext, bot: Bot, dimensionId: string): boolean;
/**
* Gets the tag that is used to set the dimension for the given portal type.
* @param portal The portal type.
*/
export declare function getPortalTag(portal: PortalType): string;
/**
* Gets the ID of the bot that should be used to configure the given portal.
* @param context The context.
* @param bot The bot that is defining the portal.
* @param portal The portal.
*/
export declare function getPortalConfigBotID(context: BotCalculationContext, bot: Bot, portal: PortalType): string;
/**
* Gets the theme that is set on the given bot.
* @param context The context.
* @param bot The bot.
*/
export declare function getBotTheme(context: BotCalculationContext, bot: Bot): 'auto' | 'light' | 'dark';
/**
* Gets the sort order that the given bot should appear in the given dimension.
* @param context The bot calculation context.
* @param bot The bot.
* @param dimensionId The ID of the dimension that we're getting the sort order for.
*/
export declare function botDimensionSortOrder(context: BotCalculationContext, bot: Bot, dimensionId: string): number | string;
export declare function isUserActive(calc: BotCalculationContext, bot: Bot): boolean;
/**
* Formats the given value and returns a string representing it.
* @param value The value to format.
*/
export declare function formatValue(value: any): string;
/**
* Calculates the value of the given formula as if it was on the given bot (object) and tag.
* @param object The bot that the formula was from.
* @param tag The tag that the formula was from.
* @param formula The formula.
*/
export declare function calculateValue(object: Bot, tag: keyof BotTags, formula: string): any;
/**
* Defines a symbol for a property that contains the original object that
* a value was transformed from.
*/
export declare const ORIGINAL_OBJECT: unique symbol;
/**
* Gets the original object that the given object was constructed from.
* Returns the object if there is no original object.
* @param obj The object.
*/
export declare function getOriginalObject(obj: any): any;
export declare function getMaskSpaces(bot: Bot): string[];
/**
* Gets the list of spaces that the given tag mask exists in.
* @param bot The bot.
* @param tag The tag.
*/
export declare function getTagMaskSpaces(bot: Bot, tag: string): string[];
/**
* Gets the list of tags that are tag masks on the given bot.
* @param bot The bot.
*/
export declare function tagMasksOnBot(bot: Bot): string[];
/**
* Gets the value of the given tag mask in the given space.
* @param bot The bot.
* @param space The space that the tag mask is in.
* @param tag The tag.
*/
export declare function getTagMask(bot: Bot, space: string, tag: string): any;
/**
* Determines whether the given bot has a tag or mask for the given tag.
* @param bot The bot.
* @param tag The tag.
*/
export declare function hasTagOrMask(bot: Bot, tag: string): boolean;
/**
* Determines if the given bot has a mask for the given tag.
* @param bot The bot.
* @param tag The tag.
*/
export declare function hasMaskForTag(bot: Bot, tag: string): boolean;
/**
* Gets the tag value for the given space.
* If the space is null, then the tag value is retrieved from the tags.
* If the space is specified, then the tag value is retrieved from the corresponding tag masks.
* @param bot The bot.
* @param tag The tag.
* @param space The space.
*/
export declare function getTagValueForSpace(bot: Bot, tag: string, space: string): any;
/**
* Gets the first space that the given tag exists in.
* If the tag has a value in a tag mask, then the space that the mask exists in is returned.
* If the tag does not have a value in a tag mask, then null is returned.
* @param bot The bot.
* @param tag The tag.
*/
export declare function getSpaceForTag(bot: Bot, tag: string): string;
/**
* Calculates the bot update that is needed to set the given tag in the given space to the given value.
* If the given space is null, then the tag will be set in the bot'ss tags.
* If the given space has a value, then the tag will be set as a tag mask in the given space.
* @param tag The tag to change.
* @param value The value to set.
* @param space The space.
*/
export declare function getUpdateForTagAndSpace(tag: string, value: any, space: string): Partial<Bot>;
/**
* Parses the given tag to determine if it represents a script or formula.
* @param tag The tag to parse.
*/
export declare function parseNewTag(tag: string): {
name: string;
isScript: boolean;
isFormula: boolean;
};
//# sourceMappingURL=BotCalculations.d.ts.map