Skip to content

Commit 1c7b164

Browse files
refactor: snapshot prep for RPCs and value update (#1520)
* experimental: Snapshot revisiting basis * Adding back minimal ticking and update code * Adding back minimal ticking and update code * random experimentation * progressing on new structure * Debugging information * test: add sanity test for ticksystem * fix time system init * adding code to read/write the spawns * spawn snapshot, redone, still in-progress * despawns * fixing despawn lookup of tick applied * tests fixed. Now need to integrate with transport correctly * adding the SnapshotSystem's update of client/server data * Going back to passing SnapshotDataMessage around, but using lightweight pre-serialized messages * working for test and some initial SampleScene * growing buffers on the send side, as needed * stable, up-to buffer overflow * using header, starting to put back the ClientData * snapshot spawn/despawn refactored * reverting unneeded change to NetworkManager * style: code review comments * style: minor review comments Co-authored-by: Luke Stampfli <luke@stampfli.one>
1 parent e0ed62e commit 1c7b164

File tree

4 files changed

+376
-1104
lines changed

4 files changed

+376
-1104
lines changed

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ private SnapshotDespawnCommand GetDespawnCommand()
404404
var command = new SnapshotDespawnCommand();
405405
command.NetworkObjectId = NetworkObjectId;
406406

407-
command.NetworkObject = this;
408-
409407
return command;
410408
}
411409

@@ -434,37 +432,36 @@ private SnapshotSpawnCommand GetSpawnCommand()
434432
command.ObjectRotation = transform.rotation;
435433
command.ObjectScale = transform.localScale;
436434

437-
command.NetworkObject = this;
438-
439435
return command;
440436
}
441437

442438
private void SnapshotSpawn()
443439
{
444440
var command = GetSpawnCommand();
445-
NetworkManager.SnapshotSystem.Spawn(command);
441+
NetworkManager.SnapshotSystem.Spawn(command, this, null);
446442
}
447443

448444
private void SnapshotSpawn(ulong clientId)
449445
{
450446
var command = GetSpawnCommand();
451-
command.TargetClientIds = new List<ulong>();
452-
command.TargetClientIds.Add(clientId);
453-
NetworkManager.SnapshotSystem.Spawn(command);
447+
var targetClientIds = new List<ulong>();
448+
targetClientIds.Add(clientId);
449+
450+
NetworkManager.SnapshotSystem.Spawn(command, this, targetClientIds);
454451
}
455452

456453
internal void SnapshotDespawn()
457454
{
458455
var command = GetDespawnCommand();
459-
NetworkManager.SnapshotSystem.Despawn(command);
456+
NetworkManager.SnapshotSystem.Despawn(command, this, null);
460457
}
461458

462459
internal void SnapshotDespawn(ulong clientId)
463460
{
464461
var command = GetDespawnCommand();
465-
command.TargetClientIds = new List<ulong>();
466-
command.TargetClientIds.Add(clientId);
467-
NetworkManager.SnapshotSystem.Despawn(command);
462+
var targetClientIds = new List<ulong>();
463+
targetClientIds.Add(clientId);
464+
NetworkManager.SnapshotSystem.Despawn(command, this, targetClientIds);
468465
}
469466

470467
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)