mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Initial support for saving games
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import { Component } from "../component";
|
||||
import { ShapeDefinition } from "../shape_definition";
|
||||
import { types } from "../../savegame/serialization";
|
||||
|
||||
export class HubComponent extends Component {
|
||||
static getId() {
|
||||
return "Hub";
|
||||
}
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
definitionsToAnalyze: types.array(types.knownType(ShapeDefinition)),
|
||||
};
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Vector, enumDirection, enumDirectionToAngle, enumInvertedDirections } f
|
||||
import { BaseItem } from "../base_item";
|
||||
import { ShapeItem } from "../items/shape_item";
|
||||
import { ColorItem } from "../items/color_item";
|
||||
import { types } from "../../savegame/serialization";
|
||||
|
||||
/**
|
||||
* @enum {string?}
|
||||
@@ -26,7 +27,13 @@ export class ItemAcceptorComponent extends Component {
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
// slots: "TODO",
|
||||
slots: types.array(
|
||||
types.structured({
|
||||
pos: types.vector,
|
||||
directions: types.array(types.enum(enumDirection)),
|
||||
filter: types.nullable(types.enum(enumItemAcceptorItemFilter)),
|
||||
})
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,7 +42,7 @@ export class ItemAcceptorComponent extends Component {
|
||||
* @param {object} param0
|
||||
* @param {Array<{pos: Vector, directions: enumDirection[], filter?: enumItemAcceptorItemFilter}>} param0.slots The slots from which we accept items
|
||||
*/
|
||||
constructor({ slots }) {
|
||||
constructor({ slots = [] }) {
|
||||
super();
|
||||
|
||||
this.setSlots(slots);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { globalConfig } from "../../core/config";
|
||||
import { Vector, enumDirection, enumDirectionToVector } from "../../core/vector";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { gItemRegistry } from "../../core/global_registries";
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
@@ -19,7 +20,15 @@ export class ItemEjectorComponent extends Component {
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
// slots: "TODO"
|
||||
instantEject: types.bool,
|
||||
slots: types.array(
|
||||
types.structured({
|
||||
pos: types.vector,
|
||||
direction: types.enum(enumDirection),
|
||||
item: types.nullable(types.obj(gItemRegistry)),
|
||||
progress: types.ufloat,
|
||||
})
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,7 +38,7 @@ export class ItemEjectorComponent extends Component {
|
||||
* @param {Array<{pos: Vector, direction: enumDirection}>} param0.slots The slots to eject on
|
||||
* @param {boolean=} param0.instantEject If the ejection is instant
|
||||
*/
|
||||
constructor({ slots, instantEject = false }) {
|
||||
constructor({ slots = [], instantEject = false }) {
|
||||
super();
|
||||
|
||||
// How long items take to eject
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { enumDirection, Vector } from "../../core/vector";
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { gItemRegistry } from "../../core/global_registries";
|
||||
|
||||
/** @enum {string} */
|
||||
export const enumItemProcessorTypes = {
|
||||
@@ -21,7 +23,37 @@ export class ItemProcessorComponent extends Component {
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
// TODO
|
||||
nextOutputSlot: types.uint,
|
||||
type: types.enum(enumItemProcessorTypes),
|
||||
inputsPerCharge: types.uint,
|
||||
beltUnderlays: types.array(
|
||||
types.structured({
|
||||
pos: types.vector,
|
||||
direction: types.enum(enumDirection),
|
||||
})
|
||||
),
|
||||
inputSlots: types.array(
|
||||
types.structured({
|
||||
item: types.obj(gItemRegistry),
|
||||
sourceSlot: types.uint,
|
||||
})
|
||||
),
|
||||
itemsToEject: types.array(
|
||||
types.structured({
|
||||
item: types.obj(gItemRegistry),
|
||||
requiredSlot: types.nullable(types.uint),
|
||||
preferredSlot: types.nullable(types.uint),
|
||||
})
|
||||
),
|
||||
secondsUntilEject: types.ufloat,
|
||||
itemConsumptionAnimations: types.array(
|
||||
types.structured({
|
||||
item: types.obj(gItemRegistry),
|
||||
slotIndex: types.uint,
|
||||
animProgress: types.ufloat,
|
||||
direction: types.enum(enumDirection),
|
||||
})
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,8 @@ export class MinerComponent extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} param0
|
||||
*/
|
||||
constructor({}) {
|
||||
constructor() {
|
||||
super();
|
||||
this.lastMiningTime = 0;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,14 @@ export class StaticMapEntityComponent extends Component {
|
||||
}
|
||||
|
||||
static getSchema() {
|
||||
return {};
|
||||
return {
|
||||
origin: types.tileVector,
|
||||
tileSize: types.tileVector,
|
||||
rotation: types.float,
|
||||
originalRotation: types.float,
|
||||
spriteKey: types.nullable(types.string),
|
||||
silhouetteColor: types.nullable(types.string),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { globalConfig } from "../../core/config";
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { gItemRegistry } from "../../core/global_registries";
|
||||
|
||||
/** @enum {string} */
|
||||
export const enumUndergroundBeltMode = {
|
||||
@@ -13,6 +15,13 @@ export class UndergroundBeltComponent extends Component {
|
||||
return "UndergroundBelt";
|
||||
}
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
mode: types.enum(enumUndergroundBeltMode),
|
||||
pendingItems: types.array(types.pair(types.obj(gItemRegistry), types.number)),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
|
||||
Reference in New Issue
Block a user