This commit is contained in:
Sofia 2020-08-07 05:31:49 +03:00
parent 1d8e027558
commit 276c1b265e
4 changed files with 7 additions and 4 deletions

View File

@ -51,6 +51,7 @@ namespace NeonTea.Quakeball.Net.Instances {
SelfIdentPckt ident = (SelfIdentPckt)packet;
LocalPlayer.Id = ident.PlayerId;
Players.Add(LocalPlayer.Id, LocalPlayer);
Debug.Log($"I got self-identified as {LocalPlayer.Id}");
SpawnPckt spawn = new SpawnPckt();
spawn.Location = LocalPlayer.Controlled.transform.position;

View File

@ -40,12 +40,13 @@ namespace NeonTea.Quakeball.Net.Instances {
SpawnPckt spawn = new SpawnPckt();
spawn.PlayerId = p.Id;
spawn.Location = p.Controlled.transform.position;
Peer.SendReliable(conn.uid, spawn);
Peer.SendReliableLater(conn.uid, spawn);
}
NetPlayer RemotePlayer = new NetPlayer(PlayerIdCounter++);
Players.Add(RemotePlayer.Id, RemotePlayer);
SelfIdentPckt ident = new SelfIdentPckt();
ident.PlayerId = RemotePlayer.Id;
Debug.Log("Send self-ident!");
Peer.SendReliable(conn.uid, ident);
}
@ -54,6 +55,7 @@ namespace NeonTea.Quakeball.Net.Instances {
public override void Handle(Connection conn, Packet packet) {
if (packet is SpawnPckt) {
Debug.Log("Do i ever get it");
SpawnPckt spawn = (SpawnPckt)packet;
if (Players[conn.uid].Controlled == null) {
GameObject obj = Net.SpawnPlayer(spawn.Location);

View File

@ -29,7 +29,9 @@ namespace NeonTea.Quakeball.Net {
}
private void Update() {
Net.Singleton.Instance.Peer.Update();
if (Net.Singleton.Instance != null) {
Net.Singleton.Instance.Peer.Update();
}
if (Terminal != null && Terminal.isActiveAndEnabled) {
while (MessageQueue.Count > 0) {
Terminal.Println(MessageQueue.Dequeue());

View File

@ -209,8 +209,6 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
if (oldStatus == ConnectionStatus.Establishing) { // Update connection status
conn.Status = ConnectionStatus.Ready;
ProtocolActionQueues[protocol.Identifier].Enqueue(new ConnectionChangedAction(oldStatus, conn.Status, conn));
} else {
break; // They're cheating! No cheating!
}
conn.Internal.LatestOutwardReliable = buffer.ReadInt();