refactor: don't early out client/server
This commit is contained in:
parent
46f557626a
commit
ae21ba05a6
|
@ -113,21 +113,20 @@ export class Tool extends decorate(Trait) {
|
|||
|
||||
onWielderActiveSlotIndexChanged() {
|
||||
this.calculateTargets();
|
||||
if (AVOCADO_SERVER) {
|
||||
return;
|
||||
}
|
||||
const wielder = this.entity.wielder;
|
||||
if (!wielder) {
|
||||
return;
|
||||
}
|
||||
if (!wielder.is('visible')) {
|
||||
return;
|
||||
}
|
||||
if (this.entity === wielder.itemInActiveSlot()) {
|
||||
wielder.container.addChild(this.guidePrimitives);
|
||||
}
|
||||
else {
|
||||
wielder.container.removeChild(this.guidePrimitives);
|
||||
if (AVOCADO_CLIENT) {
|
||||
const wielder = this.entity.wielder;
|
||||
if (!wielder) {
|
||||
return;
|
||||
}
|
||||
if (!wielder.is('visible')) {
|
||||
return;
|
||||
}
|
||||
if (this.entity === wielder.itemInActiveSlot()) {
|
||||
wielder.container.addChild(this.guidePrimitives);
|
||||
}
|
||||
else {
|
||||
wielder.container.removeChild(this.guidePrimitives);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,50 +141,48 @@ export class Tool extends decorate(Trait) {
|
|||
}
|
||||
|
||||
renderPrimitives() {
|
||||
if (AVOCADO_SERVER) {
|
||||
return;
|
||||
}
|
||||
this.guidePrimitives.clear();
|
||||
const wielder = this.entity.wielder;
|
||||
if (!wielder) {
|
||||
return;
|
||||
}
|
||||
if (!wielder.is('layered')) {
|
||||
return;
|
||||
}
|
||||
const layer = wielder.layer;
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
const tile = Vector.floor(wielder.tile);
|
||||
const tileset = layer.tileset;
|
||||
if (!tileset) {
|
||||
return;
|
||||
}
|
||||
const tileSize = tileset.tileSize;
|
||||
for (let i = 0; i < this.targets.length; ++i) {
|
||||
const target = this.targets[i];
|
||||
const relativeTarget = Vector.sub(target, tile);
|
||||
const scaledRelativeTarget = Vector.mul(relativeTarget, tileSize);
|
||||
this.guidePrimitives.drawRectangle(
|
||||
Rectangle.compose(scaledRelativeTarget, tileSize),
|
||||
Primitives.lineStyle(new Color(255, 255, 255), 1),
|
||||
);
|
||||
if (AVOCADO_CLIENT) {
|
||||
this.guidePrimitives.clear();
|
||||
const wielder = this.entity.wielder;
|
||||
if (!wielder) {
|
||||
return;
|
||||
}
|
||||
if (!wielder.is('layered')) {
|
||||
return;
|
||||
}
|
||||
const layer = wielder.layer;
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
const tile = Vector.floor(wielder.tile);
|
||||
const tileset = layer.tileset;
|
||||
if (!tileset) {
|
||||
return;
|
||||
}
|
||||
const tileSize = tileset.tileSize;
|
||||
for (let i = 0; i < this.targets.length; ++i) {
|
||||
const target = this.targets[i];
|
||||
const relativeTarget = Vector.sub(target, tile);
|
||||
const scaledRelativeTarget = Vector.mul(relativeTarget, tileSize);
|
||||
this.guidePrimitives.drawRectangle(
|
||||
Rectangle.compose(scaledRelativeTarget, tileSize),
|
||||
Primitives.lineStyle(new Color(255, 255, 255), 1),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositionPrimitives() {
|
||||
if (AVOCADO_SERVER) {
|
||||
return;
|
||||
if (AVOCADO_CLIENT) {
|
||||
const wielder = this.entity.wielder;
|
||||
if (!wielder) {
|
||||
return;
|
||||
}
|
||||
if (!wielder.is('layered')) {
|
||||
return;
|
||||
}
|
||||
this.guidePrimitives.position = Vector.scale(wielder.tileOffset, -1);
|
||||
}
|
||||
const wielder = this.entity.wielder;
|
||||
if (!wielder) {
|
||||
return;
|
||||
}
|
||||
if (!wielder.is('layered')) {
|
||||
return;
|
||||
}
|
||||
this.guidePrimitives.position = Vector.scale(wielder.tileOffset, -1);
|
||||
}
|
||||
|
||||
listeners() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user