mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Fix multiple issues regarding saving / restoring games
This commit is contained in:
parent
0b9b35b79e
commit
34ef26b289
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c35f217cbc3c687e3ee7c25a410ce953b38637e106b8ea348caeca55bfeac394
|
||||
size 70555
|
||||
oid sha256:f2b3fec64e5d005a31c0a5876507c881b6b7f0e59d4f03bc97f594f33943b4ce
|
||||
size 70541
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -52,7 +52,8 @@ export class Blueprint {
|
||||
}
|
||||
|
||||
averagePosition.divideScalarInplace(uids.length);
|
||||
const blueprintOrigin = averagePosition.floor();
|
||||
const blueprintOrigin = averagePosition.subScalars(0.5, 0.5).floor();
|
||||
|
||||
for (let i = 0; i < uids.length; ++i) {
|
||||
newEntities[i].components.StaticMapEntity.origin.subInplace(blueprintOrigin);
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ export class MetaEnergyGenerator extends MetaBuilding {
|
||||
layer: enumLayer.wires,
|
||||
},
|
||||
],
|
||||
instantEject: true,
|
||||
})
|
||||
);
|
||||
|
||||
@ -88,7 +89,7 @@ export class MetaEnergyGenerator extends MetaBuilding {
|
||||
new EnergyGeneratorComponent({
|
||||
// Set by the energy generator system later
|
||||
requiredKey: null,
|
||||
acceptorSlotIndex: 2,
|
||||
wasteAcceptorSlotIndex: 2,
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -12,16 +12,27 @@ export class EnergyConsumerComponent extends Component {
|
||||
return {
|
||||
bufferSize: types.float,
|
||||
perCharge: types.float,
|
||||
stored: types.float,
|
||||
piledOutput: types.float,
|
||||
batteryPosition: types.vector,
|
||||
energyType: types.enum(enumItemType),
|
||||
wasteType: types.enum(enumItemType),
|
||||
acceptorSlotIndex: types.uint,
|
||||
ejectorSlotIndex: types.uint,
|
||||
|
||||
stored: types.float,
|
||||
piledOutput: types.float,
|
||||
};
|
||||
}
|
||||
|
||||
duplicateWithoutContents() {
|
||||
return new EnergyConsumerComponent({
|
||||
bufferSize: this.bufferSize,
|
||||
perCharge: this.perCharge,
|
||||
batteryPosition: this.batteryPosition.copy(),
|
||||
acceptorSlotIndex: this.acceptorSlotIndex,
|
||||
ejectorSlotIndex: this.ejectorSlotIndex,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
|
@ -3,7 +3,7 @@ import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { ShapeItem } from "../items/shape_item";
|
||||
|
||||
const maxQueueSize = 20;
|
||||
const maxQueueSize = 4;
|
||||
|
||||
export class EnergyGeneratorComponent extends Component {
|
||||
static getId() {
|
||||
@ -14,16 +14,24 @@ export class EnergyGeneratorComponent extends Component {
|
||||
return {
|
||||
requiredKey: types.nullable(types.string),
|
||||
itemsInQueue: types.uint,
|
||||
wasteAcceptorSlotIndex: types.uint,
|
||||
};
|
||||
}
|
||||
|
||||
duplicateWithoutContents() {
|
||||
return new EnergyGeneratorComponent({
|
||||
requiredKey: null,
|
||||
wasteAcceptorSlotIndex: this.wasteAcceptorSlotIndex,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {string} param0.requiredKey Which shape this generator needs, can be null if not computed yet
|
||||
* @param {number} param0.acceptorSlotIndex
|
||||
* @param {string=} param0.requiredKey Which shape this generator needs, can be null if not computed yet
|
||||
* @param {number} param0.wasteAcceptorSlotIndex Which slot accepts the waste
|
||||
*/
|
||||
constructor({ requiredKey, acceptorSlotIndex = 0 }) {
|
||||
constructor({ requiredKey, wasteAcceptorSlotIndex = 0 }) {
|
||||
super();
|
||||
this.requiredKey = requiredKey;
|
||||
|
||||
@ -37,7 +45,7 @@ export class EnergyGeneratorComponent extends Component {
|
||||
* Stores which slot accepts the waste
|
||||
* @type {number}
|
||||
*/
|
||||
this.acceptorSlotIndex = acceptorSlotIndex;
|
||||
this.wasteAcceptorSlotIndex = wasteAcceptorSlotIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +54,7 @@ export class EnergyGeneratorComponent extends Component {
|
||||
* @param {number} slot
|
||||
*/
|
||||
tryTakeItem(item, slot) {
|
||||
if (slot === this.acceptorSlotIndex) {
|
||||
if (slot === this.wasteAcceptorSlotIndex) {
|
||||
// this is the acceptor slot on the wires layer
|
||||
// just destroy it
|
||||
return true;
|
||||
|
@ -48,6 +48,20 @@ export class WiredPinsComponent extends Component {
|
||||
this.setSlots(slots);
|
||||
}
|
||||
|
||||
duplicateWithoutContents() {
|
||||
const slots = [];
|
||||
for (let i = 0; i < this.slots.length; ++i) {
|
||||
const slot = this.slots[i];
|
||||
slots.push({
|
||||
pos: slot.pos.copy(),
|
||||
type: slot.type,
|
||||
direction: slot.direction,
|
||||
});
|
||||
}
|
||||
|
||||
return new WiredPinsComponent({ slots });
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the slots of this building
|
||||
* @param {Array<WirePinSlotDefinition>} slots
|
||||
|
@ -82,7 +82,7 @@ export class PlatformWrapperImplBrowser extends PlatformWrapperInterface {
|
||||
return new Promise(resolve => {
|
||||
logger.log("Detecting storage");
|
||||
|
||||
if (!window.indexedDB) {
|
||||
if (!window.indexedDB || G_IS_DEV) {
|
||||
logger.log("Indexed DB not supported");
|
||||
this.app.storage = new StorageImplBrowser(this.app);
|
||||
resolve();
|
||||
|
@ -26,10 +26,6 @@ export class SavegameSerializer {
|
||||
* @returns {object}
|
||||
*/
|
||||
generateDumpFromGameRoot(root, sanityChecks = true) {
|
||||
// Finalize particles before saving (Like granting destroy indicator rewards)
|
||||
// root.particleMgr.finalizeBeforeSave();
|
||||
// root.uiParticleMgr.finalizeBeforeSave();
|
||||
|
||||
// Now store generic savegame payload
|
||||
const data = {
|
||||
camera: root.camera.serialize(),
|
||||
|
@ -1,15 +1,9 @@
|
||||
/* typehints:start */
|
||||
import { GameRoot } from "../game/root";
|
||||
/* typehints:end */
|
||||
|
||||
import { gComponentRegistry } from "../core/global_registries";
|
||||
import { createLogger } from "../core/logging";
|
||||
import { Entity } from "../game/entity";
|
||||
import { enumLayer, GameRoot } from "../game/root";
|
||||
|
||||
// Internal serializer methods
|
||||
export class SerializerInternal {
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* Serializes an array of entities
|
||||
* @param {Array<Entity>} array
|
||||
@ -45,6 +39,11 @@ export class SerializerInternal {
|
||||
deserializeEntity(root, payload) {
|
||||
const entity = new Entity(root);
|
||||
this.deserializeComponents(entity, payload.components);
|
||||
entity.layer = payload.layer;
|
||||
|
||||
if (!enumLayer[payload.layer]) {
|
||||
assert(false, "Invalid layer: " + payload.layer);
|
||||
}
|
||||
|
||||
root.entityMgr.registerEntity(entity, payload.uid);
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
steamPage:
|
||||
# This is the short text appearing on the steam page
|
||||
shortText: shapez.io is a game about building factories to automate the creation and combination of increasingly complex shapes within an infinite map.
|
||||
shortText: shapez.io is a game about building factories to automate the creation and processing of increasingly complex shapes across an infinitely expanding map.
|
||||
|
||||
# This is the text shown above the discord link
|
||||
discordLink: Official Discord - Chat with me!
|
||||
@ -33,36 +33,40 @@ steamPage:
|
||||
longText: >-
|
||||
[img]{STEAM_APP_IMAGE}/extras/store_page_gif.gif[/img]
|
||||
|
||||
shapez.io is a game about building factories to automate the creation and combination of shapes. Deliver the increasingly complex shapes to progress within the game and unlock upgrades to speed up your factory.
|
||||
shapez.io is a game about building factories to automate the creation and processing of increasingly complex shapes across an infinitely expanding map.
|
||||
Upon delivering the requested shapes you will progress within the game and unlock upgrades to speed up your factory.
|
||||
|
||||
Since the demand rises, you will have to scale up your factory to fit the needs - Don't forget about resources though, you will have to expand in the [b]infinite map[/b]!
|
||||
As the demand for shapes increases, you will have to scale up your factory to meet the demand - Don't forget about resources though, you will have to expand across the [b]infinite map[/b]!
|
||||
|
||||
Obviously shapes can get boring, so you need to mix colors and paint your shapes with it - Combine red, green and blue color resources to produce different colors and paint shapes with it to satisfy the demand.
|
||||
|
||||
This game features 18 levels (Which should keep you busy for hours already!) but I'm constantly adding new content - There is a lot planned!
|
||||
This game features 18 progressive levels (Which should keep you busy for hours already!) but I'm constantly adding new content - There is a lot planned!
|
||||
|
||||
Purchasing the game gives you access to the standalone version which has additional features and you'll also receive access to newly developed features.
|
||||
|
||||
[img]{STEAM_APP_IMAGE}/extras/header_standalone_advantages.png[/img]
|
||||
|
||||
[list]
|
||||
[*] Coming soon: Wires & Energy! Roughly end of July 2020.
|
||||
[*] Coming soon: More Levels
|
||||
[*] Dark Mode
|
||||
[*] Unlimited Waypoints
|
||||
[*] Unlimited Savegames
|
||||
[*] More settings
|
||||
[*] Allow me to further develop shapez.io ❤️
|
||||
[*] Additional settings
|
||||
[*] Coming soon: Wires & Energy! Aiming for (roughly) end of July 2020.
|
||||
[*] Coming soon: More Levels
|
||||
[*] Allows me to further develop shapez.io ❤️
|
||||
[/list]
|
||||
|
||||
[img]{STEAM_APP_IMAGE}/extras/header_future_updates.png[/img]
|
||||
|
||||
I am updating the game very often and try to push an update at least every week!
|
||||
I am updating the game very often and trying to push an update at least every week!
|
||||
|
||||
[list]
|
||||
[*] Different maps, and maybe map obstacles
|
||||
[*] Story mode where buildings cost shapes
|
||||
[*] Configurable map creation (Edit number and size of patches, seed, and more)
|
||||
[*] More types of shapes
|
||||
[*] More performance improvements (Although the game already runs pretty good!)
|
||||
[*] Different maps and challenges (e.g. maps with obstacles)
|
||||
[*] Puzzles (Deliver the requested shape with a restricted area / set of buildings)
|
||||
[*] A story mode where buildings have a cost
|
||||
[*] Configurable map generator (Configure resource/shape size/density, seed and more)
|
||||
[*] Additional types of shapes
|
||||
[*] Performance improvements (The game already runs pretty good!)
|
||||
[*] And much more!
|
||||
[/list]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user