mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
Resolve many issues with invisible enemies and End Behavior nodes not firing (#1044)
* Finall fix invisible enemies * Add garbage collection * Add comment * Add constexpr for lagFrames
This commit is contained in:
@@ -47,7 +47,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const {
|
||||
}
|
||||
|
||||
|
||||
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, bool ignoreInterrupts) {
|
||||
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, const float duration, bool ignoreInterrupts) {
|
||||
auto entry = BehaviorSyncEntry();
|
||||
|
||||
entry.handle = syncId;
|
||||
@@ -55,6 +55,9 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha
|
||||
entry.branchContext = branchContext;
|
||||
entry.branchContext.isSync = true;
|
||||
entry.ignoreInterrupts = ignoreInterrupts;
|
||||
// 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;
|
||||
|
||||
this->syncEntries.push_back(entry);
|
||||
}
|
||||
@@ -183,6 +186,21 @@ void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, B
|
||||
this->syncEntries.push_back(entry);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void BehaviorContext::InvokeEnd(const uint32_t id) {
|
||||
std::vector<BehaviorEndEntry> entries;
|
||||
|
||||
|
Reference in New Issue
Block a user