private void MovementQuery(Entity entity, ref MovementData movement, ref NavPathData path, ref BaseUnitSight.Component sight, ref BaseUnitStatus.Component status, ref SpatialEntityId entityId) { movement.MoveSpeed = 0.0f; movement.RotSpeed = 0.0f; if (status.State != UnitState.Alive) { return; } if (UnitUtils.IsAutomaticallyMoving(status.Type) == false) { return; } var unit = EntityManager.GetComponentObject <UnitTransform>(entity); // check ground if (unit == null || unit.GetGrounded(out var hitInfo) == false) { return; } if (sight.State == TargetState.None) { return; } var trans = unit.transform; var pos = trans.position; Vector3?tgt = null; Vector3 spread = Vector3.zero; var id = entityId.EntityId; if (vectorDic.ContainsKey(id)) { //tgt = vectorDic[id].boidTarget; spread = vectorDic[id].spread; } if (tgt == null) { tgt = sight.GetTargetPosition(this.Origin, pos); } tgt = CheckNavPathAndTarget(tgt.Value, pos, unit.SizeRadius, sight.State, entityId.EntityId.Id, ref path); if (RangeDictionary.IsSpreadValid(spread)) { var length = (tgt.Value - pos).magnitude; tgt += spread * Mathf.Max(1.0f, (length / RangeDictionary.SpreadSize)); } var positionDiff = tgt.Value - pos; var forward = get_forward(positionDiff, sight.TargetRange); MovementDictionary.TryGet(status.Type, out var speed, out var rot); var isRotate = rotate(rot, trans, positionDiff); if (forward != 0.0f) { movement.MoveSpeed = forward * speed; } if (isRotate != 0) { movement.RotSpeed = rot * isRotate; } }