Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Snapshot.cs
- public class Snapshot {
- readonly ushort id;
- Dictionary<byte, PlayerState> playerStates;
- public Snapshot(InPacket packet) {
- // ...code...
- ReadSnapshot(packet);
- }
- public void ReadSnapshot(InPacket packet) {
- // ...code...
- GameManager.Instance.UpdateEntity(entityId, entity);
- }
- }
- // NetClient.cs
- public class NetClient : GameSocket {
- // ... various members, constructors, methods ...
- private bool OnReceive(InPacket packet) {
- // ...code...
- sequences.Put(packet.Sequence);
- //...code...
- }
- }
- // GameSocket.cs
- public class GameSocket {
- // ... code ...
- }
- // GameManager.cs
- public class GameManager : MonoBehaviour
- {
- private static GameManager instance;
- public static GameManager Instance { get => instance; }
- private GameObject netPlayerCharacter;
- // ...code...
- private void Awake() {
- if (instance != null && instance != this) {
- Debug.LogWarning("GameObject instance destroyed.");
- Destroy(this.gameObject);
- } else {
- instance = this;
- }
- netPlayerCharacter = GameObject.Find("NetworkPlayerCharacter");
- Debug.Log(netPlayerCharacter.name);
- client = new NetClient(SERVER_IP, SERVER_PORT);
- client.Connect();
- }
- public void UpdateEntity(byte entityId, PlayerState entity) {
- Debug.Log("this line gets printed, the next one doesn't");
- Debug.Log(netPlayerCharacter.name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement