Browse Source

more work!

1870-zone-sprite-atlas
Shaun 2 years ago
parent
commit
6e9c2fe01c
13 changed files with 107 additions and 33 deletions
  1. +1
    -1
      src/server/clientComponents/lightPatch.js
  2. +17
    -7
      src/server/clientComponents/sprite.js
  3. +30
    -4
      src/server/clientComponents/textSprite.js
  4. +16
    -0
      src/server/clientComponents/transform.js
  5. +1
    -1
      src/server/components/extensions/socialCommands.js
  6. +21
    -0
      src/server/components/transform.js
  7. +1
    -1
      src/server/mods/feature-cards/config.js
  8. BIN
     
  9. BIN
     
  10. +0
    -2
      src/server/mods/feature-cards/index.js
  11. +2
    -2
      src/server/mods/feature-cards/recipes/recipes.js
  12. +17
    -14
      src/server/world/map/builders/object.js
  13. +1
    -1
      src/server/world/map/mapObjects.js

+ 1
- 1
src/server/clientComponents/lightPatch.js View File

@@ -75,7 +75,7 @@ define([
type: 'sprite',
sheetName: 'white',
cell: 0,
parent: rayContainer,
container: rayContainer,
alpha: ((1.0 - (j / h)) * 0.4),
tint: 0xffeb38,
blendMode: PIXI.BLEND_MODES.ADD


+ 17
- 7
src/server/clientComponents/sprite.js View File

@@ -18,29 +18,39 @@ define([
},

buildSprite: async function () {
const { layerName, sheetName, cell, parent: container } = this;
const { layerName, sheetName, cell, container } = this;

this.sprite = await renderer.buildSpriteAsync({
sheetName,
cell,
container,
layerName,
visible: false
spriteConfig: {
visible: false
}
});
},

update: function () {
const { sprite, obj } = this;

if (!sprite)
if (!sprite)
return;

let x = (obj.x * scale) + (obj.offsetX || 0);
let y = (obj.y * scale) + (obj.offsetY || 0);

const width = (obj?.transform?.width ?? obj.width) * scaleMult;
const height = (obj?.transform?.height ?? obj.height) * scaleMult;

y -= height;

Object.entries({
x: (obj.x * scale) + (obj.offsetX || 0),
y: (obj.y * scale) + (obj.offsetY || 0),
x,
y,
visible: obj.isVisible,
width: obj.width,
height: obj.height
width: width,
height: height
}).forEach(([k, v]) => {
if (sprite[k] !== v && v !== undefined)
sprite[k] = v;


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

@@ -11,28 +11,54 @@ define([

sprite: undefined,

position: 'under',

init: function (blueprint) {
this.buildSprite();
},

buildSprite: async function () {
const { layerName, text, parent: container } = this;
const { layerName, text, container } = this;

this.sprite = renderer.buildText({
this.sprite = renderer.buildTextSprite({
layerName,
container,
text
});
},

getPosition: function () {
const { obj: { x, y, height, offsetX, offsetY }, position, sprite } = this;

const width = this.obj.transform.width * scaleMult;
let rx = (x * scale);
let ry = (y * scale);

if (position === 'under') {
rx += (width / 2) - (sprite.width / 2);
ry += height;
}

if (offsetX)
rx += offsetX;

if (offsetY)
ry += offsetY;

return { x: rx, y: ry };
},

update: function () {
const { sprite, obj } = this;

if (!sprite)
return;

const { x, y } = this.getPosition();

Object.entries({
x: (obj.x * scale) + (obj.offsetX || 0),
y: (obj.y * scale) + (obj.offsetY || 0),
x,
y,
visible: obj.isVisible
}).forEach(([k, v]) => {
if (sprite[k] !== v && v !== undefined)


+ 16
- 0
src/server/clientComponents/transform.js View File

@@ -0,0 +1,16 @@
define([
'js/rendering/renderer'
], function (
renderer
) {
return {
type: 'transform',

width: scale,
height: scale,

init: function (blueprint) {
}
};
});

+ 1
- 1
src/server/components/extensions/socialCommands.js View File

@@ -109,7 +109,7 @@ module.exports = {
messageText = messageText.substr(1).split(' ');
let actionName = messageText.splice(0, 1)[0].toLowerCase();
actionName = Object.keys(commandRoles).find(a => (a.toLowerCase() === actionName));
if (!actionName) {
this.obj.socket.emit('events', {
onGetMessages: [{


+ 21
- 0
src/server/components/transform.js View File

@@ -0,0 +1,21 @@
module.exports = {
type: 'transform',

width: null,
height: null,

init: function (blueprint) {
this.width = blueprint.width;
this.height = blueprint.height;
},

simplify: function (self) {
const { width, height } = this;

return {
type: 'transform',
width,
height
};
}
};

+ 1
- 1
src/server/mods/feature-cards/config.js View File

@@ -8,7 +8,7 @@ module.exports = {
zoneConfig: {
name: 'Shady Dealer',
cell: 0,
sheetName: '$MODFOLDER$/images/mobs.png',
sheetName: 'server/mods/feature-cards/images/mobs.png',
components: {
cpnWorkbench: { type: 'gambling' }
}


BIN
View File


BIN
View File


+ 0
- 2
src/server/mods/feature-cards/index.js View File

@@ -19,8 +19,6 @@ module.exports = {
if (zoneName !== dealerZoneName)
return;

zoneConfig.sheetName = zoneConfig.sheetName.replace('$MODFOLDER$', this.folderName);

config.objects[dealerName] = zoneConfig;
},



+ 2
- 2
src/server/mods/feature-cards/recipes/recipes.js View File

@@ -64,8 +64,8 @@ module.exports = [{
name: '5 Random Idols',
description: '',
materials: [{
name: 'Tradesman\'s Pride',
quantity: 10
name: 'Magic Essence',
quantity: 1
}],
craftAction: idol.bind(null, {
rolls: 5


+ 17
- 14
src/server/world/map/builders/object.js View File

@@ -108,7 +108,7 @@ const buildObject = (mapModule, layerName, mapObj) => {
sheetName: sheetName !== undefined ? sheetName : cellInfo.sheetName,
cell: cell !== undefined ? cell : cellInfo.cell - 1,
x: x / mapScale,
y: (y / mapScale) - 1,
y: y / mapScale,
name: name,
layerName: layerName,
properties: getObjectifiedProperties(properties),
@@ -117,6 +117,16 @@ const buildObject = (mapModule, layerName, mapObj) => {

blueprint.id = blueprint.properties.id;

if (objZoneName !== name)
blueprint.objZoneName = objZoneName;

if (mapModule.zone) {
if ((mapModule.zone.objects) && (mapModule.zone.objects[objZoneName.toLowerCase()]))
extend(blueprint, mapModule.zone.objects[objZoneName.toLowerCase()]);
else if ((mapModule.zone.objects) && (mapModule.zone.mobs[objZoneName.toLowerCase()]))
extend(blueprint, mapModule.zone.mobs[objZoneName.toLowerCase()]);
}

if (blueprint.sheetName && blueprint.cell !== undefined) {
blueprint.properties.cpnSprite = {
cell: blueprint.cell,
@@ -129,29 +139,22 @@ const buildObject = (mapModule, layerName, mapObj) => {

delete blueprint.sheetName;
delete blueprint.cell;
}

if (objZoneName !== name)
blueprint.objZoneName = objZoneName;

if (mapModule.zone) {
if ((mapModule.zone.objects) && (mapModule.zone.objects[objZoneName.toLowerCase()]))
extend(blueprint, mapModule.zone.objects[objZoneName.toLowerCase()]);
else if ((mapModule.zone.objects) && (mapModule.zone.mobs[objZoneName.toLowerCase()]))
extend(blueprint, mapModule.zone.mobs[objZoneName.toLowerCase()]);
blueprint.properties.cpnTransform = {
width: mapObj.width,
height: mapObj.height
};
}

if (blueprint.blocking)
mapModule.collisionMap[blueprint.x][blueprint.y] = 1;

if ((blueprint.properties.cpnNotice) || (blueprint.properties.cpnLightPatch) || (layerName === 'rooms') || (layerName === 'hiddenRooms')) {
blueprint.y++;
blueprint.width = width / mapScale;
blueprint.height = height / mapScale;
} else if (width === 24)
blueprint.x++;
}

if (polyline)
if (blueprint.polyline)
mapObjects.polyline(mapModule.size, blueprint, mapObj, mapScale);

if (layerName === 'rooms')


+ 1
- 1
src/server/world/map/mapObjects.js View File

@@ -5,7 +5,7 @@ module.exports = {
let highX = 0;
let highY = 0;

blueprint.area = cell.polyline.map(function (v) {
blueprint.area = blueprint.polyline.map(function (v) {
let x = ~~((v.x + cell.x) / mapScale);
let y = ~~((v.y + cell.y) / mapScale);



Loading…
Cancel
Save