quakeball/Assets/Scripts/Networking/Instances/NetInstance.cs

43 lines
1.3 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NeonTea.Quakeball.Networking.Packets;
using NeonTea.Quakeball.TeaNet.Peers;
using NeonTea.Quakeball.TeaNet.Packets;
namespace NeonTea.Quakeball.Networking.Instances {
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 09:08:10 +02:00
public NetPlayer LocalPlayer;
public NetInstance() {
Peer = new Peer(Fingerprint);
}
public abstract void Start(string address, int port, PeerMessageListener listener);
public abstract void OnStop();
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
public abstract void UpdateLocalPlayer();
2020-08-07 23:57:11 +02:00
public abstract void SendPlayerSync();
2020-08-08 04:26:17 +02:00
public abstract void LocalPlayerAction(PlayerAction action, Serializable serializable = null);
2020-08-08 02:35:19 +02:00
public virtual void Update() { }
public void Stop() {
if (Peer.Running) {
OnStop();
Peer.Stop();
Peer.MessageListener.Message("Stopping");
}
}
}
}