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+ }
0 commit comments