mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Merge 54fa648238
into 958d400ff5
This commit is contained in:
commit
e0c783add5
@ -155,8 +155,9 @@ export class AtlasSprite extends BaseSprite {
|
|||||||
* @param {number} w
|
* @param {number} w
|
||||||
* @param {number} h
|
* @param {number} h
|
||||||
* @param {boolean=} clipping Whether to perform culling
|
* @param {boolean=} clipping Whether to perform culling
|
||||||
|
* @param {boolean=} extrude Whether to extrude
|
||||||
*/
|
*/
|
||||||
drawCached(parameters, x, y, w = null, h = null, clipping = true) {
|
drawCached(parameters, x, y, w = null, h = null, clipping = true, extrude = true) {
|
||||||
if (G_IS_DEV) {
|
if (G_IS_DEV) {
|
||||||
assert(parameters instanceof DrawParameters, "Not a valid context");
|
assert(parameters instanceof DrawParameters, "Not a valid context");
|
||||||
assert(!!w && w > 0, "Not a valid width:" + w);
|
assert(!!w && w > 0, "Not a valid width:" + w);
|
||||||
@ -215,6 +216,7 @@ export class AtlasSprite extends BaseSprite {
|
|||||||
destH = intersection.h;
|
destH = intersection.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const extrudeValue = extrude ? EXTRUDE : 0;
|
||||||
parameters.context.drawImage(
|
parameters.context.drawImage(
|
||||||
link.atlas,
|
link.atlas,
|
||||||
|
|
||||||
@ -227,10 +229,10 @@ export class AtlasSprite extends BaseSprite {
|
|||||||
srcH,
|
srcH,
|
||||||
|
|
||||||
// dest pos and size
|
// dest pos and size
|
||||||
destX - EXTRUDE,
|
destX - extrudeValue,
|
||||||
destY - EXTRUDE,
|
destY - extrudeValue,
|
||||||
destW + 2 * EXTRUDE,
|
destW + 2 * extrudeValue,
|
||||||
destH + 2 * EXTRUDE
|
destH + 2 * extrudeValue
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +244,9 @@ export class AtlasSprite extends BaseSprite {
|
|||||||
* @param {number} w
|
* @param {number} w
|
||||||
* @param {number} h
|
* @param {number} h
|
||||||
* @param {Rectangle=} clipRect The rectangle in local space (0 ... 1) to draw of the image
|
* @param {Rectangle=} clipRect The rectangle in local space (0 ... 1) to draw of the image
|
||||||
|
* @param {boolean=} extrude Whether to extrude
|
||||||
*/
|
*/
|
||||||
drawCachedWithClipRect(parameters, x, y, w = null, h = null, clipRect = FULL_CLIP_RECT) {
|
drawCachedWithClipRect(parameters, x, y, w = null, h = null, clipRect = FULL_CLIP_RECT, extrude = true) {
|
||||||
if (G_IS_DEV) {
|
if (G_IS_DEV) {
|
||||||
assert(parameters instanceof DrawParameters, "Not a valid context");
|
assert(parameters instanceof DrawParameters, "Not a valid context");
|
||||||
assert(!!w && w > 0, "Not a valid width:" + w);
|
assert(!!w && w > 0, "Not a valid width:" + w);
|
||||||
@ -279,6 +282,7 @@ export class AtlasSprite extends BaseSprite {
|
|||||||
let srcW = link.packedW * clipRect.w;
|
let srcW = link.packedW * clipRect.w;
|
||||||
let srcH = link.packedH * clipRect.h;
|
let srcH = link.packedH * clipRect.h;
|
||||||
|
|
||||||
|
const extrudeValue = extrude ? EXTRUDE : 0;
|
||||||
parameters.context.drawImage(
|
parameters.context.drawImage(
|
||||||
link.atlas,
|
link.atlas,
|
||||||
|
|
||||||
@ -291,10 +295,10 @@ export class AtlasSprite extends BaseSprite {
|
|||||||
srcH,
|
srcH,
|
||||||
|
|
||||||
// dest pos and size
|
// dest pos and size
|
||||||
destX - EXTRUDE,
|
destX - extrudeValue,
|
||||||
destY - EXTRUDE,
|
destY - extrudeValue,
|
||||||
destW + 2 * EXTRUDE,
|
destW + 2 * extrudeValue,
|
||||||
destH + 2 * EXTRUDE
|
destH + 2 * extrudeValue
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +255,15 @@ export class StaticMapEntityComponent extends Component {
|
|||||||
* @param {AtlasSprite} sprite
|
* @param {AtlasSprite} sprite
|
||||||
* @param {number=} extrudePixels How many pixels to extrude the sprite
|
* @param {number=} extrudePixels How many pixels to extrude the sprite
|
||||||
* @param {Vector=} overridePosition Whether to drwa the entity at a different location
|
* @param {Vector=} overridePosition Whether to drwa the entity at a different location
|
||||||
|
* @param {boolean=} extrude Whether to extrude
|
||||||
*/
|
*/
|
||||||
drawSpriteOnBoundsClipped(parameters, sprite, extrudePixels = 0, overridePosition = null) {
|
drawSpriteOnBoundsClipped(
|
||||||
|
parameters,
|
||||||
|
sprite,
|
||||||
|
extrudePixels = 0,
|
||||||
|
overridePosition = null,
|
||||||
|
extrude = true
|
||||||
|
) {
|
||||||
if (!this.shouldBeDrawn(parameters) && !overridePosition) {
|
if (!this.shouldBeDrawn(parameters) && !overridePosition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -276,7 +283,9 @@ export class StaticMapEntityComponent extends Component {
|
|||||||
worldX - extrudePixels * size.x,
|
worldX - extrudePixels * size.x,
|
||||||
worldY - extrudePixels * size.y,
|
worldY - extrudePixels * size.y,
|
||||||
globalConfig.tileSize * size.x + 2 * extrudePixels * size.x,
|
globalConfig.tileSize * size.x + 2 * extrudePixels * size.x,
|
||||||
globalConfig.tileSize * size.y + 2 * extrudePixels * size.y
|
globalConfig.tileSize * size.y + 2 * extrudePixels * size.y,
|
||||||
|
true,
|
||||||
|
extrude
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const rotationCenterX = worldX + globalConfig.halfTileSize;
|
const rotationCenterX = worldX + globalConfig.halfTileSize;
|
||||||
@ -290,7 +299,8 @@ export class StaticMapEntityComponent extends Component {
|
|||||||
-globalConfig.halfTileSize - extrudePixels * size.y,
|
-globalConfig.halfTileSize - extrudePixels * size.y,
|
||||||
globalConfig.tileSize * size.x + 2 * extrudePixels * size.x,
|
globalConfig.tileSize * size.x + 2 * extrudePixels * size.x,
|
||||||
globalConfig.tileSize * size.y + 2 * extrudePixels * size.y,
|
globalConfig.tileSize * size.y + 2 * extrudePixels * size.y,
|
||||||
false // no clipping possible here
|
false, // no clipping possible here
|
||||||
|
extrude
|
||||||
);
|
);
|
||||||
parameters.context.rotate(-Math.radians(this.rotation));
|
parameters.context.rotate(-Math.radians(this.rotation));
|
||||||
parameters.context.translate(-rotationCenterX, -rotationCenterY);
|
parameters.context.translate(-rotationCenterX, -rotationCenterY);
|
||||||
|
@ -617,7 +617,7 @@ export class WireSystem extends GameSystem {
|
|||||||
assert(sprite, "Unknown wire type: " + wireType);
|
assert(sprite, "Unknown wire type: " + wireType);
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
parameters.context.globalAlpha = opacity;
|
parameters.context.globalAlpha = opacity;
|
||||||
staticComp.drawSpriteOnBoundsClipped(parameters, sprite, 0);
|
staticComp.drawSpriteOnBoundsClipped(parameters, sprite, 0, null, false);
|
||||||
|
|
||||||
// DEBUG Rendering
|
// DEBUG Rendering
|
||||||
if (G_IS_DEV && globalConfig.debug.renderWireRotations) {
|
if (G_IS_DEV && globalConfig.debug.renderWireRotations) {
|
||||||
|
Loading…
Reference in New Issue
Block a user