Skip to content

Commit 27a8727

Browse files
committed
feat(editor): continue "add unit mod editor"
design editor ui;
1 parent 2f341dc commit 27a8727

105 files changed

Lines changed: 921 additions & 33 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.

asset-lib/unit-action/.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DS_Store
2+
.merlin
3+
.idea/
4+
.vscode/
5+
jest_0/
6+
reference/
7+
node_modules/
8+
mine/
9+
10+
coverage
11+
12+
dist/
13+
14+
npm-debug
15+
16+
.bsb.lock
17+
18+
yarn.lock
19+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
"@babel/preset-react",
5+
{
6+
targets: {
7+
node: "current",
8+
},
9+
},
10+
],
11+
[
12+
"@babel/preset-env",
13+
{
14+
targets: {
15+
node: "current",
16+
},
17+
},
18+
],
19+
]
20+
};

asset-lib/unit-action/package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "unit-action",
3+
"version": "0.0.1",
4+
"main": "./dist/static/js/main.js",
5+
"scripts": {
6+
"watch": "tsc -w -noEmit",
7+
"webpack:watch": "cross-env NODE_ENV=development webpack --watch --config webpack.config.js",
8+
"webpack": "cross-env NODE_ENV=production webpack --config webpack.config.js"
9+
},
10+
"dependencies": {
11+
"immutable": "^4.0.0-rc.12",
12+
"most": "^1.9.0",
13+
"type-api": "^0.0.1"
14+
},
15+
"devDependencies": {
16+
"@babel/node": "^7.8.7",
17+
"@babel/preset-env": "^7.9.0",
18+
"@babel/preset-typescript": "^7.13.0",
19+
"@types/jest": "^25.2.1",
20+
"@types/sinon": "^10.0.0",
21+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
22+
"babel-jest": "^24.1.0",
23+
"jest": "^25.2.7",
24+
"jest-cucumber": "^3.0.1",
25+
"ts-jest": "^26.1.4",
26+
"clean-webpack-plugin": "^4.0.0",
27+
"copy-webpack-plugin": "^11.0.0",
28+
"cross-env": "^7.0.3",
29+
"cz-customizable": "^6.3.0",
30+
"gulp": "^4.0.2",
31+
"sass": "^1.72.0",
32+
"mini-css-extract-plugin": "^0.9.0",
33+
"html-webpack-plugin": "^5.5.0",
34+
"source-map-loader": "^3.0.0",
35+
"ts-loader": "^9.2.6",
36+
"typescript": "^5.1.0",
37+
"style-loader": "^1.2.1",
38+
"css-loader": "^3.6.0",
39+
"sass-loader": "^14.1.1",
40+
"webpack": "^5.91.0",
41+
"webpack-cli": "^5.1.4",
42+
"webpack-dev-server": "^5.0.4"
43+
}
44+
}

