cleanup: remove ONIModTutorial (unrelated), merge skills/oni_agent.md into SKILL.md, move event_daemon.py to tools/

This commit is contained in:
root
2026-05-30 16:08:07 +08:00
parent 280879c4b0
commit 4d2cffd2f1
73 changed files with 16 additions and 45270 deletions

Binary file not shown.

View File

@ -1,50 +0,0 @@
name: Deploy VitePress site to Pages
on:
push:
branches: [main]
concurrency:
group: "pages"
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Build with VitePress
run: npx vitepress build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

@ -1,28 +0,0 @@
name: PR Check
on:
pull_request:
branches:
- main
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install deps
run: npm ci
- name: Build
run: npm run build

View File

@ -1,12 +0,0 @@
# 排除依赖库
node_modules/
# 排除编译输出
dist/
.temp/
.cache/
# 排除本地环境变量和日志
*.log
.DS_Store
.env

View File

@ -1,61 +0,0 @@
{
"hash": "5368ccde",
"configHash": "2733785a",
"lockfileHash": "3ae99b52",
"browserHash": "26eaea40",
"optimized": {
"vue": {
"src": "../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "605c659d",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../node_modules/@vue/devtools-api/dist/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "3cacbefb",
"needsInterop": false
},
"vitepress > @vueuse/core": {
"src": "../../../node_modules/@vueuse/core/index.mjs",
"file": "vitepress___@vueuse_core.js",
"fileHash": "770ea158",
"needsInterop": false
},
"vitepress > @vueuse/integrations/useFocusTrap": {
"src": "../../../node_modules/@vueuse/integrations/useFocusTrap.mjs",
"file": "vitepress___@vueuse_integrations_useFocusTrap.js",
"fileHash": "b915752a",
"needsInterop": false
},
"vitepress > mark.js/src/vanilla.js": {
"src": "../../../node_modules/mark.js/src/vanilla.js",
"file": "vitepress___mark__js_src_vanilla__js.js",
"fileHash": "38aa2e8f",
"needsInterop": false
},
"vitepress > minisearch": {
"src": "../../../node_modules/minisearch/dist/es/index.js",
"file": "vitepress___minisearch.js",
"fileHash": "f5e205a1",
"needsInterop": false
},
"rss-parser": {
"src": "../../../node_modules/rss-parser/index.js",
"file": "rss-parser.js",
"fileHash": "c4c7877b",
"needsInterop": true
}
},
"chunks": {
"chunk-LJKO4TMH": {
"file": "chunk-LJKO4TMH.js"
},
"chunk-QE257C5J": {
"file": "chunk-QE257C5J.js"
},
"chunk-BUSYA2B4": {
"file": "chunk-BUSYA2B4.js"
}
}
}

View File

@ -1,9 +0,0 @@
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
export {
__commonJS
};
//# sourceMappingURL=chunk-BUSYA2B4.js.map

View File

@ -1,7 +0,0 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,584 +0,0 @@
import {
DefaultMagicKeysAliasMap,
StorageSerializers,
TransitionPresets,
assert,
breakpointsAntDesign,
breakpointsBootstrapV5,
breakpointsElement,
breakpointsMasterCss,
breakpointsPrimeFlex,
breakpointsQuasar,
breakpointsSematic,
breakpointsTailwind,
breakpointsVuetify,
breakpointsVuetifyV2,
breakpointsVuetifyV3,
bypassFilter,
camelize,
clamp,
cloneFnJSON,
computedAsync,
computedEager,
computedInject,
computedWithControl,
containsProp,
controlledRef,
createEventHook,
createFetch,
createFilterWrapper,
createGlobalState,
createInjectionState,
createRef,
createReusableTemplate,
createSharedComposable,
createSingletonPromise,
createTemplatePromise,
createUnrefFn,
customStorageEventName,
debounceFilter,
defaultDocument,
defaultLocation,
defaultNavigator,
defaultWindow,
executeTransition,
extendRef,
formatDate,
formatTimeAgo,
get,
getLifeCycleTarget,
getSSRHandler,
hasOwn,
hyphenate,
identity,
increaseWithUnit,
injectLocal,
invoke,
isClient,
isDef,
isDefined,
isIOS,
isObject,
isWorker,
makeDestructurable,
mapGamepadToXbox360Controller,
noop,
normalizeDate,
notNullish,
now,
objectEntries,
objectOmit,
objectPick,
onClickOutside,
onElementRemoval,
onKeyDown,
onKeyPressed,
onKeyStroke,
onKeyUp,
onLongPress,
onStartTyping,
pausableFilter,
promiseTimeout,
provideLocal,
provideSSRWidth,
pxValue,
rand,
reactify,
reactifyObject,
reactiveComputed,
reactiveOmit,
reactivePick,
refAutoReset,
refDebounced,
refDefault,
refThrottled,
refWithControl,
resolveRef,
resolveUnref,
set,
setSSRHandler,
syncRef,
syncRefs,
templateRef,
throttleFilter,
timestamp,
toArray,
toReactive,
toRef,
toRefs,
toValue,
tryOnBeforeMount,
tryOnBeforeUnmount,
tryOnMounted,
tryOnScopeDispose,
tryOnUnmounted,
unrefElement,
until,
useActiveElement,
useAnimate,
useArrayDifference,
useArrayEvery,
useArrayFilter,
useArrayFind,
useArrayFindIndex,
useArrayFindLast,
useArrayIncludes,
useArrayJoin,
useArrayMap,
useArrayReduce,
useArraySome,
useArrayUnique,
useAsyncQueue,
useAsyncState,
useBase64,
useBattery,
useBluetooth,
useBreakpoints,
useBroadcastChannel,
useBrowserLocation,
useCached,
useClipboard,
useClipboardItems,
useCloned,
useColorMode,
useConfirmDialog,
useCountdown,
useCounter,
useCssVar,
useCurrentElement,
useCycleList,
useDark,
useDateFormat,
useDebounceFn,
useDebouncedRefHistory,
useDeviceMotion,
useDeviceOrientation,
useDevicePixelRatio,
useDevicesList,
useDisplayMedia,
useDocumentVisibility,
useDraggable,
useDropZone,
useElementBounding,
useElementByPoint,
useElementHover,
useElementSize,
useElementVisibility,
useEventBus,
useEventListener,
useEventSource,
useEyeDropper,
useFavicon,
useFetch,
useFileDialog,
useFileSystemAccess,
useFocus,
useFocusWithin,
useFps,
useFullscreen,
useGamepad,
useGeolocation,
useIdle,
useImage,
useInfiniteScroll,
useIntersectionObserver,
useInterval,
useIntervalFn,
useKeyModifier,
useLastChanged,
useLocalStorage,
useMagicKeys,
useManualRefHistory,
useMediaControls,
useMediaQuery,
useMemoize,
useMemory,
useMounted,
useMouse,
useMouseInElement,
useMousePressed,
useMutationObserver,
useNavigatorLanguage,
useNetwork,
useNow,
useObjectUrl,
useOffsetPagination,
useOnline,
usePageLeave,
useParallax,
useParentElement,
usePerformanceObserver,
usePermission,
usePointer,
usePointerLock,
usePointerSwipe,
usePreferredColorScheme,
usePreferredContrast,
usePreferredDark,
usePreferredLanguages,
usePreferredReducedMotion,
usePreferredReducedTransparency,
usePrevious,
useRafFn,
useRefHistory,
useResizeObserver,
useSSRWidth,
useScreenOrientation,
useScreenSafeArea,
useScriptTag,
useScroll,
useScrollLock,
useSessionStorage,
useShare,
useSorted,
useSpeechRecognition,
useSpeechSynthesis,
useStepper,
useStorage,
useStorageAsync,
useStyleTag,
useSupported,
useSwipe,
useTemplateRefsList,
useTextDirection,
useTextSelection,
useTextareaAutosize,
useThrottleFn,
useThrottledRefHistory,
useTimeAgo,
useTimeout,
useTimeoutFn,
useTimeoutPoll,
useTimestamp,
useTitle,
useToNumber,
useToString,
useToggle,
useTransition,
useUrlSearchParams,
useUserMedia,
useVModel,
useVModels,
useVibrate,
useVirtualList,
useWakeLock,
useWebNotification,
useWebSocket,
useWebWorker,
useWebWorkerFn,
useWindowFocus,
useWindowScroll,
useWindowSize,
watchArray,
watchAtMost,
watchDebounced,
watchDeep,
watchIgnorable,
watchImmediate,
watchOnce,
watchPausable,
watchThrottled,
watchTriggerable,
watchWithFilter,
whenever
} from "./chunk-LJKO4TMH.js";
import "./chunk-QE257C5J.js";
import "./chunk-BUSYA2B4.js";
export {
DefaultMagicKeysAliasMap,
StorageSerializers,
TransitionPresets,
assert,
computedAsync as asyncComputed,
refAutoReset as autoResetRef,
breakpointsAntDesign,
breakpointsBootstrapV5,
breakpointsElement,
breakpointsMasterCss,
breakpointsPrimeFlex,
breakpointsQuasar,
breakpointsSematic,
breakpointsTailwind,
breakpointsVuetify,
breakpointsVuetifyV2,
breakpointsVuetifyV3,
bypassFilter,
camelize,
clamp,
cloneFnJSON,
computedAsync,
computedEager,
computedInject,
computedWithControl,
containsProp,
computedWithControl as controlledComputed,
controlledRef,
createEventHook,
createFetch,
createFilterWrapper,
createGlobalState,
createInjectionState,
reactify as createReactiveFn,
createRef,
createReusableTemplate,
createSharedComposable,
createSingletonPromise,
createTemplatePromise,
createUnrefFn,
customStorageEventName,
debounceFilter,
refDebounced as debouncedRef,
watchDebounced as debouncedWatch,
defaultDocument,
defaultLocation,
defaultNavigator,
defaultWindow,
computedEager as eagerComputed,
executeTransition,
extendRef,
formatDate,
formatTimeAgo,
get,
getLifeCycleTarget,
getSSRHandler,
hasOwn,
hyphenate,
identity,
watchIgnorable as ignorableWatch,
increaseWithUnit,
injectLocal,
invoke,
isClient,
isDef,
isDefined,
isIOS,
isObject,
isWorker,
makeDestructurable,
mapGamepadToXbox360Controller,
noop,
normalizeDate,
notNullish,
now,
objectEntries,
objectOmit,
objectPick,
onClickOutside,
onElementRemoval,
onKeyDown,
onKeyPressed,
onKeyStroke,
onKeyUp,
onLongPress,
onStartTyping,
pausableFilter,
watchPausable as pausableWatch,
promiseTimeout,
provideLocal,
provideSSRWidth,
pxValue,
rand,
reactify,
reactifyObject,
reactiveComputed,
reactiveOmit,
reactivePick,
refAutoReset,
refDebounced,
refDefault,
refThrottled,
refWithControl,
resolveRef,
resolveUnref,
set,
setSSRHandler,
syncRef,
syncRefs,
templateRef,
throttleFilter,
refThrottled as throttledRef,
watchThrottled as throttledWatch,
timestamp,
toArray,
toReactive,
toRef,
toRefs,
toValue,
tryOnBeforeMount,
tryOnBeforeUnmount,
tryOnMounted,
tryOnScopeDispose,
tryOnUnmounted,
unrefElement,
until,
useActiveElement,
useAnimate,
useArrayDifference,
useArrayEvery,
useArrayFilter,
useArrayFind,
useArrayFindIndex,
useArrayFindLast,
useArrayIncludes,
useArrayJoin,
useArrayMap,
useArrayReduce,
useArraySome,
useArrayUnique,
useAsyncQueue,
useAsyncState,
useBase64,
useBattery,
useBluetooth,
useBreakpoints,
useBroadcastChannel,
useBrowserLocation,
useCached,
useClipboard,
useClipboardItems,
useCloned,
useColorMode,
useConfirmDialog,
useCountdown,
useCounter,
useCssVar,
useCurrentElement,
useCycleList,
useDark,
useDateFormat,
refDebounced as useDebounce,
useDebounceFn,
useDebouncedRefHistory,
useDeviceMotion,
useDeviceOrientation,
useDevicePixelRatio,
useDevicesList,
useDisplayMedia,
useDocumentVisibility,
useDraggable,
useDropZone,
useElementBounding,
useElementByPoint,
useElementHover,
useElementSize,
useElementVisibility,
useEventBus,
useEventListener,
useEventSource,
useEyeDropper,
useFavicon,
useFetch,
useFileDialog,
useFileSystemAccess,
useFocus,
useFocusWithin,
useFps,
useFullscreen,
useGamepad,
useGeolocation,
useIdle,
useImage,
useInfiniteScroll,
useIntersectionObserver,
useInterval,
useIntervalFn,
useKeyModifier,
useLastChanged,
useLocalStorage,
useMagicKeys,
useManualRefHistory,
useMediaControls,
useMediaQuery,
useMemoize,
useMemory,
useMounted,
useMouse,
useMouseInElement,
useMousePressed,
useMutationObserver,
useNavigatorLanguage,
useNetwork,
useNow,
useObjectUrl,
useOffsetPagination,
useOnline,
usePageLeave,
useParallax,
useParentElement,
usePerformanceObserver,
usePermission,
usePointer,
usePointerLock,
usePointerSwipe,
usePreferredColorScheme,
usePreferredContrast,
usePreferredDark,
usePreferredLanguages,
usePreferredReducedMotion,
usePreferredReducedTransparency,
usePrevious,
useRafFn,
useRefHistory,
useResizeObserver,
useSSRWidth,
useScreenOrientation,
useScreenSafeArea,
useScriptTag,
useScroll,
useScrollLock,
useSessionStorage,
useShare,
useSorted,
useSpeechRecognition,
useSpeechSynthesis,
useStepper,
useStorage,
useStorageAsync,
useStyleTag,
useSupported,
useSwipe,
useTemplateRefsList,
useTextDirection,
useTextSelection,
useTextareaAutosize,
refThrottled as useThrottle,
useThrottleFn,
useThrottledRefHistory,
useTimeAgo,
useTimeout,
useTimeoutFn,
useTimeoutPoll,
useTimestamp,
useTitle,
useToNumber,
useToString,
useToggle,
useTransition,
useUrlSearchParams,
useUserMedia,
useVModel,
useVModels,
useVibrate,
useVirtualList,
useWakeLock,
useWebNotification,
useWebSocket,
useWebWorker,
useWebWorkerFn,
useWindowFocus,
useWindowScroll,
useWindowSize,
watchArray,
watchAtMost,
watchDebounced,
watchDeep,
watchIgnorable,
watchImmediate,
watchOnce,
watchPausable,
watchThrottled,
watchTriggerable,
watchWithFilter,
whenever
};
//# sourceMappingURL=vitepress___@vueuse_core.js.map

