Files
botw/lib/EventFlow/src/evfl/ResActor.cpp
T
Léo Lam 18c60323a9 Switch to subrepos
git subrepo clone https://github.com/open-ead/sead lib/sead

subrepo:
  subdir:   "lib/sead"
  merged:   "1b66e825d"
upstream:
  origin:   "https://github.com/open-ead/sead"
  branch:   "master"
  commit:   "1b66e825d"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

git subrepo clone (merge) https://github.com/open-ead/nnheaders lib/NintendoSDK

subrepo:
  subdir:   "lib/NintendoSDK"
  merged:   "9ee21399f"
upstream:
  origin:   "https://github.com/open-ead/nnheaders"
  branch:   "master"
  commit:   "9ee21399f"
git-subrepo:
  version:  "0.4.3"
  origin:   "ssh://git@github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

git subrepo clone https://github.com/open-ead/agl lib/agl

subrepo:
  subdir:   "lib/agl"
  merged:   "7c063271b"
upstream:
  origin:   "https://github.com/open-ead/agl"
  branch:   "master"
  commit:   "7c063271b"
git-subrepo:
  version:  "0.4.3"
  origin:   "ssh://git@github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

git subrepo clone https://github.com/open-ead/EventFlow lib/EventFlow

subrepo:
  subdir:   "lib/EventFlow"
  merged:   "c35d21b34"
upstream:
  origin:   "https://github.com/open-ead/EventFlow"
  branch:   "master"
  commit:   "c35d21b34"
git-subrepo:
  version:  "0.4.3"
  origin:   "ssh://git@github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"
2022-03-21 21:31:42 +01:00

90 lines
2.8 KiB
C++

#include <algorithm>
#include <evfl/ResActor.h>
#include <ore/ResEndian.h>
#include <ore/ResMetaData.h>
namespace evfl {
void ActorBinding::Register(const ResAction* action) {
if (GetAction(*action->name.Get()) != m_actions.end())
return;
Action entry;
entry.res_action = action;
m_actions.emplace_back(entry);
}
void ActorBinding::Register(const ResQuery* query) {
if (GetQuery(*query->name.Get()) != m_queries.end())
return;
Query entry;
entry.res_query = query;
m_queries.emplace_back(entry);
}
ActorBinding::Action* ActorBinding::GetAction(const ore::StringView& name) {
return std::find_if(m_actions.begin(), m_actions.end(), [name](const Action& action) {
return name == *action.res_action->name.Get();
});
}
const ActorBinding::Action* ActorBinding::GetAction(const ore::StringView& name) const {
return std::find_if(m_actions.begin(), m_actions.end(), [name](const Action& action) {
return name == *action.res_action->name.Get();
});
}
ActorBinding::Query* ActorBinding::GetQuery(const ore::StringView& name) {
return std::find_if(m_queries.begin(), m_queries.end(), [name](const Query& query) {
return name == *query.res_query->name.Get();
});
}
const ActorBinding::Query* ActorBinding::GetQuery(const ore::StringView& name) const {
return std::find_if(m_queries.begin(), m_queries.end(), [name](const Query& query) {
return name == *query.res_query->name.Get();
});
}
bool ActBinder::Builder::Build(evfl::ActBinder* binder, ore::Allocator* allocator,
ore::IterRange<const ResActor*> actors) {
binder->m_event_used_actor_count = 0;
binder->m_allocator = allocator;
binder->m_bindings.ConstructElements(actors.size(), allocator);
auto it = actors.begin();
for (int i = 0; i < actors.size(); ++i) {
auto& binding = binder->m_bindings[i];
binding.m_actor = it;
binding.m_actions.Init(binder->m_allocator);
binding.m_queries.Init(binder->m_allocator);
++it;
}
return true;
}
const ore::Array<ActorBinding>* ActBinder::GetUsedResActors() const {
return &m_bindings;
}
void SwapEndian(ore::ResEndian* endian, ResActor* actor) {
using ore::SwapEndian;
if (endian->is_serializing) {
if (auto* params = actor->params.ToPtr(endian->base))
SwapEndian(endian, params);
SwapEndian(&actor->num_actions);
SwapEndian(&actor->num_queries);
SwapEndian(&actor->entry_point_idx);
} else {
SwapEndian(&actor->num_actions);
SwapEndian(&actor->num_queries);
SwapEndian(&actor->entry_point_idx);
if (auto* params = actor->params.ToPtr(endian->base))
SwapEndian(endian, params);
}
}
} // namespace evfl