TrueSync
UnityUtils.cs
1 using System.Collections.Generic;
2 using System;
3 using System.Reflection;
4 
5 namespace TrueSync {
6 
10  public class UnityUtils {
11 
15  public class PlayerComparer : Comparer<PhotonPlayer> {
16 
17  public override int Compare(PhotonPlayer x, PhotonPlayer y) {
18  return x.ID - y.ID;
19  }
20 
21  }
22 
27 
31  public class TSBodyComparer : Comparer<TSCollider> {
32 
33  public override int Compare(TSCollider x, TSCollider y) {
34  return x.gameObject.name.CompareTo(y.gameObject.name);
35  }
36 
37  }
38 
42  public class TSBody2DComparer : Comparer<TSCollider2D> {
43 
44  public override int Compare(TSCollider2D x, TSCollider2D y) {
45  return x.gameObject.name.CompareTo(y.gameObject.name);
46  }
47 
48  }
49 
54 
59 
63  public static Dictionary<string, MethodInfo> methodInfoByName = new Dictionary<string, MethodInfo>();
64 
65  static UnityUtils() {
66  Type type = typeof(TrueSyncManagedBehaviour);
67  methodInfoByName["TrueSyncManagedBehaviour.OnSyncedStart"] = type.GetMethod("OnSyncedStart");
68  methodInfoByName["TrueSyncManagedBehaviour.OnGamePaused"] = type.GetMethod("OnGamePaused");
69  methodInfoByName["TrueSyncManagedBehaviour.OnGameUnPaused"] = type.GetMethod("OnGameUnPaused");
70  methodInfoByName["TrueSyncManagedBehaviour.OnGameEnded"] = type.GetMethod("OnGameEnded");
71  methodInfoByName["TrueSyncManagedBehaviour.OnPlayerDisconnection"] = type.GetMethod("OnPlayerDisconnection");
72  }
73 
74  }
75 }
Provides a few utilities to be used on TrueSync exposed classes.
Definition: UnityUtils.cs:10
static Dictionary< string, MethodInfo > methodInfoByName
A few MethodInfo dictionary to allow reusable method calls.
Definition: UnityUtils.cs:63
static PlayerComparer playerComparer
Instance of a PlayerComparer.
Definition: UnityUtils.cs:26
Comparer class to guarantee PhotonPlayer order.
Definition: UnityUtils.cs:15
Abstract collider for 3D shapes.
Definition: TSCollider.cs:12
static TSBody2DComparer body2DComparer
Instance of a TSBody2DComparer.
Definition: UnityUtils.cs:58
Comparer class to guarantee TSCollider order.
Definition: UnityUtils.cs:31
Comparer class to guarantee TSCollider2D order.
Definition: UnityUtils.cs:42
static TSBodyComparer bodyComparer
Instance of a TSBodyComparer.
Definition: UnityUtils.cs:53
Abstract collider for 2D shapes.
Definition: TSCollider2D.cs:11