@@ -529,7 +529,19 @@ internal void SendClientRPCBoxed(ulong hash, List<uint> clientIds, params object
529
529
SendClientRPCPerformance ( hash , clientIds , writer ) ;
530
530
}
531
531
}
532
-
532
+
533
+ internal void SendClientRPCBoxed ( ulong hash , uint clientId , params object [ ] parameters )
534
+ {
535
+ using ( BitWriter writer = BitWriter . Get ( ) )
536
+ {
537
+ for ( int i = 0 ; i < parameters . Length ; i ++ )
538
+ {
539
+ writer . WriteObject ( parameters [ i ] ) ;
540
+ }
541
+ SendClientRPCPerformance ( hash , clientId , writer ) ;
542
+ }
543
+ }
544
+
533
545
internal void SendServerRPCPerformance ( ulong hash , BitWriter writer )
534
546
{
535
547
if ( ! isClient )
@@ -551,7 +563,7 @@ internal void SendServerRPCPerformance(ulong hash, BitWriter writer)
551
563
}
552
564
553
565
internal void SendClientRPCPerformance ( ulong hash , List < uint > clientIds , BitWriter writer )
554
- {
566
+ {
555
567
if ( ! isServer )
556
568
{
557
569
//We are NOT a server.
@@ -567,27 +579,45 @@ internal void SendClientRPCPerformance(ulong hash, List<uint> clientIds, BitWri
567
579
568
580
writer . WriteWriter ( writer ) ;
569
581
570
- for ( int i = 0 ; i < clientIds . Count ; i ++ )
582
+ if ( clientIds == null )
571
583
{
572
- if ( isHost && clientIds [ i ] == NetworkingManager . singleton . LocalClientId )
584
+ for ( int i = 0 ; i < NetworkingManager . singleton . ConnectedClientsList . Count ; i ++ )
573
585
{
574
- using ( BitReader reader = BitReader . Get ( writer . Finalize ( ) ) )
586
+ if ( isHost && NetworkingManager . singleton . ConnectedClientsList [ i ] . ClientId == NetworkingManager . singleton . LocalClientId )
587
+ {
588
+ using ( BitReader reader = BitReader . Get ( writer . Finalize ( ) ) )
589
+ {
590
+ InvokeClientRPCLocal ( hash , NetworkingManager . singleton . LocalClientId , reader ) ;
591
+ }
592
+ }
593
+ else
575
594
{
576
- InvokeClientRPCLocal ( hash , NetworkingManager . singleton . LocalClientId , reader ) ;
595
+ InternalMessageHandler . Send ( NetworkingManager . singleton . ConnectedClientsList [ i ] . ClientId , "MLAPI_CLIENT_RPC" , "MLAPI_USER_CHANNEL" , rpcWriter ) ;
577
596
}
578
597
}
579
- else
598
+ }
599
+ else
600
+ {
601
+ for ( int i = 0 ; i < clientIds . Count ; i ++ )
580
602
{
581
- InternalMessageHandler . Send ( clientIds [ i ] , "MLAPI_CLIENT_RPC" , "MLAPI_USER_CHANNEL" , rpcWriter ) ;
603
+ if ( isHost && clientIds [ i ] == NetworkingManager . singleton . LocalClientId )
604
+ {
605
+ using ( BitReader reader = BitReader . Get ( writer . Finalize ( ) ) )
606
+ {
607
+ InvokeClientRPCLocal ( hash , NetworkingManager . singleton . LocalClientId , reader ) ;
608
+ }
609
+ }
610
+ else
611
+ {
612
+ InternalMessageHandler . Send ( clientIds [ i ] , "MLAPI_CLIENT_RPC" , "MLAPI_USER_CHANNEL" , rpcWriter ) ;
613
+ }
582
614
}
583
615
}
584
616
}
585
617
}
586
618
587
619
internal void SendClientRPCPerformance ( ulong hash , uint clientId , BitWriter writer )
588
620
{
589
- Type type = GetType ( ) ; //This is cached by CLR
590
-
591
621
if ( ! isServer )
592
622
{
593
623
//We are NOT a server.
@@ -626,6 +656,92 @@ internal void SendClientRPCPerformance(ulong hash, uint clientId, BitWriter writ
626
656
public delegate void Action < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 > ( T1 t1 , T2 t2 , T3 t3 , T4 t4 , T5 t5 , T6 t6 , T7 t7 , T8 t8 , T9 t9 ) ;
627
657
public delegate void Action < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 > ( T1 t1 , T2 t2 , T3 t3 , T4 t4 , T5 t5 , T6 t6 , T7 t7 , T8 t8 , T9 t9 , T10 t10 ) ;
628
658
659
+ //BOXED CLIENT RPC
660
+
661
+ //no params
662
+ public void InvokeClientRpc ( string methodName , List < uint > clientIds )
663
+ {
664
+ SendClientRPCBoxed ( HashMethodName ( methodName ) , clientIds ) ;
665
+ }
666
+
667
+ public void InvokeClientRpc ( Action method , List < uint > clientIds )
668
+ {
669
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , clientIds ) ;
670
+ }
671
+
672
+ public void InvokeClientRpcOnOwner ( Action method )
673
+ {
674
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , OwnerClientId ) ;
675
+ }
676
+
677
+ public void InvokeClientRpcOnEveryone ( Action method )
678
+ {
679
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , null ) ;
680
+ }
681
+
682
+ //1 param
683
+ public void InvokeClientRpc < T1 > ( string methodName , List < uint > clientIds , T1 t1 )
684
+ {
685
+ SendClientRPCBoxed ( HashMethodName ( methodName ) , clientIds , t1 ) ;
686
+ }
687
+
688
+ public void InvokeClientRpc < T1 > ( Action < T1 > method , List < uint > clientIds , T1 t1 )
689
+ {
690
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , clientIds , t1 ) ;
691
+ }
692
+
693
+ public void InvokeClientRpcOnOwner < T1 > ( Action < T1 > method , T1 t1 )
694
+ {
695
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , OwnerClientId , t1 ) ;
696
+ }
697
+
698
+ public void InvokeClientRpcOnEveryone < T1 > ( Action < T1 > method , T1 t1 )
699
+ {
700
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , null , t1 ) ;
701
+ }
702
+
703
+ //2 params
704
+ public void InvokeClientRpc < T1 , T2 > ( string methodName , List < uint > clientIds , T1 t1 , T2 t2 )
705
+ {
706
+ SendClientRPCBoxed ( HashMethodName ( methodName ) , clientIds , t1 , t2 ) ;
707
+ }
708
+
709
+ public void InvokeClientRpc < T1 , T2 > ( Action < T1 , T2 > method , List < uint > clientIds , T1 t1 , T2 t2 )
710
+ {
711
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , clientIds , t1 , t2 ) ;
712
+ }
713
+
714
+ public void InvokeClientRpcOnOwner < T1 , T2 > ( Action < T1 , T2 > method , T1 t1 , T2 t2 )
715
+ {
716
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , OwnerClientId , t1 , t2 ) ;
717
+ }
718
+
719
+ public void InvokeClientRpcOnEveryone < T1 , T2 > ( Action < T1 , T2 > method , T1 t1 , T2 t2 )
720
+ {
721
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , null , t1 , t2 ) ;
722
+ }
723
+
724
+ //3 params
725
+ public void InvokeClientRpc < T1 , T2 , T3 > ( string methodName , List < uint > clientIds , T1 t1 , T2 t2 , T3 t3 )
726
+ {
727
+ SendClientRPCBoxed ( HashMethodName ( methodName ) , clientIds , t1 , t2 , t3 ) ;
728
+ }
729
+
730
+ public void InvokeClientRpc < T1 , T2 , T3 > ( Action < T1 , T2 , T3 > method , List < uint > clientIds , T1 t1 , T2 t2 , T3 t3 )
731
+ {
732
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , clientIds , t1 , t2 , t3 ) ;
733
+ }
734
+
735
+ public void InvokeClientRpcOnOwner < T1 , T2 , T3 > ( Action < T1 , T2 , T3 > method , T1 t1 , T2 t2 , T3 t3 )
736
+ {
737
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , OwnerClientId , t1 , t2 , t3 ) ;
738
+ }
739
+
740
+ public void InvokeClientRpcOnEveryone < T1 , T2 , T3 > ( Action < T1 , T2 , T3 > method , T1 t1 , T2 t2 , T3 t3 )
741
+ {
742
+ SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , null , t1 , t2 , t3 ) ;
743
+ }
744
+
629
745
//BOXED SERVER RPC
630
746
public void InvokeServerRpc ( string methodName , params object [ ] parameters )
631
747
{
@@ -642,22 +758,11 @@ public void InvokeServerRpc<T1>(Action<T1> method, T1 t1)
642
758
SendServerRPCBoxed ( HashMethodName ( method . Method . Name ) , t1 ) ;
643
759
}
644
760
645
- public void InvokeServerRpc < T1 > ( Action < T1 > method , T1 t1 )
761
+ public void InvokeServerRpc < T1 , T2 > ( Action < T1 , T2 > method , T1 t1 , T2 t2 )
646
762
{
647
- SendServerRPCBoxed ( HashMethodName ( method . Method . Name ) , t1 ) ;
763
+ SendServerRPCBoxed ( HashMethodName ( method . Method . Name ) , t1 , t2 ) ;
648
764
}
649
765
650
- //BOXED CLIENT RPC
651
- public void InvokeClientRpc ( Action method , List < uint > clientIds )
652
- {
653
- SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , clientIds ) ;
654
- }
655
-
656
- public void InvokeClientRpc < T1 > ( Action < T1 > method , List < uint > clientIds , T1 t1 )
657
- {
658
- SendClientRPCBoxed ( HashMethodName ( method . Method . Name ) , clientIds , t1 ) ;
659
- }
660
-
661
766
//PERFORMANCE SERVER RPC
662
767
public void InvokeServerRpc ( RpcDelegate method , BitWriter writer )
663
768
{
@@ -670,11 +775,21 @@ public void InvokeServerRpc(string methodName, BitWriter writer)
670
775
}
671
776
672
777
//PERFORMANCE CLIENT RPC
673
- public void InvokeClientRpc ( RpcDelegate method , BitWriter writer )
778
+ public void InvokeClientRpc ( RpcDelegate method , List < uint > clientIds , BitWriter writer )
674
779
{
675
- SendServerRPCPerformance ( HashMethodName ( method . Method . Name ) , writer ) ;
780
+ SendClientRPCPerformance ( HashMethodName ( method . Method . Name ) , clientIds , writer ) ;
676
781
}
677
-
782
+
783
+ public void InvokeClientRpcOnOwner ( RpcDelegate method , BitWriter writer )
784
+ {
785
+ SendClientRPCPerformance ( HashMethodName ( method . Method . Name ) , OwnerClientId , writer ) ;
786
+ }
787
+
788
+ public void InvokeClientRpcOnEveryone ( RpcDelegate method , BitWriter writer )
789
+ {
790
+ SendClientRPCPerformance ( HashMethodName ( method . Method . Name ) , null , writer ) ;
791
+ }
792
+
678
793
public void InvokeClientRpc ( string methodName , List < uint > clientIds , BitWriter writer )
679
794
{
680
795
SendClientRPCPerformance ( HashMethodName ( methodName ) , clientIds , writer ) ;
@@ -684,6 +799,11 @@ public void InvokeClientRpcOnOwner(string methodName, BitWriter writer)
684
799
{
685
800
SendClientRPCPerformance ( HashMethodName ( methodName ) , OwnerClientId , writer ) ;
686
801
}
802
+
803
+ public void InvokeClientRpcOnEveryone ( string methodName , BitWriter writer )
804
+ {
805
+ SendClientRPCPerformance ( HashMethodName ( methodName ) , null , writer ) ;
806
+ }
687
807
#endregion
688
808
689
809
/// <summary>
0 commit comments