CommandMessageCallsCommandTest: proper usage of weaver generated command code (static!)

This commit is contained in:
vis2k 2020-02-24 15:40:06 +01:00
parent 6d2b4eb102
commit 1315bd3dde

View File

@ -11,7 +11,10 @@ public class CommandTestNetworkBehaviour : NetworkBehaviour
public bool commandCalled;
// weaver generates this from [Command]
// but for tests we need to add it manually
public void CommandGenerated(NetworkBehaviour comp, NetworkReader reader) { commandCalled = true; }
public static void CommandGenerated(NetworkBehaviour comp, NetworkReader reader)
{
((CommandTestNetworkBehaviour)comp).commandCalled = true;
}
}
[TestFixture]
@ -579,7 +582,7 @@ public void CommandMessageCallsCommandTest()
connection.identity = identity;
// register the command delegate, otherwise it's not found
NetworkBehaviour.RegisterCommandDelegate(typeof(CommandTestNetworkBehaviour), nameof(CommandTestNetworkBehaviour.CommandGenerated), comp.CommandGenerated);
NetworkBehaviour.RegisterCommandDelegate(typeof(CommandTestNetworkBehaviour), nameof(CommandTestNetworkBehaviour.CommandGenerated), CommandTestNetworkBehaviour.CommandGenerated);
// identity needs to be in spawned dict, otherwise command handler
// won't find it