Vixen
dd8b0a81
csharp
public sealed class NetworkRulesImporter

Imports a .vxnetrules — the one asset kind networking adds.

Read the guide page for this →

As a importer

Extensions
.vxnetrules

Remarks

[16 § Rules](../../../docs/plan/16-networking.md): "NetworkRules is a policy asset referenced per prefab or set globally". The registry that answers the questions was built first and said in its own remarks that this half was not; this is that half.

Written as its serialized record rather than carried forward as text, on WaterWavesImporter's rule. There is a runtime reader — a dedicated server loads the policy into NetworkRulesRegistry and every ownership decision goes through it — and a game does not carry the YAML dialect, which is the editor's format. A text chunk would be a policy that quietly never arrives, and the symptom of that is a game rule that does not work rather than an error anybody sees.

⚠ No MathScalars.Register, deliberately, and it is worth writing down because its absence is the shape of a bug this repository has had twice. An asset type that forgets that call reads a Vector3 back as zero — and only when it runs before anything scene-shaped, so it passes in a suite and fails alone. It is not needed here: NetworkRules is six enums, and a policy has no geometry in it at all. Calling it anyway would be cargo, and cargo is what makes the next reader unsure whether the one that matters is load-bearing. ANonDefaultPolicySurvivesTheDocument round-trips every field to prove it.

⚠ A key this build does not know is a warning, and until it was one it was nothing at all. YamlSerializer ignores an unknown key unless the caller asks — deliberately, because "the caller decides whether an unknown key is news" — and no importer in the tree asked. So onOwnerDisconect: Destroy imported cleanly, produced a chunk, resolved onto a spawned node, and left the object on TransferToServer: a policy file that reads exactly right and a rule that is not the one it says. That is the same silence Validate exists to break, one field over.

Warned rather than refused, on the same line write: Everyone is drawn on. A file written by a newer engine carries keys this one does not have, and refusing it would make an unknown field a downgrade failure rather than a typo — but a typo is by far the likelier of the two, so it has to be said out loud.

⚠ What cannot be checked here is whether anything names it. A prefab naming a policy no asset carries falls back to the registry's default and counts into NetworkSpawner.UnresolvedRules — a running session with the wrong rules. The importer sees one file and cannot know which prefabs point at it; the count is where that shows.

Fields and properties (2)

  • public const string RulesType

    The alias of the type this writes.

  • public override int Version

    Its own version. Bumping it invalidates every artefact it has ever produced, which is the whole mechanism for "I fixed the mip filter, re-import everything".

Methods (1)

Used by (2)

  • BuiltInImportersVixen.Editor.Assets
  • NetworkRulesImporterTestsVixen.Editor.Assets.Tests