Added more quest stuff including dialogic quest condition
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Babushka.scripts.CSharp.Common.Quest;
|
||||
|
||||
public partial class DetectInventoryContains : QuestFulfillmentBase
|
||||
{
|
||||
[Export(PropertyHint.ArrayType)] private ItemInstance[] _itemsToContain = null!;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
QuestManager.Instance!.QuestsChanged += CheckInventory;
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged += CheckInventory;
|
||||
|
||||
CheckInventory();
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
QuestManager.Instance!.QuestsChanged -= CheckInventory;
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged -= CheckInventory;
|
||||
}
|
||||
|
||||
private void CheckInventory()
|
||||
{
|
||||
if (IsQuestActive() && InventoryManager.Instance.playerInventory.HasItems(_itemsToContain))
|
||||
{
|
||||
Fulfill();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c741nyedy26mx
|
||||
@@ -0,0 +1,6 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class DetectToolCollection : Node
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://caohn76m3n3nm
|
||||
@@ -0,0 +1,35 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.Quest;
|
||||
|
||||
public abstract partial class QuestFulfillmentBase : Node
|
||||
{
|
||||
[Export] private QuestResource _onActiveQuest;
|
||||
[Export] private QuestResource _toNextQuest;
|
||||
|
||||
[Export] private bool _whenFulfilledSetActiveQuestToDone = true;
|
||||
[Export] private bool _whenFulfilledSetNextQuestToActive = true;
|
||||
[Export] private bool _whenFulfilledSetNextQuestToFollow = true;
|
||||
|
||||
protected void Fulfill()
|
||||
{
|
||||
if (_whenFulfilledSetActiveQuestToDone)
|
||||
{
|
||||
QuestManager.Instance!.ChangeQuestStatus(_onActiveQuest, QuestStatus.Status.Done);
|
||||
}
|
||||
if (_whenFulfilledSetNextQuestToActive)
|
||||
{
|
||||
QuestManager.Instance!.ChangeQuestStatus(_toNextQuest, QuestStatus.Status.Active);
|
||||
}
|
||||
if (_whenFulfilledSetNextQuestToFollow)
|
||||
{
|
||||
QuestManager.Instance!.SetFollowQuest(_toNextQuest);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool IsQuestActive()
|
||||
{
|
||||
return QuestManager.Instance!.GetActiveQuests().Any(q => q.Key == _onActiveQuest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dw158xraniqkd
|
||||
Reference in New Issue
Block a user