public QuestNode AddNode(QuestNode parent, StringField id, StringField internalName, QuestNodeType nodeType, bool isOptional = false) { if (parent == null) { if (Debug.isDebugBuild) { Debug.LogWarning("Quest Machine: QuestBuilder.AddNode must be provided a valid parent node."); } return(null); } if (parent.childIndexList == null) { return(null); } parent.childIndexList.Add(quest.nodeList.Count); var node = new QuestNode(id, internalName, nodeType, isOptional); node.canvasRect = new Rect(parent.canvasRect.x, parent.canvasRect.y + 20 + QuestNode.DefaultNodeHeight, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight); quest.nodeList.Add(node); QuestStateInfo.ValidateStateInfoListCount(node.stateInfoList); QuestStateInfo.ValidateCategorizedContentListCount(node.stateInfoList[(int)QuestNodeState.Active].categorizedContentList); QuestStateInfo.ValidateCategorizedContentListCount(node.stateInfoList[(int)QuestNodeState.Inactive].categorizedContentList); QuestStateInfo.ValidateCategorizedContentListCount(node.stateInfoList[(int)QuestNodeState.True].categorizedContentList); return(node); }
private void ValidateListSizes() { var numStates = Enum.GetNames(typeof(QuestState)).Length; QuestStateInfo.ValidateStateInfoListCount(quest.stateInfoList, numStates); for (int i = 0; i < numStates; i++) { QuestStateInfo.ValidateCategorizedContentListCount(quest.stateInfoList[i].categorizedContentList); } }
/// <summary> /// Adds UI content to the return node. /// </summary> protected virtual void AddReturnNodeText(QuestBuilder questBuilder, QuestNode returnNode, QuestGiver questGiver, string mainTargetEntity, string mainTargetDescriptor, string domainName, PlanStep goal, string hudText) { var stateInfo = returnNode.stateInfoList[(int)QuestNodeState.Active]; QuestStateInfo.ValidateCategorizedContentListCount(stateInfo.categorizedContentList); var successText = ReplaceStepTags(StringField.GetStringValue(goal.action.actionText.successText), mainTargetEntity, mainTargetDescriptor, domainName, string.Empty, 0); var bodyText = questBuilder.CreateBodyContent(successText); var dialogueList = returnNode.stateInfoList[(int)QuestNodeState.Active].categorizedContentList[(int)QuestContentCategory.Dialogue]; dialogueList.contentList.Add(bodyText); var jrlText = "{Return to} " + questGiver.displayName; var jrlBodyText = questBuilder.CreateBodyContent(jrlText); var journalList = returnNode.stateInfoList[(int)QuestNodeState.Active].categorizedContentList[(int)QuestContentCategory.Journal]; journalList.contentList.Add(jrlBodyText); var hudBodyText = questBuilder.CreateBodyContent(hudText); var hudList = returnNode.stateInfoList[(int)QuestNodeState.Active].categorizedContentList[(int)QuestContentCategory.HUD]; hudList.contentList.Add(hudBodyText); }