2020-08-07 03:46:09 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2020-08-07 20:20:13 +02:00
|
|
|
|
using NeonTea.Quakeball.Networking.Packets;
|
2020-08-07 03:46:09 +02:00
|
|
|
|
using NeonTea.Quakeball.TeaNet.Peers;
|
|
|
|
|
using NeonTea.Quakeball.TeaNet.Packets;
|
|
|
|
|
|
2020-08-07 20:20:13 +02:00
|
|
|
|
namespace NeonTea.Quakeball.Networking.Instances {
|
2020-08-07 03:46:09 +02:00
|
|
|
|
public abstract class NetInstance {
|
|
|
|
|
|
|
|
|
|
protected static byte[] Fingerprint = new byte[] { 0xFF, 0xF7 };
|
|
|
|
|
|
|
|
|
|
public Peer Peer;
|
|
|
|
|
public List<ulong> Connections = new List<ulong>();
|
|
|
|
|
|
2020-08-08 03:03:08 +02:00
|
|
|
|
public NetInstance() {
|
|
|
|
|
Peer = new Peer(Fingerprint);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-07 03:46:09 +02:00
|
|
|
|
public abstract void Start(string address, int port, PeerMessageListener listener);
|
2020-08-08 03:03:08 +02:00
|
|
|
|
public abstract void OnStop();
|
2020-08-07 03:46:09 +02:00
|
|
|
|
public abstract void Connected(Connection conn);
|
|
|
|
|
public abstract void Disconnected(Connection conn);
|
|
|
|
|
public abstract void Handle(Connection conn, Packet packet);
|
2020-08-07 22:09:31 +02:00
|
|
|
|
|
2020-08-07 21:07:58 +02:00
|
|
|
|
public abstract void UpdateLocalPlayer();
|
2020-08-07 23:57:11 +02:00
|
|
|
|
public abstract void SendPlayerSync();
|
2020-08-07 22:09:31 +02:00
|
|
|
|
public abstract void LocalPlayerJump();
|
2020-08-07 03:46:09 +02:00
|
|
|
|
|
2020-08-08 02:35:19 +02:00
|
|
|
|
public virtual void Update() { }
|
|
|
|
|
|
2020-08-07 03:46:09 +02:00
|
|
|
|
public void Stop() {
|
2020-08-08 03:03:08 +02:00
|
|
|
|
if (Peer.Running) {
|
|
|
|
|
OnStop();
|
2020-08-07 03:46:09 +02:00
|
|
|
|
Peer.Stop();
|
|
|
|
|
Peer.MessageListener.Message("Stopping");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|