docs
This commit is contained in:
@@ -8,21 +8,21 @@ import path from 'path';
|
||||
const collection = 'assets';
|
||||
|
||||
/**
|
||||
* Game objects manager
|
||||
* Game objects manager, контролен клас за управление на игрови обекти
|
||||
*/
|
||||
class GameObjectsManager{
|
||||
name = 'gameObject';
|
||||
|
||||
/**
|
||||
* Plugin initializer
|
||||
* @param {App} app The Application
|
||||
* Plugin initializer, инициализация на плъгин
|
||||
* @param {App} app The Application, обект приложение
|
||||
*/
|
||||
init(app){
|
||||
const {db, config} = app;
|
||||
|
||||
/**
|
||||
* Gets last asset Id from database
|
||||
* @returns {Number} Last Asset Id
|
||||
* Gets last asset Id from database, намира последния пореден идентификатор на обект в базата от данни
|
||||
* @returns {Number} Last Asset Id, последен (най-голям) идентификатор
|
||||
*/
|
||||
this.getLastId = async function(){
|
||||
let ag = await db.aggregate(collection, [
|
||||
@@ -39,9 +39,9 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a game object
|
||||
* @param {Context} ctx Request context
|
||||
* @param {GameObject} data Asset data
|
||||
* Creates a game object, създаване на игрови обект
|
||||
* @param {Context} ctx Request context, контекст на заявката
|
||||
* @param {GameObject} data Asset data, данни за игровия обект
|
||||
*/
|
||||
this.create = async function(ctx, data){
|
||||
data.id = (await this.getLastId()) + 1;
|
||||
@@ -55,9 +55,9 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves game object from database
|
||||
* @param {Number} id Game object ID
|
||||
* @returns {GameObject} The game object
|
||||
* Retrieves game object from database, прочитане на обект от базата от данни
|
||||
* @param {Number} id Game object ID, идентификатор на обекта
|
||||
* @returns {GameObject} The game object, игрови обект
|
||||
*/
|
||||
this.read = async function(id){
|
||||
id = parseInt(id);
|
||||
@@ -65,9 +65,9 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates game object into the database
|
||||
* @param {Context} ctx Request context
|
||||
* @param {GameObject} data Game object
|
||||
* Updates game object into the database, обновяване на игрови обект
|
||||
* @param {Context} ctx Request context, контекст на заявката
|
||||
* @param {GameObject} data Game object, данни за игровия обект
|
||||
*/
|
||||
this.update = async function(ctx, data){
|
||||
data.id = parseInt(data.id);
|
||||
@@ -85,8 +85,8 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes game object from database
|
||||
* @param {Number} id Game object ID
|
||||
* Removes game object from database, изтриване на игрови обект от базата от данни
|
||||
* @param {Number} id Game object ID, идентификатор на игровия обект
|
||||
*/
|
||||
this.remove = async function(id){
|
||||
id = parseInt(id);
|
||||
@@ -94,9 +94,9 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a file to a game object
|
||||
* @param {GameObject} object Game object
|
||||
* @param {File} tmpFile A file
|
||||
* Assigns a file to a game object, закачване на файл към игрови обект
|
||||
* @param {GameObject} object Game object, игрови обект
|
||||
* @param {File} tmpFile A file, файл
|
||||
*/
|
||||
this.addFile = async function(object, tmpFile){
|
||||
let i = tmpFile;
|
||||
@@ -124,9 +124,9 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a thumbnail to a game object
|
||||
* @param {GameObject} object Game object
|
||||
* @param {File} thumbSrc A thumbnail
|
||||
* Assigns a thumbnail to a game object, закачане на представително изображение към игрови обект
|
||||
* @param {GameObject} object Game object, игрови обект
|
||||
* @param {File} thumbSrc A thumbnail, представително изображение
|
||||
*/
|
||||
this.addThumb = async function(object, thumbSrc){
|
||||
let dest = `${config.fs.repo}/thumb/${object.id}.webp`;
|
||||
@@ -135,9 +135,9 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of GameObjects
|
||||
* @param {Object} query Query to DB
|
||||
* @returns {GameObject[]} Array of game objects
|
||||
* Returns list of GameObjects, търсене в игровите обекти по зададени критерии
|
||||
* @param {Object} query Query to DB, критерии - заявка към базата от данни
|
||||
* @returns {GameObject[]} Array of game objects, масив от игрови обекти
|
||||
*/
|
||||
this.list = async function(query){
|
||||
return await db.list(collection, {
|
||||
@@ -148,8 +148,8 @@ class GameObjectsManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* Class starter
|
||||
* @param {App} app The application
|
||||
* Class starter, стартиране на класа
|
||||
* @param {App} app The application, базова апликация
|
||||
*/
|
||||
async start(app){
|
||||
|
||||
@@ -158,22 +158,23 @@ class GameObjectsManager{
|
||||
|
||||
/**
|
||||
* GameObject entity, can be: panorama picture, 3d environment, 3d object, 2d object (picture), a player (3d), audio or video asset
|
||||
* Игрови обект, може да бъде панорамна снимка, триизмерна среда, обект или играч, двуизмерен обект, аудио или видео актив
|
||||
*/
|
||||
class GameObject {
|
||||
/**
|
||||
* Game object name
|
||||
* Game object name, име на игровия обект
|
||||
* @type string
|
||||
*/
|
||||
name = null;
|
||||
|
||||
/**
|
||||
* Game object type
|
||||
* Game object type, тип на игровия обект
|
||||
* @type string
|
||||
*/
|
||||
type = null;
|
||||
|
||||
/**
|
||||
* Associated file
|
||||
* Associated file, асоцииран файл
|
||||
* @type File
|
||||
*/
|
||||
file = null;
|
||||
|
||||
Reference in New Issue
Block a user