|
|
@@ -5,6 +5,38 @@ import GraphView from './GraphView';
|
|
|
import TimelineView from './TimelineView';
|
|
|
import type { FactorioEngineOrchestrator } from './simulator';
|
|
|
|
|
|
+export interface MachineData {
|
|
|
+ recipe: { name: string };
|
|
|
+ isCrafting: boolean;
|
|
|
+ craftProgress: number;
|
|
|
+ inputBuffer: Record<string, number>;
|
|
|
+ outputBuffer: Record<string, number>;
|
|
|
+ outputBlockLimits: Record<string, number>;
|
|
|
+}
|
|
|
+
|
|
|
+export interface InserterData {
|
|
|
+ targetItemId: string;
|
|
|
+ state: number;
|
|
|
+ heldItems: number;
|
|
|
+ swingCount: number;
|
|
|
+ handSize?: number;
|
|
|
+ source: any; // Ideally MachineData | ChestData
|
|
|
+ destination: any; // Ideally MachineData | ChestData
|
|
|
+}
|
|
|
+
|
|
|
+export interface HistorySnapshot {
|
|
|
+ tick: number;
|
|
|
+ machines: {
|
|
|
+ isCrafting: boolean;
|
|
|
+ out: number;
|
|
|
+ in: number;
|
|
|
+ }[];
|
|
|
+ inserters: {
|
|
|
+ state: number;
|
|
|
+ held: number;
|
|
|
+ }[];
|
|
|
+}
|
|
|
+
|
|
|
export default function FactorioSimulationDashboard({ orchestrator }: { orchestrator: FactorioEngineOrchestrator }) {
|
|
|
const [viewMode, setViewMode] = useState<'classic' | 'graph' | 'timeline'>('classic');
|
|
|
const [tick, setTick] = useState(0);
|
|
|
@@ -12,7 +44,7 @@ export default function FactorioSimulationDashboard({ orchestrator }: { orchestr
|
|
|
const [tps, setTps] = useState(60);
|
|
|
const [stepAmount, setStepAmount] = useState(1);
|
|
|
|
|
|
- const [history, setHistory] = useState<any[]>([]);
|
|
|
+ const [history, setHistory] = useState<HistorySnapshot[]>([]);
|
|
|
const requestRef = useRef<number>(1);
|
|
|
const lastUpdateRef = useRef<number>(0);
|
|
|
|