asset-lib/unit-action/src/Main.ts

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
import { damageType } from "type-api/src/ImportedTypes"
2+
import { api } from "type-api/src/Type"
3+
import { category, model, action, actionType, emitSpeed, meleeRange, effect, renderEffect, skillData } from "unit-protocol/src/service/UnitType"
4+
import { actions, effects } from "./Type"
5+
6+
// export let getDefaultActions = (api: api) => {
7+
// return {
8+
// [category.EliteGiantess]: [
9+
// [action.Death]: {
10+
// path: "./asset/action/elitegiantess/default/Death.fbx",
11+
// },
12+
// ]
13+
// }
14+
// }
15+
16+
let _getAllDefaultActions = () => {
17+
return {
18+
[category.EliteGiantess]: [
19+
action.Death,
20+
action.DeathHeadshot,
21+
action.Idle,
22+
action.Lie,
23+
action.PickedControlled,
24+
action.Shake,
25+
action.StandupFromLie,
26+
action.Walk,
27+
]
28+
}
29+
}
30+
31+
let _getActions = (api: api): actions => {
32+
return {
33+
[category.EliteGiantess]: {
34+
[action.StompLight]: {
35+
type: actionType.Body,
36+
workFrameIndex: 38,
37+
getCollisionDirectionFunc: (api, forceDirection) => api.buildDownDirection(),
38+
computeAttackBoxDataFunc: (api, box, meleeRange, forceDirection) => {
39+
let sizeY = api.box3.getSize(box, api.vector3.getTempVector3()).y
40+
41+
let center = api.vector3.add(
42+
// api.box3.getCenter(box, api.vector3.getTempVector1()),
43+
api.box3.getCenter(box, api.vector3.create(0, 0, 0)),
44+
api.vector3.setY(
45+
api.vector3.multiplyScalar(
46+
forceDirection,
47+
// meleeRange / (1.3 * 1.5)
48+
meleeRange / (1.3)
49+
// meleeRange / (1.3 * 1.2)
50+
),
51+
- sizeY / 2
52+
)
53+
)
54+
let attackBox = api.box3.setFromCenterAndSize(
55+
// api.box3.getTempBox1(),
56+
api.box3.createEmpty(),
57+
center,
58+
api.vector3.create(
59+
meleeRange / 2,
60+
// meleeRange,
61+
sizeY / 2,
62+
meleeRange / 2
63+
// meleeRange
64+
)
65+
)
66+
67+
return [center, attackBox]
68+
},
69+
},
70+
[action.KickLight]: {
71+
type: actionType.Body,
72+
workFrameIndex: 38,
73+
getCollisionDirectionFunc: (api, forceDirection) => forceDirection,
74+
computeAttackBoxDataFunc: (api, box, meleeRange, forceDirection) => {
75+
let sizeY = api.box3.getSize(box, api.vector3.getTempVector1()).y
76+
77+
let center = api.vector3.add(
78+
api.box3.getCenter(box, api.vector3.getTempVector2()),
79+
api.vector3.setY(
80+
api.vector3.multiplyScalar(
81+
api.vector3.clone(forceDirection),
82+
meleeRange / (1.3)
83+
// meleeRange / (1.3 * 1.5)
84+
// meleeRange / (1.3 * 1.2)
85+
),
86+
sizeY / 3
87+
// sizeY / 1.5
88+
)
89+
)
90+
let attackBox = api.box3.setFromCenterAndSize(
91+
api.box3.getTempBox1(),
92+
center,
93+
api.vector3.create(
94+
meleeRange / 1.5,
95+
sizeY / 4,
96+
// sizeY / 2,
97+
meleeRange / 1.5
98+
)
99+
)
100+
101+
return [center, attackBox]
102+
},
103+
},
104+
}
105+
}
106+
}
107+
108+
export let getAction = (api: api, category_: category) => {
109+
return api.MutableRecordUtils.getExn(_getActions(api), category_)
110+
}
111+
112+
export let getActionData = (api: api, category_: category, action_: action) => {
113+
return api.MutableRecordUtils.getExn(getAction(api, category_), action_)
114+
}
115+
116+
117+
let _isDefaultAction = (api: api, category_: category, action_: action) => {
118+
return api.ArrayUtils.includes(_getAllDefaultActions()[category_], action_)
119+
}
120+
121+
// let _getPath = (category_, isDefault, name, postfix) => {
122+
// return `./unit-action/src/asset/${isDefault ? "default/" : ""}${name}.${postfix}`
123+
// }
124+
let _getPathPrefix = () => `./unit-action/src/asset`
125+
126+
export let getActionFilePath = (api: api, category_: category, action_: action) => {
127+
let category__ = category_.toLowerCase()
128+
129+
let actionPath, soundPath
130+
if (_isDefaultAction(api, category_, action_)) {
131+
actionPath = `${_getPathPrefix()}/action/${category__}/default/${action_}.fbx`
132+
soundPath = api.NullableUtils.getEmpty()
133+
}
134+
else {
135+
actionPath = `${_getPathPrefix()}/action/${category__}/${action_}.fbx`
136+
soundPath = api.NullableUtils.return_(`${_getPathPrefix()}/sound/${action_}.mp3`)
137+
}
138+
139+
return {
140+
action: action_,
141+
actionPath: actionPath,
142+
soundPath: soundPath
143+
}
144+
}
145+
146+
let _getAllDefaultActionFilePaths = (api: api, category_: category) => {
147+
return _getAllDefaultActions()[category_].reduce((result, action_) => {
148+
return api.ArrayUtils.push(result, getActionFilePath(api, category_, action_))
149+
}, api.ArrayUtils.create())
150+
}
151+
152+
export let getAllActionFilePaths = (api: api, category: category, skillData: skillData) => {
153+
return api.ArrayUtils.pushArrs(
154+
_getAllDefaultActionFilePaths(api, category),
155+
api.MutableRecordUtils.toArray(
156+
api.MutableRecordUtils.map(
157+
skillData,
158+
(skill) => {
159+
return getActionFilePath(api, category, skill.action)
160+
})
161+
)
162+
)
163+
}
164+
165+
166+
export let buildActionAnimationName = (category_: category, action_: action) => {
167+
return `animation_${category_}_${action_}`
168+
}
169+
170+
export let buildActionSoundId = (category_: category, action_: action) => {
171+
return `sound_${category_}_${action_}`
172+
}
173+
174+
let _getEffects = (api: api): effects => {
175+
return {
176+
[effect.DamageBody]: {
177+
actionType: actionType.Body,
178+
damageType: damageType.Direct,
179+
180+
renderEffects: [],
181+
},
182+
[effect.Stomp]: {
183+
actionType: actionType.Body,
184+
damageType: damageType.Direct,
185+
186+
// particleParam: {
187+
// TODO
188+
// },
189+
// particleData: [particleType.Smoke],
190+
// particleTypes: [particleType.Smoke],
191+
renderEffects: [renderEffect.StompDust, renderEffect.FootDamageDecal],
192+
193+
// value: {
194+
// force: forceSize.VeryLow4 * 0.4,
195+
// armorPiercingForceRatio: armorPiercingForceRatio.Low,
196+
// type: weaponType.Body,
197+
198+
// critRatio: critRatio.Zero,
199+
// explodeRange: explodeRange.Zero,
200+
// },
201+
// handleFunc:(api, effectValue) =>{
202+
203+
// }
204+
},
205+
}
206+
}
207+
208+
export let getEffect = (api: api, effectName) => {
209+
const data = _getEffects(api)
210+
211+
return api.MutableRecordUtils.getExn(data, effectName)
212+
}
213+
214+
export let getEffectData = (api: api, actionType: actionType) => {
215+
const data = _getEffects(api)
216+
217+
return api.MutableRecordUtils.reduce(data, (result, value) => {
218+
if (value.actionType_ === actionType) {
219+
return api.ArrayUtils.push(result, value)
220+
}
221+
222+
return result
223+
}, api.ArrayUtils.create())
224+
}

asset-lib/unit-action/src/Type.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { box3, damageType, nullable, vector3 } from "type-api/src/ImportedTypes"
2+
import { api } from "type-api/src/Type"
3+
import { action, actionType, category, effect, renderEffect } from "unit-protocol/src/service/UnitType"
4+
5+
export type actionData = {
6+
type: actionType,
7+
workFrameIndex: number,
8+
getCollisionDirectionFunc: (api: api, forceDirection: vector3) => vector3,
9+
computeAttackBoxDataFunc: (api: api, box: box3, meleeRange: number, forceDirection: vector3) => [vector3, vector3],
10+
}
11+
12+
export type actions = {
13+
[category.EliteGiantess]: Partial<Record<action, actionData>>,
14+
}
15+
16+
17+
export type effectData = {
18+
actionType: actionType,
19+
damageType: damageType,
20+
21+
renderEffects: Array<renderEffect>,
22+
}
23+
24+
export type effects = Record<effect, effectData>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)