示例#1
0
 /// <summary>
 /// 一般 task自己会调用此方法
 /// TODO 注意, 在调用本方法之前, 需要派发"on completed" delegates
 /// </summary>
 public void EndTask()
 {
     if (IsFinished())
     {
         return;
     }
     TaskState = EGameplayTaskState.Finished;
 }
示例#2
0
 public UGameplayTask()
 {
     bTickingTask            = false;
     bOwnedByTasksComponent  = false;
     bClaimRequiredResources = true;
     bOwnerFinished          = false;
     TaskState             = EGameplayTaskState.Uninitialized;
     ResourceOverlapPolicy = ETaskResourceOverlapPolicy.StartOnTop;
     Priority = FGameplayTaskPriority.DefaultPriority;
 }
示例#3
0
        /// <summary>
        /// 如果owner "ended", 那么本方法会被调用. 在OnDestroy中调用
        /// </summary>
        public void TaskOwnerEnded()
        {
            if (IsFinished())
            {
                return;
            }

            bOwnerFinished = true;
            // mark as finished, just to be on the safe side
            TaskState = EGameplayTaskState.Finished;
        }
示例#4
0
        /// <summary>
        /// 激活任务的入口
        /// </summary>
        private void PerformActivation()
        {
            if (IsActive())
            {
                return;
            }

            TaskState = EGameplayTaskState.Active;
            Activate();

            //有些立即完成的任务, 激活即完成
            //如果没完成, 我们才跟component打交道
            if (IsFinished() == false)
            {
                TasksComponent.OnGameplayTaskActivated(this);
            }
        }
示例#5
0
        /// <summary>
        /// 初始化任务, 但不激活. 激活需要调用Activate方法
        /// </summary>
        public void InitTask(IGameplayTaskOwnerInterface InTaskOwner, int InPriority)
        {
            //Priority = InPriority;
            TaskOwner = InTaskOwner;
            TaskState = EGameplayTaskState.AwaitingActivation;

            if (bClaimRequiredResources)
            {
                ClaimedResources.AddSet(RequiredResources);
            }

            InTaskOwner.OnGameplayTaskInitialized(this);

            TasksComponent         = InTaskOwner.GetGameplayTasksComponent(this);
            bOwnedByTasksComponent = (TaskOwner == TasksComponent);

            //避免两次调用OnGameplayTaskInitialized方法
            if (!bOwnedByTasksComponent)
            {
                TasksComponent.OnGameplayTaskInitialized(this);
            }
        }
示例#6
0
 public static string GetTaskStateName(EGameplayTaskState Value)
 {
     return("");
 }
示例#7
0
 protected virtual void Resume()
 {
     TaskState = EGameplayTaskState.Active;
     TasksComponent.OnGameplayTaskActivated(this);
 }
示例#8
0
 // protected by design. Not meant to be called outside from GameplayTaskComponent mechanics
 protected virtual void Pause()
 {
     TaskState = EGameplayTaskState.Paused;
     TasksComponent.OnGameplayTaskDeactivated(this);
 }
示例#9
0
 /* End and CleanUp the task - may be called by the task itself or by the task owner if the owner is ending.
  *	IMPORTANT! Do NOT call directly! Call EndTask() or TaskOwnerEnded()
  *	IMPORTANT! When overriding this function make sure to call Super.OnDestroy(bOwnerFinished) as the last thing,
  *		since the function internally marks the task as "Pending Kill", and this may interfere with internal BP mechanics
  */
 protected virtual void OnDestroy(bool bInOwnerFinished)
 {
     TaskState = EGameplayTaskState.Finished;
     TasksComponent.OnGameplayTaskDeactivated(this);
 }