Beispiel #1
0
        public string Localize(TaskExecutionStatus value)
        {
            switch (value)
            {
            case TaskExecutionStatus.None:
                return(string.Empty);

            case TaskExecutionStatus.Verify:
                return(Task_Verify);

            case TaskExecutionStatus.VerifyGetModInfo:
                return(Task_GetModInfo);

            case TaskExecutionStatus.VerifyGetAffectedFiles:
                return(Task_GetAffectedFiles);

            case TaskExecutionStatus.VerifyExecute:
                return(Task_Verify_Execute);

            case TaskExecutionStatus.Install:
                return(Task_Install);

            case TaskExecutionStatus.InstallGetModInfo:
                return(Task_GetModInfo);

            case TaskExecutionStatus.InstallDownload:
                return(Task_Install_Download);

            case TaskExecutionStatus.InstallUnpack:
                return(Task_Install_Unpack);

            case TaskExecutionStatus.InstallExecute:
                return(Task_Install_Execute);

            case TaskExecutionStatus.InstallStoreResults:
                return(Task_StoreResults);

            case TaskExecutionStatus.Uninstall:
                return(Task_Uninstall);

            case TaskExecutionStatus.UninstallGetModInfo:
                return(Task_GetModInfo);

            case TaskExecutionStatus.UninstallGetAffectedFiles:
                return(Task_GetAffectedFiles);

            case TaskExecutionStatus.UninstallDeleteFiles:
                return(Task_Uninstall_DeleteFiles);

            case TaskExecutionStatus.UninstallRestoreBackups:
                return(Task_Uninstall_RestoreBackups);

            case TaskExecutionStatus.UninstallStoreResults:
                return(Task_StoreResults);

            default:
                return(LocalizationStringNotFound);
            }
        }
Beispiel #2
0
    public override bool CanExecute(
        PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;
        if (!player)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        var enemy = target.GetComponent <EnemyController>();

        if (!enemy)
        {
            return(false);
        }

        if (enemy.Stats.IsDead)
        {
            return(false);
        }

        var possibleTargets = lazyEnemies();

        if (!possibleTargets.FirstOrDefault(x => x.transform == target))
        {
            reason = TaskExecutionStatus.InvalidTarget;
            return(false);
        }

        var collider = target.GetComponent <SphereCollider>();

        if (!collider)
        {
            Debug.LogError("Target enemy does not have a sphere collider to mark max distance.");
            return(false);
        }

        //var range = collider.radius;
        //if (player.TrainingRanged) range = player.RangedAttackRange;
        //if (player.TrainingMagic) range = player.MagicAttackRange;

        var range    = player.GetAttackRange();
        var distance = Vector3.Distance(player.transform.position, target.position);

        if (distance > range)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        reason = TaskExecutionStatus.Ready;
        return(true);
    }
Beispiel #3
0
    public override bool CanExecute(PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;

        if (!player)
        {
            return(false);
        }

        if (player.Stats.IsDead)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        if (!target)
        {
            return(false);
        }

        var possibleTargets = lazyTrees();

        if (!possibleTargets.FirstOrDefault(x => x.transform == target))
        {
            reason = TaskExecutionStatus.InvalidTarget;
            return(false);
        }

        var tree = target.GetComponent <TreeController>();

        if (!tree)
        {
            return(false);
        }

        var collider = target.GetComponent <SphereCollider>();

        if (!collider)
        {
            return(false);
        }

        var distance = Vector3.Distance(player.transform.position, target.position);

        if (distance >= collider.radius)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        reason = TaskExecutionStatus.Ready;
        return(true);
    }
 public TaskExecutionResult(TaskExecutionStatus status, int workItemId, byte[] artifacts)
 {
     Requires.Range(workItemId > 0, "workItemId");
     Status      = status;
     WorkItemId  = workItemId;
     Artifacts   = artifacts;
     _messages   = new List <string>();
     _exceptions = new List <Exception>();
 }
 public TaskExecutionMeta(DateTime startedAt,
                          DateTime?completedAt,
                          TaskExecutionStatus status,
                          string referenceValue = null)
 {
     StartedAt      = startedAt;
     CompletedAt    = completedAt;
     Status         = status;
     ReferenceValue = referenceValue;
 }
 public TaskExecutionMeta(DateTime startedAt,
     DateTime? completedAt,
     TaskExecutionStatus status,
     string referenceValue = null)
 {
     StartedAt = startedAt;
     CompletedAt = completedAt;
     Status = status;
     ReferenceValue = referenceValue;
 }
Beispiel #7
0
 public void SetStatus(Type type, TaskExecutionStatus status, Action <TaskSettings> action)
 {
     Update(type, taskSettings =>
     {
         taskSettings.Status = status;
         if (action != null)
         {
             action(taskSettings);
         }
     });
 }
Beispiel #8
0
    public override bool CanExecute(PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;

        if (!player)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        if (player.Stats.IsDead)
        {
            return(false);
        }

        if (!target)
        {
            return(false);
        }

        if (!arena.AvailablePlayers.FirstOrDefault(x => x.transform == target))
        {
            reason = TaskExecutionStatus.InvalidTarget;
            return(false);
        }

        if (!arena.InsideArena(target))
        {
            return(false);
        }

        if (!arena.InsideArena(player.transform))
        {
            return(false);
        }

        if (Vector3.Distance(player.transform.position, target.position) > player.AttackRange)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        return(true);
    }
