public override void UpdateTask(MAnimalBrain brain, int index) { if (when == ExecuteTask.OnUpdate) { if (MTools.ElapsedTime(brain.TasksTime[index], interval)) { Execute_Task(brain); brain.SetElapsedTaskTime(index); } } }
public override void UpdateTask(MAnimalBrain brain, int index) { if (Play == ExecuteTask.OnUpdate) //If the animal is in range of the Target { if (MTools.ElapsedTime(brain.TasksTime[index], CoolDown)) { StateActivate(brain); brain.SetElapsedTaskTime(index); } } }
public override void UpdateTask(MAnimalBrain brain, int index) { if (interval > 0) { if (MTools.ElapsedTime(brain.TasksTime[index], interval)) { UpdateMovementTask(brain, index); brain.SetElapsedTaskTime(index); } } else { UpdateMovementTask(brain, index); } }
internal void StartTaks(MAnimalBrain brain, int i) { if (brain.TasksStarted[i]) { return; //DO NOT START AN ALREADY STARTED TASK } // Debug.Log($"<B>{brain.Animal.name}:</B> Start Task: [{name}] [{i}]-[{tasks[i].name }]"); if (i == 0 || !tasks[i].WaitForPreviousTask) { //Prepare the Task brain.TasksStarted[i] = true; brain.SetElapsedTaskTime(i); tasks[i].StartTask(brain, i); //Start the Task after it has being prepared. if (tasks[i].MessageID != 0) { brain.OnTaskStarted.Invoke(tasks[i].MessageID); //Send Events after the Task has started } } }
public override void UpdateTask(MAnimalBrain brain, int index) { if (Play == PlayWhen.Forever) //If the animal is in range of the Target { if (near && !brain.ArrivedToTarget) { return; //Dont play if Play on target is true but we are not near the target. } if (MTools.ElapsedTime(brain.TasksTime[index], CoolDown)) { PlayMode(brain); brain.SetElapsedTaskTime(index); } } else { switch (affect) { case Affected.Self: if (!brain.Animal.IsPlayingMode) { brain.TaskDone(index); } break; case Affected.Target: if (brain.TargetAnimal && !brain.TargetAnimal.IsPlayingMode) { brain.TaskDone(index); } break; default: break; } } }