steamsheep-ts-game-engine 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -189,7 +189,7 @@ interface ExtraData {
|
|
|
189
189
|
|
|
190
190
|
```typescript
|
|
191
191
|
// src/game/config/init.ts
|
|
192
|
-
import type { GameState } from '
|
|
192
|
+
import type { GameState } from 'steamsheep-ts-game-engine/core';
|
|
193
193
|
|
|
194
194
|
export const initialState: GameState<Stats, Items, Flags, ExtraData> = {
|
|
195
195
|
stats: {
|
|
@@ -220,7 +220,7 @@ export const initialState: GameState<Stats, Items, Flags, ExtraData> = {
|
|
|
220
220
|
|
|
221
221
|
```typescript
|
|
222
222
|
// src/game/store.ts
|
|
223
|
-
import { createGameEngineStore } from '
|
|
223
|
+
import { createGameEngineStore } from 'steamsheep-ts-game-engine/state';
|
|
224
224
|
import { initialState } from './config/init';
|
|
225
225
|
|
|
226
226
|
export const useGameStore = createGameEngineStore(
|
|
@@ -235,7 +235,7 @@ export type GameStore = ReturnType<typeof useGameStore>;
|
|
|
235
235
|
|
|
236
236
|
```typescript
|
|
237
237
|
// src/game/content/actions.ts
|
|
238
|
-
import type { ActionDef } from '
|
|
238
|
+
import type { ActionDef } from 'steamsheep-ts-game-engine/core';
|
|
239
239
|
|
|
240
240
|
export const attackAction: ActionDef<Stats, Items, Flags, ExtraData> = {
|
|
241
241
|
id: 'attack_goblin',
|
|
@@ -276,8 +276,8 @@ export const attackAction: ActionDef<Stats, Items, Flags, ExtraData> = {
|
|
|
276
276
|
```typescript
|
|
277
277
|
// src/components/GameUI.tsx
|
|
278
278
|
import { useGameStore } from '@/game/store';
|
|
279
|
-
import { FlowSystem } from '
|
|
280
|
-
import { QuerySystem } from '
|
|
279
|
+
import { FlowSystem } from 'steamsheep-ts-game-engine/systems';
|
|
280
|
+
import { QuerySystem } from 'steamsheep-ts-game-engine/systems';
|
|
281
281
|
import { attackAction } from '@/game/content/actions';
|
|
282
282
|
|
|
283
283
|
function GameUI() {
|
|
@@ -399,7 +399,7 @@ export const EngineEvents = {
|
|
|
399
399
|
#### 监听事件
|
|
400
400
|
|
|
401
401
|
```typescript
|
|
402
|
-
import { gameEvents, EngineEvents } from '
|
|
402
|
+
import { gameEvents, EngineEvents } from 'steamsheep-ts-game-engine/systems';
|
|
403
403
|
|
|
404
404
|
// 监听属性变化
|
|
405
405
|
const unsubscribe = gameEvents.on(EngineEvents.STAT_CHANGE, (data) => {
|
|
@@ -489,7 +489,7 @@ static executeAction(...) {
|
|
|
489
489
|
#### 使用方法
|
|
490
490
|
|
|
491
491
|
```typescript
|
|
492
|
-
import { FlowSystem } from '
|
|
492
|
+
import { FlowSystem } from 'steamsheep-ts-game-engine/systems';
|
|
493
493
|
|
|
494
494
|
const success = FlowSystem.executeAction(store, action);
|
|
495
495
|
|
|
@@ -509,7 +509,7 @@ if (success) {
|
|
|
509
509
|
#### 常用查询
|
|
510
510
|
|
|
511
511
|
```typescript
|
|
512
|
-
import { QuerySystem } from '
|
|
512
|
+
import { QuerySystem } from 'steamsheep-ts-game-engine/systems';
|
|
513
513
|
|
|
514
514
|
// 检查是否有物品
|
|
515
515
|
const hasKey = QuerySystem.hasItem(state, 'key');
|
|
@@ -619,8 +619,8 @@ store.showModal('警告:此操作不可撤销', 'warn');
|
|
|
619
619
|
|
|
620
620
|
```typescript
|
|
621
621
|
// src/App.tsx
|
|
622
|
-
import { OverlaySystem } from '
|
|
623
|
-
import { LogStream } from '
|
|
622
|
+
import { OverlaySystem } from 'steamsheep-ts-game-engine/ui';
|
|
623
|
+
import { LogStream } from 'steamsheep-ts-game-engine/ui';
|
|
624
624
|
|
|
625
625
|
function App() {
|
|
626
626
|
return (
|
|
@@ -1053,7 +1053,7 @@ store.showToast('获得 10 金币', 'success');
|
|
|
1053
1053
|
2. **添加 `OverlaySystem` 组件**
|
|
1054
1054
|
```typescript
|
|
1055
1055
|
// src/App.tsx
|
|
1056
|
-
import { OverlaySystem } from '
|
|
1056
|
+
import { OverlaySystem } from 'steamsheep-ts-game-engine/ui';
|
|
1057
1057
|
|
|
1058
1058
|
function App() {
|
|
1059
1059
|
return (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "steamsheep-ts-game-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "通用游戏引擎框架 - 基于 TypeScript 和 Zustand 构建的文字冒险/RPG 游戏引擎",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"author": "Corey.H",
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"react": "^18.0.0",
|
|
59
|
-
"zustand": "^4.0.0"
|
|
58
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
59
|
+
"zustand": "^4.0.0 || ^5.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^18.0.0",
|