mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
New building sprites
This commit is contained in:
@@ -20,7 +20,7 @@ export class MetaHubBuilding extends MetaBuilding {
|
||||
return "#eb5555";
|
||||
}
|
||||
|
||||
isRotateable() {
|
||||
getIsRotateable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export class MetaLeverBuilding extends MetaBuilding {
|
||||
return true;
|
||||
}
|
||||
|
||||
isRotateable() {
|
||||
getIsRotateable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ export class MetaLogicGateBuilding extends MetaBuilding {
|
||||
];
|
||||
}
|
||||
|
||||
getRenderPins() {
|
||||
// We already have it included
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Entity} entity
|
||||
|
||||
@@ -20,7 +20,7 @@ export class MetaTrashBuilding extends MetaBuilding {
|
||||
super("trash");
|
||||
}
|
||||
|
||||
isRotateable(variant) {
|
||||
getIsRotateable(variant) {
|
||||
return variant !== defaultBuildingVariant;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export class MetaWireTunnelBuilding extends MetaBuilding {
|
||||
return true;
|
||||
}
|
||||
|
||||
isRotateable() {
|
||||
getIsRotateable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ export class MetaBuilding {
|
||||
* @param {string} variant
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isRotateable(variant) {
|
||||
getIsRotateable(variant) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -172,6 +172,14 @@ export class MetaBuilding {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should return false if the pins are already included in the sprite of the building
|
||||
* @returns {boolean}
|
||||
*/
|
||||
getRenderPins() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the entity without placing it
|
||||
* @param {object} param0
|
||||
@@ -225,7 +233,7 @@ export class MetaBuilding {
|
||||
* @return {{ rotation: number, rotationVariant: number, connectedEntities?: Array<Entity> }}
|
||||
*/
|
||||
computeOptimalDirectionAndRotationVariantAtTile({ root, tile, rotation, variant, layer }) {
|
||||
if (!this.isRotateable(variant)) {
|
||||
if (!this.getIsRotateable(variant)) {
|
||||
return {
|
||||
rotation: 0,
|
||||
rotationVariant: 0,
|
||||
|
||||
@@ -169,26 +169,28 @@ export class WiredPinsSystem extends GameSystemWithFilter {
|
||||
const tile = staticComp.localTileToWorld(slot.pos);
|
||||
|
||||
const worldPos = tile.toWorldSpaceCenterOfTile();
|
||||
|
||||
const effectiveRotation = Math.radians(
|
||||
staticComp.rotation + enumDirectionToAngle[slot.direction]
|
||||
);
|
||||
drawRotatedSprite({
|
||||
parameters,
|
||||
sprite: this.pinSprites[slot.type],
|
||||
x: worldPos.x,
|
||||
y: worldPos.y,
|
||||
angle: effectiveRotation,
|
||||
size: globalConfig.tileSize + 2,
|
||||
offsetX: 0,
|
||||
offsetY: 0,
|
||||
});
|
||||
|
||||
if (staticComp.getMetaBuilding().getRenderPins()) {
|
||||
drawRotatedSprite({
|
||||
parameters,
|
||||
sprite: this.pinSprites[slot.type],
|
||||
x: worldPos.x,
|
||||
y: worldPos.y,
|
||||
angle: effectiveRotation,
|
||||
size: globalConfig.tileSize + 2,
|
||||
offsetX: 0,
|
||||
offsetY: 0,
|
||||
});
|
||||
}
|
||||
|
||||
// Draw contained item to visualize whats emitted
|
||||
const value = slot.value;
|
||||
if (value) {
|
||||
const offset = new Vector(0, -5).rotated(effectiveRotation);
|
||||
value.draw(worldPos.x + offset.x, worldPos.y + offset.y, parameters, 12);
|
||||
const offset = new Vector(0, -9).rotated(effectiveRotation);
|
||||
value.draw(worldPos.x + offset.x, worldPos.y + offset.y, parameters, 9);
|
||||
}
|
||||
|
||||
// Debug view
|
||||
|
||||
Reference in New Issue
Block a user