-
Notifications
You must be signed in to change notification settings - Fork 450
feat: snapshot spawn pre-requisite 2 #1192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…date. Helps pinpointing the issue with snapshot enabled
…e-buttons' into feature/enable-snapshot-spawn
…moval' into feature/enable-snapshot-spawn
…zing them with spawn command
…moval' into feature/enable-snapshot-spawn
… spawn from value updates for NetworkList
@@ -73,10 +73,20 @@ public override bool IsDirty() | |||
public override void WriteDelta(Stream stream) | |||
{ | |||
using var writer = PooledNetworkWriter.Get(stream); | |||
|
|||
if (base.IsDirty()) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problably stupid question because I'm misunderstanding this. But this causes the full list to be serialized to all connected clients whenever IsDirty
is set to true? Wouldn't that happen too often? E.g. when:
- An item is added / removed from the list
- The object becomes visible on any client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the first point, my understanding is that NetworkList.Add()
will do:
m_List.Add(item); // add to the underlying container
var listEvent = new NetworkListEvent<T>() {
Type = NetworkListEvent<T>.EventType.Add,
... }; // create an event
HandleAddListEvent(listEvent); // handle the event
}
This then does:
private void HandleAddListEvent(NetworkListEvent<T> listEvent)
{
m_DirtyEvents.Add(listEvent);
OnListChanged?.Invoke(listEvent);
}
and as such does not mark the list dirty. So, dirty
means: needs complete refresh, and m_DirtyEvents
means need incremental changes.
On the second point, yeah. There's a price to pay here. But until AoI is integrated and we start automatically hiding/showing object, I think these will be very infrequent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay yeah that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow, but would add:
- please add a comment to the effect of "IsDirty means totally dirty, else m_DirtyEvents means incremental
- but I have a hunch this will bite us and should be re-visited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were going to remove NetworkShow/Hide in this release?
We can only(reasonably) do that once we have AoI. The theory is that even though the whole show/hide mechanism has technical debt, the API itself is reasonable. So, when proper AoI-based show/hide drops in, the NetworkShow/NetworkHide API becomes an helper mechanism with AoI. e.g.: User can put rules, like "hide zombies that are far and not green, but not from my team" via AoI, but also "Hide this Zombie for this player, I know what I'm doing" via NetworkHide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a bit confused because I thought we rip out the visibility system @mattwalsh-unity but the PR itself here looks good.
…am/feature/client-network-transform * sam/feature/interpolation-for-network-transform: feat: snapshot spawn pre-requisite 2 (#1192) removing useless meta files
* feat: snapshot. Enabling spawns via snapshot by default * feat: snapshot. Fixing the snapshot spawns mechanism to not rely on Singleton * feat: snapshot. Removing the default on for snapshot spawns * test: adjusted HiddenVariableTests to separate spawning from value update. Helps pinpointing the issue with snapshot enabled * fix This fixes the issue with the UnityTransport updates breaking the ability to still use UNetTransport. * refactor Just minor refactoring of when we actually need the ENABLE_RELAY_SERVICE define. Also some cleanup. * refactor removing the InputField pefab. unpacked this inside of the ConnectionModeButtons prefab. updated SampleScene to reflect this change * style updating comments * chore: removal of EnableNetworkVariable in NetworkConfig. It's always True now * feat: snpashot enabled. Marking variables as dirty instead of serializing them with spawn command * fix: this bool write cannot be remoed yet * feat: snapshot spawn. Improving test, and re-enabling * feat: snapshot. Pre-requisite to enabling snapshot spawns. Separating spawn from value updates for NetworkList * style: standards.py fix, removing useless using directive Co-authored-by: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
This separates the spawning of NetworkList from the value updates. It adds a "full" event to the NetworkList which consists of sending the whole list. It gets performed when the variable is marked dirty.
We also add a mechanism to mark all the NetworkVariables of an object dirty and remove the serialization of the NetVars with the spawn command.
The HiddenVariable test is also modified to not rely on the count of events, but rather on the actual values after each step of the test. This is better because it tests the right thing, but also because it allows for timing differences. The spawn could occur before the value update or simultaneously. As such, relying on the count of events would be incorrect.