Skip to content
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

Spawndata refactor #682

Open
wants to merge 26 commits into
base: dev4
Choose a base branch
from
Open

Conversation

eh-jogos
Copy link
Collaborator

@eh-jogos eh-jogos commented Sep 20, 2024

Fixes Issue #612

SpawnData Refactor

Changes are made mostly inline with the comment in that issue.
SpawnData was refactored to be more of a base class, and any other type of spawn can extend it with its own specifications. Right now we have:

- SpawnData 
|- CharacterSpawnData (used for NPCs)
|- ItemSpawnData
  |- SarcophagusSpawnData

Adding a SpawnData for TinyItems was not necessary, normal SpawnData could cover it and they don't seem to be working anyway. If they're fully implemented in the future, it might be worthy to create a specialized SpawnData for them.

LargeObjectSpawn was removed and refactored into AnchorSpawner.

It expects to be configured on the editor with a nodepath to a node that has several Marker3D as before.
But now it doesn't need the owner to have specific variables and doesn't decide the position on where to spawn the items that were decided in the world generation phase. Instead it just expects someone else to give it a dictionary of index of Marker3D nodes as keys and SpawnData as values and chooses the correct nodes by index and uses the SpawnData to spawn there.

The sarcophagus itself receives that dictionary from it's spawn data, and uses the AnchorSpawner spawn them.

All of the decision making logic is in the world generation phases, using the correct rng, and all of the spawning logic itself is in the spawn data.

Astar during world generation

Some other improvements were made, now after corridors are generated we update the Astar to be a representation of walkable cells. This can be used in following steps, for example, I'm using it for spawning items from the initial settings "debug" list close to the player.

After spawning sarcos close to walls, I'm also removing the wall tiles from the Astar, as you can walk on the "second" tile the sarco width occupies but not close to the wall where the bulk of the sarco is located. Center sarcos are rare and they might be occupying a large area of two tiles if they're centralized so I couldn't find a good way to do it should be possible in the future if this is desired or necessary.

Here is how the visualization of the Astar looks like (red outlined tiles are the Astar Grid, yellow lines are the Astar connections)
image

This can be shown/hidden or configured in the RoomGraphViz scene.

These were to create connections without creating warnings
in the editor, but it's something from Godot 3.x and not needed
in Godot 4.x
Also change its logic so that it spawns on cells close to the player
and not beginning from the top left cells of the dungeon
This allows for knowing if a spawn position is for going down or
going up and have other important info associated with it, so we can know how and where player will be spawned for each
position during world generation phase
...trying to finish generate_initial_settings_items.gd
Sarcophagus and Lid are now forward their dict of SpawnData to
AnchorSpawner. Anchor Spawner simply takes the Anchor in the
correct index and spawns whatever spawndata was assigned to it.

But all the logic for deciding what goes where stays in the generation
steps.
I had changed them just to make it easier for me to see things
I was testing and navigate the levels
@eh-jogos eh-jogos changed the base branch from main to dev4 September 20, 2024 21:25
@eh-jogos eh-jogos changed the title WIP Spawndata refactor Spawndata refactor Sep 20, 2024
Copy link
Owner

@Mooses2k Mooses2k left a comment

Choose a reason for hiding this comment

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

  1. triviality: typo in C:\Games\GODOT\SecretHistories\utils\debug_scenes_base\game_placholder.gd (should be game_placeholder.gd)
  2. You left a debug light around the player active
  3. nm, fixed
  4. Repeatable crash entering DLvl 5 on seeds -30069 and 0.
    Out of bounds get index '5' (on base: 'Dictionary') on line 450 of world_data.gd
    Remember, < and > are debug DLvl change keys.
  5. Please merge dev4, I'm guessing it's a trivial thing from inventory.gd of Visnicio's PR I just merged. Comments only affected, I think.

Thanks. I'm happy with how you did the debug start menu spawning of initial items, that's so much better, thanks.

That's it. The rest of my testing didn't find problems. This will be very nice to have in the game once 1, 2, 4, 5 are done.

@Mooses2k
Copy link
Owner

@eh-jogos Just checking in here - only a few things left.

  1. triviality: typo in C:\Games\GODOT\SecretHistories\utils\debug_scenes_base\game_placholder.gd (should be game_placeholder.gd)
  2. You left a debug light around the player active
  3. nm, fixed
  4. Repeatable crash entering DLvl 5 on seeds -30069 and 0.
    Out of bounds get index '5' (on base: 'Dictionary') on line 450 of world_data.gd
    Remember, < and > are debug DLvl change keys.
  5. Please merge dev4, I'm guessing it's a trivial thing from inventory.gd of Visnicio's PR I just merged. Comments only affected, I think.

Thanks. I'm happy with how you did the debug start menu spawning of initial items, that's so much better, thanks.

That's it. The rest of my testing didn't find problems. This will be very nice to have in the game once 1, 2, 4, 5 are done.

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