Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. // Snapshot.cs
  2.  
  3. public class Snapshot {
  4.     readonly ushort id;
  5.     Dictionary<byte, PlayerState> playerStates;
  6.  
  7.     public Snapshot(InPacket packet) {
  8.         // ...code...
  9.         ReadSnapshot(packet);
  10.     }
  11.  
  12.     public void ReadSnapshot(InPacket packet) {
  13.         // ...code...
  14.         GameManager.Instance.UpdateEntity(entityId, entity);
  15.     }
  16. }
  17.  
  18. // NetClient.cs
  19.  
  20. public class NetClient : GameSocket {
  21.     // ... various members, constructors, methods ...
  22.  
  23.     private bool OnReceive(InPacket packet) {
  24.         // ...code...
  25.         sequences.Put(packet.Sequence);
  26.         //...code...
  27.     }
  28. }
  29.  
  30. // GameSocket.cs
  31.  
  32. public class GameSocket {
  33.     // ... code ...
  34. }
  35.  
  36. // GameManager.cs
  37.  
  38. public class GameManager : MonoBehaviour
  39. {
  40.     private static GameManager instance;
  41.     public static GameManager Instance { get => instance; }
  42.  
  43.     private GameObject netPlayerCharacter;
  44.  
  45.     // ...code...
  46.    
  47.     private void Awake() {
  48.         if (instance != null && instance != this) {
  49.             Debug.LogWarning("GameObject instance destroyed.");
  50.             Destroy(this.gameObject);
  51.         } else {
  52.             instance = this;
  53.         }
  54.  
  55.         netPlayerCharacter = GameObject.Find("NetworkPlayerCharacter");
  56.         Debug.Log(netPlayerCharacter.name);
  57.  
  58.         client = new NetClient(SERVER_IP, SERVER_PORT);
  59.         client.Connect();
  60.     }
  61.  
  62.     public void UpdateEntity(byte entityId, PlayerState entity) {
  63.         Debug.Log("this line gets printed, the next one doesn't");
  64.         Debug.Log(netPlayerCharacter.name);
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement