@@ -10,6 +10,16 @@ function GameObjectManager:__init(p_Realm)
10
10
m_Logger :Write (" Initializing GameObjectManager: " .. tostring (p_Realm ))
11
11
self .m_Realm = p_Realm
12
12
self :RegisterVars ()
13
+ self :RegisterEvents ()
14
+ end
15
+
16
+ function GameObjectManager :RegisterEvents ()
17
+ Events :Subscribe (" Shared:StoreTimeStamps" , self , self .StoreTimeStamps )
18
+ end
19
+
20
+ --- @param p_GUID_To_Timestamps table
21
+ function GameObjectManager :StoreTimeStamps (p_GUID_To_Timestamps )
22
+ self .m_GUID_To_Timestamps = p_GUID_To_Timestamps
13
23
end
14
24
15
25
function GameObjectManager :RegisterVars ()
@@ -24,6 +34,9 @@ function GameObjectManager:RegisterVars()
24
34
25
35
--- key: child (ReferenceObjectData) guid, value: parent GameObject guid
26
36
self .m_ReferenceObjectDatas = {}
37
+
38
+ -- workaround for origin type 3
39
+ self .m_GUID_To_Timestamps = {}
27
40
end
28
41
29
42
function GameObjectManager :OnLevelDestroy ()
44
57
--- @param p_Variation integer
45
58
--- @param p_IsPreviewSpawn boolean
46
59
--- @param p_Overrides table
47
- function GameObjectManager :InvokeBlueprintSpawn (p_GameObjectGuid , p_SenderName , p_BlueprintPartitionGuid , p_BlueprintInstanceGuid , p_ParentData , p_LinearTransform , p_Variation , p_IsPreviewSpawn , p_Overrides )
60
+ --- @param p_TimeStamp number
61
+ function GameObjectManager :InvokeBlueprintSpawn (p_GameObjectGuid , p_SenderName , p_BlueprintPartitionGuid , p_BlueprintInstanceGuid , p_ParentData , p_LinearTransform , p_Variation , p_IsPreviewSpawn , p_Overrides , p_TimeStamp )
48
62
if p_BlueprintPartitionGuid == nil or
49
63
p_BlueprintInstanceGuid == nil or
50
64
p_LinearTransform == nil then
@@ -66,15 +80,15 @@ function GameObjectManager:InvokeBlueprintSpawn(p_GameObjectGuid, p_SenderName,
66
80
67
81
-- m_Logger:Write('Invoking spawning of blueprint: '.. s_ObjectBlueprint.name .. " | ".. s_Blueprint.typeInfo.name .. ", ID: " .. p_GameObjectGuid .. ", Instance: " .. tostring(p_BlueprintInstanceGuid) .. ", Variation: " .. p_Variation)
68
82
if p_IsPreviewSpawn == false then
69
- self .m_PendingCustomBlueprintGuids [p_BlueprintInstanceGuid ] = { customGuid = p_GameObjectGuid , creatorName = p_SenderName , parentData = p_ParentData , overrides = p_Overrides }
83
+ self .m_PendingCustomBlueprintGuids [p_BlueprintInstanceGuid ] = { customGuid = p_GameObjectGuid , creatorName = p_SenderName , parentData = p_ParentData , overrides = p_Overrides , timeStamp = p_TimeStamp }
70
84
else
71
85
local s_PreviewSpawnParentData = GameObjectParentData {
72
86
guid = EMPTY_GUID , -- Root
73
87
typeName = " previewSpawn" ,
74
88
}
75
89
m_Logger :Write (" Added s_PreviewSpawnParentData: " .. tostring (s_PreviewSpawnParentData .guid ))
76
90
m_Logger :WriteTable (s_PreviewSpawnParentData )
77
- self .m_PendingCustomBlueprintGuids [p_BlueprintInstanceGuid ] = { customGuid = p_GameObjectGuid , creatorName = p_SenderName , parentData = s_PreviewSpawnParentData , overrides = p_Overrides }
91
+ self .m_PendingCustomBlueprintGuids [p_BlueprintInstanceGuid ] = { customGuid = p_GameObjectGuid , creatorName = p_SenderName , parentData = s_PreviewSpawnParentData , overrides = p_Overrides , timeStamp = p_TimeStamp }
78
92
end
79
93
80
94
local s_Params = EntityCreationParams ()
@@ -153,6 +167,14 @@ function GameObjectManager:OnEntityCreateFromBlueprint(p_HookCtx, p_Blueprint, p
153
167
end
154
168
end
155
169
170
+ local s_TimeStamp
171
+ if s_PendingCustomBlueprintInfo then
172
+ s_TimeStamp = s_PendingCustomBlueprintInfo .timeStamp
173
+ end
174
+ if not s_TimeStamp then
175
+ s_TimeStamp = SharedUtils :GetTimeMS ()
176
+ end
177
+
156
178
--- @type GameObject
157
179
local s_GameObject = GameObject {
158
180
guid = GenerateTempGuid (), -- we set a tempGuid, it will later be set to a vanilla or custom guid
@@ -161,6 +183,7 @@ function GameObjectManager:OnEntityCreateFromBlueprint(p_HookCtx, p_Blueprint, p
161
183
transform = p_Transform ,
162
184
variation = s_Variation ,
163
185
origin = GameObjectOriginType .Vanilla ,
186
+ timeStamp = s_TimeStamp ,
164
187
isDeleted = false ,
165
188
isEnabled = true ,
166
189
gameEntities = {},
@@ -318,9 +341,9 @@ function GameObjectManager:OnEntityCreateFromBlueprint(p_HookCtx, p_Blueprint, p
318
341
-- TODO: update blueprint data with the correct realm if its client or server only
319
342
if self .m_Realm == Realm .Realm_Server then
320
343
m_Logger :Write (s_UnresolvedRODCount .. ' client-only gameobjects weren\' t resolved' )
321
- -- for l_Guid, l_Value in pairs(self.m_ReferenceObjectDatas) do
322
- -- m_Logger:Write(tostring(l_Guid) .. ', '..l_Value.typeName)
323
- -- end
344
+ -- for l_Guid, l_Value in pairs(self.m_ReferenceObjectDatas) do
345
+ -- m_Logger:Write(tostring(l_Guid) .. ', '..l_Value.typeName)
346
+ -- end
324
347
elseif self .m_Realm == Realm .Realm_Client then
325
348
m_Logger :Write (s_UnresolvedRODCount .. ' server-only gameobjects weren\' t resolved' )
326
349
-- for l_Guid, l_Value in pairs(self.m_ReferenceObjectDatas) do
360
383
function GameObjectManager :ResolveRootObject (p_GameObject , p_PendingInfo )
361
384
self .m_GameObjects [tostring (p_GameObject .guid )] = nil -- Remove temp guid from array
362
385
363
- if p_PendingInfo then -- We spawned this custom entitybus
386
+ if p_PendingInfo then -- We spawned this custom entitybus
364
387
p_GameObject .parentData = GameObjectParentData {
365
388
guid = p_PendingInfo .parentData .guid ,
366
389
typeName = p_PendingInfo .parentData .typeName ,
@@ -369,26 +392,46 @@ function GameObjectManager:ResolveRootObject(p_GameObject, p_PendingInfo)
369
392
}
370
393
p_GameObject .guid = Guid (p_PendingInfo .customGuid )
371
394
p_GameObject .origin = GameObjectOriginType .Custom
395
+ -- if not p_GameObject.timeStamp or p_GameObject.timeStamp == 0 then
396
+ -- self:InsertTimestamp(p_GameObject)
397
+ -- end
372
398
else
373
-
374
399
if string.find (p_GameObject .blueprintCtrRef .name :lower (), " nohavok" ) then
375
400
local s_BundleName = p_GameObject .blueprintCtrRef .name :gsub (' NoHavok_' , ' ' )
376
401
p_GameObject .origin = GameObjectOriginType .NoHavok
377
402
-- No parent data, add the bundle name as an offset and use a predefined havok guid
378
403
p_GameObject .guid = self :GetNoHavokGuid (HAVOK_GUID , s_BundleName .. ' /' .. p_GameObject .name , p_GameObject .transform .trans )
404
+ -- if not p_GameObject.timeStamp or p_GameObject.timeStamp == 0 then
405
+ -- self:InsertTimestamp(p_GameObject)
406
+ -- end
379
407
else
380
408
-- This is a vanilla root object
381
409
p_GameObject .guid = self :GetVanillaGuid (p_GameObject .name , p_GameObject .transform .trans )
382
410
p_GameObject .origin = GameObjectOriginType .Vanilla
411
+ -- if not p_GameObject.timeStamp or p_GameObject.timeStamp == 0 then
412
+ -- self:InsertTimestamp(p_GameObject)
413
+ -- end
383
414
384
415
-- table.insert(self.m_VanillaGameObjectGuids, p_GameObject.guid)
385
416
self .m_VanillaGameObjectGuids [tostring (p_GameObject .guid )] = p_GameObject .guid
386
417
end
387
418
end
419
+ -- if p_GameObject.timeStamp == 0 then
420
+ -- self:InsertTimestamp(p_GameObject)
421
+ -- end
388
422
389
423
self .m_GameObjects [tostring (p_GameObject .guid )] = p_GameObject
390
424
end
391
425
426
+ --- @param p_GameObject GameObject
427
+ function GameObjectManager :InsertTimestamp (p_GameObject )
428
+ local s_ObjectTimeStamp = self .m_GUID_To_Timestamps [tostring (p_GameObject .guid )]
429
+ if not s_ObjectTimeStamp then
430
+ s_ObjectTimeStamp = SharedUtils :GetTimeMS ()
431
+ end
432
+ p_GameObject .timeStamp = s_ObjectTimeStamp
433
+ end
434
+
392
435
function GameObjectManager :ResolveChildObject (p_GameObject , p_ParentGameObject )
393
436
-- This is a child of either a custom gameObject or a vanilla gameObject, find the parent!
394
437
p_GameObject .parentData = GameObjectParentData {
@@ -408,9 +451,16 @@ function GameObjectManager:ResolveChildObject(p_GameObject, p_ParentGameObject)
408
451
if p_GameObject .origin == GameObjectOriginType .Vanilla then
409
452
p_GameObject .guid = self :GetVanillaGuid (p_GameObject .name , p_GameObject .transform .trans )
410
453
-- table.insert(self.m_VanillaGameObjectGuids, p_GameObject.guid)
454
+ -- if not p_GameObject.timeStamp or p_GameObject.timeStamp == 0 then
455
+ -- self:InsertTimestamp(p_GameObject)
456
+ -- end
411
457
self .m_VanillaGameObjectGuids [tostring (p_GameObject .guid )] = p_GameObject .guid
412
458
elseif p_GameObject .origin == GameObjectOriginType .NoHavok then
413
459
p_GameObject .guid = self :GetNoHavokGuid (p_GameObject .parentData .guid , p_GameObject .name , p_GameObject .transform .trans )
460
+
461
+ -- if not p_GameObject.timeStamp or p_GameObject.timeStamp == 0 then
462
+ -- self:InsertTimestamp(p_GameObject)
463
+ -- end
414
464
else
415
465
local i = 1
416
466
local s_CustomGuid
@@ -422,6 +472,10 @@ function GameObjectManager:ResolveChildObject(p_GameObject, p_ParentGameObject)
422
472
423
473
p_GameObject .guid = s_CustomGuid
424
474
p_GameObject .origin = GameObjectOriginType .CustomChild
475
+
476
+ -- if not p_GameObject.timeStamp or p_GameObject.timeStamp == 0 then
477
+ -- self:InsertTimestamp(p_GameObject)
478
+ -- end
425
479
end
426
480
427
481
self .m_GameObjects [tostring (p_GameObject .guid )] = p_GameObject
0 commit comments