Commit the last half of the previous commit
This commit is contained in:
parent
6f0ff60952
commit
1f001c03b7
@ -237,6 +237,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
Camera: {fileID: 9173392441446035453}
|
Camera: {fileID: 9173392441446035453}
|
||||||
DisableInput: 0
|
DisableInput: 0
|
||||||
|
FullSyncFrequency: 2
|
||||||
--- !u!114 &3508289943927587728
|
--- !u!114 &3508289943927587728
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -80,8 +80,8 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
PlayerJumpPckt jump = (PlayerJumpPckt)packet;
|
PlayerJumpPckt jump = (PlayerJumpPckt)packet;
|
||||||
Players[jump.PlayerId].Controlled.Jump();
|
Players[jump.PlayerId].Controlled.Jump();
|
||||||
} else if (packet is PlayerSyncPacket) {
|
} else if (packet is PlayerSyncPacket) {
|
||||||
PlayerSyncPacket sync = (PlayerSyncPacket)packet;
|
PlayerSyncPacket syncPckt = (PlayerSyncPacket)packet;
|
||||||
|
Players[syncPckt.PlayerId].Controlled.ProcessSyncPacket(syncPckt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,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.ProcessUpdatePacket(ref pckt);
|
Players[pckt.PlayerId].Controlled.ProcessUpdatePacket(pckt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateLocalPlayer() {
|
public override void UpdateLocalPlayer() {
|
||||||
@ -108,8 +108,8 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
|
|
||||||
public override void SendPlayerSync() {
|
public override void SendPlayerSync() {
|
||||||
if (SelfIdentified && Server != null) {
|
if (SelfIdentified && Server != null) {
|
||||||
PlayerSyncPacket packet; // Get the sync packet for LocalPlayer
|
PlayerSyncPacket packet = LocalPlayer.Controlled.CreateSyncPacket();
|
||||||
// SendUnreliable(Server.uid, packet);
|
Peer.SendUnreliable(Server.uid, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.ProcessUpdatePacket(ref updatePckt);
|
Players[conn.uid].Controlled.ProcessUpdatePacket(updatePckt);
|
||||||
}
|
}
|
||||||
} else if (packet is PlayerJumpPckt) {
|
} else if (packet is PlayerJumpPckt) {
|
||||||
PlayerJumpPckt jump = (PlayerJumpPckt)packet;
|
PlayerJumpPckt jump = (PlayerJumpPckt)packet;
|
||||||
@ -89,7 +89,11 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (packet is PlayerSyncPacket) {
|
} else if (packet is PlayerSyncPacket) {
|
||||||
PlayerSyncPacket sync = (PlayerSyncPacket)packet;
|
PlayerSyncPacket syncPckt = (PlayerSyncPacket)packet;
|
||||||
|
if (Players[conn.uid].Controlled != null) {
|
||||||
|
syncPckt.PlayerId = conn.uid;
|
||||||
|
Players[conn.uid].Controlled.ProcessSyncPacket(syncPckt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,9 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
|
|
||||||
if (Time.time - PreviousPlayerFullSync >= 1f / FullSyncFrequency) {
|
if (Time.time - PreviousPlayerFullSync >= 1f / FullSyncFrequency) {
|
||||||
FullSyncFrequency = Time.time;
|
FullSyncFrequency = Time.time;
|
||||||
// TODO: Create and send the packet
|
if (Networking.Net.Singleton.Instance != null) {
|
||||||
|
Networking.Net.Singleton.Instance.SendPlayerSync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
return new PlayerUpdatePckt(MoveDirection, CurrentMoveStyle, Pitch, Yaw, id);
|
return new PlayerUpdatePckt(MoveDirection, CurrentMoveStyle, Pitch, Yaw, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Updates this Player with the given packet, and sets it to null. No reusing packets.</summary>
|
/// <summary>Updates this Player with the given packet.</summary>
|
||||||
public void ProcessUpdatePacket(ref PlayerUpdatePckt packet) {
|
public void ProcessUpdatePacket(PlayerUpdatePckt packet) {
|
||||||
Pitch = packet.Pitch;
|
Pitch = packet.Pitch;
|
||||||
Yaw = packet.Yaw;
|
Yaw = packet.Yaw;
|
||||||
MoveDirection = packet.MoveDirection;
|
MoveDirection = packet.MoveDirection;
|
||||||
@ -74,13 +74,21 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
packet = null;
|
packet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Creates a PlayerSyncPacket representing this Player's position and velocity, for sending to the server</summary>
|
/// <summary>Creates a PlayerSyncPacket representing this Player's position and velocity, for sending to the server.</summary>
|
||||||
public PlayerSyncPacket CreateSyncPacket(ulong id = 0) {
|
public PlayerSyncPacket CreateSyncPacket(ulong id = 0) {
|
||||||
return new PlayerSyncPacket(id, transform.position, GroundVelocity);
|
return new PlayerSyncPacket(id, transform.position, GroundVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Creates a PlayerSyncPacket representing this Player's position and velocity, for sending to the server</summary>
|
/// <summary>Applies the sync packet, checking it for cheatiness if shouldApply is false.</summary>
|
||||||
public void ProcessSyncPacket(PlayerSyncPacket syncPckt) {
|
public void ProcessSyncPacket(PlayerSyncPacket syncPckt, bool shouldApplyWithoutInspection = true) {
|
||||||
|
bool ShouldApply = shouldApplyWithoutInspection;
|
||||||
|
if (!shouldApplyWithoutInspection) {
|
||||||
|
// TODO: Gaze into the crystal ball to determine the nefariousness level of the packet and update ShouldApply accordingly.
|
||||||
|
}
|
||||||
|
if (ShouldApply) {
|
||||||
|
transform.position = syncPckt.Location;
|
||||||
|
GroundVelocity = syncPckt.Location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The normal of the ground below the player. If there is no ground, it's <c>Vector3.up</c> by default.</summary>
|
/// <summary>The normal of the ground below the player. If there is no ground, it's <c>Vector3.up</c> by default.</summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user