Merge branch 'master' of teascade.net:neontea/quakeball

This commit is contained in:
Sofia 2020-08-07 23:18:02 +03:00
commit 45954dab1a
6 changed files with 808 additions and 696 deletions

File diff suppressed because one or more lines are too long

View File

@ -86,7 +86,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
if (pckt.PlayerId == LocalPlayer.Id) { if (pckt.PlayerId == LocalPlayer.Id) {
return; // Ignore, again. return; // Ignore, again.
} }
Players[pckt.PlayerId].Controlled.GetComponent<RemotePlayer>().QueuePacket(pckt); Players[pckt.PlayerId].Controlled.GetComponent<RemotePlayer>().ProcessPacket(pckt);
} }
public override void UpdateLocalPlayer() { public override void UpdateLocalPlayer() {

View File

@ -78,7 +78,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet; PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet;
if (Players[conn.uid].Controlled != null) { if (Players[conn.uid].Controlled != null) {
updatePckt.PlayerId = conn.uid; updatePckt.PlayerId = conn.uid;
Players[conn.uid].Controlled.GetComponent<RemotePlayer>().QueuePacket(updatePckt); Players[conn.uid].Controlled.GetComponent<RemotePlayer>().ProcessPacket(updatePckt);
} }
} else if (packet is PlayerJumpPckt) { } else if (packet is PlayerJumpPckt) {
PlayerJumpPckt jump = (PlayerJumpPckt)packet; PlayerJumpPckt jump = (PlayerJumpPckt)packet;

View File

@ -8,7 +8,7 @@ MonoImporter:
- CrouchingMoveStyle: {fileID: 11400000, guid: 2d9739d3745581a41ae0ed6a569766d5, type: 2} - CrouchingMoveStyle: {fileID: 11400000, guid: 2d9739d3745581a41ae0ed6a569766d5, type: 2}
- Head: {instanceID: 0} - Head: {instanceID: 0}
- MoveStyle: {instanceID: 0} - MoveStyle: {instanceID: 0}
executionOrder: 5 executionOrder: 100
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:

View File

@ -7,31 +7,13 @@ namespace NeonTea.Quakeball.Players {
[RequireComponent(typeof(Player))] [RequireComponent(typeof(Player))]
public class RemotePlayer : MonoBehaviour { public class RemotePlayer : MonoBehaviour {
private Player Player; private Player Player;
private PlayerUpdatePckt QueuedPckt = null;
private float LastUpdateTime = -1;
public void QueuePacket(PlayerUpdatePckt packet) { public void ProcessPacket(PlayerUpdatePckt packet) {
if (QueuedPckt != null) { Player.ProcessPacket(ref packet);
string Warning = "Can't keep up! Got another packet while one was still in queue, fast-forwarding (and probably desyncing)!";
Debug.LogWarning(Warning);
Terminal.Singleton.Println($"<color={Terminal.ERROR_COLOR}>{Warning}</color>");
// Re-sync?
Player.ProcessPacket(ref QueuedPckt);
LastUpdateTime = Time.time;
}
QueuedPckt = packet;
} }
private void Awake() { private void Awake() {
Player = GetComponent<Player>(); Player = GetComponent<Player>();
} }
private void Update() {
if (Time.time - LastUpdateTime >= 1f / Player.UpdateFrequency && QueuedPckt != null) {
Player.ProcessPacket(ref QueuedPckt);
LastUpdateTime = Time.time;
}
}
} }
} }

View File

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 50
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName: