Skip to content

Add CLEAR_ASSET_CACHE_ON_STATE_SWITCH - #1083

Open
HEIHUAa wants to merge 1 commit into
CodenameCrew:internal-mergefrom
HEIHUAa:CLEAR_ASSET_CACHE_ON_STATE_SWITCH
Open

Add CLEAR_ASSET_CACHE_ON_STATE_SWITCH#1083
HEIHUAa wants to merge 1 commit into
CodenameCrew:internal-mergefrom
HEIHUAa:CLEAR_ASSET_CACHE_ON_STATE_SWITCH

Conversation

@HEIHUAa

@HEIHUAa HEIHUAa commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Since directly modifying the State reset might not be appropriate last time, I've changed it to add a new parameter CLEAR_ASSET_CACHE_ON_STATE_SWITCH in Flags to control whether to clear all caches when switching States. During mod development, it is necessary to update assets in real time.

Comment on lines +57 to +61
for (key in [for (k in FlxG.bitmap._cache.keys()) k]) {
var graphic = FlxG.bitmap._cache.get(key);
if (graphic != null && graphic.assetsKey != null)
FlxG.bitmap.removeByKey(key);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless this doesn't work as intended, wouldn't it be simpler and slightly more optimal to iterate over the actual FlxGraphic objects instead and fetch the key from there? The FlxGraphic.key field should already point to the actual cache key.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. When I wrote that code, I wasn't actually focusing on that — instead, I was focused on figuring out how to clear the shader cache with a single button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants