Skip to content

Commit

Permalink
task into mono behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Taliayaya committed Sep 17, 2023
1 parent efcb3d4 commit a376d43
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Assets/Scripts/Gameplay/Quests/Tasks/Task.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using Gameplay.Quests.Tasks.TaskHelper.TasksModules;
using Gameplay.Quests.Tasks.TasksType;
using ScriptableObjects.Quests;
using UnityEngine;

namespace Gameplay.Quests.Tasks
{
public class Task : ScriptableObject
public class Task : MonoBehaviour
{
public delegate void TaskProgressChanged(Task task);
public delegate void StatusChanged(TaskStatus newStatus, Task task);
Expand Down Expand Up @@ -50,11 +50,20 @@ public virtual void Activate()
{
_startTime = DateTime.Now;
Status = TaskStatus.Active;
ActivateTaskModules();
}
else if (Status == TaskStatus.Completed)
Debug.Log("[Task] Activate(): Task is already completed");
}

private void ActivateTaskModules()
{
foreach (var taskModule in GetComponentsInChildren<TaskModule>())
{
taskModule.Activate(this);
}
}

public virtual bool CanComplete()
{
return Status == TaskStatus.Active;
Expand Down

0 comments on commit a376d43

Please sign in to comment.