I've seen posts on using "SendMessage(B,,MyGameObject)" and "SendMessage(B,,listener)", but I'm wondering how to make it find a scriptable object that's attached to a specific NPC (or even just call the SO from resources?)
MMORPG Kit has this dialogue component that you attach to the NPC, Which would pop up a window with the index of quests in the SO, And then clicking on a quest calls this "RenderQuestUI()" method. (From the "NpcDialog" component script above)
Code: Select all
protected virtual void RenderQuestUI(UINpcDialog uiNpcDialog, BasePlayerCharacterEntity characterEntity, List<UINpcDialogMenuAction> menuActions)
{
if (uiNpcDialog.onSwitchToQuestDialog != null)
uiNpcDialog.onSwitchToQuestDialog.Invoke();
if (uiNpcDialog.uiCharacterQuest != null)
{
if (quest != null)
{
UINpcDialogMenuAction acceptMenuAction = new UINpcDialogMenuAction();
UINpcDialogMenuAction declineMenuAction = new UINpcDialogMenuAction();
UINpcDialogMenuAction abandonMenuAction = new UINpcDialogMenuAction();
UINpcDialogMenuAction completeMenuAction = new UINpcDialogMenuAction();
acceptMenuAction.title = uiNpcDialog.MessageQuestAccept;
acceptMenuAction.icon = uiNpcDialog.questAcceptIcon;
acceptMenuAction.menuIndex = QUEST_ACCEPT_MENU_INDEX;
declineMenuAction.title = uiNpcDialog.MessageQuestDecline;
declineMenuAction.icon = uiNpcDialog.questDeclineIcon;
declineMenuAction.menuIndex = QUEST_DECLINE_MENU_INDEX;
abandonMenuAction.title = uiNpcDialog.MessageQuestAbandon;
abandonMenuAction.icon = uiNpcDialog.questAbandonIcon;
abandonMenuAction.menuIndex = QUEST_ABANDON_MENU_INDEX;
completeMenuAction.title = uiNpcDialog.MessageQuestComplete;
completeMenuAction.icon = uiNpcDialog.questCompleteIcon;
completeMenuAction.menuIndex = QUEST_COMPLETE_MENU_INDEX;
CharacterQuest characterQuest;
int index = characterEntity.IndexOfQuest(quest.DataId);
if (index >= 0)
{
characterQuest = characterEntity.Quests[index];
if (!characterQuest.isComplete)
{
if (!characterQuest.IsAllTasksDoneAndIsCompletingTarget(characterEntity, characterEntity.GetTargetEntity() as NpcEntity))
menuActions.Add(abandonMenuAction);
else
menuActions.Add(completeMenuAction);
}
else if (characterEntity.Quests[index].GetQuest().CanReceiveQuest(characterEntity))
{
menuActions.Add(acceptMenuAction);
menuActions.Add(declineMenuAction);
}
}
else
{
characterQuest = CharacterQuest.Create(quest);
menuActions.Add(acceptMenuAction);
menuActions.Add(declineMenuAction);
}
uiNpcDialog.uiCharacterQuest.Setup(characterQuest, characterEntity, index);
}
uiNpcDialog.uiCharacterQuest.Show();
}
}
With that, I can do it for the shop, storage, etc- and seems like the simplest way of integrating. Any ideas?
Edit: Better yet, call this method that calls the pop up window depending on what dialogue type the SO is (quest, shop, etc. Also from the NPCDialog component script)
Code: Select all
public override async UniTask RenderUI(UINpcDialog uiNpcDialog)
{
BasePlayerCharacterEntity characterEntity = GameInstance.PlayingCharacterEntity;
if (type != NpcDialogType.Shop && uiNpcDialog.uiSellItemRoot != null)
uiNpcDialog.uiSellItemRoot.SetActive(false);
if (type != NpcDialogType.Shop && uiNpcDialog.uiSellItemDialog != null)
uiNpcDialog.uiSellItemDialog.Hide();
if (type != NpcDialogType.Quest && uiNpcDialog.uiCharacterQuest != null)
uiNpcDialog.uiCharacterQuest.Hide();
if (type != NpcDialogType.CraftItem && uiNpcDialog.uiCraftItem != null)
uiNpcDialog.uiCraftItem.Hide();
List<UINpcDialogMenuAction> menuActions = new List<UINpcDialogMenuAction>();
switch (type)
{
case NpcDialogType.Normal:
await RenderNormalUI(uiNpcDialog, characterEntity, menuActions);
break;
case NpcDialogType.Quest:
RenderQuestUI(uiNpcDialog, characterEntity, menuActions);
break;
case NpcDialogType.Shop:
RenderShopUI(uiNpcDialog);
break;
case NpcDialogType.CraftItem:
RenderCraftUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.SaveRespawnPoint:
RenderSaveRespawnPointUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.Warp:
RenderWarpUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.RefineItem:
RenderRefineItemUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.PlayerStorage:
RenderPlayerStorageUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.GuildStorage:
RenderGuildStorageUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.DismantleItem:
RenderDismantleItemUI(uiNpcDialog, menuActions);
break;
case NpcDialogType.RepairItem:
RenderRepairItemUI(uiNpcDialog, menuActions);
break;
}
RenderMenuUI(uiNpcDialog, menuActions);
}