deep-entertainment / issues

Issue tracker for deep Entertainment projects
1 stars 0 forks source link

Cache handling in Tom's Surprise #12

Closed ThmsKnz closed 2 years ago

ThmsKnz commented 2 years ago

Project:

I did a few changes to the cache handling in my game "Tom's Surprise" that I would propose to change in the EgoVenture framework.

Reasons were: 1) I wanted to reduce waiting time when loading a game or when changing locations 2) I wanted the ability to skip the "WaitingScreen" via Mouseclick 3) I don't like progress bars :-)

Solution A) I replaced the yield in egoventure.gd -> update cache to avoid that the full cache is loaded before the scene is shown. I rather wanted to have the first scene shown and have the cache filled in parallel.

Therefore I replaced:

    var cached_items = update_cache(EgoVenture.state.current_scene, true)
    if cached_items > 0:
        yield(self, "queue_complete")

with:

    update_cache(EgoVenture.state.current_scene)

B) I avoided the use of MapHotspot. Instead I introduced a first "WaitingScene" which included an EgoVenture.update_cache() statement and which allowed to jump to the _next_scene with a mouse click.

func _ready():
    Inventory.disable()
    MainMenu.disabled = true
    Speedy.hidden = true
    Boombox.play_music(preload("<path to music>")) 
    EgoVenture.update_cache()
    yield(get_tree().create_timer(4), "timeout")
    _next_scene()

func _next_scene():
    Inventory.enable()
    MainMenu.disabled = false
    Speedy.hidden = false
    Boombox.play_background(preload("<path to background>")) 
    EgoVenture.target_view = FourSideRoom.VIEW_xxxx
    EgoVenture.change_scene("<path to first scene>") 

func _on_Hotspot_activate():
    _next_scene()

C) As I didn't use the MapHotspot I removed the need to have the current_location parameter by retrieving the base path directly from the scene. To do this a simple modification in scene_cache.gd -> update_cache was sufficient:

I replaced:

    var base_path

    if EgoVenture.current_location == "":
        base_path = _scene_path
    else:
        base_path = "%s/%s" % [_scene_path, EgoVenture.current_location]

with

    var base_path

    if EgoVenture.current_location == "":
        base_path = current_scene.get_base_dir()
    else:
        base_path = "%s/%s" % [_scene_path, EgoVenture.current_location]

So far I couldn't detect a disadvantage of this delayed loading when testing it on slow computers and I haven't received complaints from testers and players so far.

dploeger commented 2 years ago

Implemented this a bit differently like you suggested. I made the minimum wait time skippable now and implemented a visual representation of when caching was happening and when only the minimum wait time was counted.

This feature can be turned on and off in the configuration (under cache)