View File

@ -1,7 +0,0 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,348 +0,0 @@
import {
BaseTransition,
BaseTransitionPropsValidators,
Comment,
DeprecationTypes,
EffectScope,
ErrorCodes,
ErrorTypeStrings,
Fragment,
KeepAlive,
ReactiveEffect,
Static,
Suspense,
Teleport,
Text,
TrackOpTypes,
Transition,
TransitionGroup,
TriggerOpTypes,
VueElement,
assertNumber,
callWithAsyncErrorHandling,
callWithErrorHandling,
camelize,
capitalize,
cloneVNode,
compatUtils,
compile,
computed,
createApp,
createBaseVNode,
createBlock,
createCommentVNode,
createElementBlock,
createHydrationRenderer,
createPropsRestProxy,
createRenderer,
createSSRApp,
createSlots,
createStaticVNode,
createTextVNode,
createVNode,
customRef,
defineAsyncComponent,
defineComponent,
defineCustomElement,
defineEmits,
defineExpose,
defineModel,
defineOptions,
defineProps,
defineSSRCustomElement,
defineSlots,
devtools,
effect,
effectScope,
getCurrentInstance,
getCurrentScope,
getCurrentWatcher,
getTransitionRawChildren,
guardReactiveProps,
h,
handleError,
hasInjectionContext,
hydrate,
hydrateOnIdle,
hydrateOnInteraction,
hydrateOnMediaQuery,
hydrateOnVisible,
initCustomFormatter,
initDirectivesForSSR,
inject,
isMemoSame,
isProxy,
isReactive,
isReadonly,
isRef,
isRuntimeOnly,
isShallow,
isVNode,
markRaw,
mergeDefaults,
mergeModels,
mergeProps,
nextTick,
nodeOps,
normalizeClass,
normalizeProps,
normalizeStyle,
onActivated,
onBeforeMount,
onBeforeUnmount,
onBeforeUpdate,
onDeactivated,
onErrorCaptured,
onMounted,
onRenderTracked,
onRenderTriggered,
onScopeDispose,
onServerPrefetch,
onUnmounted,
onUpdated,
onWatcherCleanup,
openBlock,
patchProp,
popScopeId,
provide,
proxyRefs,
pushScopeId,
queuePostFlushCb,
reactive,
readonly,
ref,
registerRuntimeCompiler,
render,
renderList,
renderSlot,
resolveComponent,
resolveDirective,
resolveDynamicComponent,
resolveFilter,
resolveTransitionHooks,
setBlockTracking,
setDevtoolsHook,
setTransitionHooks,
shallowReactive,
shallowReadonly,
shallowRef,
ssrContextKey,
ssrUtils,
stop,
toDisplayString,
toHandlerKey,
toHandlers,
toRaw,
toRef,
toRefs,
toValue,
transformVNodeArgs,
triggerRef,
unref,
useAttrs,
useCssModule,
useCssVars,
useHost,
useId,
useModel,
useSSRContext,
useShadowRoot,
useSlots,
useTemplateRef,
useTransitionState,
vModelCheckbox,
vModelDynamic,
vModelRadio,
vModelSelect,
vModelText,
vShow,
version,
warn,
watch,
watchEffect,
watchPostEffect,
watchSyncEffect,
withAsyncContext,
withCtx,
withDefaults,
withDirectives,
withKeys,
withMemo,
withModifiers,
withScopeId
} from "./chunk-QE257C5J.js";
import "./chunk-BUSYA2B4.js";
export {
BaseTransition,
BaseTransitionPropsValidators,
Comment,
DeprecationTypes,
EffectScope,
ErrorCodes,
ErrorTypeStrings,
Fragment,
KeepAlive,
ReactiveEffect,
Static,
Suspense,
Teleport,
Text,
TrackOpTypes,
Transition,
TransitionGroup,
TriggerOpTypes,
VueElement,
assertNumber,
callWithAsyncErrorHandling,
callWithErrorHandling,
camelize,
capitalize,
cloneVNode,
compatUtils,
compile,
computed,
createApp,
createBlock,
createCommentVNode,
createElementBlock,
createBaseVNode as createElementVNode,
createHydrationRenderer,
createPropsRestProxy,
createRenderer,
createSSRApp,
createSlots,
createStaticVNode,
createTextVNode,
createVNode,
customRef,
defineAsyncComponent,
defineComponent,
defineCustomElement,
defineEmits,
defineExpose,
defineModel,
defineOptions,
defineProps,
defineSSRCustomElement,
defineSlots,
devtools,
effect,
effectScope,
getCurrentInstance,
getCurrentScope,
getCurrentWatcher,
getTransitionRawChildren,
guardReactiveProps,
h,
handleError,
hasInjectionContext,
hydrate,
hydrateOnIdle,
hydrateOnInteraction,
hydrateOnMediaQuery,
hydrateOnVisible,
initCustomFormatter,
initDirectivesForSSR,
inject,
isMemoSame,
isProxy,
isReactive,
isReadonly,
isRef,
isRuntimeOnly,
isShallow,
isVNode,
markRaw,
mergeDefaults,
mergeModels,
mergeProps,
nextTick,
nodeOps,
normalizeClass,
normalizeProps,
normalizeStyle,
onActivated,
onBeforeMount,
onBeforeUnmount,
onBeforeUpdate,
onDeactivated,
onErrorCaptured,
onMounted,
onRenderTracked,
onRenderTriggered,
onScopeDispose,
onServerPrefetch,
onUnmounted,
onUpdated,
onWatcherCleanup,
openBlock,
patchProp,
popScopeId,
provide,
proxyRefs,
pushScopeId,
queuePostFlushCb,
reactive,
readonly,
ref,
registerRuntimeCompiler,
render,
renderList,
renderSlot,
resolveComponent,
resolveDirective,
resolveDynamicComponent,
resolveFilter,
resolveTransitionHooks,
setBlockTracking,
setDevtoolsHook,
setTransitionHooks,
shallowReactive,
shallowReadonly,
shallowRef,
ssrContextKey,
ssrUtils,
stop,
toDisplayString,
toHandlerKey,
toHandlers,
toRaw,
toRef,
toRefs,
toValue,
transformVNodeArgs,
triggerRef,
unref,
useAttrs,
useCssModule,
useCssVars,
useHost,
useId,
useModel,
useSSRContext,
useShadowRoot,
useSlots,
useTemplateRef,
useTransitionState,
vModelCheckbox,
vModelDynamic,
vModelRadio,
vModelSelect,
vModelText,
vShow,
version,
warn,
watch,
watchEffect,
watchPostEffect,
watchSyncEffect,
withAsyncContext,
withCtx,
withDefaults,
withDirectives,
withKeys,
withMemo,
withModifiers,
withScopeId
};
//# sourceMappingURL=vue.js.map

View File

@ -1,7 +0,0 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

View File

@ -1,131 +0,0 @@
import { defineConfig } from 'vitepress'
// https://vitepress.dev/reference/site-config
export default defineConfig({
base: process.env.CF_PAGES ? '/' : '/ONIModTutorial/',
title: "ONIModTutorial",
description: "缺氧MOD教程",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '首页', link: '/' },
{ text: '教程示例', link: '/markdown-examples' }
],
// 导航栏右侧的社交链接
socialLinks: [
{
icon: {
svg: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><title>前往我的 GitHub 仓库</title><path d="M10,0 C15.523,0 20,4.59 20,10.253 C20,14.782 17.138,18.624 13.167,19.981 C12.66,20.082 12.48,19.762 12.48,19.489 C12.48,19.151 12.492,18.047 12.492,16.675 C12.492,15.719 12.172,15.095 11.813,14.777 C14.04,14.523 16.38,13.656 16.38,9.718 C16.38,8.598 15.992,7.684 15.35,6.966 C15.454,6.707 15.797,5.664 15.252,4.252 C15.252,4.252 14.414,3.977 12.505,5.303 C11.706,5.076 10.85,4.962 10,4.958 C9.15,4.962 8.295,5.076 7.497,5.303 C5.586,3.977 4.746,4.252 4.746,4.252 C4.203,5.664 4.546,6.707 4.649,6.966 C4.01,7.684 3.619,8.598 3.619,9.718 C3.619,13.646 5.954,14.526 8.175,14.785 C7.889,15.041 7.63,15.493 7.54,16.156 C6.97,16.418 5.522,16.871 4.63,15.304 C4.63,15.304 4.101,14.319 3.097,14.247 C3.097,14.247 2.122,14.234 3.029,14.87 C3.029,14.87 3.684,15.185 4.139,16.37 C4.139,16.37 4.726,18.2 7.508,17.58 C7.513,18.437 7.522,19.245 7.522,19.489 C7.522,19.76 7.338,20.077 6.839,19.982 C2.865,18.627 0,14.783 0,10.253 C0,4.59 4.478,0 10,0" fill="currentColor"></path></svg>'
},
link: 'https://github.com/ChiYuKe/ONIModTutorial',
ariaLabel: '前往 GitHub 仓库'
},
{
icon: {
svg: '<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>我的Steam创意工坊</title><path d="M18.102 12.129c0-0 0-0 0-0.001 0-1.564 1.268-2.831 2.831-2.831s2.831 1.268 2.831 2.831c0 1.564-1.267 2.831-2.831 2.831-0 0-0 0-0.001 0h0c-0 0-0 0-0.001 0-1.563 0-2.83-1.267-2.83-2.83 0-0 0-0 0-0.001v0zM24.691 12.135c0-2.081-1.687-3.768-3.768-3.768s-3.768 1.687-3.768 3.768c0 2.081 1.687 3.768 3.768 3.768v0c2.080-0.003 3.765-1.688 3.768-3.767v-0zM10.427 23.76l-1.841-0.762c0.524 1.078 1.611 1.808 2.868 1.808 1.317 0 2.448-0.801 2.93-1.943l0.008-0.021c0.155-0.362 0.246-0.784 0.246-1.226 0-1.757-1.424-3.181-3.181-3.181-0.405 0-0.792 0.076-1.148 0.213l0.022-0.007 1.903 0.787c0.852 0.364 1.439 1.196 1.439 2.164 0 1.296-1.051 2.347-2.347 2.347-0.324 0-0.632-0.066-0.913-0.184l0.015 0.006zM15.974 1.004c-7.857 0.001-14.301 6.046-14.938 13.738l-0.004 0.054 8.038 3.322c0.668-0.462 1.495-0.737 2.387-0.737 0.001 0 0.002 0 0.002 0h-0c0.079 0 0.156 0.005 0.235 0.008l3.575-5.176v-0.074c0.003-3.12 2.533-5.648 5.653-5.648 3.122 0 5.653 2.531 5.653 5.653s-2.531 5.653-5.653 5.653h-0.131l-5.094 3.638c0 0.065 0.005 0.131 0.005 0.199 0 0.001 0 0.002 0 0.003 0 2.342-1.899 4.241-4.241 4.241-2.047 0-3.756-1.451-4.153-3.38l-0.005-0.027-5.755-2.383c1.841 6.345 7.601 10.905 14.425 10.905 8.281 0 14.994-6.713 14.994-14.994s-6.713-14.994-14.994-14.994c-0 0-0.001 0-0.001 0h0z" fill="currentColor"></path></svg>'
},
link: 'https://steamcommunity.com/profiles/76561199064454583/myworkshopfiles/?appid=457140',
ariaLabel: '查看我的 Steam 创意工坊'
}
],
sidebar: {
// 1. 默认侧边栏:显示在根目录及基础章节
'/': [
{
text: '01. 项目概述',
collapsed: false,
items: [
{ text: '开发引言', link: '/preface' },
{ text: '开发环境配置', link: '/development-environment' },
{ text: '游戏资产提取', link: '/asset-extraction' },
{ text: '游戏源码分析工具', link: '/dnspy-analysis' }
]
},
{
text: '02. 核心开发',
collapsed: false,
items: [
{ text: 'C# 基础与补丁语法', link: '/csharp-basics' },
{ text: 'Mod 结构', link: '/mod-structure' },
{ text: '第一个Mod', link: '/first-mod-tutorial' },
{ text: '编译流程扩展', link: '/build-and-debug' },
{ text: 'Unity篇', link: '/resource-unity' }
]
},
{
text: '03. 游戏内容扩展',
collapsed: true, // 在主站默认折叠,避免太长
items: [
{ text: '新增建筑', link: '/content/buildings' },
{ text: '新增植物', link: '/content/plants' },
{ text: '新增物品', link: '/content/items' },
{ text: '新增生物', link: '/content/creatures' },
{ text: '新增元素', link: '/content/elements' }
]
},
{
text: '04. 发布与维护',
collapsed: true,
items: [
{ text: 'Steam Workshop 上传', link: '/steam-workshop-upload' },
{ text: '多版本兼容性处理', link: '/version-compatibility' },
{ text: '开源协议与社区规范', link: '/community-guidelines' }
]
},
{
text: '05. 其他',
collapsed: true,
items: [
{ text: '贡献者名单', link: '/contributors' },
{ text: '加入贡献', link: '/contribute' },
{ text: '新闻公告', link: '/announcements' },
{ text: '创意工坊', link: '/workshop-list' }
]
}
],
// 2. 内容扩展专用侧边栏
'/content/': [
{
text: '🏗️ 游戏内容扩展',
items: [
{ text: '← 返回教程主页', link: '/preface' },
{ text: '新增建筑 (Buildings)', link: '/content/buildings' },
{ text: '新增植物 (Plants)', link: '/content/plants' },
{ text: '新增物品 (Items)', link: '/content/items' },
{ text: '新增生物 (Creatures)', link: '/content/creatures' },
{ text: '新增元素 (Elements)', link: '/content/elements' }
]
}
]
},
editLink: {
pattern: 'https://github.com/ChiYuKe/ONIModTutorial/edit/main/:path',
text: '在 GitHub 上编辑此页'
},
search: {
provider: 'local'
},
lastUpdated: {
text: '最后更新于',
formatOptions: {
dateStyle: 'full',
timeStyle: 'medium'
}
},
}
})

