2022-08-06 03:01:59 +00:00
|
|
|
#include "BehaviorContext.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "Behavior.h"
|
|
|
|
#include "BehaviorBranchContext.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "Game.h"
|
2023-10-21 23:31:55 +00:00
|
|
|
#include "Logger.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "dServer.h"
|
2023-09-21 01:06:28 +00:00
|
|
|
#include "BitStreamUtils.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "DestroyableComponent.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "EchoSyncSkill.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "PhantomPhysicsComponent.h"
|
|
|
|
#include "RebuildComponent.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2023-10-09 20:18:51 +00:00
|
|
|
#include "TeamManager.h"
|
2023-05-03 21:38:32 +00:00
|
|
|
#include "eConnectionType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BehaviorSyncEntry::BehaviorSyncEntry() {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BehaviorTimerEntry::BehaviorTimerEntry() {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BehaviorEndEntry::BehaviorEndEntry() {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
uint32_t BehaviorContext::GetUniqueSkillId() const {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* entity = Game::entityManager->GetEntity(this->originator);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entity == nullptr) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Invalid entity for (%llu)!", this->originator);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* component = entity->GetComponent<SkillComponent>();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (component == nullptr) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("No skill component attached to (%llu)!", this->originator);;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return component->GetUniqueSkillId();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-05 13:57:47 +00:00
|
|
|
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, const float duration, bool ignoreInterrupts) {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto entry = BehaviorSyncEntry();
|
|
|
|
|
|
|
|
entry.handle = syncId;
|
|
|
|
entry.behavior = behavior;
|
|
|
|
entry.branchContext = branchContext;
|
2022-12-21 08:26:17 +00:00
|
|
|
entry.branchContext.isSync = true;
|
2022-12-19 20:52:00 +00:00
|
|
|
entry.ignoreInterrupts = ignoreInterrupts;
|
2023-04-05 13:57:47 +00:00
|
|
|
// Add 10 seconds + duration time to account for lag and give clients time to send their syncs to the server.
|
|
|
|
constexpr float lagTime = 10.0f;
|
|
|
|
entry.time = lagTime + duration;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
this->syncEntries.push_back(entry);
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second) {
|
2022-04-27 04:44:35 +00:00
|
|
|
BehaviorTimerEntry entry;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
entry.time = branchContext.duration;
|
|
|
|
entry.behavior = behavior;
|
|
|
|
entry.branchContext = branchContext;
|
|
|
|
entry.second = second;
|
|
|
|
|
|
|
|
this->timerEntries.push_back(entry);
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::RegisterEndBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second) {
|
2021-12-05 17:54:36 +00:00
|
|
|
BehaviorEndEntry entry;
|
|
|
|
|
|
|
|
entry.behavior = behavior;
|
|
|
|
entry.branchContext = branchContext;
|
|
|
|
entry.second = second;
|
|
|
|
entry.start = branchContext.start;
|
|
|
|
|
|
|
|
this->endEntries.push_back(entry);
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::ScheduleUpdate(const LWOOBJID id) {
|
|
|
|
if (std::find(this->scheduledUpdates.begin(), this->scheduledUpdates.end(), id) != this->scheduledUpdates.end()) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->scheduledUpdates.push_back(id);
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::ExecuteUpdates() {
|
|
|
|
for (const auto& id : this->scheduledUpdates) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* entity = Game::entityManager->GetEntity(id);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (entity == nullptr) continue;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->SerializeEntity(entity);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this->scheduledUpdates.clear();
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bitStream) {
|
2021-12-05 17:54:36 +00:00
|
|
|
BehaviorSyncEntry entry;
|
|
|
|
auto found = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There may be more than one of each handle
|
|
|
|
*/
|
2022-07-28 13:39:57 +00:00
|
|
|
for (auto i = 0u; i < this->syncEntries.size(); ++i) {
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto syncEntry = this->syncEntries.at(i);
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (syncEntry.handle == syncId) {
|
2021-12-05 17:54:36 +00:00
|
|
|
found = true;
|
|
|
|
entry = syncEntry;
|
|
|
|
|
|
|
|
this->syncEntries.erase(this->syncEntries.begin() + i);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (!found) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to find behavior sync entry with sync id (%i)!", syncId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* behavior = entry.behavior;
|
|
|
|
const auto branch = entry.branchContext;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (behavior == nullptr) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Invalid behavior for sync id (%i)!", syncId);
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-11 10:59:29 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
behavior->Sync(this, bitStream, branch);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::Update(const float deltaTime) {
|
|
|
|
for (auto i = 0u; i < this->timerEntries.size(); ++i) {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto entry = this->timerEntries.at(i);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entry.time > 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
entry.time -= deltaTime;
|
|
|
|
|
|
|
|
this->timerEntries[i] = entry;
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entry.time > 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry.behavior->Timer(this, entry.branchContext, entry.second);
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<BehaviorTimerEntry> valid;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& entry : this->timerEntries) {
|
|
|
|
if (entry.time <= 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
valid.push_back(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->timerEntries = valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, Behavior* behavior, const BehaviorBranchContext& branch, const bool ignoreInterrupts) {
|
2021-12-05 17:54:36 +00:00
|
|
|
BehaviorSyncEntry entry;
|
|
|
|
|
|
|
|
entry.behavior = behavior;
|
|
|
|
entry.time = time;
|
|
|
|
entry.branchContext = branch;
|
|
|
|
entry.handle = syncId;
|
|
|
|
entry.ignoreInterrupts = ignoreInterrupts;
|
|
|
|
|
|
|
|
this->syncEntries.push_back(entry);
|
|
|
|
}
|
|
|
|
|
2023-04-05 13:57:47 +00:00
|
|
|
void BehaviorContext::UpdatePlayerSyncs(float deltaTime) {
|
|
|
|
uint32_t i = 0;
|
|
|
|
while (i < this->syncEntries.size()) {
|
|
|
|
auto& entry = this->syncEntries.at(i);
|
|
|
|
|
|
|
|
entry.time -= deltaTime;
|
|
|
|
|
|
|
|
if (entry.time >= 0.0f) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
this->syncEntries.erase(this->syncEntries.begin() + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::InvokeEnd(const uint32_t id) {
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<BehaviorEndEntry> entries;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& entry : this->endEntries) {
|
|
|
|
if (entry.start == id) {
|
2021-12-05 17:54:36 +00:00
|
|
|
entry.behavior->End(this, entry.branchContext, entry.second);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
entries.push_back(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->endEntries = entries;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
bool BehaviorContext::CalculateUpdate(const float deltaTime) {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto any = false;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (auto i = 0u; i < this->syncEntries.size(); ++i) {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto entry = this->syncEntries.at(i);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entry.time > 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
entry.time -= deltaTime;
|
|
|
|
|
|
|
|
this->syncEntries[i] = entry;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entry.time > 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
any = true;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Echo sync
|
2023-01-07 05:17:05 +00:00
|
|
|
EchoSyncSkill echo;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
echo.bDone = true;
|
|
|
|
echo.uiBehaviorHandle = entry.handle;
|
|
|
|
echo.uiSkillHandle = this->skillUId;
|
|
|
|
|
|
|
|
auto* bitStream = new RakNet::BitStream();
|
|
|
|
|
|
|
|
// Calculate sync
|
|
|
|
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (!clientInitalized) {
|
|
|
|
echo.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
// Write message
|
|
|
|
RakNet::BitStream message;
|
|
|
|
|
2023-09-21 01:06:28 +00:00
|
|
|
BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
2021-12-05 17:54:36 +00:00
|
|
|
message.Write(this->originator);
|
|
|
|
echo.Serialize(&message);
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
ExecuteUpdates();
|
|
|
|
|
|
|
|
delete bitStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<BehaviorSyncEntry> valid;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& entry : this->syncEntries) {
|
|
|
|
if (entry.time <= 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
valid.push_back(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->syncEntries = valid;
|
|
|
|
|
|
|
|
return any;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::Interrupt() {
|
|
|
|
std::vector<BehaviorSyncEntry> keptSync{};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& entry : this->syncEntries) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!entry.ignoreInterrupts) continue;
|
|
|
|
|
|
|
|
keptSync.push_back(entry);
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
this->syncEntries = keptSync;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BehaviorContext::Reset() {
|
|
|
|
for (const auto& entry : this->timerEntries) {
|
2021-12-05 17:54:36 +00:00
|
|
|
entry.behavior->Timer(this, entry.branchContext, entry.second);
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& entry : this->endEntries) {
|
2021-12-05 17:54:36 +00:00
|
|
|
entry.behavior->End(this, entry.branchContext, entry.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->endEntries.clear();
|
|
|
|
this->timerEntries.clear();
|
|
|
|
this->syncEntries.clear();
|
|
|
|
this->scheduledUpdates.clear();
|
|
|
|
}
|
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
void BehaviorContext::FilterTargets(std::vector<Entity*>& targets, std::forward_list<int32_t>& ignoreFactionList, std::forward_list<int32_t>& includeFactionList, bool targetSelf, bool targetEnemy, bool targetFriend, bool targetTeam) const {
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// if we aren't targeting anything, then clear the targets vector
|
|
|
|
if (!targetSelf && !targetEnemy && !targetFriend && !targetTeam && ignoreFactionList.empty() && includeFactionList.empty()) {
|
|
|
|
targets.clear();
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// if the caster is not there, return empty targets list
|
|
|
|
auto* caster = Game::entityManager->GetEntity(this->caster);
|
|
|
|
if (!caster) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG_DEBUG("Invalid caster for (%llu)!", this->originator);
|
2023-10-09 20:18:51 +00:00
|
|
|
targets.clear();
|
|
|
|
return;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
auto index = targets.begin();
|
|
|
|
while (index != targets.end()) {
|
|
|
|
auto candidate = *index;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// make sure we don't have a nullptr
|
|
|
|
if (!candidate) {
|
|
|
|
index = targets.erase(index);
|
|
|
|
continue;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// handle targeting the caster
|
|
|
|
if (candidate == caster){
|
|
|
|
// if we aren't targeting self, erase, otherise increment and continue
|
|
|
|
if (!targetSelf) index = targets.erase(index);
|
|
|
|
else index++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure that the entity is targetable
|
|
|
|
if (!CheckTargetingRequirements(candidate)) {
|
|
|
|
index = targets.erase(index);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get factions to check against
|
|
|
|
// CheckTargetingRequirements checks for a destroyable component
|
|
|
|
// but we check again because bounds check are necessary
|
|
|
|
auto candidateDestroyableComponent = candidate->GetComponent<DestroyableComponent>();
|
|
|
|
if (!candidateDestroyableComponent) {
|
|
|
|
index = targets.erase(index);
|
|
|
|
continue;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// if they are dead, then earse and continue
|
|
|
|
if (candidateDestroyableComponent->GetIsDead()){
|
|
|
|
index = targets.erase(index);
|
|
|
|
continue;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// if their faction is explicitly included, increment and continue
|
|
|
|
auto candidateFactions = candidateDestroyableComponent->GetFactionIDs();
|
|
|
|
if (CheckFactionList(includeFactionList, candidateFactions)){
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// check if they are a team member
|
|
|
|
if (targetTeam){
|
|
|
|
auto* team = TeamManager::Instance()->GetTeam(this->caster);
|
|
|
|
if (team){
|
|
|
|
// if we find a team member keep it and continue to skip enemy checks
|
|
|
|
if(std::find(team->members.begin(), team->members.end(), candidate->GetObjectID()) != team->members.end()){
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
2023-10-09 20:18:51 +00:00
|
|
|
|
|
|
|
// if the caster doesn't have a destroyable component, return an empty targets list
|
|
|
|
auto* casterDestroyableComponent = caster->GetComponent<DestroyableComponent>();
|
|
|
|
if (!casterDestroyableComponent) {
|
|
|
|
targets.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we arent targeting a friend, and they are a friend OR
|
|
|
|
// if we are not targeting enemies and they are an enemy OR.
|
|
|
|
// if we are ignoring their faction is explicitly ignored
|
|
|
|
// erase and continue
|
|
|
|
auto isEnemy = casterDestroyableComponent->IsEnemy(candidate);
|
|
|
|
if ((!targetFriend && !isEnemy) ||
|
|
|
|
(!targetEnemy && isEnemy) ||
|
|
|
|
CheckFactionList(ignoreFactionList, candidateFactions)) {
|
|
|
|
index = targets.erase(index);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
index++;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2023-10-09 20:18:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// some basic checks as well as the check that matters for this: if the quickbuild is complete
|
|
|
|
bool BehaviorContext::CheckTargetingRequirements(const Entity* target) const {
|
|
|
|
// if the target is a nullptr, then it's not valid
|
|
|
|
if (!target) return false;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-09 20:18:51 +00:00
|
|
|
// ignore quickbuilds that aren't completed
|
|
|
|
auto* targetQuickbuildComponent = target->GetComponent<RebuildComponent>();
|
|
|
|
if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != eRebuildState::COMPLETED) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns true if any of the object factions are in the faction list
|
|
|
|
bool BehaviorContext::CheckFactionList(std::forward_list<int32_t>& factionList, std::vector<int32_t>& objectsFactions) const {
|
|
|
|
if (factionList.empty() || objectsFactions.empty()) return false;
|
|
|
|
for (auto faction : factionList){
|
|
|
|
if(std::find(objectsFactions.begin(), objectsFactions.end(), faction) != objectsFactions.end()) return true;
|
|
|
|
}
|
|
|
|
return false;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BehaviorContext::BehaviorContext(const LWOOBJID originator, const bool calculation) {
|
2021-12-05 17:54:36 +00:00
|
|
|
this->originator = originator;
|
|
|
|
this->syncEntries = {};
|
|
|
|
this->timerEntries = {};
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (calculation) {
|
2021-12-05 17:54:36 +00:00
|
|
|
this->skillUId = GetUniqueSkillId();
|
2022-07-28 13:39:57 +00:00
|
|
|
} else {
|
2021-12-05 17:54:36 +00:00
|
|
|
this->skillUId = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BehaviorContext::~BehaviorContext() {
|
2021-12-05 17:54:36 +00:00
|
|
|
Reset();
|
|
|
|
}
|