From fb24fe0f7babdafa0a19c0830b08d6709c114a23 Mon Sep 17 00:00:00 2001 From: Sergey Sklyarov Date: Thu, 17 Jul 2025 00:19:54 +0300 Subject: [PATCH] Update Drone.cs --- DroneSimulator/Drone.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DroneSimulator/Drone.cs b/DroneSimulator/Drone.cs index 36b9594..b068f92 100644 --- a/DroneSimulator/Drone.cs +++ b/DroneSimulator/Drone.cs @@ -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);