The OnKeyAssigned function will still be called when the dungeon is generated from the editor, so you should be able to cache the key into a serialized field or property so it can be accessed later. Something like this:
public class LockedDoor : MonoBehaviour, IKeyLock
{
[SerializeField]
private int keyID;
[SerializeField]
private KeyManager keyManager;
public void OnKeyAssigned(Key key, KeyManager manager)
{
keyID = key.ID;
keyManager = manager;
}
private void Start()
{
if (keyManager == null)
return;
// Get the key from the key manager
var key = keyManager.GetKeyByID(keyID);
}
}
Now you can use the cached keyID to get the key from the KeyManager at runtime (like Iām doing here in the Start function) to do whatever you need to do with it.
Amazing another issue solved
I wonder if could use a prefab set as Blocker in a doorway with Prop Local Spawner with an array element a Key Spawnerā¦ Have you tested it?
I havenāt tested that yet, but the order that these things are processed in the code goes doorways > props > locks & keys, so I think what youāve written should work.
Hi, I get the following error when I try to generate it in the Generate Dungeon Window on the editor.
MissingReferenceException: The object of type āRandomPrefabā has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
DunGen.RandomPrefab.Process (DunGen.RandomStream randomStream, DunGen.Tile tile) (at Assets/DunGen/Code/RandomPrefab.cs:27)
DunGen.DungeonGenerator.ProcessLocalProps () (at Assets/DunGen/Code/DungeonGenerator.cs:1207)
DunGen.DungeonGenerator+d__131.MoveNext () (at Assets/DunGen/Code/DungeonGenerator.cs:1144)
DunGen.DungeonGenerator.Wait (System.Collections.IEnumerator routine) (at Assets/DunGen/Code/DungeonGenerator.cs:257)
DunGen.DungeonGenerator+d__111.MoveNext () (at Assets/DunGen/Code/DungeonGenerator.cs:367)
DunGen.DungeonGenerator.Wait (System.Collections.IEnumerator routine) (at Assets/DunGen/Code/DungeonGenerator.cs:257)
DunGen.DungeonGenerator+d__108.MoveNext () (at Assets/DunGen/Code/DungeonGenerator.cs:246)
DunGen.DungeonGenerator.Wait (System.Collections.IEnumerator routine) (at Assets/DunGen/Code/DungeonGenerator.cs:257)
DunGen.DungeonGenerator.Generate () (at Assets/DunGen/Code/DungeonGenerator.cs:190)
DunGen.Editor.DungeonGeneratorWindow.GenerateDungeon () (at Assets/DunGen/Code/Editor/Windows/DungeonGeneratorWindow.cs:58)
DunGen.Editor.DungeonGeneratorWindow.OnGUI () (at Assets/DunGen/Code/Editor/Windows/DungeonGeneratorWindow.cs:28)
It appears that generator is accessing a RandomPrefab that was deleted in the LocalPropSet draw. For unknown reason, this does not occur while in playback mode.
Iām loving this asset so far - the only thing Iāve been scratching my head on is trying to make sure the start room uses more than one doorway. Basically, the main path generates, and the branches branch of off it (and other branches). This leads to other doorways in the start room being unused, where Iād like them to be used. Is this possible? To get branches to start from the main roomās extra doorways? Or, is it simply relying on RNG to loop back to the start? Iād be willing to modify the generator if thatās what it takes, but I figured Iād ask first to see if thereās any out-of-the-box solution.
Branches are currently only supported on the connections between nodes in the dungeon flow graph, not on the nodes themselves (including the start and goal tiles).
Unfortunately, modifying that behaviour would be a fairly involved process since the branch settings are all in the Archetype class. Iāll need to find some time to look into it properly and see what it would take to support branches everywhere. I feel there was a reason I didnāt allow branches from graph nodes, but itās been so long I donāt know what it was or if the reason is even relevant any more.
Hello, I am getting these errors after importing Dungen, A* Pathfinding Project and the Adapter:
Assets\DunGen\Integration\AStarPathfindingProjectPro\AStarNavMeshAdapter.cs(70,50): error CS1061: āProgressā does not contain a definition for ādescriptionā and no accessible extension method ādescriptionā accepting a first argument of type āProgressā could be found (are you missing a using directive or an assembly reference?)
Assets\DunGen\Integration\AStarPathfindingProjectPro\AStarNavMeshAdapter.cs(90,26): error CS0029: Cannot implicitly convert type āintā to āPathfinding.PathfindingTagā