117 lines
3.4 KiB
C#
117 lines
3.4 KiB
C#
using System.Runtime.InteropServices;
|
|
using FlaxEngine;
|
|
using FlaxEngine.Networking;
|
|
|
|
namespace Game
|
|
{
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct PlayerInputState
|
|
{
|
|
/*static PlayerInputState()
|
|
{
|
|
NetworkReplicator.AddSerializer(typeof(PlayerInputState),
|
|
(ptr, streamPtr) =>
|
|
{
|
|
|
|
},
|
|
(ptr, streamPtr) =>
|
|
{
|
|
|
|
});
|
|
}*/
|
|
|
|
public PlayerInputState(ulong frame, float viewDeltaX, float viewDeltaY, float moveForward, float moveRight,
|
|
bool attacking, bool jumping)
|
|
{
|
|
this.frame = frame;
|
|
this.viewDeltaX = viewDeltaX;
|
|
this.viewDeltaY = viewDeltaY;
|
|
this.moveForward = moveForward;
|
|
this.moveRight = moveRight;
|
|
this.attacking = attacking;
|
|
this.jumping = jumping;
|
|
/*this.verificationPosition = verificationPosition;
|
|
this.verificationVelocity = verificationVelocity;
|
|
this.verificationViewAngles = verificationViewAngles;
|
|
this.verificationOrientation = verificationOrientation;*/
|
|
}
|
|
|
|
public PlayerInputState(ulong frame, float viewDeltaX, float viewDeltaY, float moveForward, float moveRight,
|
|
bool attacking, bool jumping, Float3 verificationPosition, Float3 verificationVelocity,
|
|
Float3 verificationViewAngles, Quaternion verificationOrientation)
|
|
{
|
|
this.frame = frame;
|
|
this.viewDeltaX = viewDeltaX;
|
|
this.viewDeltaY = viewDeltaY;
|
|
this.moveForward = moveForward;
|
|
this.moveRight = moveRight;
|
|
this.attacking = attacking;
|
|
this.jumping = jumping;
|
|
this.verificationPosition = verificationPosition;
|
|
this.verificationVelocity = verificationVelocity;
|
|
this.verificationViewAngles = verificationViewAngles;
|
|
this.verificationOrientation = verificationOrientation;
|
|
}
|
|
|
|
public ulong frame;
|
|
public float viewDeltaX, viewDeltaY;
|
|
public float moveForward;
|
|
public float moveRight;
|
|
public bool attacking;
|
|
public bool jumping;
|
|
|
|
public Float3 verificationPosition;
|
|
public Float3 verificationVelocity;
|
|
public Float3 verificationViewAngles;
|
|
public Quaternion verificationOrientation;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct PlayerActorState
|
|
{
|
|
public Float3 position;
|
|
public Float3 velocity;
|
|
public Quaternion orientation;
|
|
public Float3 viewAngles; // yaw, pitch, roll
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct PlayerState
|
|
{
|
|
public PlayerInputState input;
|
|
public PlayerActorState actor;
|
|
}
|
|
|
|
public class PlayerInput
|
|
{
|
|
public const byte DemoVer = 1;
|
|
public PlayerState currentState;
|
|
public ulong frame;
|
|
|
|
public virtual void OnUpdate()
|
|
{
|
|
}
|
|
|
|
public virtual void OnFixedUpdate()
|
|
{
|
|
}
|
|
|
|
public virtual void OnEndFrame()
|
|
{
|
|
}
|
|
|
|
public virtual void RecordCurrentActorState(PlayerActorState actorState)
|
|
{
|
|
}
|
|
|
|
public PlayerInputState GetCurrentInputState()
|
|
{
|
|
return currentState.input;
|
|
}
|
|
|
|
public PlayerActorState GetCurrentActorState()
|
|
{
|
|
return currentState.actor;
|
|
}
|
|
}
|
|
} |