Spaces:
Runtime error
Runtime error
File size: 776 Bytes
ac55997 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
using System;
using Photon.Deterministic;
namespace Quantum
{
unsafe partial struct Input
{
// input bandwidth trick by Erick Passos
// using a single Byte to encode a 2D direction with 2 degrees of accuracy
public FPVector2 Direction
{
get {
if (EncodedDirection == default) return default;
Int32 angle = ((Int32)EncodedDirection - 1) * 2;
return FPVector2.Rotate(FPVector2.Up, angle * FP.Deg2Rad);
}
set {
if (value == default)
{
EncodedDirection = default;
return;
}
var angle = FPVector2.RadiansSigned(FPVector2.Up, value) * FP.Rad2Deg;
angle = (((angle + 360) % 360) / 2) + 1;
EncodedDirection = (Byte)(angle.AsInt);
}
}
}
}
|