converter now has cycleLength. storage save load fix
This commit is contained in:
+18
-13
@@ -31,14 +31,14 @@ export class Game {
|
||||
const behavioursById = new Map(this.nodes.map((node) => [node.behaviour.id, node.behaviour]));
|
||||
|
||||
for (const node of this.nodes)
|
||||
node.behaviour.produce(deltaTime);
|
||||
node.behaviour.tick(deltaTime);
|
||||
for (const node of this.nodes)
|
||||
node.behaviour.pull(deltaTime, (id) => behavioursById.get(id));
|
||||
node.behaviour.pull((id) => behavioursById.get(id));
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.time = Decimal.dZero;
|
||||
for (const node of this.nodes)
|
||||
for (const node of this.nodes)
|
||||
node.behaviour.reset();
|
||||
}
|
||||
|
||||
@@ -48,30 +48,35 @@ export class Game {
|
||||
}
|
||||
}
|
||||
|
||||
export type SerializedConverterInput = {
|
||||
export type SerializedInput = {
|
||||
resource: Resource;
|
||||
rate: DecimalSource;
|
||||
link: {
|
||||
target: SerializedNodeBehaviour['id'],
|
||||
resource: Resource,
|
||||
}
|
||||
}
|
||||
|
||||
export type SerializedConverterOutput = {
|
||||
export type SerializedOutput = {
|
||||
resource: Resource;
|
||||
rate: DecimalSource;
|
||||
}
|
||||
|
||||
export type SerializedConverterInputs = {
|
||||
pins: SerializedConverterInput[];
|
||||
export type SerializedInputs = {
|
||||
pins: SerializedInput[];
|
||||
}
|
||||
|
||||
export type SerializedConverterOutputs = {
|
||||
pins: SerializedConverterOutput[];
|
||||
export type SerializedOutputs = {
|
||||
pins: SerializedOutput[];
|
||||
}
|
||||
|
||||
export type SerializedConverter = {
|
||||
kind: 'converter';
|
||||
cycleTime?: DecimalSource;
|
||||
storage?: Partial<Record<Resource, DecimalSource>>;
|
||||
rules: {
|
||||
cycleLength: DecimalSource;
|
||||
inputRates?: Partial<Record<Resource, DecimalSource>>;
|
||||
outputRates?: Partial<Record<Resource, DecimalSource>>;
|
||||
}
|
||||
}
|
||||
|
||||
export type SerializedStorage = {
|
||||
@@ -80,8 +85,8 @@ export type SerializedStorage = {
|
||||
|
||||
export type SerializedNodeBehaviour = {
|
||||
id: string;
|
||||
inputs: SerializedConverterInputs;
|
||||
outputs: SerializedConverterOutputs;
|
||||
inputs: SerializedInputs;
|
||||
outputs: SerializedOutputs;
|
||||
} & (SerializedConverter | SerializedStorage);
|
||||
|
||||
export type SerializedNode = {
|
||||
|
||||
Reference in New Issue
Block a user