Пример #1
0
        public virtual void OnGameplayTaskActivated(UGameplayTask Task)
        {
            KnownTasks.Add(Task);

            if (Task.IsTickingTask())
            {
                if (!TickingTasks.Contains(Task))
                {
                    TickingTasks.Add(Task);
                }
                // If this is our first ticking task, set this component as active so it begins ticking
                if (TickingTasks.Count == 1)
                {
                    UpdateShouldTick();
                }
            }

            if (!Task.IsOwnedByTasksComponent())
            {
                var TaskOwner = Task.GetTaskOwner();
                if (TaskOwner != null)
                {
                    TaskOwner.OnGameplayTaskActivated(Task);
                }
            }
        }
Пример #2
0
        public virtual void OnGameplayTaskDeactivated(UGameplayTask Task)
        {
            bool bIsFinished = Task.IsFinished();

            var childTask = Task.GetChildTask();

            if (childTask != null && bIsFinished)
            {
                if (Task.HasOwnerFinished())
                {
                    childTask.TaskOwnerEnded();
                }
                else
                {
                    childTask.EndTask();
                }
            }

            if (Task.IsTickingTask())
            {
                // If we are removing our last ticking task, set this component as inactive so it stops ticking
                TickingTasks.Remove(Task);
            }

            if (bIsFinished)
            {
                // using RemoveSwap rather than RemoveSingleSwap since a Task can be added
                // to KnownTasks both when activating as well as unpausing
                // while removal happens only once. It's cheaper to handle it here.
                KnownTasks.Remove(Task);
            }

            // Resource-using task
            if (Task.RequiresPriorityOrResourceManagement() && bIsFinished)
            {
                OnTaskEnded(Task);
            }

            if (!Task.IsOwnedByTasksComponent() && !Task.HasOwnerFinished())
            {
                var TaskOwner = Task.GetTaskOwner();
                TaskOwner.OnGameplayTaskDeactivated(Task);
            }

            UpdateShouldTick();
        }