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

Prevent state from being actorless #15

Open
NicoooByte opened this issue Aug 22, 2023 · 2 comments
Open

Prevent state from being actorless #15

NicoooByte opened this issue Aug 22, 2023 · 2 comments

Comments

@NicoooByte
Copy link

OS
Windows 10

Unity
Unity 2021.2.0f1

DialogueGraph
2.0.0

Description
If the state has no actor, the following error occurs:

System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <7b5f9a2f7db343a4ab54846ed680277b>:0)
DialogueGraph.Runtime.RuntimeDialogueGraph.GetCurrentActor () (at Library/PackageCache/[email protected]/Runtime/RuntimeDialogueGraph.cs:68)

originating from "RuntimeDialogueGraph.cs"

public ActorData GetCurrentActor() {
            var currentNode = DlogObject.NodeDictionary[currentNodeGuid];
            if (currentNode.Type != NodeType.NPC) return null;
            var currentNodeActorGuid = currentNode.ActorGuid;
            var actor = CurrentData.ActorData[CurrentData.ActorDataIndices[currentNodeActorGuid]]; // <- Throws error
            return actor;
        }
@123tris
Copy link
Contributor

123tris commented Aug 24, 2023

The reason this throws an error is because GetCurrentActor is called when the current node is an NPC node but doesn't actually contain actor data. The solution to this is simple. When retrieving currentNode we should check if currentNode.ActorGuid is null or an empty string. Pull-request I submitted that fixes it:
#16

@TeodorVecerdi
Copy link
Owner

Thanks for the fix @123tris!
I'll close this issue once I release a new version of DialogueGraph containing the fix 👍

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

No branches or pull requests

3 participants