1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Initial support for blueprints (Buggy)

This commit is contained in:
tobspr
2020-05-27 14:30:59 +02:00
parent f5f08a08e2
commit 0cd324c82b
41 changed files with 633 additions and 77 deletions

View File

@@ -18,6 +18,10 @@ export class BeltComponent extends Component {
};
}
duplicateWithoutContents() {
return new BeltComponent({ direction: this.direction });
}
/**
*
* @param {object} param0

View File

@@ -54,6 +54,32 @@ export class ItemAcceptorComponent extends Component {
};
}
duplicateWithoutContents() {
const slotsCopy = [];
for (let i = 0; i < this.slots.length; ++i) {
const slot = this.slots[i];
slotsCopy.push({
pos: slot.pos.copy(),
directions: slot.directions.slice(),
});
}
const beltUnderlaysCopy = [];
for (let i = 0; i < this.beltUnderlays.length; ++i) {
const underlay = this.beltUnderlays[i];
beltUnderlaysCopy.push({
pos: underlay.pos.copy(),
direction: underlay.direction,
});
}
return new ItemAcceptorComponent({
slots: slotsCopy,
beltUnderlays: beltUnderlaysCopy,
animated: this.animated,
});
}
/**
*
* @param {object} param0

View File

@@ -32,6 +32,22 @@ export class ItemEjectorComponent extends Component {
};
}
duplicateWithoutContents() {
const slotsCopy = [];
for (let i = 0; i < this.slots.length; ++i) {
const slot = this.slots[i];
slotsCopy.push({
pos: slot.pos.copy(),
direction: slot.direction,
});
}
return new ItemEjectorComponent({
slots: slotsCopy,
instantEject: false,
});
}
/**
*
* @param {object} param0

View File

@@ -48,6 +48,13 @@ export class ItemProcessorComponent extends Component {
};
}
duplicateWithoutContents() {
return new ItemProcessorComponent({
processorType: this.type,
inputsPerCharge: this.inputsPerCharge,
});
}
/**
*
* @param {object} param0

View File

@@ -19,6 +19,12 @@ export class MinerComponent extends Component {
};
}
duplicateWithoutContents() {
return new MinerComponent({
chainable: this.chainable,
});
}
/**
*/
constructor({ chainable = false }) {

View File

@@ -8,4 +8,8 @@ export class ReplaceableMapEntityComponent extends Component {
static getId() {
return "ReplaceableMapEntity";
}
duplicateWithoutContents() {
return new ReplaceableMapEntityComponent();
}
}

View File

@@ -19,10 +19,23 @@ export class StaticMapEntityComponent extends Component {
rotation: types.float,
originalRotation: types.float,
spriteKey: types.nullable(types.string),
blueprintSpriteKey: types.string,
silhouetteColor: types.nullable(types.string),
};
}
duplicateWithoutContents() {
return new StaticMapEntityComponent({
origin: this.origin.copy(),
tileSize: this.tileSize.copy(),
rotation: this.rotation,
originalRotation: this.originalRotation,
spriteKey: this.spriteKey,
silhouetteColor: this.silhouetteColor,
blueprintSpriteKey: this.blueprintSpriteKey,
});
}
/**
*
* @param {object} param0
@@ -31,6 +44,7 @@ export class StaticMapEntityComponent extends Component {
* @param {number=} param0.rotation Rotation in degrees. Must be multiple of 90
* @param {number=} param0.originalRotation Original Rotation in degrees. Must be multiple of 90
* @param {string=} param0.spriteKey Optional sprite
* @param {string} param0.blueprintSpriteKey Blueprint sprite, required
* @param {string=} param0.silhouetteColor Optional silhouette color override
*/
constructor({
@@ -40,6 +54,7 @@ export class StaticMapEntityComponent extends Component {
originalRotation = 0,
spriteKey = null,
silhouetteColor = null,
blueprintSpriteKey = null,
}) {
super();
assert(
@@ -53,6 +68,7 @@ export class StaticMapEntityComponent extends Component {
this.rotation = rotation;
this.originalRotation = originalRotation;
this.silhouetteColor = silhouetteColor;
this.blueprintSpriteKey = blueprintSpriteKey;
}
/**
@@ -202,14 +218,25 @@ export class StaticMapEntityComponent extends Component {
* @param {AtlasSprite} sprite
* @param {number=} extrudePixels How many pixels to extrude the sprite
* @param {boolean=} clipping Whether to clip
* @param {Vector=} overridePosition Whether to drwa the entity at a different location
*/
drawSpriteOnFullEntityBounds(parameters, sprite, extrudePixels = 0, clipping = true) {
const worldX = this.origin.x * globalConfig.tileSize;
const worldY = this.origin.y * globalConfig.tileSize;
if (!this.shouldBeDrawn(parameters)) {
drawSpriteOnFullEntityBounds(
parameters,
sprite,
extrudePixels = 0,
clipping = true,
overridePosition = null
) {
if (!this.shouldBeDrawn(parameters) && !overridePosition) {
return;
}
let worldX = this.origin.x * globalConfig.tileSize;
let worldY = this.origin.y * globalConfig.tileSize;
if (overridePosition) {
worldX = overridePosition.x * globalConfig.tileSize;
worldY = overridePosition.y * globalConfig.tileSize;
}
if (this.rotation === 0) {
// Early out, is faster

View File

@@ -19,6 +19,10 @@ export class StorageComponent extends Component {
};
}
duplicateWithoutContents() {
return new StorageComponent({ maximumStorage: this.maximumStorage });
}
/**
* @param {object} param0
* @param {number=} param0.maximumStorage How much this storage can hold

View File

@@ -23,6 +23,13 @@ export class UndergroundBeltComponent extends Component {
};
}
duplicateWithoutContents() {
return new UndergroundBeltComponent({
mode: this.mode,
tier: this.tier,
});
}
/**
*
* @param {object} param0

View File

@@ -8,4 +8,8 @@ export class UnremovableComponent extends Component {
static getSchema() {
return {};
}
duplicateWithoutContents() {
return new UnremovableComponent();
}
}