-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(script): handle dispose script component
add "dispose" event function; pass run test;
- Loading branch information
Showing
15 changed files
with
223 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"is_debug": false, | ||
"is_debug": true, | ||
"context": { | ||
"alpha": true, | ||
"depth": true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
open StateDataMainType; | ||
|
||
let isAlive = (script, {disposedIndexArray}: scriptRecord) => | ||
DisposeComponentService.isAlive(script, disposedIndexArray); | ||
|
||
let _disposeData = (script, {scriptRecord} as state) => { | ||
let {gameObjectMap, scriptEventFunctionDataMap, scriptAttributeMap} = scriptRecord; | ||
|
||
{ | ||
...state, | ||
scriptRecord: { | ||
...scriptRecord, | ||
gameObjectMap: | ||
DisposeComponentService.disposeSparseMapData(script, gameObjectMap), | ||
scriptEventFunctionDataMap: | ||
scriptEventFunctionDataMap | ||
|> WonderCommonlib.ImmutableSparseMapService.deleteVal(script), | ||
scriptAttributeMap: | ||
scriptAttributeMap | ||
|> WonderCommonlib.ImmutableSparseMapService.deleteVal(script), | ||
}, | ||
}; | ||
}; | ||
|
||
let _batchExecDisposeEventFunction = (scriptArray, {scriptRecord} as state) => | ||
state | ||
|> OperateScriptEventFunctionDataMainService.execAllEventFunction( | ||
OperateScriptEventFunctionDataMainService.getScriptAllDisposeEventFunctionData( | ||
scriptArray, | ||
state, | ||
), | ||
); | ||
|
||
/* TODO test */ | ||
let handleBatchDisposeComponent = | ||
(scriptArray: array(ComponentType.component), {scriptRecord} as state) => { | ||
WonderLog.Contract.requireCheck( | ||
() => | ||
WonderLog.( | ||
Contract.( | ||
Operators.( | ||
DisposeComponentService.checkComponentShouldAliveWithBatchDispose( | ||
scriptArray, | ||
isAlive, | ||
scriptRecord, | ||
) | ||
) | ||
) | ||
), | ||
IsDebugMainService.getIsDebug(StateDataMain.stateData), | ||
); | ||
|
||
let {scriptRecord} as state = | ||
_batchExecDisposeEventFunction(scriptArray, state); | ||
|
||
let {disposedIndexArray} = scriptRecord; | ||
|
||
scriptArray | ||
|> WonderCommonlib.ArrayService.reduceOneParam( | ||
(. state, script) => state |> _disposeData(script), | ||
{ | ||
...state, | ||
scriptRecord: { | ||
...scriptRecord, | ||
disposedIndexArray: | ||
disposedIndexArray |> Js.Array.concat(scriptArray), | ||
}, | ||
}, | ||
); | ||
}; |
Oops, something went wrong.