UNPKG

@evitcastudio/kit

Version:

A single-player/multiplayer framework for the Vylocity Game Engine.

1,089 lines (933 loc) 183 kB
/**The world object.*/ type World = { /** * returns an array of diobs in the world depending on the provided arguments; if pType is not set, all diobs in the game will be returned; if pType is set but pChild is not, all diobs with the exact type of pType will be returned; if pType is set and pChild is set, all diobs with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Mob' with pChild undefined, all diobs with the exact type of 'Mob' will be returned, but if pChild is set, then all mobs in the game will be returned * @env Client | Server * @param {string} [pType] - optional; string containing type path to return * @param {boolean} [pChild] - optional; boolean that determines if child types are included * @returns {Diob[]} returns an array of diobs in the world depending on the provided arguments; if pType is not set, all diobs in the game will be returned; if pType is set but pChild is not, all diobs with the exact type of pType will be returned; if pType is set and pChild is set, all diobs with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Mob' with pChild undefined, all diobs with the exact type of 'Mob' will be returned, but if pChild is set, then all mobs in the game will be returned */ getDiobs(pType?: string, pChild?: boolean): Diob[] /** * object that will become the contents of 'settings.json' file for your game server * @env Client | Server */ serverSettings: {[key: string]: unknown, 'port'?: number,'name'?: string,'accessCode'?: 'string','secure'?: {'key': string, 'cert': string}} /** * alphanumeric string between 1 and 48 characters needed to list a server and use the api for the game * @env Client | Server */ webAccessCode: string /** * SERVER-ONLY; default 10000; number of milliseconds to wait before pinging a client to see if it is still connected * @env Server */ pingDelay: number /** * SERVER-ONLY; default port to use when hosting; if the host sets a port in settings.json that port will override this one * @env Server */ mainPort: number /** * type of map to use; 'normal' or 'isometric' * @env Client | Server */ mapMode: 'normal' | 'isometric' /** * a string containing the address of the server to automatically connect players to; example '127.0.0.1:1234' * @env Client | Server */ mainServer: string /** * passes an array of objects containing information about the game servers currently online; example {'name': 'Server 1', 'address': '127.0.0.1:1234', 'players': 12, 'guests': 2} would be the data for a server named Server 1 with 12 players and 2 guests on it at 127.0.0.1:1234 address to pFunc * @env Client | Server * @param {Function} pFunc - function to call after the servers have been retrieved */ getServers(pFunc: Function): void /** * returns an array of diobs in the world that have the tag pTag * @env Client | Server * @param {string} pTag - string containing tag to look for * @returns {Diob[]} returns an array of diobs in the world that have the tag pTag */ getDiobsByTag(pTag: string): Diob[] /** * returns an object {'width': world.gameWidth, 'height': world.gameHeight} containing the width and height of the game * @env Client | Server * @returns {{'width': number, 'height': number}} returns an object {'width': world.gameWidth, 'height': world.gameHeight} containing the width and height of the game */ getGameSize(): {'width': number, 'height': number} /** * closes the socket connection * @env Client | Server * @param {string} pAddress - address of server to open a socket to; example '127.0.0.1:1234' * @param {Function} pFunc - function to call once the socket has been opened; an object holding the socket information is passed into pFunc * @param {object} pSettings - object containing settings values; example: {'secure': true} */ openWebSocket(pAddress: string, pFunc: Function, pSettings: object): void /** * name that the server's js file will have, default being 'server' making it 'server.js' * @env Client | Server */ serverFileName: string /** * closes the host socket * @env Server * @param {number} pPort - the port to listen for sockets on * @param {Function} pFunc - the function to call once the host socket has started * @returns {unknown[]} returns an array of all the socket client objects */ hostWebSocket(pPort: number, pFunc: Function): unknown[] /** * checks if Vylocity account pName is a subscriber of the game then calls pFunc; server-side only * @env Server * @param {string | number} pName - name of the Vyocity account to check sub of * @param {Function} pFunc - function to call after the sub check; function is called with up to two parameters where the first is true or false depending on if the account is a sub or not and the second is a string containing an error message if there was one */ checkSub(pName: string | number, pFunc: Function): void /** * plays a sound to all objects in pArr; returns the Sound object * @env Client | Server * @param {string | {'soundName': string, 'volume': number}} pSound - either a string with the name of a sound file, or a string containing the path of a Sound object, or an actual Sound object, or a basic object with the proper information; ex ( {'soundName': 'name', 'volume': 50} ) * @param {unknown} [pArr] - optional list of objects to play sound to * @param {unknown} [pStart] - optional; time to start playing the sound at * @param {unknown} [pDuration] - optional; how long to play the sound for * @returns {void} returns the Sound object */ playSound(pSound: string | {'soundName': string, 'volume': number}, pArr?: unknown, pStart?: unknown, pDuration?: unknown): void /** * sends a request of method pMethod to the url pLink and passes the response into pFunc * @env Client | Server * @param {string} pLink - string containing the link to send a request to; for example 'https://vylocity.com/' * @param {string} [pMethod] - optional; string containing method type of request, ex 'POST', 'GET' * @param {object} [pHeaders] - optional; object containing custom headers * @param {unknown} [pData] - optional; data to send with method 'POST' * @param {Function} [pFunc] - optional; function to call after the request has been sent and a response received, the arguments of the function will be (pData, pError) where pData is the data returned and pError the error (if there is one) */ sendRequest(pLink: string, pMethod?: string, pHeaders?: object, pData?: unknown, pFunc?: Function): void /** * SERVER-ONLY; a string containing addresses allowed to use scripts to access and download resources from this game server (currently set for .vyr|.json|.txt files); default '*' which allows all addresses * @env Server */ resourceOrigin: string /** * map to be loaded when the game starts * @env Client | Server */ mainMap: string /** * a string containing the address of the server to download resources from (game server or web server); default '.' which is same address as the game; if using web server, add htaccess file in the resources folder to set header Access-Control-Allow-Origin ex of htaccess file: ( Header set Access-Control-Allow-Origin "*" ); this feature only works for the client of multiplayer, if playing solo the resources at the index location will be used and the server in multiplayer will use its own resource location * @env Client | Server */ resourceServer: string /** * returns an object {'width': world.tileWidth, 'height': world.tileHeight} containing the width and height of the game tiles * @env Client | Server * @returns {{'width': number, 'height': number}} returns an object {'width': world.tileWidth, 'height': world.tileHeight} containing the width and height of the game tiles */ getTileSize(): {'width': number, 'height': number} /** * gracefully reboot the server * @env Client | Server */ reboot(): void /** * string containing the name of the default macro atlas * @env Client | Server */ mainMacro: string /** * returns an array of objects that are in pArr depending on the provided arguments; if pType is not set, all objects in the game will be returned; if pType is set but pChild is not, all diobs with the exact type of pType will be returned; if pType is set and pChild is set, all diobs with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Mob' with pChild undefined, all diobs with the exact type of 'Mob' will be returned, but if pChild is set, then all mobs in the game will be returned * @env Client | Server * @param {unknown[]} pArr - array to check for objects in * @param {string} [pType] - optional; string containing type path to return * @param {boolean} [pChild] - optional; boolean that determines if child types are included * @returns {unknown[]} returns an array of objects that are in pArr depending on the provided arguments; if pType is not set, all objects in the game will be returned; if pType is set but pChild is not, all diobs with the exact type of pType will be returned; if pType is set and pChild is set, all diobs with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Mob' with pChild undefined, all diobs with the exact type of 'Mob' will be returned, but if pChild is set, then all mobs in the game will be returned */ getObjectsFromArray(pArr: unknown[], pType?: string, pChild?: boolean): unknown[] /** * returns a string containing the address of the server or client; for example '1.2.3.4:1234' for server and 'localhost' always for client * @env Client | Server * @returns {string} returns a string containing the address of the server or client; for example '1.2.3.4:1234' for server and 'localhost' always for client */ getHostAddress(): string /** * goes to pLink and passes the content of the page to pFunc once it is finished * @env Client * @param {string} pLink - string containing the link to read; for example 'http://vylocity.com/' * @param {Function} pFunc - function to call after the content has been retrieved * @param {unknown} [pMime] - CLIENT-ONLY; optional; set the mime type; ex text/html or application/octet-stream */ getWebContent(pLink: string, pFunc: Function, pMime?: unknown): void /** * SERVER-ONLY; reference to the node process (https://nodejs.org/api/process.html); warning: for advanced users * @env Server */ nodeProcess: NodeJS.Process /** * version of the game * @env Client | Server */ gameVersion: string | number /** * displays pMes to the console * @env Client | Server * @param {string} pMes - message to display */ log(pMes: string): void /** * returns a string containing the game version * @env Client | Server * @returns {string | number} returns a string containing the game version */ getGameVersion(): string | number /** * outputs text to an interface element for all clients; if pInt or pEl is not set or is invalid, text goes to client.mainOutput * @env Client | Server * @param {string} pText - text to be displayed * @param {string} pInt - string containing interface file name to output to * @param {string} pEl - string containing the interface element name to output to */ outputText(pText: string, pInt: string, pEl: string): void /** * SERVER-ONLY; a string containing the address that can access the API ( '*' to allow all ) or an array of strings for each address with access * @env Server */ apiOrigin: string | string[] /** * sends a string message pMes to another server located at pAddress; game server getting the message must have World/apiOrigin set to allow the message * @env Client | Server * @param {string} pAddress - address of the server to send a message to * @param {string} pMes - string containing the message to send * @param {Function} [pCallback] - optional; function to call after the message has been sent; the function will have two arguments, the first being an error if there was one, the second being the response from the server (the return value of the World/onMessage) */ sendMessage(pAddress: string, pMes: string, pCallback?: Function): void /** * called when a map finishes loading * @env Client | Server * @event * @param {string | number} pName - name of map that has loaded */ onMapLoaded(pName: string | number): void /** * string containing the path of the mob for the player to control * @env Client | Server */ mainMob: string /** * returns an array of all connected clients * @env Client | Server * @returns {Client[]} returns an array of all connected clients */ getClients(): Client[] /** * terminates the connection and prevents any queued data from being processed * @env Server * @param {object} pDatabase - object containing database information * @param {Function} [pFunc] - optional; hostname of database; default localhost * @returns {object} returns one argument that contains any error information<br /> called: returns the connection pool object after connecting to the MySQL database pDatabase */ openMySQL(pDatabase: object, pFunc?: Function): object /** * returns a string containing information about what the code type is; code ran in solo will return 'local'; code ran in multi-player client will return 'client'; code ran on the server will return 'server' * @env Client | Server * @returns {'local' | 'client' | 'server'} returns a string containing information about what the code type is; code ran in solo will return 'local'; code ran in multi-player client will return 'client'; code ran on the server will return 'server' */ getCodeType(): 'local' | 'client' | 'server' /** * gracefully shut down the server * @env Client | Server */ shutdown(): void /** * returns the diob with the specified ID * @env Client | Server * @param {string} pID - id of the diob to get * @returns {Diob} returns the diob with the specified ID */ getDiobByID(pID: string): Diob /** * an object containing width and height of tiles on the map {'width': 32, 'height': 32}; acts as the default size of diobs * @env Client | Server */ tileSize: {'width': number, 'height': number} /** * a number; 1 for single player game, 2 for multi-player game, 3 for single and multi-player * @env Client | Server */ playerMode: 1 | 2 | 3 /** * returns a string contain server IP and port in 'ip:port' format * @env Client | Server * @returns {string} returns a string contain server IP and port in 'ip:port' format */ getAddress(): string /** * sends a notification with the message pMessage to the Vylocity account pName and then calls pFunc; server-side only * @env Server * @param {string | number} pName - name of the Vyocity account to send notification to * @param {unknown} pMessage - message to send; 256 characters max * @param {Function} pFunc - function to call after the notification has been sent or attempted; function is called with up to two parameters where the first is true or false depending on the success of the send and the second is a string containing an error message if there was one */ sendNotification(pName: string | number, pMessage: unknown, pFunc: Function): void /** * only manually set this if you are using the offline IDE and are setting the source to match the game id for vylocity.com * @env Client | Server */ gameID: number /** * evaluates the JavaScript code in the pScript string; if the world is running on the server-side this code will be Node.js * @env Client | Server * @param {string} pScript - a string containing the JavaScript code to evaluate */ evalWebScript(pScript: string): void /** * returns a number containing the game's player mode * @env Client | Server * @returns {number} returns a number containing the game's player mode */ getPlayerMode(): number /** * array of files to preload when the game starts up or '*' to load all resources; if no name is provided, all resources of that type will be preloaded; for example [{'type': 'icon', 'name': 'icon1'}, {'type': 'sound'}] to load an icon named icon1 and all sound resources; all interface files and macro files are automatically preloaded; you may include remote resources by giving the object a 'remote' property and setting it to the web URL path of the resource * @env Client | Server */ preloadResources: {'type': string, 'name': string}[] | '*' /** * kicks the client pClient and displays the pReason message to them if there is one * @env Client | Server * @param {Client} pClient - client to kick * @param {string} [pReason] - optional; message to display to the client being kicked */ kickClient(pClient: Client, pReason?: string): void /** * SERVER-ONLY; default 50; number of milliseconds to wait before sending built-in engine packets (custom client packets are sent immediately) * @env Server */ packetDelay: number /** * default 45; how many tiles to combine into chunks to improve efficiency for rendering and networking; recommended to use at least 1.5x map view, so if the map view is 1920x1080 and the tile size is 32x32, you would want at least 90 chunk (90x90 tiles); if a part of the remaining map (after other parts have been chunked) is smaller than the chunk size, it will be added to the nearest chunk instead * @env Client | Server */ mapChunk: number /** * sends the data for the pD diob to all clients in the world, if pVar is set it will send only those variables, if it is not set it will only send built-in engine variables * @env Server * @param {Diob} pD - reference to the diob to send * @param {unknown[]} [pVar] - optional; variable name or array of variable names */ sendDiob(pD: Diob, pVar?: unknown[]): void } /**The base object that Diob extends from.*/ type Object = { /** * object containing ticker details if in an active ticker; set to null to remove from ticker * @env Client | Server */ inTicker: object /** * sets the pVal value of the pVar static variable belonging to the type pType; static variables are variables that belong to all Objects of this type collectively and are different than normal variables, usually static variables can only be set once, but VyScript static variables may be changed if that is what the developer wants * @env Client | Server * @param {unknown} pVar - name of the static variable to set * @param {boolean} pVal - value to give to the static variable */ setStaticVariable(pVar: unknown, pVal: boolean): void /** * returns the static variable value belonging to the type pType * @env Client | Server * @param {unknown} pVar - name of the static variable to get * @returns {unknown} returns the static variable value belonging to the type pType */ getStaticVariable(pVar: unknown): unknown } /**The diob object.*/ type Diob = { /** * returns true if this Diob is currently shown on the screen, false if not * @env Client | Server * @returns {void} returns true if this Diob is currently shown on the screen, false if not */ checkScreenShown(): void /** * removes the specified filter * @env Client | Server * @param {string | number} pName - name of filter to remove */ removeFilter(pName: string | number): void /** * sets the diob's overlays to the array pOver * @env Client | Server * @param {Diob[]} pOver - array of overlays to set this diob's overlays to * @param {boolean} [pSave] - optional; if set, removed overlays will not be deleted, otherwise this call will delete removed overlays after removing them from the overlays */ setOverlays(pOver: Diob[], pSave?: boolean): void /** * when this diob has a transition change; if pVar, pChange, and pStart are all unset then this is the event called when all transitions have ended * @env Client | Server * @event * @param {string} pVar - a string containing the name of the variable involved in the transition * @param {unknown} pChange - the amount changed * @param {object} pStart - if this is set then this is the event called when a transition starts; this will be a reference to the transition object used */ onTransition(pVar: string, pChange: unknown, pStart: object): void /** * returns an array of diobs currently in this diob's viewer array * @env Client | Server * @returns {unknown[]} returns an array of diobs currently in this diob's viewer array */ getInvisibilityViewers(): unknown[] /** * if set, diob will be invisible to all other diobs with visibility less than this value * @env Client | Server */ invisibility: number /** * sets this diob's icon anchor to pX and pY; default is 0.5,0.5 which is the center of the diob's icon (0,0 would be the top-left corner); * @env Client | Server * @param {number} pX - default 0.5; x value of the diob's icon anchor * @param {number} [pY] - optional; default 0.5; y value of the diob's icon anchor */ setAnchor(pX: number, pY?: number): void /** * modifies scale, angle, or alpha of the over screen * @env Client | Server * @param {object} pMod - object containing mods; scale, angle, alpha; ex ( {'angle': 0.8} ) * @param {unknown} [pAdd] - optional; if set, the values in pMod will be added to the current mod object */ setOverScreenMod(pMod: object, pAdd?: unknown): void /** * moves this to specified location; if pVal1 and pVal2 are numbers, this is moved to the coordinate pVal1, pVal2; if pVal1 is an object but not a tile, this is moved to the location of object; if pVal1 is a tile, this is moved to that tile * @env Client | Server */ setLoc(): Diob /** * returns the current diob being used as a mask * @env Client | Server * @returns {Diob} returns the current diob being used as a mask */ getMask(): Diob /** * a string to be displayed as text above the diob * @env Client | Server */ text: string /** * adds pDiob to this diob's viewer array, allowing pDiob to always see this diob * @env Client | Server * @param {Diob} pDiob - the diob to add */ addInvisibilityViewer(pDiob: Diob): void /** * when this diob and pD have overlapping bounding boxes and one of them changes position and stays overlapped * @env Client | Server * @event * @param {Diob} pD - diob that is crossed with this diob * @param {unknown} pInit - if set, pD was relocated and initiated the event */ onCrossedRelocated(pD: Diob, pInit: unknown): void /** * turns this diob's sprite into a repeating pattern; call with no arguments to return to a normal sprite * @env Client | Server * @param {number} pX - default 0; position where the pattern starts on the x-axis * @param {number} pY - default 0; position where the pattern starts on the y-axis * @param {number} [pWidth] - optional; width of the pattern * @param {number} [pHeight] - optional; height of the pattern */ setPattern(pX: number, pY: number, pWidth?: number, pHeight?: number): void /** * determines if the object is dense or not; true or false for dense or not, or a number for value, over 1 for different densities; for example, density 3 diobs can move over density 2 and lower diobs but not anything density 3 or higher * @env Client | Server */ density: unknown /** * name of icon inside object's icon atlas * @env Client | Server */ iconName: string /** * adds the specified filter * @env Client | Server * @param {string | number} pName - name of the filter; only one name may be used at a time, using the name will remove the old filter with that name * @param {string} pType - the type of filter to add; below is the types and their specific possible pArgs values * @param {unknown} pArgs - color-based filter */ addFilter(pName: string | number, pType: string, pArgs: unknown): void /** * position of object on the grid x-axis * @env Client | Server */ xCoord: number /** * sets the width and height of the diob * @env Client | Server * @param {number} pWidth - value to set the diob's width to * @param {number} pHeight - value to set the diob's height to */ setSize(pWidth: number, pHeight: number): void /** * called when a packet is sent from this diob on the client or server using diob.sendPacket * @env Client | Server * @event * @param {Client} pClient - client that sent the packet * @param {string | number} pName - name of packet * @param {unknown} pData - any data containing information for packet; ex {'a': 1, 'b': 2} or 'test' */ onPacket(pClient: Client, pName: string | number, pData: unknown): void /** * called when the mouse clicks this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob * @param {unknown} pButton - the button used; 1 for left, 2 for middle, 3 for right */ onMouseClick(pClient: Client, pX: number, pY: number, pButton: unknown): void /** * the region that the diob is in * @env Client | Server */ region: unknown /** * name of atlas the object's icon is in * @env Client | Server */ atlasName: string /** * returns an array of diobs that are crossing this diob using the provided arguments; if pType is not set, all diobs will be returned; if pType is set but pChild is not, all diobs with the exact type of pType will be returned; if pType is set and pChild is set, all diobs with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Mob' with pChild undefined, all diobs with the exact type of 'Mob' will be returned, but if pChild is set, then all mobs will be returned * @env Client | Server * @param {string} [pType] - optional; string containing type path to return * @param {boolean} [pChild] - optional; boolean that determines if child types are included * @returns {Diob[]} returns an array of diobs that are crossing this diob using the provided arguments; if pType is not set, all diobs will be returned; if pType is set but pChild is not, all diobs with the exact type of pType will be returned; if pType is set and pChild is set, all diobs with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Mob' with pChild undefined, all diobs with the exact type of 'Mob' will be returned, but if pChild is set, then all mobs will be returned */ getCrossed(pType?: string, pChild?: boolean): Diob[] /** * changes the appearance of the diob based on the values provided by pDiob * @env Client | Server * @param {Diob} pDiob - object containing the appearance information or a diob itself; values used: atlasName, iconName, iconState, width, height, layer, scale, color, alpha, transform, anchor, angle, composite, plane, text, textStyle, animator, overlays, overScreen */ setAppearance(pDiob: Diob): void /** * sets the x and y origin offsets * @env Client | Server * @param {number} pX - the x offset of the origin of this object from the left * @param {number} pY - the y offset of the origin of this object from the top */ setOrigin(pX: number, pY: number): void /** * if set, the client will not interpolation position changes * @env Client | Server */ preventInterpolation: unknown /** * default 0; number of pixels to offset the text by on the y-axis * @env Client | Server */ textStyle: object /** * name of the type of the object * @env Client | Server */ type: string /** * unique ID of the diob * @env Client | Server */ id: unknown /** * the diob's transformation matrix or transformation object; example [scaleX, skewY, 0, skewX, scaleY, 0, moveX, moveY, 1] where scaleX scales the diob's appearance on the x-axis, skewY skews on the y-axis, moveX moves on the x-axis, skewX skews on the x-axis, scaleY scales on the y-axis, moveY moves on the y-axis, and the last three are static for matrix; example {'scaleX': 2, 'skewY': 0.1} would scale by 2 on the x-axis and skew by 0.1 on the y-axis for object * @env Client | Server */ transform: object | number[] /** * sets the scale of the diob * @env Client | Server * @param {number} pX - number to scale the width of the diob by; for example 2 would be a 200% scale * @param {number} [pY] - optional; number to scale the height of the diob by; for example 2 would be a 200% scale; pX used if null */ setScale(pX: number, pY?: number): void /** * transitions this diob's pO properties from their current values to the new values over time; if pO is not set all transitions will be cancelled and all properties will automatically go to their end transition values; current allowed properties: alpha, angle, scale, xScale, yScale, xIconOffset, yIconOffset * @env Client | Server * @param {object} pO - object containing properties to transition; ex {'alpha': 0.5, 'xIconOffset': 20} * @param {number} pS - number of steps to take to transition the properties; default 1; -1 for a step every frame * @param {number} pT - number of milliseconds between each step; default 100; if pS is -1 then this is the total time * @param {number} [pQ] - optional; if set, this transition will be added to a queue and happen after the current transition finishes or the rest of the queue clears; set as -1 to merge this with the last thing in the queue * @param {number} [pLoop] - optional; if set, this transition will be added to the current loop of transitions and repeat until told to stop, if this transition is first, this can be set to a specify number to stop looping after that amount of loops; -1 to loop forever * @param {string} [pEase] - optional; use an easing equation that isn't linear; options: 'quadraticIn', 'quadraticOut', 'quadraticInOut', 'cubicIn', 'cubicOut', 'cubicInOut', 'quarticIn', 'quarticOut', 'quarticInOut', 'quinticIn', 'quinticOut', 'quinticInOut', 'sineIn', 'sineOut', 'sineInOut', 'expoIn', 'expoOut', 'expoInOut', 'circularIn', 'circularOut', 'circularInOut' */ setTransition(pO: object, pS: number, pT: number, pQ?: number, pLoop?: number, pEase?: string): void /** * the tile that the diob is on * @env Client | Server */ loc: unknown /** * when this diob leaves the client's screen view * @env Client | Server * @event * @param {Client} pClient - a reference to the client */ onScreenHide(pClient: Client): void /** * returns the transformation matrix of this diob * @env Client | Server * @param {unknown} [pAsObj] - optional; if set, the diob's transformation matrix will be returned as an object, for example {'scaleX': scaleX, 'skewY': skewY} * @returns {void} returns the transformation matrix of this diob */ getTransform(pAsObj?: unknown): void /** * returns the over screen mod * @env Client | Server * @returns {void} returns the over screen mod */ getOverScreenMod(): void /** * returns an object {'atlas': atlasName, 'icon': iconName} containing the diob's icon atlas and icon names * @env Client | Server * @returns {object} returns an object {'atlas': atlasName, 'icon': iconName} containing the diob's icon atlas and icon names */ getIcon(): object /** * grabs an object with the screen x offset, y offset, width, height, settings, and either an array of pixel data or a data url depending on pType (data returned client-side only). The data can then be changed and used elsewhere or drawn onto another screen. To read the width and height you could use object.width and object.height, where object is the object returned by the function. The object data array is as follows: object.data[0] is the red value (0-255) of the pixel at 0,0, object.data[1] is the green value (0-255) of the pixel at 0,0, object.data[2] is the blue value (0-255) of the pixel at 0,0, and object.data[3] is the alpha value (0-255) of the pixel at 0,0. Then object.data[4], object.data[5], object.data[6], and object.data[7] are the respective values for the pixel at 1,0. This trend continues through the whole array for every pixel. object ex: {'x': 0, 'y': 0, 'width': 100, 'height': 100, 'data': ''} * @env Client * @param {string} pType - type of data to get; 'url', 'pixels', 'canvas', or 'sprite' */ getOverScreen(pType: string): void /** * angle of the diob (0 to 2PI) * @env Client | Server */ angle: number /** * changes the over screen information; adding data optional * @env Client | Server * @param {number} pX - x offset of display * @param {number} pY - y offset of display * @param {number} pWidth - width of display * @param {number} pHeight - height of display * @param {unknown} [pData] - optional; data to add to the screen * @param {object} [pSet] - optional; settings object; ex ( {'scaleNearest': true} ); */ setOverScreen(pX: number, pY: number, pWidth: number, pHeight: number, pData?: unknown, pSet?: object): void /** * when this diob changes maps; this event will be called twice if the map has not already been loaded, once before loading and once after the loading has completed (the first event will have pBefore set) * @env Client | Server * @event * @param {string} pMap - name of the old map or name of the new map if pBefore is set * @param {unknown} pBefore - if set then the map is currently loading and this is the pre-load event */ onMapChange(pMap: string, pBefore: unknown): void /** * returns an object {'width': width, 'height': height} containing the diob's width and height * @env Client | Server * @returns {object} returns an object {'width': width, 'height': height} containing the diob's width and height */ getSize(): object /** * custom string used to identify the diob * @env Client | Server */ tag: string /** * all invisible diobs with invisibility levels equal to or less than this will be visible to this diob * @env Client | Server */ visibility: number /** * called when the mouse double clicks this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob * @param {unknown} pButton - the button used; 1 for left, 2 for middle */ onMouseDblClick(pClient: Client, pX: number, pY: number, pButton: unknown): void /** * when an object exits the contents of another object * @env Client | Server * @event * @param {Diob} pDiob - object that exited */ onExited(pDiob: Diob): void /** * performs the specified draw function using the specified pArgs object; ex ( {'type': 'image', 'image': this, 'x': 1, 'y': 1} ) * @env Client | Server * @param {object | object[]} pArgs - an object or array of objects which determines the settings of the draw */ overScreenDraw(pArgs: object | object[]): void /** * how visible the diob appears; (0 to 1); 0 completely invisible, 1 completely visible, between partially visible, higher the number the more visible * @env Client | Server */ alpha: number /** * changes display icon of object * @env Client | Server * @param {string} pAtlas - name of atlas icon is in * @param {string} pIcon - name of icon in pAtlas */ setIcon(pAtlas: string, pIcon: string): void /** * position on the y-axis of the origin from the top edge of the diob * @env Client | Server */ yOrigin: number /** * position of object on the grid y-axis * @env Client | Server */ yCoord: number /** * returns an object {'x': xOrigin, 'y': yOrigin} containing the diob's x and y origin offsets * @env Client | Server * @returns {object} returns an object {'x': xOrigin, 'y': yOrigin} containing the diob's x and y origin offsets */ getOrigin(): object /** * when this diob changes icons * @env Client | Server * @event */ onIconUpdate(): void /** * returns an object {'x': x,'y': y} containing the x and y icon offsets * @env Client | Server * @returns {object} returns an object {'x': x,'y': y} containing the x and y icon offsets */ getIconOffsets(): object /** * turns pMask into a mask which this diob interacts with; transparent portions of the pMask's icon will cut out those same spots from this diob's icon * @env Client | Server * @param {Diob} pMask - diob to use as a mask */ setMask(pMask: Diob): void /** * if this diob is an Overlay type or is being used as an overlay, this will be set; if the overlay has a parent diob, this will be a reference to that diob * @env Client | Server */ isOverlay: unknown /** * height to use when calculating y position relayering * @env Client | Server */ relayerHeight: unknown /** * SERVER-ONLY; if set, the server will not update clients when changes are made; can be 'true' to prevent all clients from getting updated or can be an object containing variables and/or specific clients to ignore; possible variables 'pos', 'dir', 'icon'; ex ( {'type': ['pos', 'dir'], 'client': [someClient]} ) * @env Server */ preventClientUpdates: unknown /** * called when a mouse wheel button is scrolled upward while over this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob */ onMouseWheelScrollUp(pClient: Client, pX: number, pY: number): void /** * data shared automatically from the server-side to clients that have a sync for this diob; changing the variable will update any clients that have this diob's sync in realtime * @env Client | Server */ clientSyncData: unknown /** * sends a packet to a client or server specifically for this diob, depending on where the code is executed; client code executing this will send the packet to the server; server code executing this will send the packet to the client; this will invoke Diob/onPacket on client-side if the sendPacket is server-side and on the server-side if it is on the client-side * @env Client | Server * @param {string | number} pName - name of packet to send * @param {unknown} pData - data to be sent; ex {'a': 1, 'b': 2} or 'test' * @param {Client} [pClient] - SERVER ONLY; optional; specific client or array of clients to send this packet to; if no client is specified the packet will be sent to all clients currently synced with this diob */ sendPacket(pName: string | number, pData: unknown, pClient?: Client): void /** * returns an object {'x': x, 'y': y} containing the x and y coord offsets of the object * @env Client | Server * @returns {object} returns an object {'x': x, 'y': y} containing the x and y coord offsets of the object */ getCoordOffsets(): object /** * removes all overlays with the pOver type or the exact overlay matching pOver * @env Client | Server * @param {string | Diob | Object} pOver - string of the type of object or overlay to remove or actual overlay to remove * @param {unknown} [pSave] - optional; if set, the overlay will not be deleted, otherwise this call will delete pOver after removing it from the overlays */ removeOverlay(pOver: string | Diob | Object, pSave?: unknown): void /** * called when the mouse exits this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob */ onMouseExit(pClient: Client, pX: number, pY: number): void /** * returns an object {'x': x, 'y': y} containing the x and y positions of the diob on the map * @env Client | Server * @returns {{'x': number,'y': number}} returns an object {'x': x, 'y': y} containing the x and y positions of the diob on the map */ getPos(): {'x': number,'y': number} /** * how many pixels object is offset on the grid x-axis from the xCoord * @env Client | Server */ xCoordOffset: number /** * if set, any movable with the same density as this diob may cross over it * @env Client | Server */ allowDensityCross: boolean /** * when an object enters the contents of another object * @env Client | Server * @event * @param {Diob} pDiob - object that entered */ onEntered(pDiob: Diob): void /** * height of the collision box of the object * @env Client | Server */ height: number /** * string containing composite value that determines how this diob is drawn with other diobs on the same plane; possible values: normal, add, multiply, screen * @env Client | Server */ composite: 'source-over' | 'source-atop' | 'source-in' | 'source-out' | 'destination-over' | 'destination-atop' | 'destination-in' | 'destination-out' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity' /** * sets the animation frame to pFrame and freezes for pDelay milliseconds before returning to the previous frame or continuing on if pCont is set * @env Client | Server * @param {number} pFrame - frame number * @param {number} [pDelay] - optional; delay in milliseconds to freeze the newly set frame for; passing in -1 will pause the animation until you unpause it by changing the diob's 'animator.isPaused' to false * @param {boolean} [pCont] - optional; if true, animation will play like normal after the frame delay; false will return the animation to the frame it was at before the set after the delay */ setFrame(pFrame: number, pDelay?: number, pCont?: boolean): void /** * returns an object containing the information for the diob's current animation; current variables, onFrame for the current frame the animation is on, frameCount for total number of frames in the animation, atlasName for atlas of the current animation, iconName for icon name of current animation, iconState for state of current animation; example {'onFrame': 1, 'frameCount' 20, 'atlasName': '', 'iconName': '', 'iconState': ''} * @env Client | Server * @param {boolean} [pVal] - optional; string with name of specific value to get; options: 'onFrame', 'frameCount', 'atlasName', 'iconName', 'iconState' * @returns {object,number} returns an object containing the information for the diob's current animation; current variables, onFrame for the current frame the animation is on, frameCount for total number of frames in the animation, atlasName for atlas of the current animation, iconName for icon name of current animation, iconState for state of current animation; example {'onFrame': 1, 'frameCount' 20, 'atlasName': '', 'iconName': '', 'iconState': ''} */ getAnimation(pVal?: boolean): object,number /** * when this diob and pMovable no longer have overlapping bounding boxes * @env Client | Server * @event * @param {Diob} pDiob - diob that uncrossed with this diob */ onUncrossed(pDiob: Diob): void /** * called when a mouse button has been pressed while over this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob * @param {unknown} pButton - the button used; 1 for left, 2 for middle, 3 for right */ onMouseDown(pClient: Client, pX: number, pY: number, pButton: unknown): void /** * called when the mouse moves after entering this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob */ onMouseMove(pClient: Client, pX: number, pY: number): void /** * returns the coords of the diob with an object {'x': x, 'y': y} * @env Client | Server * @returns {object} returns the coords of the diob with an object {'x': x, 'y': y} */ getCoords(): object /** * CLIENT-ONLY; if set, the client will not update the draw layer of this diob when it changes location on the screen * @env Client */ preventScreenRelayer: boolean /** * calls on the client-side when clientSyncData is changed by the server * @env Client | Server * @event * @param {unknown} pOld - old data in clientSyncData */ onClientSyncData(pOld: unknown): void /** * returns an array of locations the diob is on; if diob is a tile, it returns an array containing only itself * @env Client | Server * @returns {Diob[]} returns an array of locations the diob is on; if diob is a tile, it returns an array containing only itself */ getLocs(): Diob[] /** * name of the lowest level parent type * @env Client | Server */ baseType: string /** * sets the coord offset of the object * @env Client | Server * @param {number} pX - the x offset from the xCoord * @param {number} pY - the y offset from the yCoord */ setCoordOffsets(pX: number, pY: number): void /** * name of object * @env Client | Server */ name: unknown /** * sets the icon state of the diob's icon * @env Client | Server * @param {string} pState - state of the icon to set * @param {number} [pFrame] - optional; if true, animation will start from the frame the last iconState left off on */ setIconState(pState: string, pFrame?: number): void /** * when this diob has an overlay removed from it * @env Client | Server * @event * @param {Diob} pD - the diob that was removed from the overlays */ onRemoveOverlay(pD: Diob): void /** * called when a mouse button is released while over this object * @env Client | Server * @event * @param {Client} pClient - client of the mouse * @param {number} pX - the x position of the mouse over the diob * @param {number} pY - the y position of the mouse over the diob * @param {unknown} pButton - the button used; 1 for left, 2 for middle, 3 for right */ onMouseUp(pClient: Client, pX: number, pY: number, pButton: unknown): void /** * position on the x-axis of the origin from the left edge of the diob * @env Client | Server */ xOrigin: number /** * when pMovable attempts to cross this diob resulting in overlapping bounding boxes; this function must return 'true' in order for pMovable to cross; this event is called for both diobs if they are both movable; tiles do not have this event * @env Client | Server * @event * @param {unknown} pMovable - movable that is attempting to cross with this diob * @param {unknown} pInit - if set, pMovable initiated the event */ onCross(pMovable: unknown, pInit: unknown): void /** * position on the y-axis from top to bottom of the map * @env Client | Server */ yPos: number /** * when this diob has an overlay added to it * @env Client | Server * @event * @param {Diob} pD - the diob added as an overlay */ onAddOverlay(pD: Diob): void /** * adds an overlay to the object which is a visual icon that always follows the object; returns the new overlay * @env Client | Server * @param {string | Diob | Object} pOver - string of the type of object or overlay to add an overlay of or actual diob to get type from * @param {number | boolean} [pAppearance] - optional; if 1 or positive, this overlay will be be treated as if it is part of the the parent's actual appearance - appearance settings such as angle and alpha of the parent will be used for this overlay and the overlay will be drawn directly on top of the parent so no other diobs that are not an overlay of the parent can appear between it and the parent (it will basically be an extension of the parent's icon); if this is false or 0, the overlay will be treated as an independent diob that just follows the parent arou