Skip to content

Commit 1053936

Browse files
committed
feat(editor): add reward related
1 parent 10769f8 commit 1053936

223 files changed

Lines changed: 2167 additions & 596 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contributes/meta3d-action-mod-unit-init/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "meta3d-action-mod-unit-init",
3-
"version": "1.3.18",
3+
"version": "1.3.19",
44
"publisher": "meta3d",
55
"protocol": {
66
"name": "meta3d-action-mod-unit-init-protocol"

contributes/meta3d-action-mod-unit-init/src/Main.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { getActions, getActionSnapshotPath } from "./asset-lib/unit-action/Main"
1212
import { reducePromise } from "meta3d-structure-utils/src/ArrayUtils"
1313
import { imageSrcToBase64 } from "meta3d-file-ts-utils/src/ImageUtils"
1414
import { action, countFactor, emitSpeed, emitterSpeed, excitement } from "meta3d-action-mod-unit-publish-to-game-protocol/src/UnitType"
15+
import { getAllPropData, getPropSnapshotPath } from "./asset-lib/prop/Main"
16+
import { gem } from "meta3d-action-mod-unit-publish-to-game-protocol/src/Type"
1517

1618
// let _buildAllDefaultCareerFeatures = (api: api) => {
1719
// // let modAPI = _buildFakeModAPI()
@@ -123,13 +125,33 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
123125
},
124126
api.immutable.createMap()
125127
).then(newAllActionData => {
126-
meta3dState = api.action.setActionState(meta3dState, actionName, {
127-
...api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName)),
128-
allModelData: newAllModelData,
129-
allActionData: newAllActionData,
130-
})
128+
return reducePromise(
129+
getAllPropData(),
130+
(result, data) => {
131+
return new Promise((resolve, reject) => {
132+
imageSrcToBase64(
133+
resolve,
134+
reject,
135+
getPropSnapshotPath(_getPathPrefix("prop"), data.name)
136+
)
137+
}).then((imageBase64) => {
138+
return result.push({
139+
...data,
140+
snapshotImageBase64: imageBase64,
141+
})
142+
})
143+
},
144+
api.immutable.createList()
145+
).then(newProps => {
146+
meta3dState = api.action.setActionState(meta3dState, actionName, {
147+
...api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName)),
148+
allModelData: newAllModelData,
149+
allActionData: newAllActionData,
150+
allPropData: newProps,
151+
})
131152

132-
return meta3dState
153+
return meta3dState
154+
})
133155
})
134156
})
135157
})
@@ -161,10 +183,12 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
161183
// allModelData: api.immutable.createMapOfData(getAllModelData()),
162184
allModelData: api.immutable.createMap(),
163185
allActionData: api.immutable.createMap(),
186+
allPropData: api.immutable.createList(),
164187

165188
selectedModelIndex: api.nullable.getEmpty(),
166189
selectedSmallSkillObjectActionIndex: api.nullable.getEmpty(),
167190
selectedBigSkillObjectActionIndex: api.nullable.getEmpty(),
191+
// selectedPropIndex: api.nullable.getEmpty(),
168192

169193
// isShowModelWindow: false,
170194
// isShowSkillWindow: false,
@@ -175,6 +199,7 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
175199
isShowActionModal: false,
176200
isShowSmallSkillObjectActionValueModal: false,
177201
isShowBigSkillObjectActionValueModal: false,
202+
isShowPropModal: false,
178203

179204
excitement: excitement.Level5,
180205

@@ -205,6 +230,9 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
205230

