DoubleDeez / MDFramework

A multiplayer C# game framework for Godot 3.4 Mono.
https://discord.gg/UH49eHK
MIT License
77 stars 13 forks source link

Faster lookup for MDRset and MDRpc #43

Closed Beider closed 4 years ago

Beider commented 4 years ago

The new implementation of MDRset/MDRpc that uses the game clock has to resolve the method/member every time a call is made. This is slow and it would be good to avoid this or make it faster.

There are two potential solutions,

  1. Look into using something that speeds this up such as FastMember

  2. All methods and members should be attributed with one of godot's keywords [Master], [Puppet] etc.. We could scan for all of these when the networked node is added to the replicator and then add them to a hashmap. Key could be same as the key used for the existing lookup map which is <node path>#<member name>. We would then only have to look up members if they for some reason do not exist in this map and we can then buffer them for future calls.

Personally I am leaning towards option 2, even though combining it with option 1 might also be worth it since we do need to do this every time a networked node is added.

DoubleDeez commented 4 years ago

Can we just build that map lazily? Anytime an RPC is made and the MemberInfo isn't in the map use reflection to find it?

Beider commented 4 years ago

Yeah we could just do it lazily as well. I suppose I will do this for now, at least that will make any subsequent calls faster.