Browse Source

more work

1870-zone-sprite-atlas
Shaun 2 years ago
parent
commit
01895f7663
4 changed files with 26 additions and 17 deletions
  1. +1
    -1
      src/client/js/objects/objects.js
  2. +6
    -3
      src/server/clientComponents/sprite.js
  3. +8
    -4
      src/server/clientComponents/textSprite.js
  4. +11
    -9
      src/server/world/map/builders/object.js

+ 1
- 1
src/client/js/objects/objects.js View File

@@ -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);


+ 6
- 3
src/server/clientComponents/sprite.js View File

@@ -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);
}
};
});

+ 8
- 4
src/server/clientComponents/textSprite.js View File

@@ -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);
}
};
});

+ 11
- 9
src/server/world/map/builders/object.js View File

@@ -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;

Loading…
Cancel
Save