unstaticify part1
This commit is contained in:
@@ -106,7 +106,8 @@ namespace Game
|
||||
private readonly bool demoDeltasCorrect = true;
|
||||
private readonly bool demoDeltasVerify = true;
|
||||
|
||||
|
||||
|
||||
private WorldStateManager worldStateManager;
|
||||
|
||||
private bool predicting = false;
|
||||
|
||||
@@ -188,13 +189,15 @@ namespace Game
|
||||
//string demoPath = System.IO.Path.Combine(AssetManager.DemoPath, $"{DateTimeOffset.Now.UtcTicks}.gdem");
|
||||
//input = new PlayerInputLocal(playerActor, demoPath); // TODO: support recording
|
||||
input = new PlayerInputLocal(playerActor);
|
||||
|
||||
worldStateManager = NetworkManager.serverWorldStateManager;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Print("network player: " + playerId.ToString());
|
||||
input = new PlayerInputNetwork();
|
||||
worldStateManager = NetworkManager.clientWorldStateManager;
|
||||
}
|
||||
Assert.IsTrue(worldStateManager != null);
|
||||
}
|
||||
|
||||
public void SetInput(string demoFile)
|
||||
@@ -444,10 +447,10 @@ namespace Game
|
||||
|
||||
//viewAngles = viewAnglesLastFrame;
|
||||
bool canpredict = true;
|
||||
if (true && input.Predict /*&& !NetworkManager.IsDemoPlaying*/ && WorldStateManager.ClientFrame > 0 && WorldStateManager.ServerFrame > 0)
|
||||
if (true && input.Predict /*&& !NetworkManager.IsDemoPlaying*/ && worldStateManager.ClientFrame > 0 && worldStateManager.ServerFrame > 0)
|
||||
{
|
||||
ulong currentFrame = WorldStateManager.ServerFrame;
|
||||
for (; currentFrame < WorldStateManager.ClientFrame; currentFrame++)
|
||||
ulong currentFrame = worldStateManager.ServerFrame;
|
||||
for (; currentFrame < worldStateManager.ClientFrame; currentFrame++)
|
||||
{
|
||||
if (!input.GetState(currentFrame, out var pastInputState, out var pastActorState))
|
||||
{
|
||||
@@ -469,7 +472,7 @@ namespace Game
|
||||
|
||||
|
||||
predicting = true;
|
||||
currentFrame = WorldStateManager.ServerFrame;
|
||||
currentFrame = worldStateManager.ServerFrame;
|
||||
for (; currentFrame < lastFrame; currentFrame++)
|
||||
{
|
||||
if (!input.GetState(currentFrame, out var pastInputState, out var pastActorState))
|
||||
@@ -481,7 +484,7 @@ namespace Game
|
||||
if (currentFrame == inputState.frame)
|
||||
movementState.jumped = movementState.jumped;
|
||||
|
||||
if (currentFrame == WorldStateManager.ServerFrame)
|
||||
if (currentFrame == worldStateManager.ServerFrame)
|
||||
{
|
||||
movementState.position = pastActorState.position;
|
||||
movementState.currentVelocity = pastActorState.velocity;
|
||||
@@ -891,8 +894,8 @@ namespace Game
|
||||
|
||||
if (false)
|
||||
{
|
||||
if (WorldStateManager.ServerFrame > 0 && WorldStateManager.ClientFrame > 0)
|
||||
for (ulong frame = WorldStateManager.ServerFrame; frame < WorldStateManager.ClientFrame; frame++)
|
||||
if (worldStateManager.ServerFrame > 0 && worldStateManager.ClientFrame > 0)
|
||||
for (ulong frame = worldStateManager.ServerFrame; frame < worldStateManager.ClientFrame; frame++)
|
||||
{
|
||||
if (!input.GetState(frame, out var pastInputState, out var pastActorState))
|
||||
continue;
|
||||
@@ -902,7 +905,7 @@ namespace Game
|
||||
|
||||
Float4 color1 = new Float4(Color.Red.R, Color.Red.G, Color.Red.B, Color.Red.A);
|
||||
Float4 color2 = new Float4(Color.Blue.R, Color.Blue.G, Color.Blue.B, Color.Blue.A);
|
||||
Float4 color3 = Float4.Lerp(color1, color2, (float)(frame - WorldStateManager.ServerFrame) / (float)(WorldStateManager.ClientFrame - WorldStateManager.ServerFrame));
|
||||
Float4 color3 = Float4.Lerp(color1, color2, (float)(frame - worldStateManager.ServerFrame) / (float)(worldStateManager.ClientFrame - worldStateManager.ServerFrame));
|
||||
Color color = new Color(color3.X, color3.Y, color3.Z, color3.W);
|
||||
DebugDraw.DrawBox(bbox, color * 1f);
|
||||
}
|
||||
@@ -910,7 +913,7 @@ namespace Game
|
||||
else
|
||||
{
|
||||
var serverBbox = boxCollider.OrientedBox.GetBoundingBox();
|
||||
if (input.GetState(WorldStateManager.ServerFrame, out var serverInputState, out var serverActorState))
|
||||
if (input.GetState(worldStateManager.ServerFrame, out var serverInputState, out var serverActorState))
|
||||
serverBbox.Center = serverActorState.position;
|
||||
|
||||
if (serverBbox.Center == clientBbox.Center)
|
||||
@@ -1159,7 +1162,7 @@ namespace Game
|
||||
|
||||
public void SimulatePlayerMovement(PlayerInputState inputState)
|
||||
{
|
||||
simulationTime = WorldStateManager.ClientTime + (inputState.frame * (1.0f / Time.PhysicsFPS));
|
||||
simulationTime = worldStateManager.ClientTime + (inputState.frame * (1.0f / Time.PhysicsFPS));
|
||||
|
||||
Vector3 inputDirection =
|
||||
new Float3(inputState.moveRight, 0.0f, inputState.moveForward);
|
||||
|
||||
Reference in New Issue
Block a user