public void CheckAndUpdateVoyeur(TargettedVoyeurInfo voyeur) { var newPos = GetInterpolatedPosition(voyeur.Quantum); if (newPos != null) { if (newPos.Distance(voyeur.LastSentPosition) > voyeur.Radius) { SendVoyeurUpdate(voyeur, newPos, TargetStatus.OK); } } }
public void SendVoyeurUpdate(TargettedVoyeurInfo voyeur, Position pos, TargetStatus status) { voyeur.LastSentPosition = new Position(pos); // ref? var info = new TargetInfo(0, PhysicsObj.ID, voyeur.Radius, voyeur.Quantum); info.TargetPosition = PhysicsObj.Position; info.InterpolatedPosition = new Position(pos); // ref? info.Velocity = PhysicsObj.get_velocity(); info.Status = status; var voyeurObj = PhysicsObj.GetObjectA(voyeur.ObjectID); if (voyeurObj != null) { voyeurObj.receive_target_update(info); } }
public void AddVoyeur(uint objectID, float radius, double quantum) { if (VoyeurTable != null) { VoyeurTable.TryGetValue(objectID, out var existingInfo); if (existingInfo != null) { existingInfo.Radius = radius; existingInfo.Quantum = quantum; return; } } else { VoyeurTable = new Dictionary <uint, TargettedVoyeurInfo>(); } var info = new TargettedVoyeurInfo(objectID, radius, quantum); VoyeurTable.Add(objectID, info); SendVoyeurUpdate(info, PhysicsObj.Position, TargetStatus.OK); }