Beispiel #9
0
    public override bool CanExecute(PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;

        if (player.Stats.IsDead)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        if (player.Resources.Fish <= 0 && player.Resources.Wheat <= 0)
        {
            reason = TaskExecutionStatus.InsufficientResources;
            return(false);
        }

        var possibleTargets = lazyCraftingStations();

        if (!possibleTargets.FirstOrDefault(x => x.transform == target))
        {
            reason = TaskExecutionStatus.InvalidTarget;
            return(false);
        }

        var collider = target.GetComponent <SphereCollider>();

        if (!collider)
        {
            return(false);
        }

        if (Vector3.Distance(player.transform.position, target.transform.position) >= collider.radius)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        reason = TaskExecutionStatus.Ready;
        return(true);
    }
Beispiel #10
0
    public override bool CanExecute(PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;
        if (!player)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        var enemy = target.GetComponent <EnemyController>();

        if (!enemy)
        {
            return(false);
        }

        if (enemy.Stats.IsDead)
        {
            return(false);
        }

        var collider = target.GetComponent <SphereCollider>();

        if (!collider)
        {
            Debug.LogError("Target enemy does not have a sphere collider to mark max distance.");
            return(false);
        }

        var distance = Vector3.Distance(player.transform.position, target.position);

        if (distance > collider.radius)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        reason = TaskExecutionStatus.Ready;
        return(true);
    }
Beispiel #11
0
    public override bool CanExecute(PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;

        if (!player)
        {
            return(false);
        }

        if (player.Stats.IsDead)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        if (!target)
        {
            return(false);
        }

        var collider = target.GetComponent <CapsuleCollider>();

        if (!collider)
        {
            return(false);
        }

        if (Vector3.Distance(player.transform.position, target.transform.position) >= collider.radius)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        reason = TaskExecutionStatus.Ready;
        return(true);
    }
    public override bool CanExecute(
        PlayerController player, Transform target, out TaskExecutionStatus reason)
    {
        reason = TaskExecutionStatus.NotReady;
        if (!player)
        {
            return(false);
        }

        if (!target || target == null)
        {
            return(false);
        }

        if (!player.IsReadyForAction)
        {
            return(false);
        }

        if (player.TrainingHealing)
        {
            var tar = target.GetComponent <PlayerController>();
            if (!tar)
            {
                reason = TaskExecutionStatus.InvalidTarget;
                return(false);
            }

            if (tar.Stats.IsDead)
            {
                reason = TaskExecutionStatus.InvalidTarget;
                return(false);
            }
            //var possibleTargets = player.Island?.GetPlayers();
            //if (possibleTargets == null || !possibleTargets.FirstOrDefault(x => x != null && x && x.transform != null && target && target != null && x.transform == target))
            //{
            //    reason = TaskExecutionStatus.InvalidTarget;
            //    return false;
            //}
        }
        else
        {
            var enemy = target.GetComponent <EnemyController>();
            if (!enemy)
            {
                return(false);
            }

            if (enemy.Stats.IsDead)
            {
                return(false);
            }

            var possibleTargets = lazyEnemies();
            if (!possibleTargets.FirstOrDefault(x => x.transform == target))
            {
                reason = TaskExecutionStatus.InvalidTarget;
                return(false);
            }
        }

        var range    = player.GetAttackRange();
        var collider = target.GetComponent <SphereCollider>();

        if (collider && collider.radius > range)
        {
            range = collider.radius;
        }

        var distance = Vector3.Distance(player.transform.position, target.position);

        if (distance > range)
        {
            reason = TaskExecutionStatus.OutOfRange;
            return(false);
        }

        reason = TaskExecutionStatus.Ready;
        return(true);
    }
 public MemoryTaskExecutionEntity(Guid executorId, DateTime startDate)
 {
     Status     = TaskExecutionStatus.Started;
     ExecutorId = executorId;
     StartDate  = startDate;
 }
Beispiel #14
0
 private void SetStatus(Type type, TaskExecutionStatus status, Action <TaskSettings> action = null)
 {
     _taskSettingManager.SetStatus(type, status, action);
 }
Beispiel #15
0
 public bool CanExecuteTask(PlayerController player, Transform target, out TaskExecutionStatus reason)
 {
     reason = TaskExecutionStatus.NotReady;
     return(this.task != null && this.task.CanExecute(player, target, out reason));
 }
 private void UpdateStatus(TaskExecutionStatus status, double progress = 0)
 {
     Status   = status;
     Progress = progress;
     TaskStateChanged?.Invoke(this, new TaskStateChangedEventArgs(Task, Status, Progress));
 }
Beispiel #17
0
 public abstract bool CanExecute(PlayerController player, Transform target, out TaskExecutionStatus reason);
 private TaskExecutionResultInfo(TaskExecutionStatus status, QueuedTaskError error, bool isRecoverable)
 {
     mStatus        = status;
     mError         = error;
     mIsRecoverable = isRecoverable;
 }
Beispiel #19
0
 public TaskStateChangedEventArgs(Task task, TaskExecutionStatus status, double progress)
 {
     Task     = task;
     Status   = status;
     Progress = progress;
 }