Skip to content

Commit

Permalink
Add Requeue system.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcushutchings committed Jan 3, 2024
1 parent 66c6b48 commit b8d78b7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
42 changes: 42 additions & 0 deletions rts/Sim/Path/QTPFS/Systems/RequeuePathsSystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#include "RequeuePathsSystem.h"

#include "Sim/Path/IPathManager.h"
#include "Sim/Path/QTPFS/Components/Path.h"
#include "Sim/Path/QTPFS/PathManager.h"
#include "Sim/Path/QTPFS/Registry.h"

#include "System/Ecs/EcsMain.h"
#include "System/Ecs/Utils/SystemGlobalUtils.h"
#include "System/TimeProfiler.h"
#include "System/Log/ILog.h"

using namespace SystemGlobals;
using namespace QTPFS;


void RequeuePathsSystem::Init()
{
systemUtils.OnUpdate().connect<&RequeuePathsSystem::Update>();
}

void RequeuePathsSystem::Update()
{
SCOPED_TIMER("ECS::RequeuePathsSystem::Update");

auto* pm = dynamic_cast<PathManager*>(pathManager);
auto view = registry.view<PathRequeueSearch>();
for (auto pathEntity : view) {
bool &requeueSearch = view.get<PathRequeueSearch>(pathEntity).value;
if (requeueSearch) {
pm->RequeueSearch(&registry.get<IPath>(pathEntity), true, false);
registry.emplace_or_replace<PathUpdatedCounterIncrease>(pathEntity);
requeueSearch = false;
}
}
}

void RequeuePathsSystem::Shutdown() {
systemUtils.OnUpdate().disconnect<&RequeuePathsSystem::Update>();
}
17 changes: 17 additions & 0 deletions rts/Sim/Path/QTPFS/Systems/RequeuePathsSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef REQUEUE_PATHS_SYSTEM_H__
#define REQUEUE_PATHS_SYSTEM_H__

namespace QTPFS {

class RequeuePathsSystem {
public:
static void Init();
static void Update();
static void Shutdown();
};

}

#endif

0 comments on commit b8d78b7

Please sign in to comment.