diff --git a/src/client/js/objects/objects.js b/src/client/js/objects/objects.js index 7f398ac4..f2dc25fa 100644 --- a/src/client/js/objects/objects.js +++ b/src/client/js/objects/objects.js @@ -61,7 +61,7 @@ define([ let objects = this.objects; let list = objects.filter(o => { - if ((!o.stats) || (o.nonSelectable) || (o === window.player) || (!o.sprite.visible)) + if ((!o.stats) || (o.nonSelectable) || (o === window.player) || (!o.isVisible)) return false; let dx = Math.abs(o.x - x); diff --git a/src/server/clientComponents/sprite.js b/src/server/clientComponents/sprite.js index 8dbdfc76..ed75ef71 100644 --- a/src/server/clientComponents/sprite.js +++ b/src/server/clientComponents/sprite.js @@ -43,8 +43,6 @@ define([ const width = (obj?.transform?.width ?? obj.width) * scaleMult; const height = (obj?.transform?.height ?? obj.height) * scaleMult; - y -= height; - Object.entries({ x, y, @@ -68,7 +66,12 @@ define([ }, destroy: function () { - + const { sprite } = this; + + if (!sprite) + return; + + sprite.parent.removeChild(sprite); } }; }); diff --git a/src/server/clientComponents/textSprite.js b/src/server/clientComponents/textSprite.js index 39637cb7..bde799eb 100644 --- a/src/server/clientComponents/textSprite.js +++ b/src/server/clientComponents/textSprite.js @@ -34,14 +34,13 @@ define([ let rx = (x * scale); let ry = (y * scale); - if (position === 'under') { + if (position === 'under' || position === 'above') rx += (width / 2) - (sprite.width / 2); + if (position === 'under') ry += height; - } if (offsetX) rx += offsetX; - if (offsetY) ry += offsetY; @@ -76,7 +75,12 @@ define([ }, destroy: function () { - + const { sprite } = this; + + if (!sprite) + return; + + sprite.parent.removeChild(sprite); } }; }); diff --git a/src/server/world/map/builders/object.js b/src/server/world/map/builders/object.js index 5cf257e3..e0c36f7c 100644 --- a/src/server/world/map/builders/object.js +++ b/src/server/world/map/builders/object.js @@ -53,12 +53,14 @@ const buildHiddenRoom = (mapModule, blueprint) => { } }; -const buildRegularObject = (mapModule, blueprint) => { - const { mapFile } = mapModule; +const buildRegularObject = (mapModule, blueprint, mapObj) => { + const { mapScale, mapFile } = mapModule; + + if (!mapFile.properties.isRandom) { + blueprint.y -= (mapObj.height / mapScale); - if (!mapFile.properties.isRandom) spawners.register(blueprint, blueprint.spawnCd || mapFile.properties.spawnCd); - else { + } else { const room = mapModule.rooms.find(r => { return !( blueprint.x < r.x || @@ -149,7 +151,7 @@ const buildObject = (mapModule, layerName, mapObj) => { if (blueprint.blocking) mapModule.collisionMap[blueprint.x][blueprint.y] = 1; - if ((blueprint.properties.cpnNotice) || (blueprint.properties.cpnLightPatch) || (layerName === 'rooms') || (layerName === 'hiddenRooms')) { + if (blueprint.properties.cpnNotice || blueprint.properties.cpnLightPatch || layerName === 'rooms' || layerName === 'hiddenRooms') { blueprint.width = width / mapScale; blueprint.height = height / mapScale; } @@ -158,13 +160,13 @@ const buildObject = (mapModule, layerName, mapObj) => { mapObjects.polyline(mapModule.size, blueprint, mapObj, mapScale); if (layerName === 'rooms') - buildRoom(mapModule, blueprint); + buildRoom(mapModule, blueprint, mapObj); else if (layerName === 'hiddenRooms') - buildHiddenRoom(mapModule, blueprint); + buildHiddenRoom(mapModule, blueprint, mapObj); else if (!clientObj) - buildRegularObject(mapModule, blueprint); + buildRegularObject(mapModule, blueprint, mapObj); else - buildClientObject(mapModule, blueprint); + buildClientObject(mapModule, blueprint, mapObj); }; module.exports = buildObject;