mirror of
https://github.com/zeldaret/botw
synced 2026-06-01 17:57:31 -04:00
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#include "KingSystem/ActorSystem/actBaseProcCreateTaskSelector.h"
|
|
#include <limits>
|
|
#include "KingSystem/ActorSystem/actBaseProcCreateTask.h"
|
|
#include "KingSystem/Map/mapObject.h"
|
|
|
|
namespace ksys::act {
|
|
|
|
SEAD_SINGLETON_DISPOSER_IMPL(BaseProcCreateTaskSelector)
|
|
|
|
util::Task* BaseProcCreateTaskSelector::selectTask(const util::TaskSelectionContext& context) {
|
|
util::Task* min_task = nullptr;
|
|
util::Task* lane1_task = nullptr;
|
|
auto min = std::numeric_limits<float>::max();
|
|
|
|
for (auto& it : context) {
|
|
auto* task = sead::DynamicCast<BaseProcCreateTask>(&it);
|
|
if (!task)
|
|
return ⁢
|
|
|
|
if (task->getLaneId() == u8(BaseProcCreateTask::LaneId::_2))
|
|
return ⁢
|
|
|
|
if (task->mMapObject && task->mMapObject->getFlags0().isOff(map::Object::Flag0::_4))
|
|
return ⁢
|
|
|
|
if (task->mDistanceToLoadSphere >= 0.0 && min > task->mDistanceToLoadSphere)
|
|
min_task = ⁢
|
|
|
|
if (task->mDistanceToLoadSphere >= 0.0 && min > task->mDistanceToLoadSphere)
|
|
min = task->mDistanceToLoadSphere;
|
|
|
|
if (task->getLaneId() == u8(BaseProcCreateTask::LaneId::_1))
|
|
lane1_task = ⁢
|
|
}
|
|
|
|
if (min_task)
|
|
return min_task;
|
|
|
|
if (lane1_task)
|
|
return lane1_task;
|
|
|
|
return std::addressof(*context.begin());
|
|
}
|
|
|
|
} // namespace ksys::act
|