Added Quest field
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,6 +28,7 @@ public static class WateringCanState
|
||||
|
||||
public delegate void WateringCanDelegate(bool state);
|
||||
public static event WateringCanDelegate WateringCanActiveStateChanged;
|
||||
public static event Action? OnWater;
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +46,10 @@ public static class WateringCanState
|
||||
public static void Water()
|
||||
{
|
||||
if(_fillstate > 0)
|
||||
{
|
||||
_fillstate--;
|
||||
OnWater?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.Farming;
|
||||
using Babushka.scripts.CSharp.Common.Quest;
|
||||
|
||||
public partial class DetectFieldWork : QuestFulfillmentBase
|
||||
{
|
||||
private int wateredCounter = 0;
|
||||
|
||||
[Export] private int _wateringNeeded = 5;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
WateringCanState.OnWater += CountWater;
|
||||
QuestManager.Instance!.QuestsChanged += CheckFieldWork;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
WateringCanState.OnWater -= CountWater;
|
||||
QuestManager.Instance!.QuestsChanged -= CheckFieldWork;
|
||||
}
|
||||
|
||||
public void CountWater()
|
||||
{
|
||||
wateredCounter++;
|
||||
CheckFieldWork();
|
||||
}
|
||||
|
||||
public void CheckFieldWork()
|
||||
{
|
||||
if (IsQuestActive() && wateredCounter >= _wateringNeeded)
|
||||
{
|
||||
Fulfill();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bhbldab74vmhy
|
||||
@@ -1,6 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class DetectToolCollection : Node
|
||||
{
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://caohn76m3n3nm
|
||||
@@ -3,6 +3,12 @@ using System;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.Quest;
|
||||
|
||||
/// <summary>
|
||||
/// Acts as a base for scripts to check for conditions to complete quests.
|
||||
///
|
||||
/// The derived Class is responsible for triggering the Check.
|
||||
/// It is recommended to always check on QuestManager.Instance!.QuestsChanged
|
||||
/// </summary>
|
||||
public abstract partial class QuestFulfillmentBase : Node
|
||||
{
|
||||
[Export] private QuestResource _onActiveQuest;
|
||||
@@ -12,6 +18,8 @@ public abstract partial class QuestFulfillmentBase : Node
|
||||
[Export] private bool _whenFulfilledSetNextQuestToActive = true;
|
||||
[Export] private bool _whenFulfilledSetNextQuestToFollow = true;
|
||||
|
||||
[Signal] private delegate void OnFulfilledEventHandler();
|
||||
|
||||
protected void Fulfill()
|
||||
{
|
||||
if (_whenFulfilledSetActiveQuestToDone)
|
||||
@@ -26,6 +34,8 @@ public abstract partial class QuestFulfillmentBase : Node
|
||||
{
|
||||
QuestManager.Instance!.SetFollowQuest(_toNextQuest);
|
||||
}
|
||||
|
||||
EmitSignalOnFulfilled();
|
||||
}
|
||||
|
||||
protected bool IsQuestActive()
|
||||
|
||||
@@ -17,7 +17,7 @@ public partial class SceneTransition : Node
|
||||
public void LoadSceneAtIndex(int index)
|
||||
{
|
||||
string sceneName = _sceneNamesToLoad[index];
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFileThreaded(sceneName);
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFile(sceneName);
|
||||
UnloadAfterDelay();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
extends Node
|
||||
class_name DialogicStartSpecific
|
||||
|
||||
@export var timeline : String
|
||||
|
||||
func start():
|
||||
Dialogic.start(timeline)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dih1b0opgc3f7
|
||||
Reference in New Issue
Block a user