1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Minor fixes

This commit is contained in:
tobspr 2020-10-08 10:41:06 +02:00
parent c65c955984
commit 7b01db5dae
8 changed files with 1658 additions and 1642 deletions

View File

@ -7,6 +7,7 @@ import { BeltComponent } from "../components/belt";
import { Entity } from "../entity"; import { Entity } from "../entity";
import { MetaBuilding } from "../meta_building"; import { MetaBuilding } from "../meta_building";
import { GameRoot } from "../root"; import { GameRoot } from "../root";
import { THEME } from "../theme";
export const arrayBeltVariantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right]; export const arrayBeltVariantToRotation = [enumDirection.top, enumDirection.left, enumDirection.right];
@ -22,7 +23,7 @@ export class MetaBeltBuilding extends MetaBuilding {
} }
getSilhouetteColor() { getSilhouetteColor() {
return "#777"; return THEME.map.chunkOverview.beltColor;
} }
getPlacementSound() { getPlacementSound() {

View File

@ -26,7 +26,7 @@ export class ItemEjectorComponent extends Component {
static getSchema() { static getSchema() {
// The cachedDestSlot, cachedTargetEntity fields are not serialized. // The cachedDestSlot, cachedTargetEntity fields are not serialized.
return { return {
slots: types.array( slots: types.fixedSizeArray(
types.structured({ types.structured({
item: types.nullable(typeItemSingleton), item: types.nullable(typeItemSingleton),
progress: types.float, progress: types.float,

View File

@ -31,7 +31,7 @@ export class WiredPinsComponent extends Component {
static getSchema() { static getSchema() {
return { return {
slots: types.array( slots: types.fixedSizeArray(
types.structured({ types.structured({
value: types.nullable(typeItemSingleton), value: types.nullable(typeItemSingleton),
}) })

View File

@ -32,7 +32,8 @@
}, },
"chunkOverview": { "chunkOverview": {
"empty": "#444856", "empty": "#444856",
"filled": "#646b7d" "filled": "#646b7d",
"beltColor": "#9096a3"
}, },
"wires": { "wires": {

View File

@ -33,7 +33,8 @@
"chunkOverview": { "chunkOverview": {
"empty": "#a6afbb", "empty": "#a6afbb",
"filled": "#c5ccd6" "filled": "#c5ccd6",
"beltColor": "#777"
}, },
"wires": { "wires": {

View File

@ -96,6 +96,13 @@ export const types = {
return new TypeArray(innerType); return new TypeArray(innerType);
}, },
/**
* @param {BaseDataType} innerType
*/
fixedSizeArray(innerType) {
return new TypeArray(innerType, true);
},
/** /**
* @param {SingletonFactoryTemplate<*>} innerType * @param {SingletonFactoryTemplate<*>} innerType
*/ */

View File

@ -122,7 +122,7 @@ export class BaseDataType {
"serialization verify failed: " + "serialization verify failed: " +
errorCode + errorCode +
" [value " + " [value " +
JSON.stringify(value).substr(0, 100) + (JSON.stringify(value) || "").substr(0, 100) +
"]" "]"
); );
} }
@ -859,8 +859,9 @@ export class TypeArray extends BaseDataType {
/** /**
* @param {BaseDataType} innerType * @param {BaseDataType} innerType
*/ */
constructor(innerType) { constructor(innerType, fixedSize = false) {
super(); super();
this.fixedSize = fixedSize;
this.innerType = innerType; this.innerType = innerType;
} }
@ -887,7 +888,9 @@ export class TypeArray extends BaseDataType {
targetObject[targetKey] = destination = new Array(value.length); targetObject[targetKey] = destination = new Array(value.length);
} }
for (let i = 0; i < value.length; ++i) { const size = this.fixedSize ? Math.min(value.length, destination.length) : value.length;
for (let i = 0; i < size; ++i) {
const errorStatus = this.innerType.deserializeWithVerify(value[i], destination, i, root); const errorStatus = this.innerType.deserializeWithVerify(value[i], destination, i, root);
if (errorStatus) { if (errorStatus) {
return errorStatus; return errorStatus;

View File

@ -80,7 +80,10 @@ export class SerializerInternal {
for (const componentId in data) { for (const componentId in data) {
if (!entity.components[componentId]) { if (!entity.components[componentId]) {
if (G_IS_DEV && !globalConfig.debug.disableSlowAsserts) { if (G_IS_DEV && !globalConfig.debug.disableSlowAsserts) {
logger.warn("Entity no longer has component:", componentId); // @ts-ignore
if (++window.componentWarningsShown < 100) {
logger.warn("Entity no longer has component:", componentId);
}
} }
continue; continue;
} }