record demos as packets
This commit is contained in:
@@ -135,7 +135,6 @@ namespace Game
|
||||
public Float3 viewAngles;
|
||||
private Float3 viewAnglesLastFrame;
|
||||
|
||||
[NetworkReplicated]
|
||||
public uint PlayerId = 0;
|
||||
|
||||
[ReadOnly]
|
||||
@@ -186,8 +185,9 @@ namespace Game
|
||||
if (PlayerId == NetworkManager.LocalPlayerClientId)//if (NetworkReplicator.GetObjectRole(this.Parent) == NetworkObjectRole.OwnedAuthoritative)// if (playerId == NetworkManager.LocalPlayerClientId)
|
||||
{
|
||||
Console.Print("local player?: " + playerId.ToString());
|
||||
string demoPath = System.IO.Path.Combine(AssetManager.DemoPath, $"{DateTimeOffset.Now.UtcTicks}.gdem");
|
||||
input = new PlayerInputLocal(playerActor, demoPath); // TODO: support recording
|
||||
//string demoPath = System.IO.Path.Combine(AssetManager.DemoPath, $"{DateTimeOffset.Now.UtcTicks}.gdem");
|
||||
//input = new PlayerInputLocal(playerActor, demoPath); // TODO: support recording
|
||||
input = new PlayerInputLocal(playerActor);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -327,67 +327,14 @@ namespace Game
|
||||
|
||||
public override void OnFixedUpdate()
|
||||
{
|
||||
PlayerInputDemo demoInput = input as PlayerInputDemo;
|
||||
if (demoInput != null)
|
||||
demoInput.OnUpdate();
|
||||
|
||||
float timeDeltaDiff = Time.DeltaTime - 1.0f / Time.PhysicsFPS;
|
||||
if (Math.Abs(timeDeltaDiff) > 0.0001f)
|
||||
if (Time.PhysicsFPS > 0 && Math.Abs(timeDeltaDiff) > 0.0001f)
|
||||
Console.Print("Time.DeltaTime is not stable: " + timeDeltaDiff);
|
||||
|
||||
input.OnFixedUpdate();
|
||||
PlayerInputState inputState = input.GetCurrentInputState();
|
||||
|
||||
if (demoInput != null && demoInput.IsPlaying)
|
||||
{
|
||||
ApplyInputToCamera(inputState, true);
|
||||
|
||||
// Verify view angles first
|
||||
if (demoDeltasVerify)
|
||||
{
|
||||
Float3 verifAngles = new Float3(inputState.verificationViewAngles.Y, inputState.verificationViewAngles.X, inputState.verificationViewAngles.Z);
|
||||
float viewAnglesDelta = (viewAngles - verifAngles).Length;
|
||||
if (viewAnglesDelta > 0.00001)
|
||||
{
|
||||
Console.Print($"Demo verification failed, view angles delta: {viewAnglesDelta}, viewAngles:{viewAngles}, verif:{verifAngles}");
|
||||
if (demoDeltasCorrect)
|
||||
SetCameraEulerAngles(verifAngles, false);
|
||||
}
|
||||
}
|
||||
|
||||
SimulatePlayerMovement(inputState);
|
||||
|
||||
if (demoDeltasVerify)
|
||||
{
|
||||
// verify
|
||||
float positionDelta = (movementState.position - inputState.verificationPosition).Length;
|
||||
if (positionDelta > 0.00001)
|
||||
Console.Print("Demo verification failed, position delta: " + positionDelta);
|
||||
|
||||
float velocityDelta = (movementState.currentVelocity - inputState.verificationVelocity).Length;
|
||||
if (velocityDelta > 0.00001)
|
||||
Console.Print("Demo verification failed, velocity delta: " + velocityDelta);
|
||||
|
||||
float orientationDelta = (rootActor.Orientation - inputState.verificationOrientation).Length;
|
||||
if (orientationDelta > 0.00001)
|
||||
{
|
||||
Console.Print("Demo verification failed, orientation delta: " + orientationDelta);
|
||||
if (demoDeltasCorrect)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if (currentInputFrame == 0)
|
||||
/*{
|
||||
//Console.Print("repos: " + inputState.verificationPosition);
|
||||
movementState.position = inputState.verificationPosition;
|
||||
currentVelocity = inputState.verificationVelocity;
|
||||
rootActor.Orientation = inputState.verificationOrientation;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else if (input is PlayerInputNetwork)
|
||||
if (input is PlayerInputNetwork)
|
||||
{
|
||||
#if false
|
||||
bool canpredict = true;
|
||||
@@ -497,7 +444,7 @@ namespace Game
|
||||
|
||||
//viewAngles = viewAnglesLastFrame;
|
||||
bool canpredict = true;
|
||||
if (true && input.Predict && GameModeManager.ClientFrame > 0 && GameModeManager.ServerFrame > 0)
|
||||
if (true && input.Predict /*&& !NetworkManager.IsDemoPlaying*/ && GameModeManager.ClientFrame > 0 && GameModeManager.ServerFrame > 0)
|
||||
{
|
||||
ulong currentFrame = GameModeManager.ServerFrame;
|
||||
for (; currentFrame < GameModeManager.ClientFrame; currentFrame++)
|
||||
@@ -580,9 +527,11 @@ namespace Game
|
||||
|
||||
predicting = false;
|
||||
|
||||
if ((movementState.position - oldPos).Length > 0.001)
|
||||
var posDelta = (movementState.position - oldPos);
|
||||
var velDelta = (movementState.currentVelocity - oldVel);
|
||||
if (posDelta.Length > 0.001)
|
||||
Console.Print($"mispredicted final position");
|
||||
if ((movementState.currentVelocity - oldVel).Length > 0.001)
|
||||
if (velDelta.Length > 0.001)
|
||||
Console.Print($"mispredicted final velocity");
|
||||
|
||||
|
||||
@@ -602,7 +551,8 @@ namespace Game
|
||||
SimulatePlayerMovement(inputState);
|
||||
}
|
||||
|
||||
if ((viewAngles - oldAngles).Length > 0.001)
|
||||
var viewDelta = (viewAngles - oldAngles);
|
||||
if (viewDelta.Length > 0.001)
|
||||
Console.Print($"mispredicted final viewangles: {viewAngles} <- {oldAngles}");
|
||||
|
||||
//if (viewAngles != new Float3(90f, 0f, 0f))
|
||||
|
||||
Reference in New Issue
Block a user