206231
bo_sceneData_rate: 0,
207232
bo_sceneData_countFactor: countFactor.Level5,
233+
234+
235+
prop: [],
208236
}
209237
}
210238
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { propName, props } from "meta3d-action-mod-unit-publish-to-game-protocol/src/UnitType"
2+
3+
export let getAllPropData = (): props => {
4+
return [
5+
{
6+
name: propName.AddHp1,
7+
},
8+
{
9+
name: propName.AddHp2,
10+
},
11+
]
12+
}
13+
14+
export let getPropSnapshotPath = (pathPrefix, propName: propName) => {
15+
return `${pathPrefix}/${propName}.png`
16+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
.merlin
3+
.log
4+
.ninja_log
5+
.cmi
6+
.ast
7+
.cmt
8+
.bsdeps
9+
.compiler.log
10+
11+
.idea/
12+
.vscode/
13+
jest_0/
14+
reference/
15+
node_modules/
16+
mine/
17+
dist/
18+
lib/bs/
19+
.bs.js
20+
.gen.tsx
21+
lib/js/
22+
lib/es6_global/
23+
24+
coverage
25+
26+
dist/
27+
28+
npm-debug
29+
30+
.bsb.lock
31+
32+
yarn.lock
33+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var gulp = require("gulp");
2+
var path = require("path");
3+
var fs = require("fs");
4+
var publish = require("meta3d-tool-publish")
5+
var bundle = require("meta3d-tool-bundle-to-custom")
6+
var clipboard = require('clipboardy')
7+
8+
gulp.task("publish_local_env_bundle", function (done) {
9+
let filePath = "./src/Main.ts"
10+
11+
let bundleContent = bundle.bundle(
12+
bundle.getLocalModulePath(
13+
filePath
14+
),
15+
fs.readFileSync(filePath, "utf-8")
16+
)
17+
18+
let clipedBundleContent = `import { api } from "meta3d-type"
19+
import { service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
20+
` + bundleContent
21+
clipedBundleContent = clipedBundleContent.replace(/getContribute\s\=\s\(api\)/g, "getContribute = (api:api)")
22+
23+
clipboard.default.writeSync(
24+
clipedBundleContent
25+
)
26+
27+
28+
29+
publish.publishBundledContribute(
30+
"local",
31+
path.join(__dirname, "package.json"),
32+
bundleContent
33+
).then(() => {
34+
done()
35+
})
36+
});
37+
38+
39+
40+
// gulp.task("publish_local_env", function (done) {
41+
// publish.publishContribute(
42+
// "local",
43+
// path.join(__dirname, "package.json"),
44+
// path.join(__dirname, "dist/static/js", "main.js")
45+
// ).then(() => {
46+
// done()
47+
// })
48+
// });
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// declare module 'asset-loader!*' {
2+
// // const contents: { default: string }
3+
// const contents: string
4+
// // const contents: ArrayBuffer
5+
// export = contents
6+
// }
7+
8+
declare module '*' {
9+
// const contents: { default: string }
10+
const contents: string
11+
// const contents: ArrayBuffer
12+
export = contents
13+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "meta3d-action-mod-unit-reward-clearprop",
3+
"version": "1.3.1",
4+
"publisher": "meta3d",
5+
"protocol": {
6+
"name": "meta3d-action-mod-unit-reward-clearprop-protocol"
7+
},
8+
"license": "MIT",
9+
"scripts": {
10+
"watch": "tsc -w -noEmit",
11+
"webpack": "webpack --config webpack.config.js",
12+
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
13+
"meta3d:publish_dev": "cross-env NODE_ENV=development npm run webpack && gulp publish_local_env_bundle"
14+
},
15+
"keywords": [],
16+
"dependencies": {
17+
"meta3d-action-mod-unit-reward-clearprop-protocol": "^1.3.0",
18+
"meta3d-editor-whole-protocol": "^1.3.0",
19+
"meta3d-type": "^1.3.0"
20+
},
21+
"devDependencies": {
22+
"clean-webpack-plugin": "^4.0.0",
23+
"clipboardy": "^5.0.2",
24+
"cross-env": "^7.0.3",
25+
"cz-customizable": "^6.3.0",
26+
"gulp": "^4.0.2",
27+
"meta3d-tool-publish": "^1.3.0",
28+
"source-map-loader": "^3.0.0",
29+
"ts-loader": "^9.2.6",
30+
"typescript": "^5.1.0",
31+
"webpack": "^5.62.1",
32+
"webpack-cli": "^4.9.1"
33+
}
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { state as meta3dState, getContribute as getContributeMeta3D, api } from "meta3d-type"
2+
import { actionContribute, service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
3+
import { actionName, state, uiData } from "meta3d-action-mod-unit-reward-clearprop-protocol"
4+
import { eventName, inputData } from "meta3d-action-mod-unit-reward-clearprop-protocol/src/EventType"
5+
import { actionName as initActionName, state as initState } from "meta3d-action-mod-unit-init-protocol"
6+
7+
export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> = (api) => {
8+
return {
9+
actionName: actionName,
10+
init: (meta3dState) => {
11+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
12+
13+
return new Promise((resolve, reject) => {
14+
resolve(eventSourcingService.on<inputData>(meta3dState, eventName, 0, (meta3dState) => {
15+
let state = api.action.getActionState<initState>(meta3dState, initActionName)
16+
meta3dState = api.action.setActionState<initState>(meta3dState, initActionName, {
17+
...state,
18+
prop: []
19+
})
20+
21+
return Promise.resolve(meta3dState)
22+
}, (meta3dState) => {
23+
return Promise.resolve(meta3dState)
24+
}))
25+
})
26+
},
27+
handler: (meta3dState, uiData) => {
28+
return new Promise<meta3dState>((resolve, reject) => {
29+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
30+
31+
resolve(eventSourcingService.addEvent<inputData>(meta3dState, {
32+
name: eventName,
33+
isOnlyRead: true,
34+
inputData: []
35+
}))
36+
})
37+
},
38+
createState: () => {
39+
return null
40+
}
41+
}
42+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "ES6",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"resolveJsonModule": true,
8+
"esModuleInterop": true,
9+
"jsx": "react",
10+
// "noEmit": true,
11+
// "noUnusedLocals": true,
12+
// "noUnusedParameters": true,
13+
"noImplicitReturns": true,
14+
"lib": [
15+
"DOM",
16+
"ESNext",
17+
],
18+
"types": [
19+
"node"
20+
],
21+
// "strict": true
22+
},
23+
"include": [
24+
"./src",
25+
"./loader.d.ts"
26+
]
27+
}

0 commit comments

Comments
 (0)