1
This commit is contained in:
parent
9b83b364ac
commit
7a2e5ffbf2
@ -3,6 +3,8 @@
|
||||
#include "batchsync.h"
|
||||
|
||||
#include "creature.h"
|
||||
#include "team.h"
|
||||
#include "human.h"
|
||||
|
||||
BatchSync::BatchSync(Room* room)
|
||||
{
|
||||
@ -19,6 +21,23 @@ void BatchSync::AddGlobalObject(Creature* c)
|
||||
if (global_object_hash_.find(c->GetUniId()) != global_object_hash_.end()) {
|
||||
abort();
|
||||
}
|
||||
auto timer_wp = f8::Timer::Instance()->SetIntervalWpEx
|
||||
(
|
||||
1000,
|
||||
[] (int event, const a8::Args* args)
|
||||
{
|
||||
|
||||
},
|
||||
&timer_attacher_);
|
||||
SyncObject sync_obj;
|
||||
sync_obj.obj_uniid = c->GetUniId();
|
||||
sync_obj.c = c->GetWeakPtrRef();
|
||||
sync_obj.pos = c->GetPos().ToGlmVec3();
|
||||
sync_obj.dir = c->GetAttackDir();
|
||||
sync_obj.last_sync_frameno = 0;
|
||||
|
||||
global_object_hash_[c->GetUniId()] =
|
||||
std::make_tuple(timer_wp, sync_obj);
|
||||
}
|
||||
|
||||
void BatchSync::RemoveGlobalObject(int obj_uniid)
|
||||
@ -35,6 +54,30 @@ void BatchSync::AddTeam(Team* team)
|
||||
if (team_hash_.find(team) != team_hash_.end()) {
|
||||
abort();
|
||||
}
|
||||
auto timer_wp = f8::Timer::Instance()->SetIntervalWpEx
|
||||
(
|
||||
1000,
|
||||
[] (int event, const a8::Args* args)
|
||||
{
|
||||
|
||||
},
|
||||
&timer_attacher_);
|
||||
std::vector<SyncObject> sync_objects;
|
||||
team->TraverseMembers
|
||||
(
|
||||
[&sync_objects] (Human* hum)
|
||||
{
|
||||
SyncObject sync_obj;
|
||||
sync_obj.obj_uniid = hum->GetUniId();
|
||||
sync_obj.c = hum->GetWeakPtrRef();
|
||||
sync_obj.pos = hum->GetPos().ToGlmVec3();
|
||||
sync_obj.dir = hum->GetAttackDir();
|
||||
sync_obj.last_sync_frameno = 0;
|
||||
sync_objects.push_back(sync_obj);
|
||||
return true;
|
||||
});
|
||||
team_hash_[team] =
|
||||
std::make_tuple(timer_wp, sync_objects);
|
||||
}
|
||||
|
||||
void BatchSync::UpdateTeam(Team* team)
|
||||
|
Loading…
x
Reference in New Issue
Block a user