-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support assetBundle #510
Changes from 5 commits
38ea0b2
ae344e7
18a2d2a
cbddfe9
4dd00c0
69f3a1e
a6c96be
2ec763c
ec9cddd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { AssetBundleConfiguration } from "@akashic/game-configuration"; | ||
Check failure on line 1 in src/InitialScene.ts GitHub Actions / Node 18.x / ubuntu-latest
Check failure on line 1 in src/InitialScene.ts GitHub Actions / Node 20.x / ubuntu-latest
Check failure on line 1 in src/InitialScene.ts GitHub Actions / Node 18.x / ubuntu-latest
|
||
import { Trigger } from "@akashic/trigger"; | ||
import type { SceneParameterObject } from "./Scene"; | ||
import { Scene } from "./Scene"; | ||
|
||
/** | ||
* グローバルアセットを読み込むための初期シーン。 | ||
*/ | ||
export class InitialScene extends Scene { | ||
/** | ||
* ゲームの実行に必要なグローバルアセットがすべて読み込まれた際に発火される Trigger。 | ||
* `gameConfiguration` に `assetBundle` が指定されている場合は、そのアセットもすべて読み込み完了後に発火される。 | ||
* 一方、`this.onLoad` は `gameConfiguration` の `assetBundle` 指定を無視して発火する点に注意が必要。 | ||
*/ | ||
onAllAssetsLoad: Trigger<void>; | ||
|
||
constructor(param: SceneParameterObject) { | ||
super(param); | ||
this.onAllAssetsLoad = new Trigger(); | ||
this.onLoad.add(this._handleLoad, this); | ||
} | ||
|
||
override destroy(): void { | ||
super.destroy(); | ||
if (!this.onAllAssetsLoad.destroyed()) { | ||
this.onAllAssetsLoad.destroy(); | ||
} | ||
this.onAllAssetsLoad = undefined!; | ||
} | ||
|
||
_handleLoad(): void { | ||
if (this.game._configuration.assetBundle) { | ||
Check failure on line 32 in src/InitialScene.ts GitHub Actions / Node 18.x / ubuntu-latest
Check failure on line 32 in src/InitialScene.ts GitHub Actions / Node 20.x / ubuntu-latest
Check failure on line 32 in src/InitialScene.ts GitHub Actions / Node 18.x / ubuntu-latest
|
||
const assetBundle: AssetBundleConfiguration = this.game._moduleManager._internalRequire(this.game._configuration.assetBundle); | ||
Check failure on line 33 in src/InitialScene.ts GitHub Actions / Node 18.x / ubuntu-latest
Check failure on line 33 in src/InitialScene.ts GitHub Actions / Node 20.x / ubuntu-latest
Check failure on line 33 in src/InitialScene.ts GitHub Actions / Node 18.x / ubuntu-latest
|
||
this.game._assetManager.setAssetBundle(assetBundle); | ||
const assetIds = Object.keys(assetBundle.assets); | ||
this.requestAssets(assetIds, this._handleRequestAssets.bind(this)); | ||
} else { | ||
this.onAllAssetsLoad.fire(); | ||
} | ||
} | ||
|
||
_handleRequestAssets(): void { | ||
this.onAllAssetsLoad.fire(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assetId の方使わなくなったので
Object.values()
でよさそうです。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
69f3a1e にて修正しました。