Update Drone.cs

This commit is contained in:
2025-07-17 00:19:54 +03:00
parent 771440f642
commit fb24fe0f7b

View File

@ -41,6 +41,7 @@ namespace DroneSimulator
private Vector2 MoveOF = Vector2.Zero;
private uint CountOF = 0;
private bool ReadyOF = false;
public struct Physics
{
@ -296,7 +297,7 @@ namespace DroneSimulator
Quat = Quaternion.Identity;
}
else */
Rotate(SpdPRY.X * time, SpdPRY.Y * time, SpdPRY.Z * time);
Rotate(SpdPRY.X * time, SpdPRY.Y * time, SpdPRY.Z * time);
Vector4 ori = GetOrientation();
@ -363,10 +364,12 @@ namespace DroneSimulator
bool of = RealOF.Update(of_xy, LaserRange, tick);
if(of) lock (this)
lock (this)
{
MoveOF += RealOF.result;
CountOF += 1;
if (of) ReadyOF = true;
}
}
@ -530,7 +533,7 @@ namespace DroneSimulator
lock (this)
{
if (CountOF != 0)
if (ReadyOF && CountOF != 0)
{
of.X = MoveOF.X / CountOF;
of.Y = MoveOF.Y / CountOF;
@ -545,6 +548,7 @@ namespace DroneSimulator
MoveOF = Vector2.Zero;
CountOF = 0;
ReadyOF = false;
}
return getBytes(of);