-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Problem statement
Today, server side mods (Oxide plugins, Harmony mods, etc.) can send custom UIs to clients by passing a JSON string through an RPC call. This results in multiple problems.
- Requires 3rd party libraries or DIY to build and serialize UIs, since the server side assemblies don't have any bundled utilities for this, notably putting Harmony mods at a disadvantage, and resulting in duplicated community effort as multiple frameworks and server networks reimplement basically the same library
- Common patterns for building UIs (e.g., create, then serialize with Newtonsoft) strains the CPU and allocates a significant amount of garbage, resulting in various developers attempting to build solutions to this problem which pool objects, cache string representations of numbers, and build JSON using character arrays (most notably dassjosh/Rust.UIFramework), which should not be necessary and is not accessible to developers who want to distribute mods without dependencies (or thousands of lines of bundled code)
Proposed solution
- [Client & Server] Implement protobuf classes for CUI elements and CUI components (can be mostly auto generated), and include those classes in server side assemblies for mod developers
- [Client] Implement new RPC call (e.g.,
AddUIProto
) so the server can send a UI as a protobuf payload - [Client] Refactor this code base to build UIs from protobuf classes rather than from JSON objects
- [Client] For backwards compatibility, implement deserialization from JSON to the protobuf classes
Benefits:
- Smaller payloads
- Reduced CPU usage when building UI payloads
- No garbage allocations when building UI payloads
- No 3rd party library needed for vast majority of existing use cases, improving accessibility to all modding frameworks
- Allows 3rd party library developers to focus on higher level concerns such as building abstract widgets
Zer0x89A, rostov114, david7-dev, Kulltero, TurEduard and 4 more
Metadata
Metadata
Assignees
Labels
No labels