From 706279ef184701f2fa43d876d0abbd4cf513c9a6 Mon Sep 17 00:00:00 2001 From: elexis Date: Tue, 24 Oct 2017 03:09:42 +0000 Subject: [PATCH] Define rmgen Entity class, refs #4831. Make playerID non-optional. Move default orientation code to the function header. Add missing quotes. git-svn-id: https://svn.wildfiregames.com/public/ps/trunk@20337 3db68df2-c116-0410-a063-a993310a9797 --- .../data/mods/public/maps/random/rmgen/entity.js | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) rewrite binaries/data/mods/public/maps/random/rmgen/entity.js (82%) diff --git a/binaries/data/mods/public/maps/random/rmgen/entity.js b/binaries/data/mods/public/maps/random/rmgen/entity.js dissimilarity index 82% index 254a965d08..6784622a62 100644 --- a/binaries/data/mods/public/maps/random/rmgen/entity.js +++ b/binaries/data/mods/public/maps/random/rmgen/entity.js @@ -1,33 +1,25 @@ -///////////////////////////////////////////////////////////////////////////////////////// -// Entity -// -// Object for holding entity data -// -// templateName: string containing name of the template for this entity, -// optionally prefixed with "actor|". -// player: id of player who owners this entity. -// x,z: position of this entity in tiles. -// orientation: rotation of this entity about the y-axis (up). -// -///////////////////////////////////////////////////////////////////////////////////////// - -// TODO: support full position and rotation -function Entity(templateName, player, x, z, orientation) -{ - // Get unique ID - this.id = g_Map.getEntityID(); - this.templateName = templateName; - this.player = (player !== undefined ? player : 0); - - // Map units (4.0 map units per 1.0 tile) - this.position = { - x: x * CELL_SIZE, - y: 0, - z: z * CELL_SIZE - }; - this.rotation = { - x: 0, - y: (orientation !== undefined ? orientation : 0), - z: 0 - }; -} +/** + * The Entity class stores the given template name, owner and location of an entity and assigns an entityID. + * Instances of this class are passed as such to the engine. + * + * @param orientation - rotation of this entity about the y-axis (up). + */ +// TODO: support full position and rotation +function Entity(templateName, playerID, x, z, orientation = 0) +{ + this.id = g_Map.getEntityID(); + this.templateName = templateName; + this.player = playerID; + + this.position = { + "x": x * CELL_SIZE, + "y": 0, + "z": z * CELL_SIZE + }; + + this.rotation = { + "x": 0, + "y": orientation, + "z": 0 + }; +} -- 2.11.4.GIT