ic10
v5.2.1
Published
[](https://www.npmjs.com/package/ic10) [](https://www.npmjs.com/package/ic10) [](https
Readme
IC10 Emulator & Development Toolkit
This project is an IC10 emulator (programming language for the game Stationeers) with a complete toolkit for development, testing, and code generation.
🚀 Features
- Full IC10 Emulation - Execute IC10 code with support for all instructions
- TypeScript Type Generation - Automatic generation of types for devices, instructions, and constants
- Device System - Typed classes for all in-game devices
- Development Tools - Automatic code generation, index files, and configurations
- Testing - Comprehensive test system with VSCode support
- Watch Mode - Automatic rebuild on source code changes
🏗️ Project Structure
src/
├── Core/ # Base classes (Device, Housing, Network, Slot, Stack)
├── Defines/ # Generated constants and definitions
├── Devices/ # Auto-generated device classes
├── Ic10/ # IC10 emulator core
│ ├── Context/ # Execution contexts (Real, Sandbox)
│ ├── Instruction/ # IC10 instruction implementations
│ ├── Lines/ # Code line processing
│ └── SandBox.ts # Execution sandbox
tests/ # Tests
tools/ # Generation scripts and utilities
samples/ # IC10 code examples🛠️ Installation & Setup
Prerequisites
- Bun (required)
- IDE with TypeScript support (VSCode recommended)
Installation
git clone <repository-url>
cd ic10
bun installDevelopment
# Run in development mode with file watching
bun run dev
# Run tests
bun test
# Full project rebuild
bun run upgrade📋 package.json Scripts
Main Commands
dev- Development mode with file watchingbuild- Full project buildtest- Run testsupgrade- Full data update and regeneration
Code Generation
download- Download latest data from servergenerate-device- Generate device classesgenerate:index- Update index filesgenerate-intruction-index- Generate instruction indexgenerate-vscode- Update VSCode configuration
Code Quality
lint- Code checking with Biomefix- Automatic problem fixingformat- Code formatting
🔧 Development Process
1. Project Initialization
bun run upgradeThis script performs:
- Downloading current device, instruction, and constant data
- Generating TypeScript types and classes
- Creating index files
- Updating VSCode configuration
2. Development Mode
bun run devThe whatch.ts script monitors changes and automatically:
- Regenerates index files when sources change
- Updates devices when definitions change
- Rebuilds instruction index when instruction classes change
3. Creating a New Instruction
- Create a class in
src/Ic10/Instruction/ - Inherit from the base Instruction class
- Implement the
tests()method for testing - The system will automatically detect and add the instruction
4. Testing
# Run all tests
bun test
# Run specific test
bun test tests/ic10/main.test.ts
# Show executed tests
bun run show🎯 Using the Emulator
comming soon
🔄 Code Generation System
Device Generation (generate-devices.ts)
- Analyzes device data from API
- Creates typed TypeScript classes
- Groups devices by base types (Housing, Structure, Item)
- Generates index files for export
Instruction Generation (generate-intruction-index.ts)
- Automatically discovers instruction classes
- Creates instruction map for quick access
- Generates TypeScript types for instruction names
VSCode Update (generate-vscode.ts)
- Collects instruction test information
- Updates launch.json for debugging
- Provides autocompletion for instruction names
📊 Change Monitoring
The whatch.ts system provides:
- Debounce mechanism - Prevents multiple rebuilds
- Selective regeneration - Only necessary parts on change
- Template support - Different scripts for different file types
- Unnecessary file ignoring - Prevents cyclic rebuilds
🧪 Testing
The project uses a comprehensive testing system:
- Unit tests for individual components
- Integration tests for the IC10 emulator
- Instruction tests with automatic discovery
- JUnit format report generation
🔧 Configuration
VSCode
- Autocompletion for IC10 instructions
- Debug configuration for tests
- Biome integration for linting
Biome
- Code formatting
- TypeScript linting
- Automatic problem fixing
Vite
- Library building
- TypeScript type generation
- ESM and CommonJS support
🏛 Used Libraries
exact-ic10-math (by Aidan647)
- Porting mathematical and bitwise functions from the Game (C#) to Typescript
- Acknowledgments: Aidan647 for creating the exact math library that provides full calculation compatibility with Stationeers game
Other Key Libraries
- crc-32 - Checksum calculation for device operations
- uuid - Unique identifier generation for emulator entities
- axios - HTTP client for data downloading
- vite - Modern project build system
- biome - Code formatting and linting
🤝 Contributing
- Fork the repository
- Create a feature branch
- Implement changes
- Add tests
- Ensure all tests pass
- Create a Pull Request
Code Standards
- Use
bun run fixbefore commit - Follow Biome code style
- Add tests for new functionality
- Update documentation when necessary
📝 Useful Commands
# Quick project check
bun run fix
# Formatting only
bun run format
# Formatting check
bun run format:check
# Run specific generation script
bun run generate-device