mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Refactor static map entity component to store building metaclass
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Loader } from "../../core/loader";
|
||||
import { formatItemsPerSecond } from "../../core/utils";
|
||||
import { enumAngleToDirection, enumDirection, Vector } from "../../core/vector";
|
||||
import { SOUNDS } from "../../platform/sound";
|
||||
@@ -40,6 +39,10 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
|
||||
return SOUNDS.placeBelt;
|
||||
}
|
||||
|
||||
getSprite() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the entity at the given location
|
||||
* @param {Entity} entity
|
||||
@@ -88,7 +91,6 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
|
||||
updateVariants(entity, rotationVariant) {
|
||||
entity.components.Belt.direction = arrayBeltVariantToRotation[rotationVariant];
|
||||
entity.components.ItemEjector.slots[0].direction = arrayBeltVariantToRotation[rotationVariant];
|
||||
entity.components.StaticMapEntity.spriteKey = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,11 @@ export class MetaHubBuilding extends MetaBuilding {
|
||||
return null;
|
||||
}
|
||||
|
||||
getSprite() {
|
||||
// We render it ourself
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the entity at the given location
|
||||
* @param {Entity} entity
|
||||
@@ -41,9 +46,6 @@ export class MetaHubBuilding extends MetaBuilding {
|
||||
})
|
||||
);
|
||||
|
||||
// We render the sprite ourself
|
||||
entity.components.StaticMapEntity.spriteKey = null;
|
||||
|
||||
entity.addComponent(new UnremovableComponent());
|
||||
entity.addComponent(
|
||||
new ItemAcceptorComponent({
|
||||
|
||||
@@ -71,6 +71,10 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
|
||||
return super.getAvailableVariants(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} rotationVariant
|
||||
* @param {string} variant
|
||||
*/
|
||||
getPreviewSprite(rotationVariant, variant) {
|
||||
let suffix = "";
|
||||
if (variant !== defaultBuildingVariant) {
|
||||
@@ -87,6 +91,10 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} rotationVariant
|
||||
* @param {string} variant
|
||||
*/
|
||||
getBlueprintSprite(rotationVariant, variant) {
|
||||
let suffix = "";
|
||||
if (variant !== defaultBuildingVariant) {
|
||||
@@ -103,6 +111,14 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} rotationVariant
|
||||
* @param {string} variant
|
||||
*/
|
||||
getSprite(rotationVariant, variant) {
|
||||
return this.getPreviewSprite(rotationVariant, variant);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {GameRoot} root
|
||||
*/
|
||||
@@ -201,10 +217,6 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
|
||||
*/
|
||||
updateVariants(entity, rotationVariant, variant) {
|
||||
entity.components.UndergroundBelt.tier = enumUndergroundBeltVariantToTier[variant];
|
||||
entity.components.StaticMapEntity.spriteKey = this.getPreviewSprite(
|
||||
rotationVariant,
|
||||
variant
|
||||
).spriteName;
|
||||
|
||||
switch (arrayUndergroundRotationVariantToMode[rotationVariant]) {
|
||||
case enumUndergroundBeltMode.sender: {
|
||||
|
||||
Reference in New Issue
Block a user