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} h
|
||||
* @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) {
|
||||
assert(parameters instanceof DrawParameters, "Not a valid context");
|
||||
assert(!!w && w > 0, "Not a valid width:" + w);
|
||||
@ -215,6 +216,7 @@ export class AtlasSprite extends BaseSprite {
|
||||
destH = intersection.h;
|
||||
}
|
||||
|
||||
const extrudeValue = extrude ? EXTRUDE : 0;
|
||||
parameters.context.drawImage(
|
||||
link.atlas,
|
||||
|
||||
@ -227,10 +229,10 @@ export class AtlasSprite extends BaseSprite {
|
||||
srcH,
|
||||
|
||||
// dest pos and size
|
||||
destX - EXTRUDE,
|
||||
destY - EXTRUDE,
|
||||
destW + 2 * EXTRUDE,
|
||||
destH + 2 * EXTRUDE
|
||||
destX - extrudeValue,
|
||||
destY - extrudeValue,
|
||||
destW + 2 * extrudeValue,
|
||||
destH + 2 * extrudeValue
|
||||
);
|
||||
}
|
||||
|
||||
@ -242,8 +244,9 @@ export class AtlasSprite extends BaseSprite {
|
||||
* @param {number} w
|
||||
* @param {number} h
|
||||
* @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) {
|
||||
assert(parameters instanceof DrawParameters, "Not a valid context");
|
||||
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 srcH = link.packedH * clipRect.h;
|
||||
|
||||
const extrudeValue = extrude ? EXTRUDE : 0;
|
||||
parameters.context.drawImage(
|
||||
link.atlas,
|
||||
|
||||
@ -291,10 +295,10 @@ export class AtlasSprite extends BaseSprite {
|
||||
srcH,
|
||||
|
||||
// dest pos and size
|
||||
destX - EXTRUDE,
|
||||
destY - EXTRUDE,
|
||||
destW + 2 * EXTRUDE,
|
||||
destH + 2 * EXTRUDE
|
||||
destX - extrudeValue,
|
||||
destY - extrudeValue,
|
||||
destW + 2 * extrudeValue,
|
||||
destH + 2 * extrudeValue
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -255,8 +255,15 @@ export class StaticMapEntityComponent extends Component {
|
||||
* @param {AtlasSprite} sprite
|
||||
* @param {number=} extrudePixels How many pixels to extrude the sprite
|
||||
* @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) {
|
||||
return;
|
||||
}
|
||||
@ -276,7 +283,9 @@ export class StaticMapEntityComponent extends Component {
|
||||
worldX - extrudePixels * size.x,
|
||||
worldY - extrudePixels * size.y,
|
||||
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 {
|
||||
const rotationCenterX = worldX + globalConfig.halfTileSize;
|
||||
@ -290,7 +299,8 @@ export class StaticMapEntityComponent extends Component {
|
||||
-globalConfig.halfTileSize - extrudePixels * size.y,
|
||||
globalConfig.tileSize * size.x + 2 * extrudePixels * size.x,
|
||||
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.translate(-rotationCenterX, -rotationCenterY);
|
||||
|
@ -617,7 +617,7 @@ export class WireSystem extends GameSystem {
|
||||
assert(sprite, "Unknown wire type: " + wireType);
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
parameters.context.globalAlpha = opacity;
|
||||
staticComp.drawSpriteOnBoundsClipped(parameters, sprite, 0);
|
||||
staticComp.drawSpriteOnBoundsClipped(parameters, sprite, 0, null, false);
|
||||
|
||||
// DEBUG Rendering
|
||||
if (G_IS_DEV && globalConfig.debug.renderWireRotations) {
|
||||
|
Loading…
Reference in New Issue
Block a user