View File

@ -1,89 +0,0 @@
<template>
<div class="contributors-container">
<div v-for="user in contributors" :key="user.id" class="contributor-card">
<a :href="user.html_url" target="_blank" rel="noreferrer">
<img :src="user.avatar_url" :alt="user.login" class="avatar" />
<span class="username">{{ user.login }}</span>
</a>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const props = defineProps({
repo: { type: String, required: true } // 格式: "Owner/RepoName"
})
const contributors = ref([])
onMounted(async () => {
const cacheKey = `contributors-${props.repo}`;
const cachedData = localStorage.getItem(cacheKey);
const cacheTime = localStorage.getItem(`${cacheKey}-timestamp`);
// 如果缓存存在且没超过 1 小时,直接用缓存
if (cachedData && cacheTime && Date.now() - cacheTime < 3600000) {
contributors.value = JSON.parse(cachedData);
return;
}
try {
const response = await fetch(`https://api.github.com/repos/${props.repo}/contributors`);
const data = await response.json();
if (Array.isArray(data)) {
const users = data.filter(user => user.type === 'User');
contributors.value = users;
// 存入缓存
localStorage.setItem(cacheKey, JSON.stringify(users));
localStorage.setItem(`${cacheKey}-timestamp`, Date.now().toString());
}
} catch (e) {
console.error('获取失败', e);
}
});
</script>
<style scoped>
.contributors-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
gap: 20px;
margin-top: 24px;
justify-items: center;
}
.contributor-card a {
display: flex;
flex-direction: column;
align-items: center;
text-decoration: none;
transition: transform 0.2s ease;
width: 80px;
}
.contributor-card a:hover {
transform: translateY(-5px);
}
.avatar {
width: 60px;
height: 60px;
border-radius: 50%;
border: 2px solid var(--vp-c-brand);
object-fit: cover;
background-color: var(--vp-c-bg-soft);
}
.username {
font-size: 12px;
margin-top: 8px;
color: var(--vp-c-text-1);
text-align: center;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>

View File

@ -1,35 +0,0 @@
<template>
<div class="timeline">
<div class="timeline-item" v-for="(item, index) in steps" :key="index">
<div class="timeline-dot"></div>
<div class="timeline-content">
<div class="timeline-date">{{ item.status }}</div>
<h4 class="timeline-title">{{ item.title }}</h4>
<p class="timeline-desc">{{ item.desc }}</p>
</div>
</div>
</div>
</template>
<script setup>
const steps = [
{ status: '已完成', title: '摸鱼', desc: '了解上班摸鱼写文档的流程。' },
{ status: '进行中', title: 'Mod 基础教程', desc: '掌握变量、类与对象,这是制作 Mod 的基石。' },
{ status: '计划中', title: 'UI 界面开发', desc: '教你如何在游戏里画出自己的窗口和按钮。' }
]
</script>
<style scoped>
.timeline { margin: 2rem 0; padding-left: 20px; border-left: 2px solid var(--vp-c-divider); }
.timeline-item { position: relative; margin-bottom: 2rem; padding-left: 30px; }
.timeline-dot {
position: absolute; left: -31px; top: 5px;
width: 20px; height: 20px;
background: var(--vp-c-brand);
border: 4px solid var(--vp-c-bg);
border-radius: 50%;
}
.timeline-date { font-size: 0.8rem; color: var(--vp-c-brand); font-weight: bold; }
.timeline-title { margin: 5px 0 !important; color: var(--vp-c-text-1); }
.timeline-desc { font-size: 0.9rem; color: var(--vp-c-text-2); margin: 0; }
</style>

View File

@ -1,292 +0,0 @@
<script setup>
import { ref, reactive, onMounted } from 'vue'
const articles = ref([])
const loading = ref(true)
const APP_ID = '457140'
// Tooltip 相关状态
const tooltip = reactive({
visible: false,
lines: [],
style: {}
})
// 解析 Steam 补丁说明为纯文本行数组
function parseSteamDescription(html) {
if (!html) return []
return html
.replace(/\r?\n/g, '')
.replace(/<li>(.*?)<\/li>/gi, '• $1\n')
.replace(/<\/p>|<br\s*\/?>/gi, '\n')
.replace(/<[^>]+>/g, '')
.split('\n')
.map(l => l.trim())
.filter(Boolean)
}
// 显示 Tooltip
function showTooltip(e, item) {
const rect = e.currentTarget.getBoundingClientRect()
const MAX_LINES = 10
const GAP = 12
const WIDTH = 700
const LINE_HEIGHT = 22
const PADDING = 24
const total = item.parsedLines.length
if (total > MAX_LINES) {
tooltip.lines = [
...item.parsedLines
.slice(0, MAX_LINES - 1)
.map(t => ({ text: t })),
{ text: '......', ellipsis: true }
]
} else {
tooltip.lines = item.parsedLines.map(t => ({ text: t }))
}
const estimatedHeight =
tooltip.lines.length * LINE_HEIGHT + PADDING
let top
// 优先显示在上方
if (rect.top < estimatedHeight + GAP) {
top = rect.bottom + GAP
} else {
top = rect.top - estimatedHeight - GAP
}
tooltip.style = {
position: 'fixed',
top: `${top}px`,
left: `${rect.left}px`,
width: `${WIDTH}px`
}
tooltip.visible = true
}
function hideTooltip() {
tooltip.visible = false
}
// 获取 Steam 新闻数据
onMounted(async () => {
try {
const res = await fetch(
`https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fstore.steampowered.com%2Ffeeds%2Fnews%2Fapp%2F${APP_ID}`
)
const data = await res.json()
if (data.status === 'ok') {
articles.value = data.items.slice(0, 10).map(item => {
const imgReg = /<img.*?src=["'](.*?)["']/
const match = item.content?.match(imgReg)
const fallbackImg =
`https://cdn.akamai.steamstatic.com/steam/apps/${APP_ID}/header.jpg`
return {
...item,
displayImage: (match ? match[1] : item.thumbnail) || fallbackImg,
displayDate: item.pubDate.split(' ')[0],
parsedLines: parseSteamDescription(item.description)
}
})
}
} catch (e) {
console.error(e)
} finally {
loading.value = false
}
})
</script>
<template>
<div class="steam-container">
<div v-if="loading" class="loading">
正在同步 Steam 补丁说明...
</div>
<div v-else class="news-list">
<a
v-for="item in articles"
:key="item.guid"
:href="item.link"
target="_blank"
class="news-card"
@mouseenter="e => showTooltip(e, item)"
@mouseleave="hideTooltip"
>
<div class="news-card-inner">
<div class="card-text">
<div class="card-header">
<span class="tag">游戏更新</span>
<span class="date">{{ item.displayDate }}</span>
</div>
<h3 class="title">{{ item.title }}</h3>
<p class="description">
{{ item.parsedLines.join(' ').slice(0, 60) }}...
</p>
</div>
<div class="card-image-box">
<img :src="item.displayImage" />
</div>
</div>
</a>
</div>
<Teleport to="body">
<div
v-if="tooltip.visible"
class="global-tooltip"
:style="tooltip.style"
>
<div
v-for="(line, i) in tooltip.lines"
:key="i"
class="tooltip-line"
:class="{
bullet: line.text.startsWith('•'),
ellipsis: line.ellipsis
}"
>
{{ line.text }}
</div>
</div>
</Teleport>
</div>
</template>
<style scoped>
.news-list {
display: flex;
flex-direction: column;
gap: 1rem;
}
.news-card {
text-decoration: none;
color: inherit;
}
.news-card-inner {
display: flex;
justify-content: space-between;
background: #2a313d;
border: 1px solid #535a66;
border-radius: 4px;
transition: transform 0.2s, background 0.2s;
}
.news-card:hover .news-card-inner {
background: #363f4c;
transform: translateX(4px);
}
.card-text {
padding: 1rem;
}
.card-header {
font-size: 12px;
display: flex;
gap: 10px;
}
.tag {
color: #8f98a0;
}
.date {
color: #66c0f4;
}
.title {
margin: 6px 0 0;
font-size: 1.1rem;
color: #fff;
}
.description {
font-size: 0.85rem;
color: #acb2b8;
}
.card-image-box {
width: 200px;
height: 112px;
margin: 0.75rem;
overflow: hidden;
border-radius: 4px;
}
.card-image-box img {
width: 100%;
height: 100%;
object-fit: cover;
}
.global-tooltip {
background: rgba(18, 22, 28, 0.96);
border: 1px solid #3d4450;
border-radius: 4px;
padding: 12px;
width: 700px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
z-index: 9999999;
pointer-events: none;
}
.tooltip-line {
font-size: 0.8rem;
color: #dcdedf;
line-height: 1.45;
margin-bottom: 6px;
}
.tooltip-line.bullet {
padding-left: 14px;
text-indent: -14px;
color: #c7d5e0;
}
.tooltip-line.ellipsis {
color: #66c0f4;
font-weight: 500;
}
</style>

View File

@ -1,290 +0,0 @@
<script setup>
import { ref, onMounted } from 'vue'
const mods = ref([])
const loading = ref(true)
const STATS_CACHE_TTL = 60 * 60 * 1000 // 60 分钟
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
function getCachedStats(id) {
const raw = localStorage.getItem('workshop_stats_' + id)
if (!raw) return null
const { time, data } = JSON.parse(raw)
if (Date.now() - time > STATS_CACHE_TTL) return null
return data
}
function setCachedStats(id, data) {
localStorage.setItem(
'workshop_stats_' + id,
JSON.stringify({
time: Date.now(),
data
})
)
}
async function fetchWorkshopStats(detailUrl) {
try {
const match = detailUrl.match(/id=(\d+)/)
if (!match) return null
const cleanUrl = `https://steamcommunity.com/sharedfiles/filedetails/?id=${match[1]}`
const cached = getCachedStats(match[1])
if (cached) return cached
const workerUrl =
`https://aged-dream-7a55.liukele015.workers.dev/?url=${encodeURIComponent(cleanUrl)}`
const res = await fetch(workerUrl)
if (!res.ok) {
console.warn('Worker 返回失败:', res.status, res.statusText)
return null
}
const data = await res.json()
if (!data || !data.stats) {
console.warn('Worker 返回数据不正确:', data)
return null
}
setCachedStats(match[1], data.stats)
return data.stats
} catch (err) {
console.warn('统计获取失败:', detailUrl, err)
return null
}
}
async function loadStats(mod) {
if (!mod.link || mod.link === '#') return
if (mod.stats || mod.statsLoading) return
mod.statsLoading = true
mod.stats = await fetchWorkshopStats(mod.link)
mod.statsLoading = false
}
async function loadStatsSequentially(list) {
for (const mod of list) {
await loadStats(mod)
await sleep(150)
}
}
onMounted(async () => {
try {
const steamUrl =
'https://steamcommunity.com/workshop/browse/' +
'?appid=457140' +
'&browssemethod=trend' +
'&section=readytouseitems' +
'&actualsort=trend' +
'&p=1' +
'&numperpage=6'
// 这里使用 Cloudflare做为代理避免 CORS 问题
const proxyUrl =
`https://aged-dream-7a55.liukele015.workers.dev/?mode=workshop&url=${encodeURIComponent(steamUrl)}`
const res = await fetch(proxyUrl)
const html = await res.text()
const doc = new DOMParser().parseFromString(html, 'text/html')
const items = doc.querySelectorAll('.workshopItem')
mods.value = Array.from(items).map(item => {
const titleEl = item.querySelector('.workshopItemTitle')
const linkEl = item.querySelector('a')
const authorEl = item.querySelector('.workshopItemAuthorName a')
const imgDiv = item.querySelector('.workshopItemImg')
const bg = imgDiv?.style?.backgroundImage || ''
const bgUrl = bg.match(/url\(["']?(.*?)["']?\)/)?.[1] || null
const imgPreview = item.querySelector('img.preview_image')
const previewUrl = imgPreview?.src || null
const imgAny = item.querySelector('img')
const anyUrl = imgAny?.src || null
let thumbnail =
bgUrl || previewUrl || anyUrl ||
'https://via.placeholder.com/200x120?text=No+Image'
if (thumbnail.startsWith('//')) {
thumbnail = 'https:' + thumbnail
}
thumbnail = `https://images.weserv.nl/?url=${encodeURIComponent(thumbnail)}`
return {
title: titleEl?.innerText.trim() ?? '未知模组',
link: linkEl?.href ?? '#',
author: authorEl?.innerText.trim() ?? '匿名作者',
thumbnail,
stats: null,
statsLoading: false
}
})
loading.value = false
loadStatsSequentially(mods.value)
} catch (err) {
console.error('抓取 Workshop 失败:', err)
loading.value = false
}
})
</script>
<template>
<div class="workshop-container">
<div v-if="loading" class="loading-box">
正在连接 Steam 创意工坊...
</div>
<div v-else class="mod-grid">
<a
v-for="mod in mods"
:key="mod.link"
:href="mod.link"
target="_blank"
class="mod-card"
>
<div class="mod-img">
<img :src="mod.thumbnail" loading="lazy" />
</div>
<div class="mod-card__body">
<div class="mod-card__title">{{ mod.title }}</div>
<div class="mod-card__meta">By {{ mod.author }}</div>
<div class="mod-card__stats">
<template v-if="mod.stats">
<span>访客 {{ mod.stats.visitors }}</span>
<span>订阅 {{ mod.stats.subscribers }}</span>
<span>收藏 {{ mod.stats.favorites }}</span>
</template>
<template v-else-if="mod.statsLoading">
<span>统计加载中</span>
</template>
<template v-else>
<span></span>
</template>
</div>
</div>
</a>
</div>
</div>
</template>
<style scoped>
.workshop-container {
margin: 1.5rem 0;
}
.loading-box {
text-align: center;
padding: 2rem;
color: var(--vp-c-text-2);
background: var(--vp-c-bg-soft);
border-radius: 8px;
}
.mod-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
@media (max-width: 900px) {
.mod-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 600px) {
.mod-grid {
grid-template-columns: 1fr;
}
}
.mod-card {
background: var(--vp-c-bg-soft);
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
overflow: hidden;
text-decoration: none !important;
transition: all 0.25s ease;
}
.mod-card:hover {
border-color: var(--vp-c-brand);
transform: translateY(-4px);
background: var(--vp-c-bg-mute);
}
.mod-img {
width: 100%;
height: 125px;
background: #000;
}
.mod-img img {
width: 100%;
height: 100%;
object-fit: cover;
}
.mod-card__body {
padding: 12px;
}
.mod-card__title {
color: var(--vp-c-text-1);
font-weight: 600;
font-size: 0.95rem;
line-height: 1.3;
height: 2.6em;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.mod-card__meta {
color: var(--vp-c-text-2);
font-size: 0.8rem;
margin-top: 8px;
}
.mod-card__stats {
margin-top: 10px;
display: flex;
gap: 8px;
flex-wrap: wrap;
font-size: 0.75rem;
color: var(--vp-c-text-2);
}
.mod-card__stats span {
padding: 4px 8px;
border-radius: 999px;
border: 1px solid var(--vp-c-divider);
background: var(--vp-c-bg-soft);
}
</style>

View File

@ -1,61 +0,0 @@
/**
* VitePress 布局宽度自定义
*/
:root {
/* 1. 文档内容的最大宽度 (默认是 1152px) */
/* 设置为 1280px 或 1440px 可以让代码块更宽,减少横向滚动条 */
--vp-content-max-width: 1280px;
/* 2. 整个页面的最大宽度 (包括侧边栏和正文) */
--vp-layout-max-width: 1600px;
/* --vp-c-brand-1: #8f2a3b;
--vp-c-brand-2: #8f2a3b; */
}
.VPHero .name {
/* 撤销默认的渐变色背景 */
background: none !important;
-webkit-background-clip: initial !important;
background-clip: initial !important;
-webkit-text-fill-color: initial !important;
}
/* 强制覆盖首页标题的渐变效果 */
.VPHero .name span.color-w {
background: none !important;
-webkit-text-fill-color: initial !important;
color: var(--vp-c-text-1) !important;
}
.VPHero .name span.color-r {
background: none !important;
-webkit-text-fill-color: #ff4d4f !important; /* 红色 */
color: #ff4d4f !important;
}
/* 正文里的颜色 */
span.color-white {
color: #ffffff !important;
}
span.color-white {
color: #ff4d4f !important;
}
/* 如果你希望“代码块”在宽屏下表现更好,可以加上这个微调 */
@media (min-width: 1280px) {
.VPDoc .container {
/* 这里的 margin 会自动平衡左右空间 */
margin: 0 auto;
}
}
/* 3. (可选) 首页 Hero 部分的宽度调整 */
:root {
--vp-home-hero-max-width: 1152px;
}

View File

@ -1,19 +0,0 @@
// .vitepress/theme/index.mts
import DefaultTheme from 'vitepress/theme'
import './custom.css' // 这里的引入才是有效的
// @ts-ignore
import Contributors from './components/Contributors.vue'
import SteamNews from './components/SteamNews.vue'
import LearningTimeline from './components/LearningTimeline.vue'
import WorkshopList from './components/WorkshopList.vue'
export default {
extends: DefaultTheme,
enhanceApp({ app }: any) {
app.component('Contributors', Contributors)
app.component('SteamNews', SteamNews)
app.component('LearningTimeline', LearningTimeline)
app.component('WorkshopList', WorkshopList)
}
}

View File

@ -1,115 +0,0 @@
<div align="center">
<h1>🧩 ONIModTutorial</h1>
[![VitePress](https://img.shields.io/badge/Docs-VitePress-4FC08D)](https://vitepress.vuejs.org/)
_📘 《缺氧Oxygen Not Included》Mod 开发教程 · 从入门到进阶 · 长期维护_
</div>
---
## 🎯 仓库目标
- 帮助新人快速入门 ONI Mod 开发
- 系统整理缺氧 Mod 常用技术与思路
- 记录 Harmony 补丁、反编译、组件分析等实战经验
- 作为长期维护的知识库,而不是零散笔记
---
## 📚 教程内容概览
教程内容主要包括(并持续补充中):
- 缺氧 Mod 开发基础认知
- 开发环境搭建
- Mod 基本结构与加载流程
- C# 基础(面向 ONI Mod
- Harmony 补丁详解与实战
- dnSpy / 反编译分析游戏源码
- 常见系统解析建筑、复制人、植物、逻辑、UI 等)
- 实用代码示例与踩坑记录
---
## 📁 仓库结构说明
- content/
教程正文内容,所有章节均以 `.md` 文件形式存在
- preface.md —— 教程引言
- csharp-basics.md —— C# 基础ONI Mod 向)
- harmony-reference.md —— Harmony 补丁整理与示例
- 其他章节持续增加中…
- .github/workflows/
GitHub Actions 配置(如自动构建文档)
- vitepress/
VitePress 文档站点配置
- public/
文档站点用到的静态资源
---
## 🚀 本地测试
### 直接阅读(推荐)
- 直接在 GitHub 中按顺序阅读 `content` 目录下的 Markdown 文件即可
### 本地测试运行文档站点(可选)
1. 安装 Node.js推荐使用 v16 及以上长期支持版本【LTS】windows系统确保安装时勾选添加到 PATH
[Node.js下载及安装](https://nodejs.org/zh-cn/download)
安装完成后,打开终端(如 bash、PowerShell、CMD 等),输入 `node -v` 确认安装成功并正确添加Node到系统环境变量中。
2. 克隆仓库
```
git clone https://github.com/ChiYuKe/ONIModTutorial.git
```
3. 安装依赖
```
npm install
```
4. 启动本地文档
```
npm run dev
```
5. 浏览器访问终端提示的本地地址,通常是 `http://localhost:端口号/ONIModTutorial/`
```
http://localhost:5173/ONIModTutorial/
```
6. 在浏览器尽情阅读
---
## 🧠 适合人群
✔ 想制作《缺氧》Mod 的玩家
✔ 有一定 C# 基础,想深入理解 ONI 内部逻辑
✔ 希望系统学习 Harmony Patch 的开发者
✔ 已在做 Mod但想补齐底层理解的人
---
## 🤝 贡献说明
欢迎任何形式的贡献,包括但不限于:
- 修正教程错误
- 补充新的章节
- 提供实战案例
- 优化结构和表述
你可以通过 **Issue****Pull Request** 提交改动。
---

View File

@ -1,7 +0,0 @@
::: info 提示
下方动态实时同步自 Steam 官方,若图片加载较慢请稍候。
:::
<ClientOnly>
<SteamNews />
</ClientOnly>

View File

@ -1,3 +0,0 @@
---
outline: deep
---

View File

@ -1,109 +0,0 @@
# 🎨 游戏资产提取 (Asset Extraction)
在进行《缺氧》Oxygen Not Included的 Mod 开发时,获取原版资产(贴图、动画、文本)是进行二次创作和保持视觉一致性的基础。本章将详细介绍开发者常用的资产解包与处理工具。
## 一 . 资源解包
### 1.1 AssetRipper
目前处理 Unity 引擎资源最强大的开源工具之一。它不仅能提取静态贴图,还能在一定程度上还原 Unity 项目的资源目录结构。
* **[📥 官方仓库 (GitHub Releases)](https://github.com/AssetRipper/AssetRipper/releases)**
* **适用范围**UI 图标Sprite、建筑贴图Texture2D、音频文件AudioClip... 。
#### 🛠️ 提取指南
* **载入资源:** 运行 `AssetRipper` ,选择游戏的 `OxygenNotIncluded_Data` 文件夹。
* **资源导出:** 在视图中,通过 `Export`导出全部资源。
### 1.2 AssetStudio
如果你不需要还原整个项目只想快速找到某几张特定的贴图、立绘或听一段音频AssetStudio 是更高效的选择。它支持实时预览,让你在导出前就能看到资源内容。
* **[📥 官方仓库 (GitHub Releases)](https://github.com/aelurum/AssetStudio/releases)**
* **适用范围**:快速筛选特定贴图、导出 3D 模型Mesh、预览动画片段... 。
#### 🛠️ 提取指南
* **载入资源:** 运行 `AssetStudioModGUI` ,点击菜单栏的 `File` -> `Load Folder` ,选择游戏的 `OxygenNotIncluded_Data` 文件夹。
* **资源导出:** 点击 `Filter Type` 勾选你需要的类型(如 `Texture2D` `Sprite` `TexAsset`),最后 `Export` -> `Filtered assets` 导出勾选的类型
### 💡 进阶技巧:如何选择工具?
| 需求场景 | 推荐工具| 优势 |
|----------|----------|----------|
| 我想研究游戏的 UI 布局或逻辑 | `AssetRipper` | 能够尽可能还原 `.prefab` 和文件夹结构。 |
| 我只想拿到动画纹理资源 | `AssetStudio` | 无需等待漫长的导出过程,导出方便 |
---
## 二 . 动画处理
《缺氧》的动态表现基于 Klei 自定义的 **KAnim** 系统,而非 Unity 原生动画。每个动画对象由三个核心文件组成:`图集(*_0.png)``结构(*_build.bytes)``序列(*_anim.bytes)`
### 🛠️ 推荐转换工具
#### kanimal-SE (KAnim转换)
**kanimal-SE** 是处理 KAnim 的标准工具,支持将字节流转换为可编辑的 SCML 格式。
* **[📥 官方仓库 (kanimal-SE)](https://github.com/skairunner/kanimal-SE)**
::: code-group
```powershell [Windows (PowerShell)]
# 解包:将 KAnim 转换为可编辑的 SCML (用于 Spriter 编辑)
.\kanimal-cli.exe scml [file_name].png [file_name]_anim.bytes [file_name]_build.bytes
# 打包:将修改后的 SCML 重新编译为游戏可读的 KAnim
.\kanimal-cli.exe kanim [file_name].scml
```
:::
::: tip 🚀 推荐KAnim_GUI (可视化操作)
**KAnim_GUI** 对 `kanimal-SE` 提供了极简的图形化界面,支持快速解压和重组 KAnim极大地降低了命令行操作的门槛。需要将 `kanimal-SE(kanimal-cli.exe)` 放入 `KAnim_GUI(KAnimGui.exe)` 同目录下才能正常工作
* **[📥 官方仓库 (KAnim_GUI)](https://github.com/ChiYuKe/KAnim_GUI)**
:::
---
## 三 . 多语言与文本处理
无论是寻找建筑的 `PrefabID`,还是为 Mod 增加多语言支持,都需要处理 `.po` 格式的翻译文件。
### 🔍 文本利器Poedit
* **[📥 官方下载 (Poedit 官网)](https://poedit.net/)**
::: info 实战技巧
* **快速溯源**:使用 `Ctrl + F` 搜索游戏内的中文词条(如“电解器”),即可快速定位其对应的 `StringKey`(例如:`STRINGS.BUILDINGS.PREFABS.ELECTROLYZER.NAME`)。
* **规范化翻译**:使用 Poedit 维护你的 `zh.po` 文件,可以确保翻译格式完全符合 Klei 的底层加载规范,避免乱码。
:::
---
## ⚠️ 开发准则与约束
::: danger 法律声明:严禁商业用途
所有提取自《缺氧》的游戏资产(包括但不限于原画、音效、动画脚本、底层代码)所有权均归 **Klei Entertainment** 所有,严禁用于任何形式的商业盈利行为。
:::
::: warning 尊重版权
* **禁止二次分发**:请勿在公开平台分发未经大幅修改的官方原始资源包。
* **致谢声明**:若你的作品基于官方素材修改,请在说明文档中按照惯例标注 `"Credit to Klei Entertainment"`。
:::
---
<div align="center" style="margin-top: 3rem; padding: 2rem; border-top: 1px solid var(--vp-c-divider);">
<p style="font-size: 1.1rem; font-style: italic; color: var(--vp-c-text-2); margin-bottom: 1.5rem;">
“逻辑是生存的第一步,而代码是改写规则的起点。”
</p>
<a href="dnspy-analysis">
<button style="background: var(--vp-c-brand-1); color: white; padding: 10px 24px; border-radius: 20px; font-weight: bold; cursor: pointer; border: none;">
游戏源码工具 →
</button>
</a>
</div>

View File

@ -1,37 +0,0 @@
# 开源协议与社区规范
在开发《缺氧》Mod 并将其发布至 Steam 创意工坊之前请务必阅读并遵守科雷Klei官方发布的通用准则。
## 官方准则 (Klei Official Guidelines)
> [!IMPORTANT]
> **官方原文链接:** [General Mod and & UGC Guidelines](https://support.klei.com/hc/en-us/articles/360029556052-General-Mod-and-UGC-Guidelines)
### 1. 允许的 Mod 类型
* **新实体**:包括自定义美术资产和特殊能力的各色角色。
* **平衡调整**:对现有角色、建筑或物品的数值微调。
* **逻辑修改**:改变生物行为、世界生成规则或 UI 界面。
* **新机制**:为玩家提供全新的游戏挑战或功能扩展。
### 2. 严禁行为 (Prohibited)
为了维护社区环境,以下行为是被严格禁止的,违规可能导致 Mod 被下架:
* **侵权与盗用**:未经授权使用他人作品,或包含未授权的版权材料(如其他游戏的素材)。
* **破解与绕过**:试图解锁 DLC、皮肤或绕过付费所有权验证。
* **代码混淆****禁止加密或模糊化代码**。Klei 官方和玩家必须能够审计代码以确保安全性。
* **商业化/付费墙**:严禁任何形式的付费 Mod、付费皮肤或“赞助者提前体验”等金钱交易。
### 3. 开发礼仪 (Etiquette)
* **默认不授权**:若原作者未明确说明,一律视为“未获得授权”。
* **二次开发**:引用或修改他人作品前请务必联系作者,并注明出处。
* **维护义务**:作者没有义务必须更新 Mod但建议在发布时提供完整的说明和截图。
* **关于弃坑**:若原作者未明确禁止且 Mod 已失效,社区成员可以进行兼容性更新并重新上传,但需尊重原作者的移除请求。
---
## 开源协议建议
对于你自己的代码,我建议在 GitHub 上选择一个开源协议(如 **MIT****GPL-3.0**)。
* **MIT**:最宽松,别人可以随意使用你的代码,只需保留你的署名。
* **GPL-3.0**:最严格,如果别人用了你的代码,他们的 Mod 也必须开源。
**尊重他人劳动成果,是社区良性发展的基石。**

View File

@ -1,175 +0,0 @@
# 🚀 编写第一个 物品
本章将带你亲手编写一个物品或者说掉落物。
---
## 一 . 准备工作
在开始之前,你需要手动创建一个文件夹,用于存放你开发的 Mod 文件:
* **路径**`%USERPROFILE%\Documents\Klei\OxygenNotIncluded\mods\`
* **操作**:在此目录下创建一个名为 **`Dev`** 的文件夹。
---
## 二 . 创建项目
1. 打开 **Visual Studio 2022**
2. 选择 **创建新项目** -> 搜索 **类库**(建议选择支持 **.NET Standard 2.1** 的类库模板)-> 点击下一步。
3. **项目名称**:输入 `MyFirstItem`
4. **目标框架**:务必选择 **.NET Standard 2.1**。
---
## 三 . 导入游戏核心库 (References)
你需要把游戏的 `.dll` 文件“介绍”给 Visual Studio它才能理解游戏代码。
1. 在右侧 **解决方案资源管理器** 中,当然你的可能在左侧,右键点击 **引用 (References)** -> **添加引用**
2. 点击 **浏览**,进入游戏目录:
`...\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\`
3. **选中并添加以下文件:**
* `Assembly-CSharp.dll`
* `Assembly-CSharp-firstpass.dll`
* `0Harmony.dll`
* `UnityEngine.dll`
* `UnityEngine.CoreModule.dll`
---
## 四 . 编写代码
在我们的工程中,创建如下 `.cs` 文件结构:
``` 文件结构
MyFirstItem/
├── Patch.cs # Harmony补丁入口文件用来在游戏加载时注册你的Mod逻辑
├── MyFirstItemConfig.cs # 物品的定义文件ID、动画、属性等核心配置
├── STRINGS.cs # 本地化文本(名称、描述、效果说明)
└── MyFirstItem.cs # 自定义组件逻辑(功能代码实现)
```
---
### MyFirstItemConfig.cs 的处理
我们需要先继承 `IEntityConfig`。
在 Oxygen Not Included 中:
> `IEntityConfig` 是用来“定义一个实体”的接口。
简单说:
> 它告诉游戏:我要注册一个新的实体,请按这些规则创建它。
---
### 基础结构
```csharp
using System.Collections.Generic;
using UnityEngine;
namespace ONIModTutorialCode
{
public class MyFirstItemConfig : IEntityConfig
{
public GameObject CreatePrefab()
{
}
public void OnPrefabInit(GameObject inst)
{
// 预制体初始化时调用
}
public void OnSpawn(GameObject inst)
{
// 实例生成时调用(生成到地图上才会触发)
}
public string[] GetDlcIds()
{
return null; // 所有 DLC 可用
}
}
}
```
---
### 实现 CreatePrefab()
在 `CreatePrefab()` 中,我们使用 `EntityTemplates.CreateLooseEntity()` 来注册它。
这里的动画资源我们使用仙水掌的 `cactus_kanim` 中的 `idle_empty` 状态。
常规掉落物通常使用 `"object"`。
(这里为什么是 `idle_empty` 而不是 `object`,我们会在后面说明。)
---
### 完整代码(可直接复制)
```csharp
using System.Collections.Generic;
using UnityEngine;
namespace ONIModTutorialCode
{
public class MyFirstItemConfig : IEntityConfig
{
// 物品ID
public const string ID = "MYFIRSTITEM";
public GameObject CreatePrefab()
{
GameObject gameObject = EntityTemplates.CreateLooseEntity(
ID,
STRINGS.ITEMS.MYFIRSTITEM.NAME,
STRINGS.ITEMS.MYFIRSTITEM.DESC,
5f,
true,
Assets.GetAnim("cactus_kanim"),
"idle_empty",
Grid.SceneLayer.SolidConduits,
EntityTemplates.CollisionShape.RECTANGLE,
0.6f,
0.6f,
true,
0,
SimHashes.Creature,
new List<Tag> { GameTags.IndustrialIngredient }
);
return gameObject;
}
public void OnPrefabInit(GameObject inst)
{
// 预制体初始化时调用
}
public void OnSpawn(GameObject inst)
{
// 实例生成时调用
}
public string[] GetDlcIds()
{
return null;
}
}
}
```
---
> 🚧 **To Be Continued...**
>
> 先写一点,有点累了,睡一觉

View File

@ -1,11 +0,0 @@
---
layout: home
hero:
name: <span class="color-r">加入贡献</span>
text: 共同打造这个教程文档
tagline: 无论你是新手还是大佬,我们都欢迎。
actions:
- theme: brand
text: 加入群聊(QQ)
link: https://qm.qq.com/q/9IXwoJzOus
---

View File

@ -1,10 +0,0 @@
---
editLink: false
---
# 贡献者名单
感谢所有为本项目做出贡献的小伙伴!
<Contributors repo="ChiYuKe/ONIModTutorial" />

View File

@ -1,182 +0,0 @@
---
sidebar: false
---
<a href="javascript:history.back()" class="back-button">
⬅ 返回
</a>
<style scoped>
.back-button {
position: fixed;
left: 20px;
top: 100px;
display: flex;
align-items: center;
gap: 8px;
padding: 10px 15px;
background-color: var(--vp-c-brand);
color: white !important;
border-radius: 20px;
text-decoration: none !important;
font-weight: bold;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
transition: transform 0.2s;
z-index: 100;
cursor: pointer;
}
.back-button:hover {
transform: scale(1.05);
opacity: 0.9;
}
</style>
# ⚡ C# 核心语法
---
这不是一篇“C# 入门”,而是 **专门为《缺氧ONI》Mod 开发提炼的最小语法集**
> 🎯 阅读目标:
>
> * 能**直接看懂 ONI 源码**
> * 能**独立写 Harmony Patch**
> * 知道哪些语法是“必须会”,哪些可以先无视
---
## 🧠 总览
> **ONI Mod 的 C# 本质只有四件事:**
>
> 1⃣ 类 + 组件
> 2⃣ static + ref
> 3⃣ 数组 + 泛型
> 4⃣ null 判断
下面所有内容,都是在为这四点服务。
---
## 🧱 一、class 是一切的起点
### 你在 ONI 里只会写这三种类
```csharp
public class XXXConfig : IBuildingConfig {}
public class XXXPatch {}
public class XXXComponent : KMonoBehaviour {}
```
结论:
* **类必须是 `public`**
* 不要纠结面向对象
---
## 🔧 二、static为什么 Patch 必须是 static
### 普通方法ONI 几乎不用)
```csharp
public void DoSomething() {}
```
### Patch 方法(必须这样)
```csharp
public static void Postfix() {}
```
原因一句话解释:
> Harmony **不会 new 你的类**,只能调用静态方法。
👉 **Patch 写错 90% 都是这里的问题**
---
## 🧬 三、ref为什么 ONI Patch 能“改游戏”
### 没有 ref改不到
```csharp
public static void Postfix(BuildingDef def)
{
def.EnergyConsumptionWhenActive = 1f; // ❌ 无效
}
```
### 有 ref直接改内存
```csharp
public static void Postfix(ref BuildingDef __result)
{
__result.EnergyConsumptionWhenActive = 1f; // ✅ 生效
}
```
一句话结论:
> **Harmony 能改游戏,全靠 ref。**
---
## 📦 四、组件思维ONI ≈ Unity
### 所有功能 = 组件
```csharp
go.AddOrGet<ElementConverter>();
go.AddOrGet<Operational>();
```
### AddOrGet 的真实含义
```text
有 → 拿
无 → 加
```
> ❗ ONI 世界里
>
> * **没有组件 = 没有功能**
---
## 🔍 五、泛型 `<T>`:不要怕,它只是“占位”
### 看到下面这两行,直接翻译成中文
```csharp
go.AddOrGet<ElementConverter>();
go.GetComponent<KPrefabID>();
```
翻译:
> “我要 **ElementConverter** 这个组件”
> `<T>` = 类型占位符,仅此而已
---
## 🚧 六、null 判断ONI Mod 的生命线
### 正确写法
```csharp
var converter = go.GetComponent<ElementConverter>();
if (converter == null)
return;
```
原因一句话:
> Patch 执行顺序不固定,**组件不一定存在**。
👉 **不写 null 判断 = 随机崩溃**
---

View File

@ -1,77 +0,0 @@
# 🛠️ C# 开发基础ONI Mod 专用)
在编写《缺氧Oxygen Not Included, ONI》Mod 代码之前,你需要掌握一些 **C# 的核心概念**。本篇内容将**专门围绕 ONI Mod 开发中最常见、最实用的语法与结构**展开,避免泛泛而谈。
---
## 📦 一、命名空间与类Namespace & Class
《缺氧》的源码规模非常庞大,因此大量使用 **命名空间namespace** 来对功能进行划分。你的 Mod 代码也应当遵循这一习惯,以避免冲突、提升可维护性。
### ✅ 开始
::: danger 💡 建议
如果不知道什么是 `空间命名namespace` `类名Class` `方法名Method` 是什么的,在这里你就可以止步了,可以花点时间快速了解一下 `C#` ,这会让你后续的开发事半功倍。
:::
* [C# 杂七杂八](./csharp-basics-reference.md)
* [Harmony的小整理](./harmony-reference.md)
* [Harmony官方文档](https://harmony.pardeike.net/articles/patching.html)。
---
---
## 🔧 二、HarmonyPatch精准定位游戏源码
在《缺氧》Mod 开发中,`[HarmonyPatch]` 属性Attribute就像一个**手术定位仪**。它告诉补丁框架:你需要拦截哪个“类”里的哪个“方法”。
### 1. 核心语法:三种定位方式
根据目标方法的复杂程度,你通常会用到以下三种写法:
| 定位类型 | 代码示例 (Attribute) | 适用场景 |
| :--- | :--- | :--- |
| **基础定位** | `[HarmonyPatch(typeof(Db), "Initialize")]` | **最常用**。目标类中只有一个同名方法时使用。 |
| **重载定位** | `[HarmonyPatch(typeof(Assets), "GetSprite", new Type[] { typeof(HashedString) })]` | 当方法有**多个重载**(名字相同但参数不同)时,必须指定参数类型。 |
| **属性定位** | `[HarmonyPatch(typeof(BuildingDef), "IsSolid", MethodType.Getter)]` | 专门用于拦截 C# 的 **属性 (Property)**。需指定是修改 `Getter` 还是 `Setter`。 |
---
### 2. 🔍 实战:如何从 dnSpy 提取 Patch 信息?
当你使用 **dnSpy** 查看游戏源码 `Assembly-CSharp.dll` 时,请按照以下逻辑进行拆解:
* **类名 (Class)**:看代码最顶层的 `public class` 后面跟着的单词。
* 源码:`public class GeneratedBuildings`
* 对应参数:**`typeof(GeneratedBuildings)`**
* **方法名 (Method)**:看括号左边的那个单词。
* 源码:`public static void LoadGeneratedBuildings(...)`
* 对应参数:**`"LoadGeneratedBuildings"`**
* **参数类型 (Parameters)**:看括号里面的内容,如果是[重载](./harmony-reference.md#postfix-Overloading)方法则需要提取。
* 源码:`(ICollection<Type> types)`
* 对应参数:**`new Type[] { typeof(ICollection<Type>) }`**
---
### 3. 📝 标准代码结构模板
```csharp
using HarmonyLib; // 必须引用 Harmony 库
using UnityEngine; // 如果用到 Debug.Log 或 GameObject
namespace MyOniMod
{
// 1. 定位:我们要改哪个类的哪个方法?
[HarmonyPatch(typeof(EntityConfigManager), "LoadGeneratedEntities")]
public class MyEntityPatch
{
// 2. 注入在原方法执行后Postfix做点什么
public static void Postfix()
{
// 你的逻辑代码
Debug.Log("ONI Mod: 游戏实体加载完成!");
}
}
}

View File

@ -1,24 +0,0 @@
# 🛠️ 开发环境搭建
在编写代码之前,我们需要准备好开发工具,并配置针对《缺氧》的自动编译环境。
---
## 软件准备清单
你需要安装以下工具。请确保它们已正确安装:
| 工具 | 作用 | 下载链接 | 推荐版本 |
| :--- | :--- | :--- | :--- |
| **Visual Studio 2026** | 核心开发 IDE | [官方下载地址](https://visualstudio.microsoft.com/zh-hans/vs/community/) | 社区版 (Community) |
| **dnSpy** | 逆向源码 / 找代码 | [GitHub 下载页](https://github.com/dnSpy/dnSpy/releases) | 最新版 (win64) |
---
### ⚠️ 核心注意事项
> **💡 关键点:关于 .NET 版本**
> 《缺氧》官方现在把 [**.NET Standard 2.1**](https://learn.microsoft.com/zh-cn/dotnet/standard/net-standard) 视为模组开发的更佳起点;与此同时,游戏本体仍保留 Unity 的 **.NET Framework API Compatibility Target** 作为兼容层。
>
> * **如果不选这个版本**:你的 Mod 在加载时也许会报错,或者更容易遇到引用和兼容性问题。
> * **VS 安装提示**:在安装 Visual Studio Installer 时,请务必勾选 **“.NET 桌面开发”** 工作负荷,并确保已安装用于 **.NET Standard 2.1** 的相关开发组件。
> * [图文安装教程](./visual-studio-installation.md) <span id="back-point"></span>|

View File

@ -1,24 +0,0 @@
# 🎨 游戏代码反编译
## 一. 代码反编译
如果你想了解游戏的逻辑(如建筑如何运作、掉落概率等),你需要反编译游戏的 `.dll` 文件。
### 🛠️ 工具dnSpy
目前社区最推荐的 `.NET` 反编译器和调试器。
* **[📥 官方仓库 (GitHub Releases)](https://github.com/dnSpyEx/dnSpy/releases)**
* **适用范围**:查看 `C#` 代码、搜索特定方法、甚至直接修改并重新编译代码。
#### 💡 操作步骤
* 找到游戏的程序集文件:通常位于 `OxygenNotIncluded_Data/Managed/Assembly-CSharp.dll`
* 将该文件拖入 **dnSpy**
* 使用 `Ctrl + Shift + K` 进行全局搜索,快速定位你想研究的类名(如 `ElectrolyzerConfig` )。
* 或者选择目标 `.dll` 文件,将其导出成 `Visual Studio` 工程文件。

View File

@ -1,137 +0,0 @@
# 🚀 编写第一个 Mod节能电解器
本章将带你亲手编写一个 Mod把电解器的 120W 功耗改为 1W。
---
## 一 . 准备工作
在开始之前,你需要手动创建一个文件夹,用于存放你开发的 Mod 文件:
* **路径**`%USERPROFILE%\Documents\Klei\OxygenNotIncluded\mods\`
* **操作**:在此目录下创建一个名为 **`Dev`** 的文件夹。
---
## 二 . 创建项目
1. 打开 **Visual Studio 2022**
2. 选择 **创建新项目** -> 搜索 **类库**(建议选择支持 **.NET Standard 2.1** 的类库模板)-> 点击下一步。
3. **项目名称**:输入 `MyFirstMod`
4. **目标框架**:务必选择 **.NET Standard 2.1**。
---
## 三 . 导入游戏核心库 (References)
你需要把游戏的 `.dll` 文件“介绍”给 Visual Studio它才能理解游戏代码。
1. 在右侧 **解决方案资源管理器** 中,当然你的可能在左侧,右键点击 **引用 (References)** -> **添加引用**
2. 点击 **浏览**,进入游戏目录:
`...\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\`
3. **选中并添加以下文件:**
* `Assembly-CSharp.dll`
* `Assembly-CSharp-firstpass.dll`
* `0Harmony.dll`
* `UnityEngine.dll`
* `UnityEngine.CoreModule.dll`
---
## 四 . 编写补丁代码
<!-- <a href="./harmony-replenish#postfix" class="guide-link">
🚀 了解 Postfix
</a>
<style scoped>
.guide-link {
display: inline-flex;
align-items: center;
gap: 8px;
margin: 10px 0;
padding: 8px 16px;
background-color: var(--vp-c-brand-soft); /* 浅色背景 */
color: var(--vp-c-brand-1) !important; /* 品牌主色文本 */
border: 1px solid var(--vp-c-brand);
border-radius: 8px;
font-weight: 600;
text-decoration: none !important;
transition: all 0.2s ease;
}
.guide-link:hover {
background-color: var(--vp-c-brand); /* 悬浮变深色 */
color: white !important;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
</style> -->
::: info 进阶指引
想要进一步了解补丁?请点击阅读:
[了解 Postfix →](./harmony-reference.md#postfix)
:::
删除项目自动生成的 `Class1.cs` 里的所有内容,粘贴下面的代码:
```csharp
using HarmonyLib;
namespace MyFirstMod
{
// 告诉游戏:要在 ElectrolyzerConfig 的 CreateBuildingDef 执行完后动刀
[HarmonyPatch(typeof(ElectrolyzerConfig), "CreateBuildingDef")]
public class MyFirstPatch
{
// Postfix 代表后置补丁
public static void Postfix(ref BuildingDef __result)
{
// 将电解器的功耗改为 1 瓦
__result.EnergyConsumptionWhenActive = 1f;
Debug.Log("电解器的功耗已被修改为 1 瓦");
}
}
}
```
### 📝 调试技巧
> 如果 Mod 运行不正常,可以在这里查看日志排查:
`%USERPROFILE%\AppData\LocalLow\Klei\Oxygen Not Included\player.log`
---
## 🎁 五 . 下载项目模板 (可选)
前面叽里咕噜没看懂?
没关系我这里提供了一份Mod模板如果你是按教程来的那么在这里我将默认你安装了Visual Studio 2026版本。
### 安装方法:
* [点击此处下载模板 .zip 文件](/templates/ONIModTemplate.zip)(不要解压)。
* 将其放入Visual Studio 模板文件夹:
> `%USERPROFILE%\Documents\Visual Studio 18\Templates\ProjectTemplates`
<details>
<summary>📸 点击展开查看ProjectTemplates目录结构</summary>
<br>
<div align="center">
<img src="/images/first-mod/Project.png" alt="发布界面" width="600" />
</div>
</details>
* 重启你的Visual Studio, 创建项目时候你将可以看到:
<details>
<summary>📸 点击展开查看预览图</summary>
<br>
<div align="center">
<img src="/images/first-mod/ModTemplate.png" alt="发布界面" width="600" />
</div>
</details>
## 六 . 编译与部署
1. **生成 DLL**:点击顶部菜单栏的 **生成 (Build)** -> **生成解决方案** 或者直接在 **解决方案资源管理器** 当中右键项目然后 **生成 (Build)**
2. **找到文件**:进入项目文件夹的 `bin/Debug` 目录,找到 `MyFirstMod.dll`
3. **放入游戏**:在 `Documents\Klei\OxygenNotIncluded\mods\Dev\` 当中创建一个`MyFirstMod`文件夹,将 `MyFirstMod.dll`放入其中,记住不要少了上一章讲的
`mod.yaml``mod_info.yaml`
---

View File

@ -1,395 +0,0 @@
---
sidebar: false
---
<a href="javascript:history.back()" class="back-button">
⬅ 返回
</a>
<style scoped>
.back-button {
position: fixed;
left: 20px;
top: 100px;
display: flex;
align-items: center;
gap: 8px;
padding: 10px 15px;
background-color: var(--vp-c-brand);
color: white !important;
border-radius: 20px;
text-decoration: none !important;
font-weight: bold;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
transition: transform 0.2s;
z-index: 100;
cursor: pointer;
}
.back-button:hover {
transform: scale(1.05);
opacity: 0.9;
}
</style>
# 🧩 Harmony 补丁整理
> **本篇是 Harmony 在《缺氧ONI》Mod 开发中的实战速查表**
> 👉 目标:**快速了解以及什么时候该用哪一种 Patch**
---
## 📖 阅读指引
- **基础操作**:了解 `Harmony` 初始化及 `Prefix / Postfix` 的基本用法。
- **常用参数**:了解 `__instance / __state / AccessTools` 读写游戏数据。
- **特殊场景**:了解 `Transpiler / Finalizer` 处理底层逻辑与异常的方式。
---
## 🧠 一、Harmony 是什么?
Harmony 是一个 **运行时方法注入库**,用于在**不修改源代码**的情况下:
- 插入逻辑
- 拦截原方法
- 修改返回值
- 重写部分执行流程
---
## 🧩 二、Patch 类型总览
| Patch 类型 | 执行时机 | 常见用途 |
|----------|----------|----------|
| Prefix | 原方法执行前 | 拦截 / 改参数 / 阻止执行 |
| Postfix | 原方法执行后 | 补充逻辑 / 改返回值 |
| Transpiler | IL 层 | 改硬编码 / if / 常量 |
| Finalizer | 所有逻辑后 | 捕获异常 / 兜底 |
---
## ⚙️ 三、Harmony 初始化
> 在 ONI 中,继承 UserMod2 后,游戏会自动帮你执行 harmony.PatchAll()。你不需要再手动调用它,除非你有特殊的动态补丁需求。
```csharp
using HarmonyLib;
using KMod;
namespace MyMod
{
public class MyFirstMod : UserMod2
{
public override void OnLoad(Harmony harmony)
{
// 1. 必须保留基类调用,它会处理自动 PatchAll
base.OnLoad(harmony);
// 2. 这里通常用来放“全局初始化”逻辑
// 比如:打印日志确认 Mod 已加载
Debug.Log("MyFirstMod 已成功加载!");
}
}
}
```
---
## 🟦 四、Prefix执行前拦截
`Prefix` 用于在原代码跑起来之前先一步执行。
### 4.1 基础用法:单纯插入逻辑
如果你只想在某个动作发生时顺便做点事(比如记录日志),补丁返回 void 即可。
```csharp
[HarmonyPatch(typeof(Operational), nameof(Operational.SetActive))]
public static class Log_Patch
{
public static void Prefix(bool value)
{
// 只是看一眼参数,不影响原逻辑执行
Debug.Log($"建筑状态尝试切换为: {value}");
}
}
```
---
### 4.2 进阶用法:干预原逻辑
如果你想改变游戏的结果,需要注意 bool 返回值和 ref 关键字的作用。
| 方式 | 代码关键点| 实际效果 |
|----------|----------|----------|
| 强行篡改 | `ref bool value` | 改指令。 原代码照样跑,但你偷偷换掉了它的参数(比如让关机指令变成开机) |
| 彻底拦截 | `return false` | 断后路。 原代码被直接掐断,后面的逻辑(动画、音效、状态改变)全都不再执行 |
**案例对比:**
我们依然是在`[HarmonyPatch(typeof(Operational), nameof(Operational.SetActive))]`上打补丁。
```csharp
// 情况 A篡改参数原逻辑继续跑但用你的数
public static void Prefix(ref bool value)
{
value = true; // 哪怕玩家点了关闭,建筑也会因为参数被改而保持开启
}
// 情况 B彻底拦截原逻辑直接罢工
public static bool Prefix(bool value, bool force_ignore)
{
return false; // 原方法体内的代码一行都不会跑,功能被完全“冻结”
}
```
---
<h2 id="postfix">🟩 五、Postfix执行后补充</h2>
`Prefix` 在原方法执行完毕后运行。它是最推荐的补丁方式,因为它不会中断游戏的正常逻辑,兼容性最好。
### 5.1 实战代码:追加额外逻辑
- 作用: 在原逻辑跑完后,顺便执行一些你自己的操作。
```csharp
[HarmonyPatch(typeof(ElectrolyzerConfig), "CreateBuildingDef")]
public class ElectrolyzerCreateBuildingDef_Patch
{
public static void Postfix(ref BuildingDef __result)
{
// 将电解器的功耗改为 1 瓦
__result.EnergyConsumptionWhenActive = 1f;
Debug.Log("电解器的功耗已被修改为 1 瓦");
}
}
```
- 场景: 初始化后的属性修正、添加自定义的组件、触发额外的通知。
- 优势: 无论你的代码写得好不好,原版代码都已经安全跑完了,不会导致核心功能丢失。
---
### 5.2 修改返回值:修改计算结果
- 作用: 劫持原方法的返回值,让游戏拿到你“调包”后的结果。
```csharp
[HarmonyPatch(typeof(Overheatable), nameof(Overheatable.OverheatTemperature), MethodType.Getter)]
public static class Overheatable_OverheatTemperature_Patch
{
// ref __result 指向原方法算出来的那个返回值
public static void Postfix(ref float __result)
{
__result = 9999f; // 让建筑永远不会因为温度过高而损坏(强行改掉判定数值)
}
}
```
| 枚举项 | 怎么认出它(看 ILSpy/dnSpy | 干嘛的 |
| :--- | :--- | :--- |
| **Normal** | 方法名后面带个括号,比如 OnSpawn() | 在某个动作执行前后“插一脚” |
| **Getter** | 代码里长这样float Speed { get; } | 用于修改游戏“读取”到的数据 |
| **Setter** | 代码里长这样set { ... } | 用于在游戏尝试修改某个数值时进行拦截 |
| **Constructor** | 跟类名长得一模一样的方法 | 在对象刚创建、还没放进世界时,提前修改它的默认字段或初始化逻辑 |
| **StaticConstructor** |前面带 static 的构造函数 | 专门用来修改游戏加载时就定死的全局静态常量 |
| **Enumerator** | 里面有一堆 yield return 的方法 | 专门对付 ONI 里的异步动作、动画序列或那些不是瞬间完成的任务 |
<h3 id="postfix-Overloading">5.3 处理重载</h3>
在 ONI 源码中经常会出现多个方法名相同但参数不同的方法。如果不指定参数类型Harmony 会报错。
**案例:拦截 `ModUtil.AddBuildingToPlanScreen`**
这个方法在游戏源码中有多个重载版本,我们对比来看:
```csharp
public static class ModUtil
{
// 重载 A只有 2 个参数
public static void AddBuildingToPlanScreen(HashedString category, string building_id) { ... }
// 重载 B有 3 个参数
public static void AddBuildingToPlanScreen(HashedString category, string building_id, string subcategoryID) { ... }
// 重载 c有 5 个参数
public static void AddBuildingToPlanScreen(HashedString category, string building_id, string subcategoryID, string relativeBuildingId, ModUtil.BuildingOrdering ordering = ModUtil.BuildingOrdering.After) { ... }
}
// 【对应的 HarmonyPatch 写法】
// 拦截“重载 B”必须明确写出那 3 个参数的类型:
[HarmonyPatch(typeof(ModUtil), "AddBuildingToPlanScreen", new Type[] { typeof(HashedString), typeof(string), typeof(string) })]
// 试试举一反三 重载a会是怎么样的
// ❌ 错误写法
[HarmonyPatch(typeof(ModUtil), "AddBuildingToPlanScreen")]
```
---
### 🛠️ 总结Prefix 与 Postfix 怎么选?
- 选 Prefix 的唯一理由:你需要在事情发生之前拦住它(比如阻止一个动作,或者在原逻辑使用参数前改掉参数)。
- 其他情况全选 Postfix只要不需要拦截原逻辑就往原逻辑后面接代码。这是保持 Mod 稳定、不坏档的金法则。
---
## 🔁 六、状态桥接__state 传值)
有时候你需要在执行之后知道执行之前发生了什么(比如:存货前有多少,存货后剩多少)。`__state` 就是专门用来在 `Prefix``Postfix` 之间带货的“临时储物柜”。
### 6.1 实战用法:前后状态对比
- 作用: 记录一个初始值,等原逻辑跑完后再拿出来算差值。
```csharp
[HarmonyPatch(typeof(Storage), "Store")]
public static class Storage_Monitor_Patch
{
// 1. 在执行前,把当前帧数塞进 __state 储物柜
public static void Prefix(out int __state)
{
__state = Time.frameCount;
}
// 2. 在执行后,从 __state 储物柜拿出刚才存的帧数
public static void Postfix(int __state)
{
int cost = Time.frameCount - __state;
if (cost > 0)
{
Debug.Log($"这次存货居然花了 {cost} 帧的时间!");
}
}
}
```
### 💡 为什么用它?
* **性能追踪:** 记录方法运行前后的时间差。
* **逻辑判定:** 记录执行前的数值(比如生命值),执行后发现数值没变,就触发补救逻辑。
* **简洁性:** 它只在这一次补丁调用中有效,跑完就销毁,不会像全局变量那样污染你的代码。
### 🔑 参数细节说明(避坑)
* **Prefix 里:** 必须用 out 或者 ref比如 out int __state否则存不进去。
* **Postfix 里:** 直接用(比如 int __state即可拿到之前存的值。
---
## 🔓 七、访问 private 字段AccessTools与 ___
在 ONI 源码中,很多变量被声明为 `private` 你直接用 `__instance` 变量名 是访问不到的。这时有两种常用的“破门”方法。
### 7.1 方法一:三下划线暗号(最快、最推荐)
如果只是想简单读写一个实例变量Harmony 提供了一个极简写法:在参数名前加 三个下划线。
```csharp
[HarmonyPatch(typeof(Storage), "OnSpawn")]
public static class Storage_Easy_Patch
{
// ___capacityKg 对应 Storage 类里的私有变量 capacityKg
public static void Postfix(Storage __instance, ref float ___capacityKg)
{
___capacityKg = 9999f; // 直接像改普通变量一样改掉它
}
}
```
### 7.2 方法二:使用 AccessTools性能更好、更强大
当你需要在多个地方频繁访问同一个变量,或者要处理 `static`(静态)私有变量时,建议先提前定义一个“后门”。
```csharp
using System.Reflection;
public static class Storage_Hard_Patch
{
// 1. 先定义后门(只找一次,性能更优)
private static readonly FieldInfo CapacityField =
AccessTools.Field(typeof(Storage), "capacityKg");
[HarmonyPatch(typeof(Storage), "OnSpawn")]
public static class Patch
{
public static void Postfix(Storage __instance)
{
// 2. 暴力写入新值
CapacityField.SetValue(__instance, 9999f);
}
}
}
```
### 💡 怎么选?
* **三下划线 (`___`)****日常主力。** 只要能跑通,就优先用它,代码短且不容易写错。
* **AccessTools****重型工具。**
- 专门对付 `static private`(静态私有)变量。
- 适合在补丁函数体外面拿取数据。
- 如果你需要极致的性能优化,提前定义一个 `static readonly FieldInfo` 会比三下划线快那么一点点。
---
## 🧬 Transpiler改底层指令
这是 Harmony 中最硬核的补丁。
- 它不是在方法前后插话,而是直接冲进原代码内部,把某几行代码“抠掉”或者“掉包”。
### 8.1 它的作用
如果你发现 `Prefix``Postfix` 都没法改掉某个逻辑,通常是因为那个逻辑是硬编码在方法中间的。
* **改常量:** 比如代码里写死了一个 `if (speed > 10f)`,你想把 `10f` 改成 `100f`
* **删代码:** 比如你想把原版中某一行烦人的检测逻辑彻底抹除。
* **加指令:** 在方法的第 50 行和第 51 行中间塞进你自己的逻辑。
### 8.2 实战代码:修改硬编码数值
- 场景: 游戏原本规定挖矿只掉一半掉落物`0.5f`,我们通过补丁把它改成全掉 `1.0f`
```csharp
[HarmonyPatch(typeof(WorldDamage), "OnDigComplete")]
public static class WorldDamage_OnDigComplete_Patch
{
// Transpiler 接收的是一组 IL 指令集
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (var ins in instructions)
{
// 目标:找到指令是“加载浮点数 0.5”的那一行
if (ins.opcode == OpCodes.Ldc_R4 && (float)ins.operand == 0.5f)
{
// 改成 1.0f
ins.operand = 1.0f;
}
yield return ins;
}
}
}
```
### ⚠️ 为什么说要慎用?
* **报错难找:** 普通的补丁写错,通常只是功能失效;`Transpiler` 写错,可能会导致游戏直接闪退或整个类崩掉。
* **极易冲突:** 如果有两个 Mod 同时对同一个方法的同一行代码动了“手术”,游戏大概率会当场报废。
* **门槛高:** 你需要看懂 IL中间语言 指令(类似于 `ldarg.0` `call` `stfld` 等),就像在看天书。
---
## 🧯 九、Finalizer异常兜底
```csharp
[HarmonyPatch(typeof(SomeClass), "SomeMethod")]
public static class SomeMethod_Finalizer
{
public static void Finalizer(Exception __exception)
{
if (__exception != null)
{
Debug.LogError(__exception);
}
}
}
```
---
## ⚠️ 十、ONI Mod 常见翻车点
- Patch 方法忘记 `static`
- 参数签名与原方法不一致
- Prefix `return false` 但没处理返回值
- Transpiler 修改逻辑过多
---

View File

@ -1,29 +0,0 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home
hero:
# name: "ONIModTutorial"
name: <span class="color-w">ONI</span><span class="color-r">Mod</span><span class="color-w">Tutorial</span>
text: "缺氧 MOD 教程"
tagline: "Talk is cheap. Show me the code."
actions:
- theme: brand
text: 开始阅读
link: /preface
- theme: alt
text: API Examples
# link: /api-examples
features:
- title: 开发环境搭建
details: 介绍如何配置 Visual Studio 2022 开发环境,以及如何引用游戏核心 DLL 文件。
- title: 源码反编译与分析
details: 使用 dnSpy 等工具查阅游戏底层代码逻辑,学习如何定位 Patch补丁注入点。
- title: 实践与心得
details: 分享《缺氧》Mod 开发中的实战案例,涵盖 Harmony 补丁使用及常见问题记录。
---

View File

@ -1,85 +0,0 @@
# Markdown Extension Examples
This page demonstrates some of the built-in markdown extensions provided by VitePress.
## Syntax Highlighting
VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
**Input**
````md
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````
**Output**
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
## Custom Containers
**Input**
```md
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::
```
**Output**
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::
## More
Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).

View File

@ -1,49 +0,0 @@
# 📂 Mod 目录结构
一个标准的《缺氧》Mod 目录通常包含以下核心文件。理解这些文件的角色是开发的第一步。
## 一 . 典型结构总览
每个模组都使用一个单独文件夹,例如,你的`MyFirstMod`路径应该如下所示:
`...\Klei\OxygenNotIncluded\mods\Dev\MyFirstMod\`
* `MyFirstMod.dll`
* `mod.yaml`
* `mod_info.yaml`
```text
MyFirstMod/
├── mod_info.yaml # Mod 的元数据与版本兼容性配置
├── mod.yaml # 用于配置 Mod 的名称、描述等静态信息
├── MyFirstMod.dll # 编译后的程序集文件(逻辑代码)
└── preview.png # Steam 创意工坊显示的预览图
```
## 二 . 配置文件详解
::: code-group
```yaml [mod_info.yaml 模板]
supportedContent: ALL # 支持范围VANILLA_ID, EXPANSION1_ID, 或 ALL
minimumSupportedBuild: 512719 # 运行该 Mod 所需的最低游戏版本号
version: "1.0.0" # 你自己的 Mod 版本号
```
:::
::: code-group
```yaml [mod.yaml 模板]
title: "MyFirstMod" # 游戏内 Mod 列表显示的名称
description: "这是一个示例描述" # 游戏内显示的详细功能介绍
staticID: "AuthorName.MyMod" # Mod 的唯一标识符(建议格式:作者名.Mod名
```
:::
## 三 . 资源与可选目录 (进阶)
当你的 Mod 不再仅仅是简单的逻辑修改,而是涉及新建筑、新美术或多语言支持时,需要建立以下目录结构:
* **/translations/** 用于存放多语言翻译文件(.pot 或 .po
* **/anim/assets/** 存放自定义建筑、生物或掉落物的动画资源。
* **/assets/** 额外素材
* **/elements/** 存放自定义元素的配置数据。
* **/worldgen/** 涉及地形生成、生物群落Biomes修改时的核心目录。包含 `biomes`、`features` 等子文件夹。

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
{
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
},
"devDependencies": {
"vitepress": "^1.6.4"
},
"dependencies": {
"rss-parser": "^3.13.0"
}
}

View File

@ -1,39 +0,0 @@
# 🚀 开发引言 (Preface)
这份文档旨在为 **《缺氧》***Oxygen Not Included*)的 Mod 开发者提供一份系统化的技术指南。
::: info 编写初衷
在尝试通过 Mod 扩展游戏玩法的过程中,会遇到许多问题,也会解决一些问题。本项目建立的初衷是:**整理并记录开发过程中的新发现**,让后来的开发者~~少走弯路~~。
:::
### 🛠️ 文档核心价值
| 特性 | 描述 |
| :--- | :--- |
| **源码参考** |内容主要参考当前版本的 `Assembly-CSharp.dll` 逆向结果,尽量确保时效性。 |
| **侧重实践** |分享我寻找 **Hook 点** 或修改 **Prefab** 时的思路,希望能提供一些实操参考。 |
| **尝试同步** | 由于游戏仍在更新,我会尽力在业余时间同步那些影响较大的逻辑变动。 |
### 🗺️ 学习路线图
1. <Badge type="tip" text="STEP 1" /> **环境准备**
* 介绍我常用的反编译与开发工具配置。。
2. <Badge type="warning" text="STEP 2" /> **基础机制**
* 探讨 Harmony 补丁的使用以及对游戏对象结构的理解。
3. <Badge type="danger" text="STEP 3" /> **进阶尝试**
* 记录从属性修改到实体注入的一些实验性过程。
---
::: danger 💡 学习建议
**Mod 开发需要一定的 C# 基础。** 如果你是完全的编程新手,建议先花点时间了解 C# 的基本语法变量、类、继承、Lambda 表达式),这会让你后续的开发事半功倍。
:::
---
<div align="center">
<p>从零开始,在代码中构建属于你的宇宙。</p>
<a href="development-environment">
<button style="background: var(--vp-c-brand-1); color: white; padding: 10px 24px; border-radius: 20px; font-weight: bold; cursor: pointer; border: none;">
配置开发环境 →
</button>
</a>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,98 +0,0 @@
# 缺氧Mod开发 - Unity资源使用指南
缺氧是使用Unity游戏引擎开发的。所以很多机制与资源都与Unity开发是通用的。
在我们开发缺氧mod的过程中我们可以巧妙的使用Unity相关的功能来扩展或增强我们对mod的开发能力。
## 常用Unity资源
1. Asset Bundle 资源整合包简称AB包
2. UI界面 - 自定义UI界面比如sidescreen等
3. 动画效果 - 粒子效果、材质制作
## 详细介绍
### 1. Asset Bundle包简称AB包
**简介:**
Asset Bundle是Unity中一种资源打包格式可以将游戏中的各种资源如纹理、模型、预制体等打包成一个独立的文件。在Mod开发中使用AB包有以下优势
- 减少Mod的文件体积提高加载效率
- 方便管理和更新资源
- 支持热更新无需重新编译Mod
- 可以包含复杂的Unity资源如预制体、动画等
**最常打包使用的内容:**
1. 图片资源Sprite
2. 预制体Prefab
- 预制体经常用来制作自定义的UI界面、自定义的UI效果比如粒子效果Effect等用预制体打包到AB包中
**使用步骤:**
1. **安装Asset Bundle Browser工具**
Unity菜单栏 --> Windows --> Package Manager --> + --> Add package from git url -->
`https://github.com/Unity-Technologies/AssetBundles-Browser.git`
2. **打包资源**
Unity菜单栏 --> Windows --> Asset Bundle Browser-> Tab: Configure 确认 --> Tab: Build -> Build
3. **Mod中引用**
需要引用 `UnityEngine.AssetBundleModule.dll`
```csharp
using UnityEngine;
// 载入ab包
AssetBundle assetBundle = AssetBundle.LoadFromFile(file_path);
// 加载资源
// sprite 图片资源
assetBundle.LoadAsset<Sprite>(sprite_name);
// 挂载时机:[HarmonyPath(typeof(Asset),"OnPrefabInit")]
// 资源挂载点Assets.Sprites
// prefab 预制体
GameObject prefab = assetBundle.LoadAsset<GameObject>("gameobject_name");
gameObjectNameInstance = Util.KInstantiate(prefab);
```
### 2. UI界面
**简介:**
在缺氧Mod开发中自定义UI界面是增强用户体验的重要部分。常见的UI界面包括
- SideScreen物品或建筑的侧边信息栏
- 自定义对话框
- 配置面板
**实现方式:**
1. 使用Unity创建UI预制体打包到AB包中
2. 在Mod中加载并实例化这些预制体
3. 使用Harmony补丁修改游戏的UI系统将自定义UI集成到游戏中
### 3. 动画效果
**简介:**
动画效果可以为Mod添加视觉吸引力包括
- 粒子效果:如特效、光晕、烟雾等
- 材质动画:如发光、变色等效果
- 模型动画:如机械运动、角色动作等
**实现方式:**
1. 在Unity中创建动画效果和材质
2. 打包到AB包中
3. 在Mod中加载并应用这些效果
## 最佳实践
1. **资源管理**合理组织AB包避免过大的包体
2. **性能优化**:只加载必要的资源,及时卸载不需要的资源
3. **版本控制**为AB包添加版本号方便更新和兼容性管理
4. **错误处理**:添加资源加载失败的处理逻辑
## 注意事项
- 确保使用与游戏版本兼容的Unity版本
- 避免使用Unity的新特性确保向后兼容性
- 测试不同平台上的资源加载情况
- 遵守Klei的Mod开发规范
通过合理使用Unity资源你可以创建更加丰富和专业的缺氧Mod为玩家带来更好的游戏体验。

View File

@ -1,64 +0,0 @@
# 📤 Steam Workshop 上传指南
配置好 `mod_info.yaml` 后,你可以使用《缺氧》游戏内置的工具将 Mod 上传至创意工坊。
---
## 一 . 上传工具
<div align="center">
<img src="/images/steam-upload/Tool.png" alt="Mod上传工具" width="600" />
</div>
此工具是缺氧游戏附赠的,在库中可搜索到
---
## 二 . 上传已有 Mod
如果你需要发布的 Mod请参考下方界面
<div align="center">
<img src="/images/steam-upload/Tool_1.png" alt="发布界面" width="600" />
</div>
按照以下步骤配置上传信息:
* <Badge type="danger" text="1" /> **选择项目**:点击此处选择你准备好的 Mod 文件夹。
* <Badge type="danger" text="2" /> **路径确认**:确保显示的是整个 Mod 文件夹的完整路径。
* <Badge type="danger" text="3" /> **预览图**:选择你 Mod 文件夹中的 `preview.png` 文件(建议尺寸 512x512
* <Badge type="danger" text="4" /> **Mod 名称**:输入你希望在创意工坊上显示的标题。
::: warning 注意事项
1. **文件夹结构**:上传前请务必确认 `mod_info.yaml` 位于文件夹根目录。
2. **预览图限制**:图片大小不得超过 1MB否则 Steam 可能会上传失败。
3. **版本号同步**:记得更新 `mod_info.yaml` 中的 `version` 字段,方便玩家识别更新内容。
:::
## 三 . 创意工坊 图片、标题与描述
* <Badge type="danger" text="1" /> **编辑标题与描述**:多国语言版本标题与描述
**常用标签
```html
<!-- 标题 -->
[h1][/h1]..[h*][/h*] [url=*][/url] [hr/]
<!-- 链接 -->
[url=链接]链接[/url] [img=链接]图片[/img]
<!-- 分隔符 -->
[hr/]
<!-- 表格 -->
[table]
[tr]
[td]单元格内容[/td]
[tr]
[table/]
<!-- 列表 -->
[list]
[*]列表项1[/*]
[*]列表项2[/*]
[list/]
<!-- 换行 -->
[br/>
```
* <Badge type="danger" text="2" /> **添加编辑图片/视频**图片尺寸比例1920/1080

View File

@ -1,65 +0,0 @@
# 🔄 多版本兼容性与发布管理
为了确保 Mod 能够在不同版本的《缺氧》如本体、DLC、测试版中正常运行你需要正确配置 `mod_info.yaml``archived_versions` 文件夹。
---
## 一 . 核心配置文件mod_info.yaml
> [!IMPORTANT]
> **官方原文链接:** [Setting up mod_info.yaml and archived_versions](https://forums.kleientertainment.com/forums/topic/158363-setting-up-mod_infoyaml-and-archived_versions/)
每个发布到 Steam Workshop 的 Mod 根目录必须包含 `mod_info.yaml`。它决定了 Mod 的“准入资格”。
::: code-group
```yaml [mod_info.yaml 模板]
supportedContent: ALL # 支持范围VANILLA_ID, EXPANSION1_ID, 或 ALL
minimumSupportedBuild: 512719 # 运行该 Mod 所需的最低游戏版本号
version: "1.0.0" # 你自己的 Mod 版本号
```
:::
## 二 . 文件夹结构archived_versions
当你需要同时兼容当前稳定版和之前的旧版本时,不能只靠一个 .dll。你需要使用文件夹分层。
📂 推荐目录结构
::: details 点击查看结构树
```yaml
MyMod/
├── mod_info.yaml # 最新版的信息(通常指向当前正式版)
├── mod.yaml # 最新版的基本描述(通常指向当前正式版)
├── MyMod.dll # 适用于当前最新正式版的代码
└── archived_versions/ # 存档版本文件夹
└── 512719/ # 文件夹名 = 适用的最低游戏版本号
├── mod_info.yaml # 该版本的独立信息
├── mod.yaml # 该版本的基本描述
└── MyMod.dll # 该版本的专用代码
```
:::
⚙️ 运行逻辑说明
* **扫描阶段:** 游戏启动时会优先扫描 `archived_versions` 文件夹。
* **匹配阶段:** 它会寻找文件夹名(版本号)小于或等于当前游戏版本,且最接近当前版本的文件夹。
* **回退阶段:** 如果没有匹配的归档文件夹,则运行根目录下的默认文件。
## 三 . 兼容性开发建议
::: tip 🛡️ 为什么使用这种结构?
* **版本隔离(防止“炸档”):** 当游戏大版本更新导致 API 变更时,旧版本用户会自动定向到 `archived_versions` 运行,确保插件不会因环境冲突而崩溃。
* **双轨并行(分支维护):** 支持同时为 **测试版 (Testing Branch)** 和 **正式版 (Live Branch)** 维护两套完全独立的 DLL 逻辑,互不干扰。
:::
### 🛠️ 自动化生成事件
在 Visual Studio 的项目属性中添加 **生成事件 (Post-build event)**,可实现编译后自动归档到对应文件夹:
```batch
# 如果是 Release 配置,自动拷贝到 512719 归档目录
if "$(ConfigurationName)" == "Release" (
xcopy /Y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)archived_versions\512719\"
)
```

View File

@ -1,57 +0,0 @@
---
sidebar: false
---
<a href="./development-environment#back-point" style="
position: fixed;
left: 20px;
top: 100px;
display: flex;
align-items: center;
gap: 8px;
padding: 10px 15px;
background-color: var(--vp-c-brand);
color: white;
border-radius: 20px;
text-decoration: none;
font-weight: bold;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
transition: transform 0.2s;
z-index: 100;
" onmouseover="this.style.transform='scale(1.1)'" onmouseout="this.style.transform='scale(1)'">
<span style="font-size: 1.2em;">返回</span>
</a>
# 🛠️ Visual Studio 安装细节
在安装过程中,正确的勾选决定了你是否能顺利编译 Mod。请参考以下图解进行配置
### 1. 选择工作负荷 (Workloads)
首先,你需要告诉 VS 你要进行桌面程序开发。
<div align="center">
<img src="/images/VSInstallation-details/VSInstall.png" alt="安装" width="600" />
</div>
> **操作:** 勾选 **“.NET 桌面开发”**。这是开发 C# 插件最基础的环境,包含了编译器和必要的库。
---
### 2. 精确勾选组件 (Individual Components)
这是最关键的一步,很多新手会因为少勾选组件而无法创建合适的项目模板。
<div align="center">
<img src="/images/VSInstallation-details/VSInstall_.png" alt="选择组件" width="600" />
</div>
**必须确保以下项已勾选:**
* **.NET 桌面开发相关组件**:用于编写针对《缺氧》的代码。
* **.NET Standard 2.1 相关开发支持**:提供项目模板和程序集引用支持。
---
### 3. 完成安装
确认右下角的安装位置有足够的空间(通常需要几 GB点击 **“修改”** 或 **“安装”**。安装完成后,建议重启电脑以确保环境变量生效。
::: tip 下一步
安装完成后,你可以回到 [开发环境搭建](./development-environment#back-point) 继续学习如何创建你的第一个 Mod 项目。
:::

View File

@ -1,15 +0,0 @@
# 玩家社区与扩展 🚀
这里同步了《缺氧》创意工坊最新的模组动态,以及我们的开发路线图。
## 创意工坊动态
<ClientOnly>
<WorkshopList />
</ClientOnly>
---
## 学习路线图 (Roadmap)
<ClientOnly>
<LearningTimeline />
</ClientOnly>

View File

@ -112,10 +112,10 @@ python tools/oni_commander.py fix_overload # 过载电路
python tools/oni_commander.py expand_base x y w h # 拓展
```
### `scripts/event_daemon.py` — 事件守护进程
### `tools/event_daemon.py` — 事件守护进程
```bash
python scripts/event_daemon.py
python tools/event_daemon.py [interval_seconds]
# 持续轮询事件,分类显示到控制台
```
@ -144,20 +144,23 @@ oni-agent/
│ ├── ONIAgentBridge.cs # Mod 源码 (C# Harmony)
│ ├── ONIAgentBridge.csproj
│ ├── mod.yaml / mod_info.yaml
├── tools/
├── tools/ # AI 直接调用的运行时工具
│ ├── oni_api.py # CLI 客户端 (20+ 子命令)
│ ├── oni_analyzer.py # 六维度分析
│ ├── oni_analyzer.py # 六维度智能分析
│ ├── oni_builder.py # 蓝图建造
── oni_commander.py # 高级指令
├── scripts/
│ ├── event_daemon.py # 事件守护进程
│ ├── build_mod.sh # 编译脚本
── setup.sh # 环境初始化
── oni_commander.py # 高级指令
│ └── event_daemon.py # 事件守护进程
├── scripts/ # 开发者/构建用脚本
│ ├── build_mod.sh # 编译 Mod
── setup.sh # 环境初始化
│ ├── watch.sh # 热重载
│ ├── fix_csharp.py # C# 修复
│ ├── annotate_apis.py # API 标注
│ ├── auto_analyze.sh # 自动分析
│ └── auto_repair.sh # 自动修复
├── docs/
│ ├── AI_KNOWLEDGE_BASE.md # AI 知识库
│ ├── AI_KNOWLEDGE_BASE.md # AI 知识库 (建筑/元素/科技)
│ └── MOD_DEV_GUIDE.md # Mod 开发指南
└── skills/
└── oni_agent.md # Agent skill 定义
```
## 文档索引

View File

@ -1,114 +0,0 @@
---
name: oni_agent
description: "Oxygen Not Included 完全游戏操控 — REST API + CLI 工具链,含分阶段目标/材料系统/可达性/建筑数据库"
version: "2.1.0"
---
# ONI Agent Skill — 缺氧 AI 完全操控
通过 `tools/oni_api.py` CLI + Mod HTTP API 完全控制游戏。**每次决策前必须先 pause**,所有操作自动拉视角到坐标。
## 一、坐标系与格子
- (0,0)=左下角x→右y→上典型地图 256×384
- 建筑坐标=左下角锚点
- 通过 `cell <x> <y>` 查看格子element / massKg / temperatureC / isSolid / isLiquid / isGas / isDiggable / hasBuilding / hasDuplicant
- `explore <x> <y> <w> <h>` AI友好区域摘要
- 可达性:复制人只能在开放空间移动,固体阻挡需挖掘,液体/气体不阻挡
- 梯子(Ladder)提供垂直移动,砖块(Tile)提供地面
## 二、材料系统
建筑需要特定类别材料:
- **BuildableRaw** = SandStone, Granite, IgneousRock, Obsidian (挖掘获得)
- **Metal** = Cuprite, IronOre, GoldAmalgam, Wolframite (挖掘→精炼)
- **RefinedMetal** = Copper, Iron, Gold, Steel (精炼生产)
- **Plastic** = Polypropylene (聚合压机制造)
- **Glass** = Glass (窑炉烧制)
- **Farmable** = Dirt (挖掘/堆肥)
AI 必须检查世界库存中哪些元素满足建筑的材料类别,选择存量最多的。
## 三、分阶段目标
### Phase 1 (Cycle 1-20): 生存基础
- **氧气**: OxygenDiffuser(藻类) 或 Electrolyzer(水→O₂+H₂)
- **电力**: ManualGenerator → [研究PowerRegulation] → CoalGenerator
- **食物**: PlanterBox×3-5 种 Mealwood (消耗Dirt)
- **卫生**: Outhouse + WashBasin → [研究Plumbing] → Lavatory循环
- **科研**: ResearchStation → FarmingTech先 → PowerRegulation → Plumbing
- **执行**: `dig` 挖空间 → `build IDs` 建造 → `research_select ID` 研究
### Phase 2 (Cycle 20-100): 自持系统
- **SPOM**: Electrolyzer+H₂发电机 → 无限O₂+部分电 (`oni_builder.py build spom`)
- **厕所循环**: Lavatory→WaterPurifier→Lavatory (`oni_builder.py build toilet_loop`)
- **电力升级**: 变压器(Transformer)防过载 + CoalGenerator
- **隔热**: InsulationTile 包围基地
- **养殖**: RanchStation + Incubator (哈奇哈奇产煤+食物)
### Phase 3 (Cycle 100+): 自动化
- 液冷模块 Aquatuner+SteamTurbine
- 石油/天然气发电
- 喷泉开发
- 太空探索
## 四、关键建筑ID速查
| ID | 尺寸 | 材料 | 耗电 | 用途 |
|----|------|------|------|------|
| ManualGenerator | 2×2 | Metal | -400W | 人力发电 |
| CoalGenerator | 2×2 | Metal | -600W | 燃煤发电 |
| HydrogenGenerator | 2×2 | Metal | -800W | 燃氢发电 |
| Electrolyzer | 2×2 | Metal | +120W | 水→O₂+H₂ |
| GasPump | 1×2 | Metal | +240W | 抽气 |
| WaterPurifier | 2×2 | Metal | +120W | 污水净化 |
| PlanterBox | 1×1 | BuildableRaw | 0 | 种植 |
| StorageLocker | 1×1 | BuildableRaw | 0 | 储存 |
| RationBox | 2×2 | BuildableRaw | 0 | 储食 |
| Tile | 1×1 | BuildableRaw | 0 | 地板 |
| InsulationTile | 1×1 | BuildableRaw | 0 | 隔热墙 |
| Ladder | 1×1 | BuildableRaw | 0 | 梯子 |
| PneumaticDoor | 1×2 | Metal | 0 | 门 |
| Battery | 1×1 | Metal | 0 | 电池 |
| Transformer | 2×1 | Metal | 0 | 变压器 |
| ResearchStation | 2×2 | BuildableRaw | +60W | 初级科研 |
| SteamTurbine | 4×2 | Metal | -850W | 热删除+发电 |
| Aquatuner | 1×2 | RefinedMetal | +1200W | 液冷 |
| Cot | 1×1 | BuildableRaw | 0 | 床 |
## 五、标准操作流程
```
1. pause "原因" ← 必须暂停
2. status / resources / events ← 感知
3. explore / cell ← 验证坐标
4. dig → build / deconstruct ← 执行(自动拉视角)
5. events ← 检查结果
6. unpause 1 ← 恢复
```
**紧急响应**: O₂<500emergency_o2 | 食物<200k建农场 | COfix_co2 | 电力过载fix_overload
## 六、工具速查
```bash
# 监控
oni_api.py status | resources | buildings | duplicants | rooms
oni_api.py events [since] | explore x y w h
oni_api.py cell x y | cells x y w h | slice axis idx start end
oni_api.py gas x y r
oni_api.py registry buildings|elements|techs [filter]
# 操作(自动拉视角)
oni_api.py pause "reason" [speed] | unpause [speed]
oni_api.py speed 1|2|3
oni_api.py dig x y w h | build id x y | deconstruct x y
oni_api.py prioritize x y 1-9 | research_select id | batch file
oni_api.py mop x y | harvest x y
oni_api.py camera x y [zoom] | save [name] | load name
# 分析
oni_analyzer.py | oni_commander.py diagnose
oni_commander.py emergency_o2 | fix_co2 | fix_overload | expand_base cx cy w h
oni_builder.py build spom/toilet_loop/bedroom/farm_mealwood/cooling/ranch_hatch x y
```

View File

@ -14,7 +14,7 @@ import json, os, sys, time, datetime
TOOLS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tools')
sys.path.insert(0, TOOLS_DIR)
from oni_api import api_get, api_post, api_url, load_config
from oni_api import api_get, api_post, load_config
POLL_INTERVAL = 5
MAX_EVENTS = 200