Optimize performance

This commit is contained in:
schmelczerandras 2020-10-26 14:18:36 +01:00
parent e4cd3284b7
commit b8ef90c100
31 changed files with 319 additions and 206 deletions

View file

@ -13,7 +13,7 @@ const redPlanetColor = redColor;
export const settings = {
lightCutoffDistance: 600,
physicsMaxStep: 2,
physicsMaxStep: 8,
maxVelocityX: 1000,
maxVelocityY: 1000,
radiusSteps: 500,
@ -33,7 +33,7 @@ export const settings = {
playerMaxStrength: 80,
endGameDeltaScaling: 4,
playerDiedTimeout: 5,
playerStrengthRegenerationPerSeconds: 40,
playerStrengthRegenerationPerSeconds: 60,
projectileMaxStrength: 40,
projectileSpeed: 4000,
projectileMaxBounceCount: 1,

View file

@ -1,7 +1,7 @@
import { serializableMapping } from './serializable-mapping';
export const deserialize = (json: string): any => {
return JSON.parse(json, (k, v) => {
return JSON.parse(json, (_, v) => {
if (v !== null && Object.prototype.hasOwnProperty.call(v, '0')) {
const possibleType = v[0];
const overridableConstructor = serializableMapping.get(possibleType);

View file

@ -1,7 +1,9 @@
export const serialize = (object: any): string => {
return JSON.stringify(object, (_, value) => {
if (value?.__serializable_type) {
return [value.__serializable_type, ...value.toArray()];
const props = value.toArray() as Array<any>;
props.unshift(value.__serializable_type);
return props;
}
return value?.toFixed ? Number(value.toFixed(3)) : value;
});