MCPcopy Create free account
hub / github.com/Norbyte/bg3se / OnECSUpdateGuarded

Method OnECSUpdateGuarded

BG3Extender/Extender/ScriptExtender.cpp:289–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289void ScriptExtender::OnECSUpdateGuarded(ecs::EntityWorld::UpdateProc* wrapped, ecs::EntityWorld* entityWorld, GameTime const& time)
290{
291 auto ecs = GetECS(entityWorld);
292 if (ecs != nullptr) {
293 ecs->Update();
294
295 {
296 DisableCrashReporting _;
297 wrapped(entityWorld, time);
298 }
299
300 ecs->PostUpdate();
301
302 auto ctx = GetCurrentContextType();
303 se_assert(ctx != ContextType::None);
304
305 if (ctx == ContextType::Server) {
306 if (GetServer().HasExtensionState()) {
307 esv::LuaServerPin lua(GetServer().GetExtensionState());
308 if (lua) {
309 lua->GetComponentEventHooks().FireDeferredEvents();
310 lua->GetSystemEventHooks().FireDeferredEvents();
311 lua->GetServerReplicationEventHooks().OnEntityReplication(*entityWorld, entityWorld->Replication);
312 }
313 }
314 } else {
315 if (GetClient().HasExtensionState()) {
316 ecl::LuaClientPin lua(GetClient().GetExtensionState());
317 if (lua) {
318 lua->GetComponentEventHooks().FireDeferredEvents();
319 lua->GetSystemEventHooks().FireDeferredEvents();
320 }
321 }
322 }
323 } else {
324 wrapped(entityWorld, time);
325 }
326}
327
328void ScriptExtender::OnECSFlushECBs(ecs::EntityWorld* entityWorld)
329{

Callers

nothing calls this directly

Calls 4

GetExtensionStateMethod · 0.80
UpdateMethod · 0.45
PostUpdateMethod · 0.45
HasExtensionStateMethod · 0.45

Tested by

no test coverage detected