public static void Update() { MousePosition = Input.mousePosition; MouseWorldPosition = Interfacing.GetWorldPos (MousePosition); CanClearSelection = !Input.GetKey (KeyCode.LeftShift); GetMousedAgent (); if (Boxing) { BoxingTime += Time.deltaTime; if (MousePosition != BoxEnd) { Vector2 RaycastTopLeft; Vector2 RaycastTopRight; Vector2 RaycastBotLeft; Vector2 RaycastBotRight; BoxEnd = MousePosition; if (BoxStart.x < BoxEnd.x) { RaycastTopLeft.x = BoxStart.x; RaycastBotLeft.x = BoxStart.x; RaycastTopRight.x = BoxEnd.x; RaycastBotRight.x = BoxEnd.x; } else { RaycastTopLeft.x = BoxEnd.x; RaycastBotLeft.x = BoxEnd.x; RaycastTopRight.x = BoxStart.x; RaycastBotRight.x = BoxStart.x; } if (BoxStart.y < BoxEnd.y) { RaycastBotLeft.y = BoxStart.y; RaycastBotRight.y = BoxStart.y; RaycastTopLeft.y = BoxEnd.y; RaycastTopRight.y = BoxEnd.y; } else { RaycastBotLeft.y = BoxEnd.y; RaycastBotRight.y = BoxEnd.y; RaycastTopLeft.y = BoxStart.y; RaycastTopRight.y = BoxStart.y; } Box_TopLeft = Interfacing.GetWorldPos (RaycastTopLeft); Box_TopRight = Interfacing.GetWorldPos (RaycastTopRight); Box_BottomLeft = Interfacing.GetWorldPos (RaycastBotLeft); Box_BottomRight = Interfacing.GetWorldPos (RaycastBotRight); } ClearBox (); int lecount = 0; if ((BoxEnd - BoxStart).sqrMagnitude >= MinBoxSqrDist) { bufferBoxedAgents.Clear (); for (int i = 0; i < PlayerManager.AgentControllerCount; i++) { var agentController = PlayerManager.GetAgentController (i); for (int j = 0; j < AgentController.MaxAgents; j++) { if (agentController.LocalAgentActive [j]) { curAgent = agentController.LocalAgents [j]; if (curAgent.CanSelect) { if (curAgent.RefEquals (MousedAgent)) { bufferBoxedAgents.Add (curAgent); } else { agentPos = curAgent.Position2; Edge = Box_TopRight - Box_TopLeft; Point = agentPos - Box_TopLeft; if (DotEdge () < 0) { Edge = Box_BottomRight - Box_TopRight; Point = agentPos - Box_TopRight; if (DotEdge () < 0) { Edge = Box_BottomLeft - Box_BottomRight; Point = agentPos - Box_BottomRight; if (DotEdge () < 0) { Edge = Box_TopLeft - Box_BottomLeft; Point = agentPos - Box_BottomLeft; if (DotEdge () < 0) { bufferBoxedAgents.Add (curAgent); continue; } } } } } } } } } bufferBoxable.FastClear (); bool noneBoxable = true; if (bufferBoxedAgents.Count > 0) { int peakBoxPriority = bufferBoxedAgents.PeekMax ().BoxPriority; while (bufferBoxedAgents.Count > 0) { LSAgent agent = bufferBoxedAgents.PopMax (); if (agent.BoxPriority < peakBoxPriority) break; BoxAgent (agent); } } } else { BoxAgent (MousedAgent); } if (Input.GetMouseButtonUp (0)) { if (CanClearSelection) { ClearSelection (); } if (PlayerManager.IsInterfacing == false) { SelectBoxedAgents (); } Boxing = false; } } else { if (PlayerManager.IsInterfacing == false && InputManager.GetInformationDown ()) { CheckBoxDistance = true; Boxing = true; BoxingTime = 0f; BoxStart = MousePosition; BoxEnd = MousePosition; } } }